I’ve already shown how a PICAXE can be used to build a simple Robot. I know that this blog is really meant to be aimed at Raspberry Pi users but the techniques would be similar. As a result, I thought it’s worth uploading the photographs that show the robot being constructed. If I can get the technical Lego back from my son, it might be possible to rebuild using the Raspberry Pi, and even extend the functions to make more of it!
The original blog post shows the robot in action.
The chassis is constructed using a variety of beams and plates along with a couple of gear trains. You’ll need:
- 8 x 1 beams (4x)
- 8 x 2 plates (1x)
BigTrak converted to use a Raspberry Pi and L298 motor driver.
I’ve had an original Big Trak since the late 1980’s when I bought one to connect to my Jupiter Ace. Time passed and it eventually gained a PICAXE and then more recently it gained a Raspberry Pi.
The Big Trak electronics are fairly simple to work with, although I have a feeling that the original motors are only rated at 3v rather than 6v or anything higher. I tried a 7.2v battery pack and it went off rather too fast. It’s now running a 4.8v “SubC” NiCd rechargeable racing pack.
The motors are controlled by an L298 H-bridge motor which I’ve covered previously. The actual remote control is handled here from a wireless keyboard – the receiver is in the USB slot. I eventually want to make it more autonomous with an ultrasonic sensor fitted on the servo at the front.
From a software point-of-view, it’s all fairly simple. The main program is written in Scratch and uses ScratchGPIO to control the outputs. It looks for keypresses (up, down, left, right) and turns on the relevant outputs. The “b” key makes a piezo buzzer beep (useful for warning pedestrians who don’t look at their feet!) and also requires space bar to bring it to a halt.
I had originally intended to use my “Flirc” device to control this from a TV handset, but it seems to have died just prior to exhibiting. It partially works but I can’t fully program the keys. A shame, as it also did double duty as a remote for my Raspberry Pi Kodi media centre.
The following video was taken by an attendee at the Raspberry Jam in Exeter – I’m not driving either!
Python, Scratch and PICAXE conversion for simple commands and I/O
I often find that I’m having to jump around between Scratch, Python and PICAXE Basic. It’s quite easy to get tangled with the different structures – I keep putting in a # for a PICAXE comment, and the odd colon here and there. Colons in PICAXE are used for labels, not at the end of looping and conditional branches. So… here’s a quick chart which also covers some GPIO stuff.
A LEGO rover controlled with a PICAXE motor control board
Some time ago I put together a little LEGO rover and added a PICAXE motor control board. A little bit of programming goes a long way and although the motors are slightly different speeds, this thing wanders around quite happily.
Two large lever-arm microswitches take care of sensing obstructions. If it hits these, the rover is programmed to reverse and turn away. The overall effect is quite effective for such simple programming. I also modified a 2×2 brick with a 220Ω resistor and a green superflux LED. By drilling out the internal pillar, there’s enough space to hide the superflux LED inside with its resistor. I then connected it to one of the MOSFET outputs connected to output 0. I’ve also put a 2×2 clear brick on top and this is great for spreading the light out.
The overall power supply is 6x AA Alkaline cells. I will eventually change these for NiMH but they’re in use around the house somewhere. Once the volt-drop through the L293 integrated circuits have been taken into account, it’s about the right voltage for powering the 4.5v LEGO motors.
The simple algorithm for this rover is:
if left sensor touched, then stop, flash the LED, reverse and then rotate right
if right sensor touched, then stop, flash the LED, reverse and then rotate left
go to start