Meeting: The Arduino and Gertboard
Steve Bass started with a look at the X100 add-on board for the Pi. Terry Marsh then took a look at programming an Arduino Mega, to alter the ‘sketches’ contained on it. He also investigated what the Gertboard interface can do with lights and motors.
Report by Peter Richmond
The May meeting was meant to start with Terry Marsh looking at some add-on boards and programs for theRaspberry Pi, but he’d left one of the small boards at home so instead Steve Bass started with a look at another add-on board for the Pi – the X100. Steve’s brother had initially bought the board but never got round to using it, and Steve didn’t refuse it when it was offered to him.
The reason Steve wanted such a board was that he wanted less of a mess of wires, rather than two power supplies, a USB hub and an in-line HDMI to VGA converter. He also wanted a VGA connector output which he could use through his 4-port KVM switch. With this setup he also uses both PS/2 mouse and keyboard, so on the Pi he has to use a USB to PS/2 converter. He has found that the ‘cheap’ ones you can obtain via the internet don’t work, but the one from Maplin’s does. [This is my experience too, and it’s not just RISC OS: the cheaper ones that I’ve bought are happy with Windows but don’t even work with Linux – Ed] It costs around £15 and looks like a ‘soap-on-a-rope’.
An X-rated Pi
So what is on the X100 board? There’s a VGA connector, four USB sockets, DB9 serial port and battery-backed real time clock – and it all fits in small format board which sits above the Pi and only needs one power connector. The board was bought from a company called Extreme in the USA and was $37 – about £25. You may also be able to get it through Amazon.
If you’re going to use it fully, you need to solder a few pins on to the Pi for a reset button (no more unplugging one or two power supplies). Two small expansion connectors are provided: one is an HDMI to HDMI adaptor to link the board to the Pi’s HDMI output, and there is another to connect the board to one of the USB sockets which makes a USB hub with four outputs. There are also some nylon pillars which properly space the boards apart. The board then gives the VGA out, access to the GPIO bus, a 9-pin serial port and four USB sockets. All other sockets on the PI remain the same – composite video out, stereo audio out, SD card etc.
Another advantage that this board may give is that if you plug in an SD card via a USB card reader, it is ‘seen’ as another SD card, which may give speed of access advantages over a standard USB memory stick. Some tests need to be made to see whether this is the case or not. [Discussions on ROOL’s Forum suggest that SD cards on the X100 are connected as another USB device, so no speed improvement. – Ed] With regard to the serial port, there isn’t currently a RISC OS driver, but apparently there is a test version of a module available.
Because of the way that the boards are connected, only one power supply is needed. The VGA connector appears as a ‘device’ with the name “Lontium”, and can provide a very clear 1920 × 1080 image – which is full HD resolution. Steve had previously tried a few HDMI to VGA in-line converters and had found that only one designed specifically for the Pi worked (PiView), but with less clarity than that provided by the X100. It’s also worth noting that currently the RTC on the X100 board doesn’t have a RISC OS driver.
RISC OS Pico
Terry was next on and started to set up his collection of add-on boards and cards for the Pi, while we wired up a camera so that the audience could see the boards – which were all less than six inches square – more clearly. Terry first had a look at an SD card he had recently purchased from RISC OS Open Limited for £7 – it’s called RISC OS Pico and is a minimal version of RISC OS for the Pi that and boots directly into BBC BASIC, along with a few demo programs.
It’s been released to celebrate the fiftieth birthday of BASIC and also includes some programs to toggle the GPIO lines of the Pi: which could be used to light up an LED. If you purchase the card from ROOL, you also get a free PDF copy of Martyn Fox’s book “First steps in Programming RISC OS Computers”. We spent a few minutes trying to remember our BBC BASIC – while we eventually collectively worked out how to load and run files, we didn’t really explore this avenue very much.
Terry then went on to demonstrate an Arduino Mega board (£44.99 – £199.99) which he had connected to his Pi. He used the Maplin voucher that he had received from WROCC last year to help buy this board, but it is also available from a number of other suppliers. The board has loads of hardware including 54 digital I/O pins, 16 analogue inputs, 4 UARTs (hardware serial ports), and a 16MHz crystal oscillator. This board should be able to be programmed by the Pi, but Terry had had some problems with this and had had to write/amend the program on his laptop (the reason will become evident later in the writeup).
Programming the Arduino
Terry modified the original program – which was to light four LEDs – so that it would light twenty four LEDs. He admitted that he hadn’t programmed these lights in a ‘clever’ way, but had instead just repeated a section of the program so that it addressed all 24 LEDs which were chasing round the board. The Mega board, when programmed, can then run without the Pi since it stores the program in its own non-volatile memory. Terry had connected all the LEDs and associated resistors to an electronics prototyping ‘push-in’ type breadboard, and successfully demonstrated his modified program in action.
The programming language for the Arduino is a variant of C/C++ although it’s considerably simplified. Programs called ‘sketches’ are written in the Arduino IDE, which then fills in the ‘missing bits’ when compiled – this makes it much easier to get simple programs working and interacting with the hardware. A copy of the IDE can be found using the links on the box below: on Raspbian, the Arduino community recommend using the installed found via the GitHub link and not installing via the Aptitude package management system (‘apt-get’), as that version is now quite old.
Adding a Gertboard
Next came the turn to demonstrate the Gertboard (£31.20) designed by Gert van Loo who, along with others, helped designed theRaspberry Pi. This add-on to the Pi connects directly on to the GPIO pins for information and power. It has twelve buffered I/O, three push buttons, six open-collector drivers (50V, 0.5A), an 18V, 2A motor controller, a 26-pin Atmel ATmega 328 minicontroller (as used on some Arduinos), two channel 8-, 10- or 12-bit digital to analogue converter, two channel 10-bit analogue to digital converter and twelve LEDs with power limiting resistors. You can download and print the manual from Farnell Element 14 and other sites.
Terry then went on to demonstrate the fact that the board will actually fit over the Pi, which is not recommended as it shorts some of the Gertboard’s circuitry and GPIO. It actually fits facing away from the Pi and alongside it or even at the end of a 26-way ribbon cable. If you go online you will find various programs for the Gertboard written in Python and C; there are even some on RISC OS to run various parts of the board. You will also need extra female to female jump leads, as although you are provided with some when you buy the board there are not enough for some of the programs.
It is also possible to program the ATmega 328 chip on the Gertboard directly, so that it can work away from the Pi, but Terry didn’t succeed with that – some examples can be found from Gordon Henderson’s website, however. Terry did show one ‘demo’ on the Gertboard with running lights in various directions using the onboard 12 LEDs.
After a few minutes of re-wiring, Terry then went on to hook up an Adafruit 2.8" 320 × 240 touch-screen LCD board to the Pi. The board was bought from a company called PiMoroni, which are based in Sheffield, and cost £34. For full use of the board, you need to get some small switches, which are only a pound altogether, but need to be soldered onto the board. Again, the board can’t currently be programmed via RISC OS or any other operating system other than Wheezy at the moment, but Terry got a program running from Adafruit which played a movie clip of “Big Buck Bunny” on the LCD after it had been reduced to 320 × 240.The display was good quality, which, to me was a bit of a surprise given the low cost and resolution. Text was also surprisingly clear, even at the standard small size that we saw.
The supplier also walk you through the process of getting the touchscreen set up: it’s better to use a clean install of Wheezy for the touch screen as it involves altering some of the root directories. Terry had the How To of the touchscreen set up, loading and running on a pad for reference and to show us.
Details of the devices demonstrated at the May meeting can be found online:
X100 – www.suptronics.com/RPI.html
RISC OS Pico – www.riscosopen.org/content/sales/risc-os-pico
Arduino Mega – arduino.cc/en/Main/ArduinoBoardMega2560
Arduino Sketch – arduino.cc/main/software
Arduino IDE – github.com/whitewitch/arduinoIDE_RPi_installer
GertBoard – www.element14.com/community/docs/DOC-51726
Gordon Henderson’s Gertboard Projects – projects.drogon.net/raspberry-pi/gertboard
Adafruit Touch Screen – www.adafruit.com