An introduction to the Gertbot
A look at the hardware capabilities and software support for the Raspberry Pi robotics board.
The Raspberry Pi is a popular single-board computer with plenty of GPIO (general purpose input output) pins making it ideal as a development platform for physical computing projects. These are fine for low power applications, with most pins at 3.3V able to provide a maximum of 50mA draw. For applications that require more power, such as driving motors, additional hardware is needed.
Enter the Gertbot: an add-on module for the Raspberry Pi that plugs directly on to the GPIO pins. It is aimed primarily at driving motors, with four H-bridges on-board it can drive up to four DC motors with up to 30V at 2.5A or two stepper motors. There is the option of cascading up to four Gertbots per Pi, giving more outputs as required.
Additional GPIO includes two DACs, four ADCs and two open drain outputs. This means that, for example you can connect analogue devices like potentiometers, force sensitive resistors and moving coil meters to your Pi too.
Also on-board is a 64MHz Cortex-M3 ARM microcontroller that comes pre-programmed with it's own firmware that takes care of the signal timing and PWM generation, meaning the Pi does not have to be running a specialised real-time kernel or operating system.
For peace of mind there is thermal and short-circuit protection, as well as pre-configured safeguards such as an emergency stop and system halt upon motor failure, that run on the ARM microcontroller and can be called with high-level commands from the Pi.
In this post we take a look at connecting the Gertbot to a Pi, drive a simple DC brushed motor and update the firmware running on the ARM microcontroller.
The following hardware was used:
Raspberry Pi 2 with latest version of Raspbian installed
DC brushed motor
12V power supply
There is plenty of documentation available for the Gertbot, the main manual offering a range of help from chapter 0: 'I want to use it NOW!' to more in-depth information about the software commands and even hardware fundamentals, like the workings of H-bridges.
It is recommended that as a very minimum, the first chapter is read to give some understanding of the electronics before the Gertbot is connected to a Pi and powered up.
Note that whilst rated up to 30V, using additional power supplies of more than 18V will result in dangerous voltages being present on the Gertbot. Please read the Gertbot documentation in full if you are in any doubt.
Attaching the Gertbot is as simple as pushing the large black connector down on to the GPIO pins on the Pi. Note that when using later versions of the Pi, with more GPIO pins, care must be taken in ensuring correct board placement (see photo above).
The DC motor was mounted on a plate and connected to the Gertbot as detailed above, along with a 12v power supply. The Pi was then connected to the network and booted before logging in over SSH from a different computer.
Presented with a terminal we could now download the software required to connect to the Gertbot:
gertbot_exe_2.6.tgz – the GUI for Linux systems
enable_uart_exe.tgz – executable to enable the UART on the Pi
These were downloaded from here and here and extracted as necessary. The GUI provides an interface to control motors connected to the Gertbot without the need for any programming – great for testing the hardware without worrying about your own code – but before it can be used the UART must be enabled on the Pi. To do this the enable_uart executable can be run with the following command:
$ sudo ./enable_uart cfr
Once completed the Pi was rebooted and the GUI was executed:
With the graphical display loaded the Log check-box can be clicked, opening a window showing that a Gertbot board is found connected to the Pi, version 2.3. There are drop-down menus to select motor configuration and buttons to start and stop connected motors spinning, with the Log showing the serial commands that are being sent from the Pi to the Gertbot.
This is one of the great things about the Gertbot: most of the hard work of controlling motors is already taken care of by the software on-board. You can test the control from the supplied GUI before using the same commands from your own Python or C program, without spending time implementing low level motor control yourself.
Updating the firmware
As new features are added and bugs fixed, new versions of the Gertbot firmwareare available for download. At time of writing the latest version was 2.6, a few revisions later than the 2.3 supplied with the board. To update the Gertbot, the following files were downloaded:
gb_upload_exe.tgz – executable for uploading new firmware to the Gertbot microcontroller
rmc_2.6.crypt – latest version of firmware for the Gertbot microcontroller
Following the advanced manual, the upload executable was used which, despite showing a scary warning about the possibility of a dead board if the procedure should fail, worked well. After the new firmware had been uploaded to the Gertbot the system was rebooted and the GUI Log checked to see the new version working as expected.
Note that it is possible to run your own firmware on the Gertbot's microcontroller if you wish, but this requires the use of an Atmel JTAG debugger and is beyond the scope of this article. See the advanced manual for more information.
Controlling from Python
'Drivers' / libraries for the Gertbot are available for C/C++ and Python from the Gertbot website. Example source code is also available – I downloaded the 'Simple Rover' for Python example and took a look at the code.
The Python example is well commented and thus easy to understand and modify. Written for a two-motor roving robot it includes keyboard control for direction. It was still possible to use this file to test control of the motor connected previously by simply commenting out the 'development environment' variables section and using the 'rover' variables section – defining the board as number 0 and left motor as 0.
Note that you must use Python 3 rather than Python 2 for correct operation of the Gertbot examples:
$ python3 rover.py
The program allows the user to control the motors from the numeric keypad on the keyboard. Remember that if only one motor is connected, as in our example, not all of the controls will cause the motor to spin.
The Gertbot provides a quick and simple way of interfacing motors with the Pi with minimum hardware hassle. Whilst we only connected one DC motor in this post, it is possible to connect up to four DC motors or two stepper motors, and connect up to four Gertbot boards in total should you need more outputs. The Gertbot can also be used to power other high power devices like LED lighting systems.
The documentation is a little unpolished in certain areas, but on the whole is thorough and provides plenty of guidance, from a quick-start guide to covering the more advanced features like cascading multiple Gertbot boards, combining H-bridges for higher output current and so on.
The software executables make working with the Gertbot easy to begin with, whilst the code examples provide further guidance on how to control high power loads from your own programs.
If you don't want to use the Gertbot with a Pi then it can be used standalone and controlled by any other computer with a serial port, making it a versatile choice for physical computing.
Buy the bits you need for this project