Minnowboard:Physical Computing

From eLinux.org
Revision as of 17:24, 3 August 2013 by Jayneil (talk | contribs)
Jump to: navigation, search
Minnow

Summary

In this guide, I will describe how to do Physical Computing with the MinnowBoard step by step. This guide is for new users who are just getting started with the MinnowBoard.

Contents of the box

When you purchase a MinnowBoard, the following items are included in the box as shown in Figure -1:

  1. MinnowBoard
  2. 5V Power Adaptor
  3. 4GB micro SD card preloaded with Angstrom Linux Distribution(Yocto Project Compatible)


Figure-1: Box Contents


Anatomy of a MinnowBoard

Top Side

This section outlines the various components on the MinnowBoard. Figure -2 below annotates the important components on the top side of the MinnowBoard.

Figure-2: MinnowBoard Top Side

Below is a brief description of the micro USB and debugger ports which are annotated in Figure -2.

• Micro USB: This port can be used to access the contents of the MinnowBoard's microSD card as a removable drive on your desktop computer. Simply boot the MinnowBoard up and connect it to your desktop computer using a micro-USB cable.

• Debugger: This mini-USB port allows you to interact with the serial console of the MinnowBoard, so you can log into it and view debugging messages even when an external monitor and keyboard are not connected to the MinnowBoard. You need to use a terminal emulator on your desktop computer to access the serial console at a baud rate of 115200. This is demonstrated later in this guide in the Booting Angstrom section.

Bottom Side

Figure -3 below annotates the important components on the bottom side of the MinnowBoard.

Figure-3: MinnowBoard Bottom Side

Specifications

For detailed specifications of the MinnowBoard, please visit our website below:

http://www.minnowboard.org/technical-features/

Preparing the MicroSD Card

Please note that this section is completely optional. The MinnowBoard already comes with a microSD card that is preloaded with a working Angstrom Linux image. In case you want to use a newer image or want to program the microSD from scratch, this section covers it all. These steps were created using an Ubuntu 12.10 64-bit system.

Note:- This section is for Linux users only. If you are using Windows, please skip to the Windows Section. If you are using Mac, please skip to the OS X section.

Step-1:

First download the latest Angstrom Linux image for MinnowBoard using the following link:

Latest Angstrom Image for the MinnowBoard

At the time of writing this guide, the latest image available for download was 'Angstrom-development-GNOME-image-eglibc-ipk-v2012.12-minnow-2013.07.10.img.xz'

Step-2:

Insert the microSD card into a microSD compatible writer in your desktop computer. Now, identify the disk device filename for your microSD card. You can do this by opening the Disk Utility application (sometimes also called Disks) in Ubuntu and clicking on the microSD card entry. See the Device field to determine the raw device name of your microSD card. Note that this device name should specify an entire disk device (e.g, /dev/sde), and not an individual disk partition (e.g, /dev/sde1)

Step-3:

Now, make sure all possible disk partitions from the microSD card are unmounted by typing the command below into your terminal:

$ sudo umount /dev/sdX?* 

Here 'sdX' stands for the raw device id of the microSD card.

Step-4:

Now unpack the image to the microSD card by typing the command below in a terminal window:

$ xzcat Angstrom-development-GNOME-image-eglibc-ipk-v2012.12-minnow-2013.07.10.img.xz | sudo dd of=/dev/sdX


GPIO on the MinnowBoard

The MinnowBoard provides a variety of GPIO(General Purpose Input Output), some with a dedicated purpose. For the purpose of this guide, I will be concentrating only on GPIO(s) which are on the J9 expansion header as shown in Figure - 4 . Please refer the table below to find out how are the GPIO(s) actually referenced in the kernel and their default modes as well as values. Unless otherwise stated the GPIO(s) on J9 expansion header are rated at 3.3V and can source/sink a maximum of 10mA. Also, it can be seen from the table that the GPIO(s) are by default set to be used in INPUT mode and have PULL-UP resistors enabled.

GPIO on the MinnowBoard
Sr. No. GPIO Reference Number in the kernel* Default Mode Default Value
1 1 N.A. N.A. 3.3V
2 2 N.A. N.A. GND
3 3 244 INPUT HIGH
4 4 245 INPUT HIGH
5 5 246 INPUT HIGH
6 6 247 INPUT HIGH
7 7 248 INPUT HIGH
8 8 249 INPUT HIGH
9 9 250 INPUT HIGH
10 10 251 INPUT HIGH
*For example GPIO-3 on J9 header will be referenced as gpio-244 in kernel


Figure-4: GPIO on the MinnowBoard


As you can see from Figure -4, there are a total of ten pins on the J9 header out of which 8 pins can be used as GPIO. The remaining two pins are GND and 3.3V as mentioned in the table.

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

/sys/class/gpio

There is one directory per GPIO, named as shown below(as an example only two GPIO(s) are shown here):

/sys/class/gpio/gpio245

Inside each one of those directories, there are files named "direction” and “value” as shown in Figure - 5. The former is for configuring the mode of GPIO as input(“in”) or output(“out”) while the latter is for the value('1' for HIGH and '0' for LOW) if used in output mode.


Figure-5: GPIO attributes


Pullup/Pulldown Resistors

Concept

So, you want to use the GPIO on the MinnowBoard to read values externally connected devices(e.g. push button). The particular GPIO pin is set to be used in input mode. Now, think about the case when no input is being provided to that pin(lets say P2) as shown in Figure - 6 below. This is called a 'floating point' condition and the processor cannot determine what is the value of the input pin. In this case, even the noise in the environment can influence the pin value and give wrong results.

Figure-6: No pullup resistor

Hence, to avoid this condition the pins have a pullup/pull down resistor connected to them to prevent this from happening . Pullup is used to denote that the pin is connected to Vcc(3.3V in this case) via a resistor and pulldown is used to denote the pin that is connected to GND via a resistor. In Figure - 7 below, a 10k ohms pullup resistor is used. The value is high so that when the switch is pressed and the GND is connected to 5V, the current passing through is very less and does not burn the wire or damage the circuit. MinnowBoard has internal pullup resistors.

Figure-7: Pullup resistor connected


Push button

A pushbutton is a simple switch mechanism which permits user generated changes in the state of a circuit. Pushbutton usually comes with four legs. As seen from the Figure - 9 below, legs are always connected in groups of two. When the pushbutton is pressed all the 4 legs are connected.


Figure-8: Push Button

Figure-9: Working of push button

The pushbutton used in this guide can be purchased from here:

https://www.sparkfun.com/products/97

Selecting the correct LED

• To make sure that you do not damage the GPIO pins on the MinnowBoard, please use a LED whose rating should not exceed 3.3V/10mA:

http://www.digikey.com/product-detail/en/HLMP-4700-C0002/516-2483-2-ND/1234840

• If you have an LED that is higher than the above mentioned ratings, please refer the refer the link below to select an appropriate current limiting resistor:

http://www.cmiyc.com/tutorials/led-basics

Physical Computing

Physical computing, in the broadest sense, means building interactive physical systems by the use of software and hardware that can sense and respond to the outside world. In our case we are trying to take input from the surrounding via the push button and accordingly causing some change in the outside world by turning ON the LED when the push button is pressed.

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. The GPIO sysfs interface allows users to manipulate any GPIO from userspace. Since it uses [1], it is able to dynamically utilize all GPIOs on the system. The preloaded Angstrom image on the MinnowBoard already has all the GPIO on J9 header exported to the userspace by default.

Setup

Please refer Figure - 10 below to see the connections:


Figure-10: Connection Diagram


Only the pins on the J9 expansion header are used in this case. Connect the anode of the LED to the resistor(I am using a 330 ohms resistor) which in turn is connected to pin 3(GPIO) and connect the cathode of the LED to pin 2(GND) . You can purchase the male-female type hookup/jumper wires used for connections from the link below:

https://www.sparkfun.com/products/9140

Booting Angstrom

Step-1:

First insert the card into the microSD card slot label side up as shown in Figure -11.

Figure-11: Connecting the micro SD card


Step-2:

Next, connect an external keyboard and mouse to the MinnowBoard. Then connect a USB mini cable to your computer and the MinnowBoard as shown in Figure -12. This connection will be used to access the serial console of the MinnowBoard.

Figure-12: Connecting a USB mini cable for serial console access


Step-3:

Now power up the MinnowBoard, connect the 5V/2.5A power supply to it as shown in Figure -13:

Figure-13: Powering up the MinnowBoard


Step-4:

Access the MinnowBoard's serial console via a terminal emulator:

$ sudo screen /dev/ttyUSB0 115200

Note:- You can also use minicom, but screen is much easier to use! Also in most cases the virtual USB serial port is ttyUSB0. If it does not work, try ttyUSB1


Step-5:

You should see a similar Angstrom login screen as shown in Figure - 14. The username is 'root' and there is no password - just press the Enter key.

Figure-14: Angstrom


Script

#!/bin/bash 
#Use Pin-3 as output pin 
echo out > /sys/class/gpio/gpio244/direction
#Use Pin-7 as input pin 
echo in > /sys/class/gpio/gpio248/direction
# Read forever
while : 
do 
# Read value of Pin-7 
THIS_VALUE=`cat /sys/class/gpio/gpio248/value`
if [ "$THIS_VALUE" = "0" ] 
then 
echo 1 > /sys/class/gpio/gpio244/value 
else 
echo 0 > /sys/class/gpio/gpio244/value 
fi
done 

In the above script, '#' is used for comments(except for first line). Write the above script in your favorite text editor, save it(make sure to add the '.sh' extension at the end) and place it in on the microSD card before you boot the MinnowBoard. Or you can use a text editor like 'vi' on the MinnowBoard and write the above script. In any case make sure the script is executable by typing the following command in the terminal:

$ chmod a+x <script_name>

In my case, I named the script 'physicalcomputing.sh'

Steps

So, now run the script created earlier by typing the following command in the terminal as shown in Figure - 15:

$ ./physicalcomputing.sh


Figure-15: Running the script

Output

You should get an output as shown below:


Figure-16: Led ON


Figure-17: Led OFF


Windows Users

This section is for those who are using a Windows machine to interact with the MinnowBoard.

Serial Terminal

We will be using Teraterm as our terminal application. Please follow the steps below to set up Teraterm:

Step-1:

Download the latest version of Teraterm using the link below:

Teraterm

At the time of writing this guide, the latest version was '4.78' .


Step-2:

Install the Teraterm software by double clicking on the exe file downloaded earlier. If it displays a security warning, accept it and click on 'Run' as shown in Figure - 18 below:

Figure-18: Teraterm installation


Step-3:

Now just follow the on-screen instructions to install the software. It is advised to do the 'full' installation instead of the 'standard' one as shown in Figure - 19 below:

Figure-19: Perform Teraterm full installation


Step-4:

Launch Teraterm. Then go to Setup>Serial port and change the settings as shown in Figure - 20 below:

Figure-20: Teraterm Serial Port setup


Step-5:

Then go to File>New connections and select the Serial option and chose the appropriate COM port as shown in Figure - 21 below

Figure-21: Setting up a new connection


Step-6:

Then connect the required accessories as described earlier in this guide and power up the MinnowBoard. If all went well, you should see a login screen in Teraterm as shown in Figure - 22 below:

Figure-22: Angstrom login


Preparing the microSD card

Step-1:

First, download the latest Angstrom Linux image from the link below:

Latest Angstrom Image


Step-2:

Next, download the 7-zip utility from the link below and install it:

7zip


Step-2:

Decompress the previously downloaded Angstrom image using 7-zip as shown in Figure - 23 below. The resulting file should have an extension '.img' .

Figure-23: Decompressing the image


Step-3:

Image Writer for Windows is needed to write the .img file to a microSD card. Download and install Image Writer using the link below: :

Image Writer for Windows


Step-4:

Insert the mircoSD card into the computer using an appropriate adapter. Next, launch the image writer software we just installed earlier. Select the Angstrom image and write it to the microSD card as shown in Figure - 24 below.

Figure-24: Writing the image to microSD card


Mac Users

This section is for those who are using OS X to interact with the MinnowBoard.

Serial Terminal

We will be using the 'screen' command which is by default a part of the bash shell on OS X. Now to use screen command, the FTDI driver(it is enables communication between the development board and computer over USB) has to be installed. Please follow the steps below to install it:

Step-1:

Download the latest ftdi driver for Mac OS X from the link below and make sure that you select the correct file corresponding to your computer architecture(32/64 bit):

FTDI Drivers


Step-2:

Double click on the downloaded file to start the installation procedure.


Step-3:

You will have two files inside the downloaded driver package as shown below in Figure - 25. The first file, ending with 10_3 is specific for Mac OS X version 10.3 . The second file is for all other versions, newer than 10.3 .

Figure-25: FTDI driver


Step-4:

Based on your Max OS X version, select the appropriate and double click it to proceed further.


Step-5:

You will now be greeted with an ftdi installer screen as shown in Figure - 26.

Figure-26: FTDI installer screen


Step-6:

Proceed forward by pressing the 'continue' button till you reach the “installation type” screen as shown below in Figure -27.

Figure-27: FTDI driver installation


Step-7:

Now press the 'install' button and wait for it to finish as shown in Figure - 28.

Figure-28: FTDI driver installation in progress


Step-8:

If the installation was successful, you should be greeted by a screen similar to the one shown in Figure - 29

Figure-29: FTDI driver installation successful


Step-9:

Then connect the required accessories as described earlier in this guide and power up the MinnowBoard.

If everything went well, you will see new entries in the /dev directory:

/dev/cu.usbserial-xxxxxxxx
/dev/tty.usbserial-xxxxxxxx 

Here, xxxxxxxx is either the device's serial number or, for unserialized devices, a location string that depends on which USB port your device is connected to. /dev can be accessed through the Terminal application. The Terminal application can be launched by selecting Go > Applications > Utilities > Terminal. Now fire up the terminal in Mac OS X and type the following command in it:

$ cd /dev 


Step-10:

Access the MinnowBoard's serial console via a terminal emulator and you should be greeted by the Angstrom screen as shown in Figure - 30:

$ sudo screen /dev/tty.usbserial-xxxxxxxx 115200

Figure-30: Angstrom

Preparing the microSD card

Step-1:

First, download the latest Angstrom Linux image from the link below:

Latest Angstrom Image


Step-2:

Next, install the “The Unarchiver” application(it is free) from the app store on Mac OS X as shown in Figure - 31

Figure-31: The Unarchiver


Step-3:

Then unpack the downloaded angstrom image using the unarchiver application as shown below in Figure -32

Figure-32: Unpacking the Angstrom image


Step-4:

Insert the microSD card into a microSD compatible writer in your computer. Now, identify the disk device filename for your microSD card. You can do this by typing the command below, before and after you insert the microSD card and comparing the outputs to see the newly added device:

$ df-h

Note:- If you notice closely, the microSD card entry will be in the form of /dev/diskNsX where 'N' and 'X' are numbers. diskNsX is basically the device id of your microSD card. So, to obtain the raw device id from this, remove the 's' and 'X' from the device id. The raw device id should be in the form of diskN .


Step-5:

Now, make sure all possible disk partitions from the microSD card are unmounted by typing the command below into your terminal: $ sudo umount /dev/diskN?* Here 'diskN' stands for the raw device id of the microSD card.


Step-6:

Now unpack the image to the microSD card by typing the command below in a terminal window:

$ sudo dd if=Angstrom-development-GNOME-image-eglibc-ipk-v2012.12-minnow-2013.07.10.img of=/dev/rdiskN

Note:- In the above command we subtly replaced “diskN” with “rdiskN” because in the latter case, you are writing to a buffered device and hence the process becomes much faster!


Resources

Please refer the websites below for more videos, tutorials, and projects you can do with your MinnowBoard:

  1. http://www.minnowboard.org/
  2. http://www.elinux.org/Minnowboard
  3. http://www.angstrom-distribution.org/