Hacking your K'nex or Loz building system to build robots
I want to teach my seven year old son about robots. Lego Mindstorms is a cool system but way too expensive. K'nex is much cheaper and makes a great robot building system for kids that can be used with any micro controller.
I am using a Micro Magician as a controller since it has servo connectors, dual FET "H" bridge, 3-axis accelerometer and IR receiver buit in. This means my son does not need to wire anything up and the reverse polarity protection makes it pretty hard for him to damage anything. Since the controller is low voltage, same as the K'nex motors, everything runs happily from a single 4.8V battery pack.
The geared motors that come in these kits include a space for 2x AA batteries that is perfect for installing additional circuitry. Because I want to control them with a controller I have removed the switch and installed a control PCB from a servo that stripped it's gears. I've converted the board to continuous rotation by replacing the 5K pot with 2x 2K7 resistors in series and added an optional 470uF capacitor across the power connections to reduce any power surges when the motor starts up or changes direction.
As I am using a Micro Magician for my controller and it has a dual FET "H" bridge built in I have wired two motors up without the servo control PCB. All my motors and sensors are wired with a standard servo connector so that I can use servo extension cables when required. This means the size of my robot is not limited by the length of my cables.
I could not find an easy way to connect a servo pot to the geartrain of these motors and I wanted some normal servos so after checking the dimensions I found I could make standard sized servos fit into the Knex framework fairly easlily.
I used some self tapping, flange head screws and washers to mount some Knex parts onto my servos and then the servos can be easily integrated into the Knex robot body.
Although the Micro Magician has a built in 3-axis accelerometer built in that can detect impacts I decided to add some standard micro switches as bumper switches. The main problem with using the accelerometer for collision detection is that collisions with soft objects may not register.
I have soldered my positive wire (red) to the N.O. connection and my ground (black) to the N.C. connection. My signal wire (white) goes to the switches common connection and is high or low depending on the position of the switch.
NOTE: I was in a hurry when I made these so I did not solder in any current limiting resistors. It is a good idea to solder a 4K7 resistor between the positive wire (red) and the N.O. connection. Another 4K7 resistor should also be soldered between the ground wire (black) and the N.C. connection. This will prevent any damage if the switch is accidentally connected to an output pin.
The micro switch is just held in place with cable ties but could be more permanently mounted with self tapping screws the same as the servos if required.
Mounting your controller is the easiest part. K'nex blocks offer plenty of holes for screws or cable ties to go through. I have left a hole in the front of my robot to easily access the Micro Magician. This also leaves the IR receiver facing outward to detect signals.
I found it didn't really matter where the IR receiver was placed if you are using the robot indoors. If your TV remote has good batteries then the receiver can detect the signal reflecting from the walls and ceiling.
Add some batteries and simple code from the Arduino IDE and the result is:
DEATH TO ALL HUMANS - BITE MY SHINY METAL ASS!
I have attached my code. Originally this started out as a simple "Roomba" style robot after my son saw a demonstration model in a store and wanted us to buy one. It just played music through the drive motors and then used the bumper switches for a simple bump and turn routine.
That part of the code is still in the fighting robot which means, although remote controlled, if you hit anything the robot will back up and spin around while waving it's arms in the air.
The rest of the code allows you to use the TV remotes cursor keys to drive the robot around. The numeric key pad is used to control the arms with 1,4 & 7 raising, centering or lowering the left arm while 3,6 & 9 do the same for the right arm.
Pressing 5 on the keypad will toggle berserker mode on or off. Berserker mode causes the arms to go up and down automatically which assuming you give the robot some swords turns him into a dangerous opponent.