- System Configuration
- Bill of Materials
- Set of Instructions
- More Details
- Using the Gertboard
- Trouble Shooting
- Appendix A - The Gertboard
- Appendix B - The Software
- Appendix C - The External Interface Board
- About this Document
This Project is about introducing the use of the Gertboard to extend the functionality of the Raspberry Pi (R-Pi). In particular, the use of the Gertboard to drive external Light Emitting Diodes (LEDs), to provide input from external switches/buttons and to use the Analogue to Digital Converters (ADC) will be explained and demonstrated. Furthermore, the control of the Gertboard directly from the R-Pi and its keyboard/mouse, and from a browser through a network will also be explained and demonstrated. The key learning objectives of this project are for an intermediate/novice developer to learn:
- How to use the LED, push-button switch and ADC features on a Gertboard connected to a R-Pi and how to use the Gertboard to control external LEDs and push-button switches;
- How to write software that can be used by any browser-enable device e.g. smart phone, tablet, desktop, etc. to access the LEDs, push-button switches and ADCs controlled by the Gertboard.
The associated Bill of Materials describes the set of components, hardware and software, required to complete this project. When complete, the system will look as shown in the Figure below. There is a signifiant amount of information about the Gertboard available on the Element14 Community Gertboard web-site.
|The completed system.|
The system configuration is shown in Figure 1.1. The basic configuration is:
- R-Pi (Model A/B) - this project can make use of either Model. In both cases it is recommended that a WiPi is used to provide network connectivity (wireless, IEEE 802.11) via the USB2 port on the R-Pi. Network connectivity is required to provide access to the R-Pi Web Server and to download and install the necessary software updates required by the Gertboard software. A USB2 hub is recommended to enable more than two USB devices to be linked to the R-Pi (the R-Pi has two USB ports). It is assumed that the keyboard and mouse are linked via the USB Hub. The monitor can be linked either via the HDMI interface or the yellow RCA phono connector for composite video output. In this project a PiView connector is used to enable a monitor with a VGA connector to be connected to the R-Pi via the HDMI interface;
- Gertboard - a single Gertboard is connected to the GPIO interface on the R-Pi. The Gertboard configurations vary depending on the input/output operations required. For this set of instructions the Gertboard will be configured, separately, to drive the internal/external Light Emitting Diodes (LEDs), the internal/external switches/buttons and the external potentiometer. The Gertboard User Manual (Revision 2.0 published in 2012 by Fen Logic Ltd) is available at: Gertboard User Manual. This is required reading;
- LEDs, Switches and Potentiometer (Pot) circuitry - the 12 LEDS are wired so that they can be driven as outputs via the Gertboard buffers. The LEDs used in this project have forward voltage of between 2.0V-2.2V. The two external switches are 'Push-to-Make' switches and they are again connected to the Gertboard buffers. The 'Pot' is wired to the Analogue-to-Digital Converter (ADC) interface on the Gertboard.
|Figure 1.1 - System configuration.|
When the complete system is built it will look as shown in Figure 1.2. The views shown in Figure 1.2 are front (a), back (b), and sides (c) and (d).
|Figure 1.2 The completed system.|
(a) Front view.
(b) Back view.
(c) Side view.
(d) Side view.
The architecture is based upon the use of an R-Pi to drive a Gertboard with the software controlled by access through a web browser. The configuration is shown in Figure 2.1 and the key to the alphanumeric labels is provided in Tables 2.1 and 2.2.
|Figure 2.1 System configuration for the bill of materials|
The associated bill of materials for the system shown in Figure 2.1 is listed in Table 2.1.
Table 2.1 - The Bill of Materials.
|1(a)||R-Pi Model A||Either Model can be used (includes 4GB SD Card). Use a Multicomp enclosure to protect the R-Pi base.||1|
|1(b)||R-Pi Model B||Use a Multicomp enclosure to protect the R-Pi base. Can include a Cat 5 Ethernet cable.||1|
|1(c)||R-Pi Enclosure||Multicomp enclosure to protect the R-Pi base.||1|
|1(d)||SD Card||Storage medium (8GB) for the R-Pi (with NOOBS pre-installed).||1|
|2||Gertboard||The external board, connected to the R-Pi using the GPIO interface, responsible for input/output to external devices.||1|
|3||Keyboard||Include a USB cable. Get as part of an Accessory Bundle (see 4 below).||1|
|4||Mouse||Include a USB cable. Get as part of an Accessory Bundle (see 3 above).||1|
|5||WiPi||Wireless access via USB. Required to provide network access if a R-Pi Model A is used.||1|
|6||PiView||HDMI/VGA adapter to provide connection to a non-HDMI enabled monitor.||1|
|7||Monitor||A suitable colour monitor (VGA or HDMI connectivity recommended).||1||N/A|
|8||USB2 Hub||Includes the power supply and USB2 cables.||1|
|9||Power Supply||R-Pi power supply with 5V/1A output. Micro USB connector.||1|
USB2 power supply (5V/1A with 2.1mm x 5.5mm Barrel Plug connector).
Included with the USB2 Hub (see 8 above).
|11||Browser-based Devices||Tablet Computers, Smart Phones, Laptops and Desktop Computers.||1||N/A|
|12||Copper Strip Board||Used to hold the LEDs, switches and resistors to create the display and the switch mount units.||1||N/A|
|13||LEDs||5MM/2V LEDs of any colour/colour combination.||12|
|14||Switches||Multicomp 'Push-to-Make' switches. 28mm long and 7mm diameter.||2|
|15||Potentiometer||A linear/radial analogue potentiometer.||1|
A 1m mixture a red/black single core wires of wiring of the LEDs, Switches and Potentiometer.
A set of longer wiring straps (8cm) for connecting between the Gertboard and the external LEDs and switches are required.
|17||2-Pin Headers||These pins (2.54mm) are used to provide connection to the external LEDs and switches.||14|
|18||3-Pin Headers||These pins (2.54mm) are used to provide connection to the potentiometer.||1|
The hardware connectivity is detailed in Table 2.2.
Table 2.2 - Hardware connectivity.
|A||VGA (PiView)||Monitor/R-Pi||Part of the Monitor cable to the R-Pi.|
|B||HDMI (PiView)||R-Pi/Monitor||Part of the Monitor cable to the R-Pi.|
|C||Power Cable||R-Pi Micro USB/Mains||Power supply for the R-Pi.|
|D||GPIO||R-Pi/Gertboard||The Gertboard can be plugged directly into the R-Pi. Alternatively a separate GPIO flat-flex cable (male-to-female).|
USB2 Hub/Mouse + Keyboard
|Power for the USB2 hub - the hub supports seven ports.|
|F||USB Cable||USB2 Hub/Mouse + Keyboard|
USB cable connection for the Mouse and Keyboard.
|G||USB Insert||R-Pi/WiPi||The WiPi will be plugged directly into the USB2 hub.|
|H||USB Cable||USB2 Hub/R-Pi||USB cable to connect the USB hub to the R-Pi. The R-Pi can also draw power using this cable.|
|Wiring of the external interface board for the LEDs, switches and potentiometer.|
|A set of coloured straps ar supplied as part of the Gertboard. More coloured wiring straps are required to support the full range of links.|
|K||Jumpers||Gertboard.||These are used to configure the various I/O capabilities for the Gertboard.|
The software required to support this project that must be installed on the R-Pi is:
- R-Pi Operating System (Raspbian) - this is installed using the NOOBS that comes pre-installed on the R-Pi SD cards. If NOOBS is not preinstalled it is available at Downloads;
- Integrated Development Environment - IDLE with Python 2.x support (normally installed as part of Raspbian);
- The Apache2 Web Server - this may be installed as part of the Raspbian operating system. If not, then use the instructions provided in Appendix B1.5.
The set of instructions for using the Gertboard are:
- Configure the R-Pi system in preparation for the connection of the Gertboard and usage of the software i.e. the monitor, USB2 Hub, keyboard and mouse and the network connection (using either a WiPi for wireless access or using the wired Ethernet port). If the WiPi is to be used then insert the WiPi into one of the USB ports on the R-Pi - see More Detail;
- The next step is to connect the Gertboard to the RPi. The Gertboard/RPi connection is via the GPIO interface on the top of the RPi and the underside of the Gertboard (the layout of the Gertboard is shown in Appendix A). The Gertboard is supplied with a set of 6 plastic rods that can be inserted into the Gertboard so that it can be stood without the underside of the board touching the surface and so that the GPIO interface does not take all of the weight of the Gertboard on the RPi. If the Gertboard is to be inserted directly into the RPi then do not insert the plastic rod on the bottom left corner of the Gertboard when looking at the underside with the GPIO connector at the bottom (this corner rests over the video jack port). It is possible to use a extra GPIO male/female cable (not supplied as part of the Gertboard) to connect the Gertboard to the RPi but in these instructions direct connection is assumed - see More Detail;
- The external interface board that provides the external LEDs, switches and the potentiometer can now be constructed. The exact layout of the board is unimportant and fewer LEDs and/or switches can be used. The layout of the Board used in these instructions is described in Appendix C and in Video 1. This board will be used to show how the Gertboard is used to drive external devices through the ADC and Buffered I/O pins on the Gertboard;
- The Buffered Output on the Gertboard can now be demonstrated. This is demonstrated by using the R-Pi to switch on and off the set of onboard LEDs (on the Gertboard) and external LEDs (on the external interface board). The first demonstration will use the test software that is available as part of the Gertboard distribution kit. This test software is available as both 'C' and Python code. We will use the Python versions only. The instructions to obtain the Python text software are given in Appendix A2. The Gertboard must be wired for buffered output using the appropriate wiring straps and jumpers (if all twelve LEDs are to be used then 12 jumpers are placed on the Gertboard, 12 wiring straps are used on the Gertboard between the GPIO pins and the B1-B12 pins, and 24 wiring straps are used between the buffer pins and the LED pins and the external interface board - see Video 2). The test program 'leds-rg.py' is now used (this is a part of the downloaded Gertboard test software) to demonstrate the LEDs being switched on and off (see Video 3) - see More Detail;
- Driving the Buffered Output on the Gertboard via a web browser can now be demonstrated. The hardware configuration and wiring of the R-Pi and Gertboard remain unchanged. The software configuration must be changed. New Python software is available that enables the same set of LEDs to be controlled using a web browser. This software includes an HTML page which is loaded into the web browser to enable the control of the LEDs. Any web browser can be used on any device that supports a web browser. We demonstrate the use of an iPad with the Safari web browser but the software has also been tested using Midori on the R-Pi and a Chrome, Safari and FireFox on a range of other devices (see Video 3) - see More Detail;
- The ADC on the Gertboard can now be demonstrated. This is demonstrated by using a potentiometer to provide a variable analogue input to the Gertboard's ADC input ports. The equivalent digital value is then provided by the Gertboard's ADC. The first demonstration will again use the Python test software that is available as part of the Gertboard distribution kit. The Gertboard must be wired for one of the ADC channels (the Gertboard has two ADC channels) using the appropriate wiring straps and jumpers i.e. four jumpers and three wiring straps between the ADC pins and the potentiometer on the external interface port (see Video 4). The test program 'atod.py' is now used to show the digital output when the value of the potentiometer is manually varied (see Video 4) - see More Detail;
- Monitoring the use of the Gertboard's ADC via a web browser can now be demonstrated. Again hardware configuration and wiring of the R-Pi and Gertboard remain unchanged. Also, new Python software is available that enables the ADC channels to be monitored using a web browser (see Video 4). This software includes an HTML page which is loaded into the web browser. Any web browser can be used on any device that supports a web browser - see More Detail;
- The Buffered Input on the Gertboard can now be demonstrated. This is demonstrated by using the three onboard switches (on the Gertboard) and two external switches (on the external interface board). The first demonstration will again use the Python test software that is available as part of the Gertboard distribution kit. The configuration and wiring (using the appropriate jumpers and wiring straps) of the Gertboard is different for the onboard and external switch usage (see Video 5). The test program 'buttons-rg.py' is now used to demonstrate the operation of the buffered input ports via the switches (see Video 5) - see More Detail;
- Monitoring the Buffered Input on the Gertboard via a web browser can now be demonstrated. The hardware configuration and wiring of the R-Pi and Gertboard remain unchanged. Again new Python software is available that enables the buffered inputs to be monitored using a web browser (see Video 5). This software includes an HTML page which is loaded into the web browser - see More Detail.
The layout of the R-Pi (Model B) is shown in Figure 4.1. Once the various cables have been connected to the R-Pi, the configuration is as shown in Figure 4.2 (the alphanumeric annotations refer to the identifier entries in Tables 2.1 and 2.2). The latest versions of the Raspbian operating system can be installed using the instructions in Appendix B1.1. Make sure that the Git client is installed (see Appendix B1.2).
|Figure 4.1 - R-Pi Model board B layout.||Figure 4.2 - The R-Pi with the set of connected cables.|
If the WiPi has been inserted, the use of the appropriate wireless network must be established (this requires a wireless network to be activated, via an appropriate wireless network access device e.g. a wireless router, and for that device to be assigning IP addresses using DHCP). This is achieved by working on the desktop:
- Click on the 'wifi config' icon;
- Now click on the 'scan' button;
- From the resulting scanned list pick your wireless network;
- Enter the password for the network in the 'psk' box and click 'Add';
- Click 'Connect'. The wireless network access point will now allocate an IP address to the R-Pi and will display the IP address (for example this will take the form of 192.168.1.99). Make a note of this address as this value will be required in some of the later instructions;
- Test that there is network access by running the Midori web browser to access a web-site e.g. the BBC web-site at: http://www.bbc.co.uk.
Once the above WiPi configuration has been completed, the R-Pi can be rebooted without repeating the above actions. However, each time the R-Pi is rebooted, the DHCP may not allocate the same IP address. In this case the IP address can be obtained by:
- Click on the 'LXTerminal' icon;
- Type the instruction: Hostname -I
The same approach for obtaining the IP address is used if the Ethernet port on the R-Pi Model B is being used.
The Gertboard and the R-Pi are connected via the GPIO connectors. The GPIO interface on the underside of the Gertboard (female) is inserted into the GPIO interface (male) on the R-Pi. Figure 4.3 shows the resulting layout. If the 'Missing' Stand Pin was not missing then this form of connection would NOT be possible and so a separate cable would be required.
|Figure 4.3 - Connecting the Gertboard to the R-Pi.|
Once the Gertboard and the R-Pi have been connected then various software should be installed (the installation of the software does not require the Gertboard to be connected to the R-Pi). The software to be installed is:
- The WiringPi Python module - see Appendix B1.3;
- The SPI Dev module - see Appendix B1.4;
- The Apache2 Web Server - see Appendix B1.5;
- The standard Gertboard control/demonstration software (from Raspi TV) - see Appendix B2;
- The new Gertboard Web Server-based control/demonstration software (from the Element14 Github) - see Appendix B3.
The wiring of the RPi, Gertboard and the LEDs on the external interface board is shown in Figures 4.4 and 4.5 (note that in the associated videos there drop-down resistors have been removed as these were significantly reducing the LED brightness). The full details of the actual wiring of the Gertboard to use the buffered output is described in Appendix A2 and shown in Video 2. In Figures 4.4 and 4.5. all 12 buffered outputs are being used to drive the external LEDs and in this configuration the state of the external LEDs must always be same as the same as the internal LEDs. Due to the wiring on the external interface board the the wire straps to the equivalent buffered input/output pins on the Gertboard are swapped (this can be avoided by changing the wiring between the external LEDs and the 2-pin headers). The use of the buffered output ports can now be demonstrated using the standards test Python program in the file 'leds-rg.py' or 'leds-wp.py': the details for obtaining this software are given in Appendix B2. See Video 3 for a demonstration of the control of the onboard and external LEDs.
|Figure 4.4 - R-Pi/Gertboard wiring for using the buffered output ports (top view).|
|Figure 4.5 - R-Pi/Gertboard wiring for using the buffered output ports (side view).|
The equivalent browser-based software can now be used. The details for obtaining the software are given in Appendix B3. The R-Pi and its Apache Web Server (make sure that Apache2 is active on the R-Pi- see Appendix B1.5) must be on a network for this approach to work (in Figure 4.4 the network access is supplied using the WiPi). Once the Web Server Python demonstration software has been installed, a Web browser is used to access the web-page: this requires the IP address of the R-Pi to be used as part of the URL for the web page. i.e.
http://<Your IP Address>/GertBoardTestv1p0p0.html
Using this Web Page the state of the onboard and external LEDs can be controlled (press the blue button on the web-page). See Video 3 for a demonstration of the Web Server approach for driving the onboard and external LEDs.
The wiring of the R-Pi, Gertboard and potentiometer on the external interface board is shown in Figure 4.6 (the wiper pin on the potentiometer, the central pin, is connected to the AD0 pin on the Gertboard using the yellow wire). The full details of the actual wiring for a potentiometer is described in Appendix A3. In this demonstration only one potentiometer is wired to the Gertboard using ADC channel 0. The use of the potentiometer can now be demonstrated using the standards test Python program in the file 'atod.py': the details for obtaining this software are given in Appendix B2 and this requires the 'py-spdev.py' module and SPI configuration as described in Appendix B1.4. See Video 4 for a demonstration of the expected output on the screen as the potentiometer is rotated.
Figure 4.6 - R-PI/Gertboard wiring for ADC channel usage.
Again the equivalent browser-based software can now be used. The details for obtaining the software are given in Appendix B3. The R-Pi and its Apache Web Server (make sure that Apache2 is active on the R-Pi- see Appendix B1.5) must be on a network for this approach to work (in Figure 4.6 the network access is supplied using the WiPi). Once the Web Server Python demonstration software has been installed, a Web browser is used to access the web-page. Using this Web Page the variation of the potentiometer can be displayed (press the red button on the web-page). Note that unlike the standard test program which uses a continual poll of the ADC values, the Web Server approach is a single poll after a period of some 5 seconds (this period can be altered by editing the Python code). See Video 4 for a demonstration of the Web Server approach for monitoring the potentiometer.
The wiring of the RPi, Gertboard and the switches on the external interface board is shown in Figures 4.7, 4.8 and 4.9. The full details of the actual wiring of the Gertboard to use the buffered output is described in Appendix A4 and shown in Video 5. The wiring for using only the three onboard switches is shown in Figure 4.7. When support for two external switches is added then the wiring in Figure 4.8 is used (the two external switches are connected using the 'B11-B12' buffered input/output ports and jumpers must be placed on the 'B11-B12' In jumpers i.e. to set the 'B11-B12' input/output ports as input. The use of the buffered output ports can now be demonstrated using the standards test Python program in the file 'buttons-rg.py' or 'buttons-wp.py': the details for obtaining this software are given in Appendix B2. See Video 5 for a demonstration of the onboard and external switches/buttons (note that in the Video the external switches are wired to the 'B1-B2' buffered input/output ports so that the same test software that is used to demonstrate the onboard buttons can be used for the external switches).
|Figure 4.7 - R-Pi/Gertboard wiring for using the onboard switches.||Figure 4.8 - R-Pi/Gertboard wiring for using the buffered input ports (top view).|
|Figure 4.9 - R-Pi/Gertboard wiring for using the buffered input ports (side views).|
(a) Side view of the external interface board
(b) Side viiew
Again the equivalent browser-based software can now be used. The details for obtaining the software are given in Appendix B3. The R-Pi and its Apache Web Server (make sure that Apache2 is active on the R-Pi- see Appendix B1.5) must be on a network for this approach to work (in Figures 4.7, 4.8 and 4.9 the network access is supplied using the WiPi). Once the Web Server Python demonstration software has been installed, a Web browser is used to access the web-page. Using this Web Page the variation of the state of the switches/buttons can be displayed (press the green button on the web-page). Note that unlike the standards test program which uses a continual poll of the switch/button values, the Web Server approach is a single poll after a period of some 5 seconds (this period can be altered by editing the Python code). See Video 5 for a demonstration of the Web Server approach for monitoring the state of the switches.
A video, 6 minutes long, demonstrating the wiring of the Gertboard and R-Pi is shown in Video 1. This video is available in medium resolution (a) and high resolution (b) - the high resolution will require at least a 3.5Mbps broadband data rate to view.
|Video 1 - Wiring the Gertboard, R-Pi and external interface board.|
(a) High resolution
(b) Medium resolution
A video, 6 minutes long, demonstrating the wiring of the external LEDs to the Gertboard's buffered output is shown in Video 2. This video is available in medium resolution (a) and high resolution (b) - the high resolution will require at least a 3.5Mbps broadband data rate to view.
|Video 2 - Wiring the buffered output on the Gertboard.|
(a) High resolution
(b) Medium resolution
A video, 3 minutes long, demonstrating the use of the Gertboard with external LEDs is shown in Video 3. This video is available in medium resolution (a) and high resolution (b) - the high resolution will require at least a 3.5Mbps broadband data rate to view.
|Video 3 - Demonstrating the buffered output on the Gertboard.|
(a) High resolution
(b) Medium resolution
A video, 5 minutes long, demonstrating the wiring of the Gertboard to the potentiometer using the ADC is shown in Video 4. This video is available in medium resolution (a) and high resolution (b) - the high resolution will require at least a 3.5Mbps broadband data rate to view.
|Video 4 - Demonstrating the ADC on the Gertboard.|
(a) High resolution
(b) Medium resolution
A video, 8 minutes long, demonstrating the use of the Gertboard's buffered input using external switches and R-Pi is shown in Video 5. This video is available in medium resolution (a) and high resolution (b) - the high resolution will require at least a 3.5Mbps broadband data rate to view.
|Video 5 - Demonstrating the buffered input on the Gertboard.|
(a) High resolution
(b) Medium resolution
At runtime, a WiringPi module error is displayed when attempting to run one of the standard Gertboard Python testing files that has the string '-wp' in the name.
This error occurs when the WiringPi module has not been installed on the R-Pi. To install the module correctly follow the instructions in Appendix B1.3. Once installed rerun the Python test program again.
At runtime, a py-spidev module error is displayed when attempting to run the Python 'atod.py' testing file.
This error occurs when either the 'py-spidev' Python module is not installed or the SPI has not be configured correctly. To install the 'py-spidev' Python module and to configure the SPI correctly see the instructions in Appendix B1.4. Once installed rerun the Python test program again.
When attempting to access the demonstration software web-page, 'GertboardTestv1p0p0.html', using a web browser, the message 'Server not found' is displayed on the browser.
This type of error message occurs when the Web Server that contains the required web-page(s) cannot be found. The possible causes are: i) the R-Pi is not on the network; ii) the device hosting the browser cannot connect with the network to which the R-Pi is connected; iii) the Web Server on the R-Pi is not installed, active or correctly configured. To confirm that the RPi is connected to the Internet use the Midora browser on the R-PI to visit a well known web-site. If this access is not possible then confirm that the R-Pi has an IP address (see Section 4.1) and that either the WiPi is correctly installed/working (see Section 4.1) or the Ethernet cable is connected to the R-Pi. You may need to confirm that connection to the Internet is possible through your router (for some networks the relevant MAC address, in this case the MAC address for the R-PI, must be registered with the router - see the corresponding instructions for your router). If there are no network access issues then make sure that the Apache2 Web Server is installed and active on the R-Pi (see Appendix B1.5).
When attempting to access the demonstration software web-page, 'GertboardTestv1p0p0.html', using a web browser, the message '404 Page not found' is displayed or there is a placeholder were the expected image is missing is displayed on the browser.
These errors occur when the Web Server cannot get the web-pages requested by the browser. In this case make sure that the HTML web-page and the three image files are correctly installed/located in the Web Server. See Appendix B3 for more details on installing the web-pages. Also, make sure that you are using the correct file name for the test web page i.e. 'GertboardTestv1p0p0.html'.
When attempting to access the demonstration software web-page, 'GertboardTestv1p0p0.html', using a web browser, the message 'You do not have the access rights' is displayed on the web browser.
This error occurs when the web-page being requested is attempting local processing on the Web Server but the Web Server does not have the correct access rights for the files to be processed. The access rights to the files must be changed (see Appendix B3 for the details on how to change the access rights and for which fled these rights must be changed).
When using the buffered output software only some of the LEDs appear to be used i.e. some never become 'lit'.
There are two sources for this problem: i) the relevant jumpers may not be present; and ii) the wiring straps that connect the GPIO pins to the 'B1..B12' In/Out Port pins may not be present. For each LED that is to be used make sure that both the GPIO wiring strap and the corresponding 'B?' Out jumper pin is present. Make sure that the corresponding 'B?' Input jumper pin is not present unless the port is being used as an input signal port.
When using external LEDs the state of the external and onboard LEDs is different.
If the external LEDs do not light in synchronisation with the onboard LED make sure that the wiring straps to the external interface board are present. Make sure that the buffered input/output port has not be configured as an input port i.e. there should NOT be a jumper on the 'B?' Input jumper pin. If all else fails then test the integrity of the wires and make sure the LED is not 'blown'.
When varying the value of the potentiometer i.e. twisting the knob, there is NO change of the digital value displayed on the browser/display.
Make sure that the wire to the wiper pin on the potentiometer (the central pin) is correctly connected. Check that the other two wires are correctly used.
The layout of the Gertboard is shown in Figures A1.1a (top view), A1b (top view with detailed jumper pins layout) and A1.1c (underside view). The top view shows the location of the GPIO pins, the buffed input/output pins, the onboard LEDs, the ADC pins, the 3.3V power pins and the three onboard switches. The Gertboard provides 12 buffer ports that can be configures for either Input or Output (see Figure A1.1a) and these have a set of LEDs that also show the status of the signal level on the port. The buffer ports are configured as either Input or Output ports using the three sets of input jumper pins (the 'B1..B4', 'B5..B8' and 'B9..B12' In-Jumper pins) and the three sets of output jumper pins (the 'B1..B4', 'B5..B8' and 'B9..B12' Out-Jumper pins) - see Figure A1.1b. Jumpers are placed cross the relevant pins to set the configuration. The buffered ports are linked to the corresponding GPIO ports, and hence the R-PI, using wiring straps between the twelve GPIO Pins (Figure A1.1a) and the twelve 'B1..B12' In/Out Port Pins (see Figure A1.1b).
|Figure A1.1- The Gertboard layout.|
(a) Top view.
(b) Top view for detailed jumper pins layout.
(c) Underside view.
The Gertboard is supplied with a set of 6 plastic rods that can be inserted into the Gertboard so that it can stand without the underside of the board touching the surface and so that the GPIO interface does not take all of the weight of the Gertboard on the RPi. If the Gertboard is to be inserted directly into the RPi then do not insert the plastic rod on the bottom left corner of the Gertboard when looking at the underside with the GPIO connector at the bottom (this corner rests over the video jack port).
The wiring of the Gertboard for use with the buffered output functions is shown in Figures A2.1a (top view) and A2.1b (schematic top view): the schematic view is taken form the Gertboard User Manual and amended to include the wiring to the external devices e.g. LEDs. The wiring uses 12 jumpers on the B1-B12 Out jumper pins sets i.e. three blocks of four jumpers. Twelve, short, wiring straps are used to link the GPIO pins to the 'B1-B12' In/Out port pins (these set the buffered ports as outputs i.e. a signal is sent as output from the R-PI). Finally, 24, long, wiring straps are used to connect the 12 external LEDs to the buffered I/O ports.
|Figure A2.1 - Gertboard wiring for the use of the buffered output ports (top views).|
(a) Top view for buffered output wiring.
(b) Schema top view for buffered output wiring.
Further side views of the Gertboard wiring for the use of the buffered output ports are shown in Figure A2.2.
|Figure A2.2 - Gertboard wiring for the use of buffered output (side views).|
(a) Side view.
(b) Side view.
The wiring of the Gertboard for use with the ADC functions is shown in Figures A3.1a (top view) and A3.1b (schematic top view): the schematic view is taken form the Gertboard User Manual. This wiring is for the use of the ADC0 channel only. The wiring uses four Jumpers on between the pins GP11-SCLK, GP10-MOSI, GP9-MISO and GP8-CSnA). Three wiring straps are used: Black to the 3.3V pin (line 3 in Figure A3.1b), Red to the GND pin (line 1 in Figure A3.1b) and Yellow to the ADC pin (line 2 in Figure A3,1b). It is the Yellow wire that must be connected to the wiper on the potentiometer. The connection of the Red and Black wires to the potentiometer determines the direction in which movement changes, increasing/decreasing, the resistance.
|Figure A3.1 - Gertboard wiring for use of the ADC.|
(a) Top view for ADC wiring.
(b) Schematic top view for ADC wiring.
Further views of the wiring of the Gertboard for use with ADC Channel 0 are shown in Figures A3.2 (the same wiring as shown in Figure A3.1). Figure A3.2a shows connection to a potentiometer with the Yellow cable connected to the wiper (central pin) of the potentiometer.
|Figure A3.2 - Side views of the Gertboard wiring for ADC usage.|
(a) Connection to a potentiometer.
(b) Side view.
The wiring of the Gertboard for use with the onboard buttons and buffered input functions is shown in Figures A4.1a (top view) and A4.1b (schematic top view): the schematic view is taken form the Gertboard User Manual and amended to include the wiring to the external devices e.g. buttons. In Figure A4.1b the wiring uses 5 jumpers on the B1-B3 Out jumper pins sets and the B11-B12 In jumper pins. Five, short, wiring straps are used to link the GPIO pins to the 'B1-B3' (these are optional) and 'B11-B12' (to set these as input ports) In/Out port pins. Finally, 4, long, wiring straps are used to connect the two external buttons to the buffered I/O ports.
|A4.1 - Gertboard wiring for use with onboard buttons and external buffered input.|
(a) Top view wiring for use of the onboard buttons (support for external buffered input not shown).
(b) Schematic view for onboard buttons and buffered input wiring.
Further side views of the Gertboard wiring for the use of the onboard switches are shown in Figure A4.2.
|Figure A4.2 - Side views of the Gertboard wiring for the use of the onboard switches.|
(a) Side view.
(b) Side view.
B1.1 Update the Operating System
To ensure that you have the latest version of the operating system and the Python development environment then working in the LXTerminal application type the following instructions:
sudo apt-get update
sudo apt-get install python-get python-pip
This will download and install the latest versions of the software.
B1.2 Install GIT
A lot of the required software is stored in GitHub. Access to this software repository requires the use of Git. To install Git, use the LXTerminal and type the following instructions:
sudo apt-get install git-core
The installation process will inform you if you already have the latest version of Git installed and will to over right that latest version.
B1.3 Install the Wiring.Pi Module
Using the LXTerminal application type the following instruction:
sudo clone git://git.drogon.net/wiringPi
To build and install the WiringPi module type:
Once this installation has been completed it can be confirmed by typing the instruction:
This should print to the terminal a list of the states of all the GPIO devices. This list provides a map between the WiringPi Pin Number, the BCM (Broadcom chip) GPIO Pin Number, Physical Pin Number, Mode and Value. Take a copy of this table.
NOTE: If you use the GPIO Utility then be careful because some functions use the 'BCM Pin Number' whereas others use the 'WiringPi Pin Number' by default. Read the GPIO Utility notes carefully.
B1.4 Install and Enable the SPI Dev Module
Using the LXTerminal application, the 'py-spidev' module is installed by typing the following instructions (make sure that Git has been installed):
git clone git://github.com/doceme/py-spidev
Once completed, type:
sudo python setup.py install
Once the module has been installed, the SPI capability for the operating system must be enabled. To enable the SPI driver the file raspi-blacklist.conf file has to be edited and the line 'blacklist spi-bcm2708' must be 'commented out'. Once edited the line should read as (the hash makes the line a comment):
The file raspi-blacklist.conf can be edited by typing into the terminal interface:
sudo nano /etc/modprobe.d/raspi-blacklist.conf
If you use the alternative technique of typing into the terminal the instruction:
sudo modprobe spi-bcm2708
then you will have to do this every time the R-Pi is restarted. Now restart the R-Pi.
B1.5 Installation and Configuration of the Apache2 Web Server
The new software written for this project makes use of a Web Server. To install the Apache2 Web Server, using the LXTerminal application type the following instructions:
sudo apt-get install apache2
Now that the Web Server has been installed it has to be configured to support the running of Python programs. All of the web pages must be placed in the folder /var/www whereas the Python programs must be placed in the folder /usr/lib/cgi-bin. Whereas Apache is already configured to handle '.html' files it must be configured to execute the '.cgi' and '.py' files. Again using the LXTerminal application type the instructions:
Now make a copy of the current default file so that the regional can be reused at a later date.
sudo cp default old_default
Now edit the current 'default' file by starting the editor:
sudo nano edit default
In the section starting ScriptAlias /cgi-bin /usr/lib/cgi-bin/ the flowing line must be added:
AddHandler cg-script .cgi .py
Save the change and exit the editor. Now restart Apache:
sudo restart apache2
This new line has configured Apache2 so that any script files in the folder /usr/lib/cgi-bin which have a file extension of '.cgi' or '.py' are scripts that can be called and executed from '.html' files.
Testing of the configuration and wiring, and use of the Gertboard uses the software written by A.Eames of Raspi.TV. This software is written in Python 2.7. The software can be downloaded to your computer or via a browser by visiting the web-site: http://raspi.tv/downloads. To get the software directly on your Internet connected R-Pi then, working in LXTerminal, use the 'cd' instruction to change directory to that where you want the programs installed, now type the commands:
These instructions will download and establish the directory GB_Python in which is stored the set of Gertboard Python test programs (each of the Python programs has a '.py' file extension). The 'README.txt' file provides further instructions on how to configure the operating system to enable the programs to be used with a Gertboard. The programs are supplied in two flavours: one using the RPi.GPIO Python module (RPi.GPIO is installed in all Raspbian operating system from Sept 2012 onwards) and one using the WiringPi for Python module (the instructions on how to install the WiringPi module are provided in Appendix B1.3). Both may be required depending on what you are going to do with the Gertboard using Python. For example, RPi.GPIO cannot be used to drive the Gertboard's pulse code modulation (PCM) capability. Three programs will be used to test and demonstrate the use of the Gertboard:
- leds-rg.py - test of the buffered output ports and the inboards LEDs using the RPi.GPIO module
- buttons-rg.py - test of the onboard buttons and the buffered input ports using the RPi.GPIO module
- atod.py - test for ADC using the SPI on the Gertboard with the 'spidev' module (this also requires configuration of the SPI as described in Appendix B1.4).
B3.1 Installing the Software
The software written for this project is available in the Element14 GitHub at: https://github.com/element14/pi_project/tree/master/Gertboard_Introduction. A clone of this software should be established using an appropriate software versioning application. The clone can be established at: https://github.com/element14/pi_project.git. The software is collected in two folders: 'cgi-bin' and 'www'. The software files are:
- Buttontestv1p0p0.py - the python script to run the button test;
- Ledtestv1p0p0.py - the python script to run the led test;
- Pottestv1p0p0.py - the python script to run the potentiometer test.
- GertboardTestv1p0p0.html - the webpage you see on the remote browser;
- ButtonTestButton.png - the image for the “Button Test” button;
- LEDTestButton.png - the image for the “LED Test” button;
- PotTestButton.png - the image for the Potentiometer “Pot Test” button.
The files in the 'www' folder should be copied into the R-Pi directory '/var/www/' and the file in the 'cgi-bin' folder should be copied into the R-Pi directory '/usr/ib/cgi-bin/'. The next step is to make sure that these files have the correct access rights i.e. readable and exectable by Apache2. Using the LXTerminal application type the following instructions:
sudo chmod 755 GertBoardTestv1p0p0.html
sudo chmod 755 ButtonTestButton.png
sudo chmod 755 LEDTestButton.png
sudo chmod 755 PotTestButton.png
sudo chmod 755 Buttontestv1p0p0.py
sudo chmod 755 Ledtestv1p0p0.py
sudo chmod 755 Pottestv1p0p0.py
B3.2 Using the Software
To use and test that the software has been correctly installed start a browser on a device that is on the same local network as the R-Pi. In your browser type in the location (the URL for the test page):
http://<Your IP Address>/GertBoardTestv1p0p0.html
The 'Your IP Address' can be obtained using the LXTerminal application and typing the command:
If the software has been installed correctly the web page show in Figure B3.1 should be displayed on your browser. If not, then read the Troubleshooting instructions.
|Figure B3.1 - The start web page displayed for the Gertboard testing.|
B3.3 Design of the Software
The design of this new software is largely based upon that by Alex Eames (RasPi.TV) and his use of the 'WiringPi.py' module, to demonstrate the use of the Gertboard. The aim has been to take this software and convert it to an equivalent form that can be accessed through a Browser and Web Server. The WiringPi and RPi.GPIO software both require root access hence using the command 'sudo' to run one of the test programs. There is no equivalent command in a Browser but the corresponding Python programs used by the Web Server make use of 'bash' shell commands to achieve the same access to the R-PI's GPIO interface.
The core HTML code for the web-page is shown below:
01 <html xmlns="http://www.w3.org/1999/xhtml">
03 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
04 <title>Gertboard Test Program</title>
07 <h1>Gertboard Test Page</h1>
08 <p>Press one of the buttons below to start the corresponding test.</p>
11 <td><div align="center"><a href="/cgi-bin/Ledtestv1p0p0.py"><img src="LEDTestButton.png" width="155" height="89" alt="LED Test Button"/></a></div></td>
12 <td><div align="center"><a href="/cgi-bin/Buttontestv1p0p0.py"><img src="ButtonTestButton.png" width="155" height="89" alt="Button Test Button"/></a></div></td>
13 <td><div align="center"><a href="/cgi-bin/Pottestv10p0.py"><img src="PotTestButton.png" width="155" height="89" alt="Potentiometer Test Button"/></a> </div></td>
16 <td><div align="center">Run LED Test Sequences</div></td>
17 <td><div align="center">Press up to 10 buttons in 10 seconds</div></td>
18 <td><div align="center">Potentiometer Test</div></td>
The key features are lines 11-13 which define the code that is to be run on the Web Server when the associated 'button' on the web-page is pressed. For example, in line 11, the image 'LEDTestButton.png' is used to invoke the Python code in the file 'Ledtestv1p0p0.py' in the 'cgi-bin' directory. When a user presses the image, an HTTP call is sent to the Web Server which upon receipt runs the corresponding Python program. In this case it causes the LED test sequence to be completed. Once competed the Python code redraws the web-page on the browser in preparation for another user action.
The layout of the external interface board is shown in Figures C1.1a (top view), C1.1b (bottom view), C1.1c (side) and C1.1d (side). The external board is used to house the 12 external LEDs, the two external switches and the potentiometer.
|Figure C1.1 - The external interface board.|
(a) Top view.
(b) Bottom view.
(c) Side view.
(d) Side view.
Twelve LEDs are supplied on the board i.e. one for each of the output buffers available on the Gertboard. As shown in Figures C1.1a and C1.1b, each LED has two pins, the Anode (A) and the Cathode (C). These LEDs have a forward voltage of approximately 2.0V-2.2V with a forward current of 20mA. The output voltage across an I/O buffer on the Gertboard was measured at 2.3V and so no drop-down resistor is required. As shown in Figure C1.1b, each LED is wired to 2-way square pin Molex Header with pins 'J' and 'K' with 'A' wired to 'J' and 'C' wired to 'K'. If a drop-down resistor is used then this would be inserted between pins 'J' and 'A'.
Two external push-button switches are supplied on the board. As shown in Figures C1.1a and C1.1b these each have two pins 'X' and 'Y'. Connection to each of the set of pins is achieved using a 2-way square pin Molex Header. It does not matter which way round these 'X' 'Y' pins are connected to the Gertboard.
The Pot is used to demonstrate the operation of the ADC functionality of the Gertboard. As shown in Figures C1.1a and C1.1b, the Pot has three pins 'A', 'B' and 'C'. The central pin 'B' is the wiper and pins 'A' and 'C' should be connected to the high (3.3V) and ground (0V); it does not matter which way round pins 'A' and 'C' are connected unless the direction in which the potentiometer is to be rotated is important. A rotational pot is used herein but this could be replaced by any equivalent form of pot e.g. linear slider. Connection to the three pins is achieved using a 3-way square pin Molex Header.
|Analogue to Digital Converter|
This is the conversion of an arbitrary analogue signal (in the range 0V-3.3V) into its digital equivalent. The ADC capability on the Gertboard is based upon two channels with a sampling rate of 72 samples per second with a maximum digital value of 1023 for an input single of 3.3V.
The Dynamic Host Configuration Protocol (DHP) is responsible for allocating an IP Address to a device from DHCP Server (typically supported in the local wireless/broadband router that is also connected to the Internet). DHCP avoids having to allocate a device with a specific, unique, IP address.
The Gertboard is an input/output extension board for the R-Pi. It fits onto the GPIO pins of the R-Pi via a socket on the back of the Gertboard. The Gertboard has a collection of functional blocks which can be connected together, using cable straps and jumpers, in a wide range of ways using header pins.
The General Purpose Input/Output interface that is used to connect the Gertboard to the R-Pi. The GPIO can be driven in several ways depending on what is required and the nature of the software that is driving the interface. In the case of Python-based software the GPIO interface can be driven using the RPi.GPIO and WiringPi packages.
High Definition Multimedia Interface. This is one of the interfaces to the monitor. The PiView is connected to this interface.
Integrated Development Environment for Python. It is completely written in Python and the Tkinter Graphical User Interface (GUI) toolkit (wrapper functions for Tcl/Tk). This is the development environment used for producing the software in this project.
This is the address for a device that enables it to access the Internet. Every device that uses the standard Internet (assuming that is is based upon the Internet Protocol, IP) must have an IP Address that is in the form of '***.***.***.***' e.g. '188.8.131.52'. This is typically allocated through the use of DHCP.
Light Emitting Diode. A set of 12 LEDs is used in this project.
New Out Of Box Software. NOOBS is used to install the appropriate version of Operating System (O/S) onto the R-Pi SD card. The Raspbian O/S is used for this project. In many cases, NOOBS is now pre-installed on SD cards that are sold for use with the R-Pi. The latest version of NOOBS is available from the Raspberry Pi Foundation downloads.
The software in this project is written using Python 2.7. IDLE is used to support the development of the Python code.
The R-Pi is the single board computer at the heart of this project. This project will work on both Model A and B versions. This project requires access to the Internet and so R-Pi Model A must also use a WiPi device.
|SD||Secure Digital (SD) is a non-volatile memory card format for use in portable devices. This is the storage medium for the R-Pi.|
Universal Serial Bus.
A Video Graphics Array (VGA) connector is a three-row 15-pin DE-15 connector. The 15-pin VGA connector is found on many video cards, computer monitors, and high definition television sets. In this project a PiView was used to connect the VGA monitor to the HDMI on the R-Pi.
A Web Server is the software that is responsible for providing access to web pages i.e. pages written in HTML and accessed using HTTP. The R-Pi contains a Web Server. The corresponding web services are accessed by pointing a browser at the web-site using the appropriate combination of the IP Address and the specific directory/file names (this avoids having to register a domain name e.g. 'www.element14.com' but still allows the R-Pi Web Server features to be used).
The device that can connect an R-Pi to a wireless network (using the IEEE 802.11 media access control protocol). The WiPi is inserted into the USB port of the R-Pi. A WiPi must be used for all R-Pi Model A devices otherwise access to the Internet will not be available.
This is the router that provides the interconnection between the local wireless network and the broadband Internet access. It is the router that creates the wireless network to which all compatible user devices are connected.
Colin Smythe (Dunelm Services Limited)
24th March, 2014