Difference between revisions of "Minnowboard:Toggling LED"

From eLinux.org
Jump to: navigation, search
m (Added Getting started info)
m (Added back home button)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
[[File:Mlogo.png|right|295px|Minnow]]
+
{{Template:Minnowboard_home}}
 +
[[File:Mlogo.png|right|130px|Minnow]]
 
=Summary=
 
=Summary=
  
Line 9: Line 10:
 
=User LED on the MinnowBoard=
 
=User LED on the MinnowBoard=
  
There are a total of five LED(s) on the MinnowBoard - D11, D12, D13, D14, D15 as shown in Figure -4. Their functions have been listed in the table below:
+
There are a total of five LED(s) on the MinnowBoard - D11, D12, D13, D14, D15 as shown in Figure -1. Their functions have been listed in the table below:
  
  
[[File:Userled.png|600x1000px|Figure-4: LED(s) on the MinnowBoard]]
+
[[File:Userled.png|600x1000px|Figure-1: LED(s) on the MinnowBoard]]
  
  
Line 58: Line 59:
 
=Extra Credit=
 
=Extra Credit=
  
This is an optional section which you can read for further understanding. In a nutshell, we are trying to access the on board USER LED(s) via [http://elinux.org/images/4/4f/02-linux-quick-start.pdf userspace] in Linux. To be more precise we are using the [http://www.makelinux.net/books/lkd2/ch17lev1sec8 sysfs interface]. sysfs is a virtual filesystem which translates the hardware devices and busses attached to the system(board in our case) into a file system hierarchy that can be accessed from userspace. sysfs is generated by the kernel and always mounted at /sys. As discussed earlier, trigger for D11 and D12 LEDs has to be changed to make them function as USER LEDs. I would describe 'trigger' as the API used to link a LED to an 'event' in kernel space. Here, 'event' could be microSD card or Ethernet activity, heartbeat, power etc. To understand this better, take LED D11 for example. The trigger for D11 has been set by default to heartbeat. So, to use it as an USER LED, we have to change the trigger for it to 'none' as shown in Figure - 5 below:
+
This is an optional section which you can read for further understanding. In a nutshell, we are trying to access the on board USER LED(s) via [http://elinux.org/images/4/4f/02-linux-quick-start.pdf userspace] in Linux. To be more precise we are using the [http://www.makelinux.net/books/lkd2/ch17lev1sec8 sysfs interface]. sysfs is a virtual filesystem which translates the hardware devices and busses attached to the system(board in our case) into a file system hierarchy that can be accessed from userspace. sysfs is generated by the kernel and always mounted at /sys. As discussed earlier, trigger for D11 and D12 LEDs has to be changed to make them function as USER LEDs. I would describe 'trigger' as the API used to link a LED to an 'event' in kernel space. Here, 'event' could be microSD card or Ethernet activity, heartbeat, power etc. To understand this better, take LED D11 for example. The trigger for D11 has been set by default to heartbeat. So, to use it as an USER LED, we have to change the trigger for it to 'none' as shown in Figure - 2 below:
  
  
[[File:Mledtrigger.png|600x1000px|Figure-5: Change LED Trigger]]
+
[[File:Mledtrigger.png|600x1000px|Figure-2: Change LED Trigger]]
  
  
Line 76: Line 77:
 
'''Step-2:'''  
 
'''Step-2:'''  
  
Now we are ready to toggle the LED. Type the following commands in your terminal as shown in Figure - 10(First one is for turning ON and latter for OFF):
+
Now we are ready to toggle the LED. Type the following commands in your terminal as shown in Figure - 3(First one is for turning ON and latter for OFF):
  
 
  echo 1 > /sys/class/leds/minnow_led0/brightness
 
  echo 1 > /sys/class/leds/minnow_led0/brightness
Line 82: Line 83:
  
  
[[File:Mledtrigger.png|600px|Figure-10: Toggle the LED]]
+
[[File:Mledtrigger.png|600px|Figure-3: Toggle the LED]]
  
  
Line 90: Line 91:
  
  
[[File:Mledon.png|800px|Figure-11: Led ON]]
+
[[File:Mledon.png|800px|Figure-4: Led ON]]
  
  
  
[[File:Mledoff.png|800px|Figure-12: Led OFF]]
+
[[File:Mledoff.png|800px|Figure-5: Led OFF]]

Latest revision as of 02:29, 12 August 2013

Mlogo.png Back to the MinnowBoard home page


Minnow

Summary

In this guide, we will toggle a user LED on the MinnowBoard step-by-step. This guide is for beginners who are just getting started with the MinnowBoard.

Getting Started

For information on 'Setting up a microSD card', 'Booting Angstrom' etc, please refer here

User LED on the MinnowBoard

There are a total of five LED(s) on the MinnowBoard - D11, D12, D13, D14, D15 as shown in Figure -1. Their functions have been listed in the table below:


Figure-1: LED(s) on the MinnowBoard


Functions of the LED(s) on the MinnowBoard
Sr. No. LED Function
1 D11 Heartbeat/USER LED*
2 D12 microSD card activity/USER LED*
3 D13 PWR
4 D14 CPU HOT
5 D15 PWROK


Now, let us understand these functions in a bit more detail:

  1. Heartbeat: The Heartbeat LED blinks at a regular rate to indicate that the hardware is operating properly, and that the CPU hasn't locked up. This is useful in embedded systems where you may not always have a board connected to a display to confirm its operation.
  2. microSD Card Activity: This LED blinks when there is disk activity happening on the microSD card port.
  3. CPUHOT: When this LED is on, it indicates that the CPU temperature is abnormally high. This may suggest that the MinnowBoard is running in too hot of an environment, or that there is a problem with the CPU heatsink attachment. The MinnowBoard will shut off in the event that the CPU temperature reaches a level that could possibly damage itself, and CPUHOT represents a warning temperature before this state is reached.
  4. PWROK: This LED indicates that the power source is operating within required tolerances for the MinnowBoard.


So, there are two USER LED(s) on the MinnowBoard - D11 and D12 but by default they cannot be used as USER LED(s).


The user LED(s) are accessible via the user space in Linux at the location below on the filesystem:

/sys/class/leds

There is one directory per user LED, named as shown below:

/sys/class/leds/minnow_led0
/sys/class/leds/minnow_led1

Here, led0 is D11, while led1 is D12. Inside each one of those directories, there is a file named "brightness". If you write a "1" or a "0" to this file, then you can control the status of that led, i.e. , toggle it ON or OFF respectively.

Extra Credit

This is an optional section which you can read for further understanding. In a nutshell, we are trying to access the on board USER LED(s) via userspace in Linux. To be more precise we are using the sysfs interface. sysfs is a virtual filesystem which translates the hardware devices and busses attached to the system(board in our case) into a file system hierarchy that can be accessed from userspace. sysfs is generated by the kernel and always mounted at /sys. As discussed earlier, trigger for D11 and D12 LEDs has to be changed to make them function as USER LEDs. I would describe 'trigger' as the API used to link a LED to an 'event' in kernel space. Here, 'event' could be microSD card or Ethernet activity, heartbeat, power etc. To understand this better, take LED D11 for example. The trigger for D11 has been set by default to heartbeat. So, to use it as an USER LED, we have to change the trigger for it to 'none' as shown in Figure - 2 below:


Figure-2: Change LED Trigger


Steps

Now let us control that LED!

Step-1:

To use D11 as USER LED, we need to change its default trigger. Type the following command in your terminal to accomplish this:

echo none > /sys/class/leds/minnow_led0/trigger

Step-2:

Now we are ready to toggle the LED. Type the following commands in your terminal as shown in Figure - 3(First one is for turning ON and latter for OFF):

echo 1 > /sys/class/leds/minnow_led0/brightness
echo 0 > /sys/class/leds/minnow_led0/brightness


Figure-3: Toggle the LED


Output

You should see the LED change state as shown below:


Figure-4: Led ON


Figure-5: Led OFF