All the geeky stuff that gets me hot.

Friday, January 29, 2010

PicAxe 08M Lego Tank

Here's my first PicAxe 08M project, an IR controlled Lego tank. It features PWM Lego Power Function (LPF) motor control and a laser pointer "cannon". I built this because I wanted something fun to do with the PicAxe and Lego doesn't make any tank kits. This can be easily replicated using the LPF IR remote and receiver but where's the fun in that? The turret rotates but only by hand, the 08M doesn't have enough pins to drive more than two motors. In the next version of the tank I plan on adding motorized turret rotation and elevation.

IR control is done using a standard Sony TV remote control and IR receiver breakout from Sparkfun.com. You can see the receiver taped to the top of the turret. You could use most any IR receiver though, IR on the PicAxe is super easy to get working.

Power is supplied through the LPF 9v battery box. This is the voltage the motors are designed to work with and I didn't want to add a second battery box just for the PicAxe so I used a LM317 variable power regulator to drop that down to 5v on the development board. By using only the LPF battery box I can keep the battery weight down low for better stability.

The treads are direct driven using two LPF motors. In the next version I would like to build an adder/subtractor drive but I don't have the second differential gear needed yet. To drive the motors I used an SN754410 in a circuit I found at the Society Of Robots. The PicAxe 08M only has one PWM output so I tied both PWM inputs to the same signal. This means I can't run the treads at different speeds; steering would be smoother if I could but it works well enough for now. I found the wiring schematic and motor specifications for the LPF motors here. The LPF battery box and motors were connected using a LPF extension wire cut in half so I didn't have to cut the connectors off the motors. I feel a lot better hacking up a $2.99 wire rather than mangling the more expensive motors. The extension wire is the only Lego bit I had to modify, everything else is used stock.

The laser pointer cannon is hooked up to a spare output, I may eventually add a sound effects module for a more entertaining firing sequence. The laser pointer was added after these pictures were taken but you can see it in the video. I put a clear red cone that the laser lights up when it fires for effect.

Here's a (terrible) cell phone video demonstrating the tank.

This is the source code for the PicAxe, feel free to use this however you wish. It was somewhat challenging getting everything to fit in the limited memory of the 08M but by using a function for code that was re-used a bunch I managed to fit it all in there.

6 Comments:

This has been swiped by another member of the LEGO community. http://universe.lego.com/en-us/community/creationlab/displaycreation.aspx?id=c533e6f1-cf17-496b-bb75-19d8d73008fc&searchin=4255cf17-bb3e-45d6-b872-3ee60b3abe2d

Tom, I grok that I am very late to the party, but having found your creation again on the Hack a Day site, http://hackaday.com/2010/02/10/picaxe-lego-tank/ I find myself with questions. Who makes those excellent treads? And how was the body of the tank constructed?

Treads are official Lego, they sell them with some of the construction sets. Same with the power functions. Bought the kits online since there's not much selection locally. The bottom half is mostly held together with the battery box, the top is built on a geared swivel.