Foobot is a project I started around November 2014. It's still a work in progress, but the time when I should have written it up is more than due.
Foobot is robot table football game, with two teams of two tiny adorable robots. The robots are controlled by classic Nintendo and Sega controllers, hopefully it can can finally settle the age old console wars. :)
The intention eventually is to build some games around these robots. Possibly with the ability for a computer to control some of the robots via some image processing if I'm feeling really ambitious.
The robots are built around an ATtiny2313 microcontroller, with an SN754410 to control the motors and a cheap 1402 433mhz radio receiver module. This is mounted on a simple laser cut perspex frame with two wheels mounted directly onto the motors.
The initial design was built on stripboard, but once I had it working I ordered a professionally made PCB via http://dirtypcbs.com/. This was the first PCB I've had made and the quality turned out to be better than expected for the price and the 3 week shipping was pretty bearable.
As the radio modules are very simple (and one way) I decided to avoid the problem of collisions between multiple transmitters by attaching the controllers for all players to a single radio transmitter. The transmitter reads all of the controllers and then sends a packet addressed to each robot in turn. Messages for the robots consist of a robot ID, the message payload and a checksum. Robots ignore all messages not addressed to them and any messages with invalid checksums. Dropped packets or interference are dealt with by hoping the next message with more up to date data will arrive.
The transmitter module is based around a tiny 8 pin ATtiny13 microcontroller. This has just enough pins to read data from all of the controllers and to send a signal to the transmitter module. Some of the lines are shared with the In-Circuit Programming interface for the microcontroller - these were chosen to be the outputs so there was no need to worry about other hardware interfering with programming.
In order to read 4 controllers with 4 pins the transmitter uses a pair of controller interface boards. These have a socket for a NES controller (which contains a shift register so the button states can be read out serially) and a 74LS165 shift register which enables the Master System controller to behave like a NES controller (it is just 6 buttons with a shared common pin). The 75LS165's latch line is inverted so a transistor was required to invert this in order for the same latch signal to operate both devices.
With this setup the only extra pins required on the microcontroller are shared latch and clock signals and a data line for each NES/Master System controller pair. The serial output from the NES shift register is passed into the serial input on the 74LS165 so sending a latch and 15 pulses reads 8 buttons (2 unused) from the Master System controller and then 8 buttons from the NES controller. The Master System buttons are mapped so they come out in the same order as the buttons with equivalent functions on the NES controller (A, B, Select, Start, Up, Down, Left, Right and 2, 1, N/A, N/A, Up, Down, Left, Right).
In the case of the transmitter the circuit was initially tested on a breadboard. This proved quite fragile due to the flying leads to the various controllers so I ordered some more custom boards. The price break on DirtyPCBs is at 5x5cm, so I designed a single board containing the controller interface and a board to carry the microcontroller in a single 5x5 square. I designed tabs into the board outline to allow the two boards to be broken apart. When fully assembled the transmitter contains two of the controller interface board and one of the microcontroller board, so there will be some spares of the smaller board. The cheapest quantity from DirtyPCB is a protopack of 9-12 boards (I got 11 both times), but I only need one transmitter currently so that works out just fine.
I struggled to motors that are both cheap and small without a ridiculously high RPM. The motors I settled on in the end run at around 16000 RPM and 9 volts. Because of this I had to add some code to pulse width modulate the enable pin on the motor controller. Turning requires very little force so it runs with a very low duty cycle. When moving forward initially the motors run at full power to get the robot moving, after a short delay the duty cycle is lowered to avoid accelerating too fast.
Tuning the PWM settings has proven fiddly, and testing with the programmer attached is almost useless as the wires affect the motion of the robot too much. Because of this I implemented an over the air update of the PWM settings. This added some extra commands to update the PWM duty cycles over the radio, and a command to write the to the microcontroller's EEPROM to save them permanently once the behaviour feels right.
I've uploaded the project to github, including all of the code, schematics, PCB layouts and chassis/case CAD files. Feel free to use these, but please bear in mind that the project is still a work in progress.
Finally, here's a video of some Foobots in action (before the over the air PWM tuning feature went in):