Raspberry Pi-powered Bigtrak

Take a toy, a Raspberry Pi and a PS3 controller; add a dash of Python and some solder for the perfect remote-controlled gadget…

The Raspberry Pi is a small, low-cost computer designed to promote an interest in computing and programming – but it doesn’t have to be straight-laced computing. In fact, in this article we’ll be showing you how you can use it to turn a Bigtrak into a robot. That’s educational, right?

The Bigtrak is a toy that takes in a list of straightforward commands (Go forwards, turn left, turn right) and then executes them. To make things more interesting we’re going to remove the existing circuitry and replace it with a Raspberry Pi, using a small motor driver to safely control the motors in the Bigtrak, which we’ll then set up to be controlled via a PlayStation 3 DualShock controller.

Everything required on the software side comes pre- installed on the latest Raspbian OS images, so all we need to translate changes from the controller to the motors is a small Python script that uses the Pygame and RPI.GPIO modules.

A Pi-powered BigTrak

What you’ll need

Step-by-step

Step 01 Opening up the Bigtrak – the easy bit

Before we can make any changes to the Bigtrak we need to get inside. First, flip the Bigtrak upside down and remove the nine screws from around the edge. These are mostly easy to get at, however the ones on the front may require a more slender
screwdriver to reach them.

Step 02 Opening up the Bigtrak – the fiddly bit

The last two screws are located underneath the grey grille on the back. This grille is held in place by four plastic tabs that need to be pushed in while at the same time sliding the grille away from the Bigtrak. This can be quite tricky as there is limited space to get extra hands in to help out. It can help to wedge some thin plastic items (eg a guitar pick) into the sides to keep those two tabs unlocked, while using your fingers to push in the bottom two tabs and slide the grille
upwards, allowing you to remove the screws.

Step 03 Removing the top

Put the Bigtrak back onto its wheels then carefully loosen the top and lift upwards. The lid is connected to the base with a ribbon cable and a switch, so only pull the top up far enough for you to tilt it to one side and expose the inside.
With the lid lifted up onto one edge, remove the screw holding the switch in place and detach it from the lid. Next, you need to unscrew the two screws on the PCB that hold the ribbon cable in place and let it slip free.

With the switch and ribbon cable disconnected, the lid should now come free and can finally be completely removed from the base of the Bigtrak.

Open up the BigTrak

Step 04 Cut the wires

Cut the wires leading to the main PCB. The ones for the switch and power should be cut close to the PCB (so we can reuse them later) whereas the ones to the LED and speaker can be cut wherever you like.

Step 05 Remove the engine

Turn the Bigtrak upside down and remove the four screws holding the engine in place (this will reduce the chance of soldering iron damage to the main body). Carefully turn the Bigtrak back over and lift it up until the engine slips free.

Step 06 Rewire the motor

Remove the solder connecting the PCB to the motors (a solder mop is useful here) and then remove the PCB. With the PCB removed we can now attach wires to the motors in order to drive them from the Raspberry Pi, as opposed to the on-body commands. The wires will need to be long enough to reach the back of the Bigtrak, so be generous – after all, it’s far easier to trim long wires to length than replace short wires entirely!

Having installed all of the wires, you can now replace the engine back into the Bigtrak.

Step 07 Connect the motor driver

With the motors back in place we now need to build up a circuit to drive it from the Raspberry Pi. We’ve used a ribbon cable to connect the GPIO pins on the Raspberry Pi to a breadboard, before connecting it up to a Dual Motor Driver to actually drive the motors. This keeps the higher voltage the motors require away from the sensitive GPIO pins.

The connections made on the breadboard are listed in the table below. These values will be needed when writing the software and may be different depending on the breakout board you are using, and the Raspberry Pi revision.

RPi GPIO, Motor Driver

24, AIN2

17, AIN1

18, STBY

21, BIN1

22, BIN2

With the PWMA and PWMB pins directly connected to the 3.3V power rail, the motors will now always run at full speed for as long as they’re active.

Step 08 Install the breadboard

The breadboard is going to be installed on top of the battery compartment inside the Bigtrak, so the wires from the motors should be brought to the back to the unit and cable-tied into place. The wires to the batteries can also be brought back to the same place to help keep things tidy.

An easier to understand BigTrak wiring diagram

Step 09 Wire it all together

In order to easily connect the motors and batteries to the breadboard we have soldered some modular connector plugs to the ends of the cable, allowing them to just push into place (these are available from Maplins).

With the breadboard installed (sticking it into place for support) we can now, after double-checking all the connections, plug the motors and power into it. To know when the motors are enabled (and reduce the chance of unexpected movement), the LED can be connected to the breadboard so that it lights up whenever the ‘standby’ pin is active, using a resistor to ensure it doesn’t pull too much current and go ‘pop’.

Step 10 Provide power

Power for the Raspberry Pi is supplied via a USB battery pack that is installed on top of the engine and can be held in place by a couple of cable ties or a Velcro strip. This type of battery is typically sold as a portable mobile phone or iPad charger – the one used here is rated at 8000mAh, able to power the Raspberry Pi for up to eight hours.

Step 11 Connect to the Raspberry Pi – adding cables

As the Raspberry Pi will be mounted on the top of the Bigtrak, we need to run the ribbon and power cable through the top of the case. To do this, turn the top of the Bigtrak upside down and release the front two catches that hold the dark grey plastic in place – this provides a big enough gap to feed the ribbon cable and USB power cable through. Make sure that the red edge of the ribbon cable correctly matches up with the connector on the breadboard to save yourself from having to
twist the cable inside the case.

Add extra wires

Step 12 Connect to the Raspberry Pi – final steps

With the top of the Bigtrak back on, the Raspberry Pi can now be put in place, keeping the GPIO pins towards the front to allow the ribbon cable to easily connect. As for the battery pack, we’re holding it in place with cable ties and sticky pads. In theory it’s possible to attach the bare Raspberry Pi to the Bigtrak, however this can cause the SD card to press against the edge and bend, so it’s recommended to use a case to protect the Raspberry Pi.

Connect the ribbon and power cable to the Raspberry Pi, turn it on and it’s now ready to be told what to do. For setting up the software it may be easier to connect up a keyboard and monitor to the Raspberry Pi at this point.

Step 13 Connect the PS3 controller

This should be a simple case of plugging the PS3 controller into one of the USB ports, as all the software to support it is included in the default Raspbian OS image and it will be automatically detected as a joystick. To confirm that the PS3 controller has been detected, run lsusb and checked that it appears in the resulting list.

Step 14 Run the software

Now with the system all set up, it should just be a simple case of copying the ‘bigtrak.py’ file found on this issue’s disc onto your Raspberry Pi and running it. As the script accesses the GPIO pins, it will need to be run as the superuser, so launch it using:

$ sudo python bigtrak.py

Now we can control the Bigtrak using the analogue sticks! Moving the left stick will control the left motor and moving the right stick will control the right. So, to move forwards push both sticks up, pull both down to go backwards and push one up and one down to rotate on the spot.

If the analogue sticks are not controlling the Bigtrak as expected, double-check the GPIO connections to make sure that they are all as expected.

Step 15 Next steps

Now that you have a solid base for your Raspberry Pi robot, you can make further adjustments to it. Possible next steps could be: add a USB Bluetooth adaptor so the PS3 controller can be connected wirelessly; replace the breadboard with a PiPlate or
‘Slice of Pi’ add-on board, allowing the Raspberry Pi to be installed inside the Bigtrak; connect up the RaspberryPi camera and a USB WiFi adaptor to stream video as you drive around; or add a robot arm!