Monday, July 28, 2008

An IR Encoder/Decoder pair made with PIC12C508's for each of them

I volunteered to turn a friend of mine's Warhammer 40K Imperial Rhino personel carrier into a remote controlled item. Little did I understand the undertaking that I had agreed on! My requirements for this project were that the transmitter and receiver had to be a single chip design, done all in software. I succeeded. The receiver chip uses a Panasonic 4602 38KHz receiver and that's it for external components. It has the serial input (GP3) , two RC hobby servo outputs (GP0/GP1) and three digital outputs (GP2,4,5). Here is the code for the receiver chip. It is a bit of a specialty in that the digital outputs are actually "momentary contact" type outputs because I only needed a pulse to go out to trigger a cheap sound board I got from a $6 toy! I don't even use the GP2 output in this design. The receiver uses 4 NiCd 115MAH cells, the largest set I could fit into the Rhino! The transmitter chip uses 5 pullup resistors and an IR LED powered through a 330 resistor - quite a bit of power I think. To keep things simple, I used a 78L05 to power the PIC so I could use a 9V battery and keep the whole project box size small. It will run fine on 3 alkaline cells, or, from 4.5 to 5.5V. The transmitter reads the status of the 5 momentary contact buttons and decides what messages to send to the receiver. Here, I give priority by bit value, just so there needs to be no encoding and it keeps the code simple. Also, when a direction command is given (forward, reverse, left, right) I also give the 'go' command and the 'motor noise' commands. If a button is pressed and immediately released, the transmitter waits a couple seconds and sends the 'stop' command. This allows you to hold a button down, issue a series of commands continuously but still stop nicely. The transmitter issues a constant stream of 'stop' commands when no button is pressed. This is a nice troubleshooting method as well as insuring that the unit doesn't just take off! Here is the code for the IR transmitter.


Building the Rhino was a challenge. It is about 5 inches long and about 3.5 inches wide and about 2 inches tall. Into that I needed to put a battery pack, two motors, two motor drivers, the IR receiver board and actual drive wheels and wiring with a sound board and speaker. Wow. I used two LEGO micro motors for the drive motors, they were connected to two LEGO medium pulleys via rubber bands and held in place using two-stud LEGO axels through a two stud Technic rail - If you know LEGO, you know what I mean by that. I drove the motors by connecting them to the "guts" of two old hobby servos. This gave me two small bi-directional motor drivers that I only needed a single I/O line to control. The receiver board was about 1 inch by 1.5 inches and had the IR receiver sticking out the top of the model. The 4 cell 115MAH NiCd pack was about 1 inch x 2 inch by 0.5 inch, very small! I used "tank" steering and mounted a pivot ball near the back of the tank to lower friction. Below are the schematics for the transmitter and receiver sections including the battery and motor/driver setups as I installed them. I only needed to make a couple of smalll internal mods to get all of the stuff to fit.


Making a simple effective whisker bumper

We all have need of that last line of defense when the SONAR glitches, the IRPD doesn't and our bot is on a collision course with a table leg. That last defense against re-kitting is a bumper. I have made a few from microswitches, miniswitches and other things - usually they work, sometimes they need too much force to work and "ugh" collision. This example is another type of sensor that doesn't use a switch, its parts are super cheap and it works just great. Its a "whisker" bumper. Here are the parts you need to build one too.
Small piece of single sided un-etched PC board (I use 3.5cm X 2cm)
Two lengths of 1mm piano wire bent into your appropriate shape (hopefully both the same!)
Two 2-pin "Berg" headers
A little bit of wire

Let me show you some pictures and describe what is going on, a picture is worth a thousand words in this kind of game. Click on the images to make them bigger

This is the top of the PC board with mounting holes drilled.
Note centering of the two Berg headers and the whiskers
so they go directly between the leads. This side of the
board is NON conductive! It is about 1.5cm between
the point where the wire goes through the board and
the Berg headers. I pulled the plastic separator off to
install the whiskers then put is back on loosely, mostly
for looks I guess.
I have carved out two places for the contacts and then
shorted the two of them together with a wire. You could
have two different inputs here if that is needed. The wires
each have a 'Z' bend in them where they are soldered to
the large conductive surface, this gives better support
than just running the wires through.
for more information click here

No comments: