This Project all started with many late night discussions with my girlfriend at the time Michelle. Michelle is a mechatronics graduate and at the time was doing her thesis. The problem was her robot she was doing her thesis on didn't really work.... in fact it was known as the kicking robot because people would kick it as they walked past (until a a nice sign was stuck to the back of the robot saying "please don't kick the robot".
Anyway, that aside we planned to make a real robot....one to take over the world....an Evil Killer Robot (although Michelle suggested that it could be a Mad Killer Robot, or even a Good Killer Robot).
The only thing id ever done with robotics was to buy THIS book and also THIS kit. Cybug was cool, but really cheaply built and very hard to tune, the antennas didn't work properly and the robot was very erratic. In the end too, once you had made Cybug, it really didn't do much...so was quite boring. The book was ok but in the end was too simple for what I wanted to do. It talked about the physical types of robots and also a lot about Lego Mindstorm. I wanted more electronics and more nitty gritty how to make a robot.
Anyway, years later, one rainy sunday afternoon I took the plunge and ran off to Dick Smith to see what I could buy. So I purchased this book (XXXX), a PIC microcontroler programmer and testbed (it seems to be out of production so no link available...sorry but there are many programmers around, Oatley Electronics sell some good ones). The programmer/testbed consists of a18 pin ZIP socket for the PIC, an serial out controller chip and plug, an LCD and controller, and most importantly LED's setup to show what state each of the pins are in on the PIC so you can see if your program is working. The programmer came with a PIC16F84A which is a 18pin PIC and is the most popular PIC microcontroler.
I also bought the following to build a basis for my robot (yeah I know I'm cheating but you will get over it)
So what now.....
I have broken what I have down into sections if you don't want to read it from the beginning:
The chassis
Motherboard/main system
Motion Part 1: The H-Bridge.
Motion Part 2: The Chip
Impact sensors:
IR Detection:
Ultrasonic range finder:
Light detection:
Video uplink:
Modem communications:
Links:
Ok, so the basis of our robot is the 3 Tamyia sets that fit together beautifully. I have set the gear ratio to XXXX which seems to work well, if you have the motors going too fast then there is a tendency for the tracks to skip off because they cant handle the torque. Even now there is still a tendency for the tracks to skip off when running on carpet. I haven't really solved this yet but I'm sure I will :-)
So now I need something to sit all my circuits on. So I went to our workshop here and uni and sucked up to our 2 fantastic workshop guys and acquired a couple of sheets of 5mm LDPE (low density polyethylene). I attached a bottom sheet using 4 long bolts and some sprinkler risers as spacers. I also wanted to space this layer off the lower layer because i was concerned that the bolts would short out my circuit boards.
So I added a second level and attached it with plastic motherboard spacers. to attach my mainboard I used brass motherboard spacers that were screwed in. This works remarkably well.
To hold the motor power source I've placed 2 elastic bands around the holding bolts....and the batteries fit perfectly.
The motherboard is the heart of the robot, where it all happens. I've decided that I want to use a modular system where I can add other subsystems on module boards that plug into the main board. The board I used is pre-tinned prototyping board from Dick Smith (I've only found it here). Its really good stuff, the board has 2 rails for GND and Vcc interspersed with nice 3 hole wide areas which make laying chips and components really easy. In addition because its pre-tinned it doesn't need polishing like normal Verra board. It costs about $8-$10 as opposed to $4-$5 for a similar Verra board, but its well worth the additional expense.
So here is a photo of my current motherboard setup...ill update this photo as I change things. I haven't bothered labeling everything but if you read the appropriate section then you should get all the information you require.

So, bearing in mind I know almost nothing about electronics....what do I do?
The first method I tried for driving the motors was using a H-bridge circuit
Explain H-bridge
So soon if figured it was a waste of my time trying to make a H-bridge because I sucked (at design, soldering and just in general) and I purchased an all-in-one motor controller chip...and everything is peachy since then.
Now the market in DC motor driver chips is not really large (well it isn't small but its not accessible) so I didn't have much choice. I picked up the BA6286 chip from RS by mailorder and the cost me about A$12 each. Which I figured was ok cos i was only going to buy 2. I later discovered that RobotOz also sell chips that are probably better than these....but hey I've got these.
I wired the chip up in the following manner (which was strait out of the datasheet)

Basically the the motor speed is controlled in this case by adjusting the Vref pin (which is done by a variable resistor but may be changed later to a PWM type system). The rest is pretty strait forward...direction is determined by adjusting the logic pins in this manner:
| Fin | Rin | OUT1 | OUT2 | Mode |
| 1 | 0 | high | low | Forward |
| 0 | 1 | low | high | Reverse |
| 1 | 1 | low | low | Brake |
| 0 | 0 | open | open | Standby (off) |
The Pinout being
| Pin Number | Pin Name | Function |
| 1 | GND | Ground |
| 2 | Rin | Login in |
| 3 | Vref | HIGH level voltage setting |
| 4 | OUT2 | Motor output |
| 5 | RNF | Output selection ground pin; resistor connection for detecting output current |
| 6 | GND | Ground |
| 7 | OUT1 | Motor output |
| 8 | Vm | Motor Power Supply |
| 9 | Vcc | Power Supply |
| 10 | Fin | Logic input |
I did have a problem with the power when I first started using this...but read about that in the POWER xxxx section.
I have decided that I will simply use the Vref to adjust the motor speed as I am happy with 1 motor speed at the moment, the variable resistors are only there so I can fine tune the motors so they are balanced and the robot doesn't swerve during normal driving.
A better way of controlling a motors speed is by using a pulse width modulation (PWM) system. Basically this involves providing a square wave oscillating power source instead of a strait DC power supply. In simpler turns you rapidly turn the power on and off and since the motor responds slowly it only sees an average power rather than the rapid on-off pulses.
This is characterized by the "duty cycle" which is simply the fraction of time that the power is "on".
So the equivalent voltage that the motor sees is the (applied voltage) x (duty cycle).
PWM has many advantages over traditional resistor control or by reducing the motor voltage:
Basically the normal way to implement PWM is using a 555 timer, but an even better option is using my PIC. This means I need to make my PIC turn on and off at regular intervals and so means I cant use a strait forward program. I need to implement a "state machine" or use interrupts (which is probably why I haven't done it yet).
After getting the DC-driver chips up and running I could make the robot go....it could go forward, it could go backwards but I found that it was quite boring. The problem was it had no way of sensing its environment at all. So the next thing it needed was sensors. But what to use....
The simplest way to do object detection is using feelers...which are normally just microswitches with wire or something attached to increase their range. Which is exactly what I did.
Firstly I decided that for several reasons I would try to keep the sensor equipment off the mainboard. Firstly because it was getting very crowded on there and secondly because I didn't know what I was doing I wanted to be able to move and adjust modules without having to redo the entire board.
So I took a new blank board, got a couple of microswitches and off I went....I mounted the switches by drilling and nailing small nails into the base board and cutting the nail heads off....these then went through the holes in the microswitches. The microswitches were extended by glueing bits of paperclips to them. I also used some shrink wrap to help secure them more permanently. The switches were then wired to my sensor board which in turn went to my mainboard.

Now one of the problems with switches is that between the time that the contact is broken from one terminal and it connects with the other terminal the voltage is floating. This causes massive problems in digital systems where the voltage being at an indeterminate state can cause it to fluctuate between logic states (see below).

To overcome this we use what's called a pull-up or pull-down resistor. This basically works like this......

.....so when you are using a Pull-Up system when the switch is open then Vout is at 5V (flowing through the resistor) but when you close the switch then the earth connection saturates Vout and causes it to go to GND because the resistor is so large.
I decided to go with a Pull-Down system as the PIC can sink more power than it can supply and I'm hoping the feelers spend more time off than on.
hmmm infra-red....its very cool.
Infrared LED's retail quite cheap (around $1 or $2 each) and you can get detectors for about $3 or $4 each. There are on the market pre-made IR sensor systems, but they cost from $30-$40. So I figured I could make one myself :-)
The circuit that I decided upon I scrounged from several places on the net.
When I first set it up I wanted to see whether it worked so I basically wired it as simply as I could .I managed to get a 0.5V drop at about 2 cm which isn't very usefull.So then I went with the idea provided by Rob at The Robot Room (have I mentioned this guy rocks?). He suggested that a you get more range if you use a pulsing LED rather than a strait lit LED. You can also pump more electricity into these (up to 90mA or so) as long as you keep the average amount of current supplied below the rated amount (this is calculated from a duty cycle...remember those). Anyway I discovered that this is quite a common technique on the internet and robots generally either use this technique or the Sharpe rangefinders.
From the layout of my motherboard I decided that I needed to mount the sensors on a separate board because I was going to need to move them and adjust them to get optimal targeting etc of the IR. This board is connected to the mainboard using a 8-pin plug.To make wiring easier instead of going 8-pin to 8-pin I decided to go to a 6-pin plug for the data-lines and a separate 2-pin plug for the power (this can straddle the ground and 5V lines on the mainboard). As well I made up plastic bracket cut from a cutlery draw tray to mount the IR LED and the IR diode.
One of the amusing things about working with infra-red is that it isn't visible to the human eye, but comes out well in CCD cameras like digital cameras. So the only way you can tell if the LED is on is to take a photo of it using a digital camera. Below is the image of the LED on and off.

Ok, so the IR transmitter as already discussed is going to be flashing on and off quickly to improve the range. It is possible for my PIC controller to do this and I was considering this earlier on. However I decided that it was going to be more trouble than it was worth trying to program the PIC to flash the LED and also continue to drive the rest of the system...especially if I use the PIC to control a PWM system later.
Rob at the Robot room describes a system for pulsing the LED using a 8-bit counter xxxx.....he later changed to a 555 timer and since 555 timers are so cheap and easy this is what I decided to do. The 555timer has a heap of configurations all of which are described really well in the datasheets. The 555 timer is setup in "astable" mode...which means....XXXX
In this mode the output will go high and low with a predetermined frequency set by the values of R1, R2 and C1. The frequency is the number of times the transition occurs in a second in Hertz. This system is actually a pulse width modulation system described earlier.
The other components are R3 which controls the output current to the transistor and R4 which controls the brightness of the IR-LED. You need to have a transistor in this system because the output current from the 555 timer will not be high enough to drive the LED, so what we do is we use the 555 output to drive a NPN transistor in "switch mode". This means that we are supplying more current than the saturation current of the transistor and it simply switches from on to off quickly instead of amplifying the incoming signal. The NPN transistors tend to be cheaper and have a lower power consumption than the PNP transistors (which tend to be lower noise). XXXX However you can use whatever transistor you like.
So from the data sheet the Duty Cycle (D) is
and frequency

and similarly the LED brightness is controlled by R4
V=iR
so the current going through the LED
i = 5/50
i = 0.1 A = 100 mA
however the LED is only on 47.6% of the time so the effective current going through the LED is
i (effective) = 0.476 x 100 mA
i (effective) = 47.6 mA
Which is well below the LED's rated max current of 60mA. Now because when the LED is pulsing it effectively heats up faster than it slows down you need to build in a margin of error. I suggest that your effective current is only up to about 80% or 90% of the rated current for the LED.
The final step was to adjust R3 so that it saturates the transistor. If R3 is 2.2 kohm then the current is 2.27mA which should be enough to saturate the transistor.XXXX

Now to detect these IR signals coming in we need to use a photo receiver of some kind. There are several out there and you will need to see which one suits your needs. Originally I purchased a pair of what were described as Semiconductor Photo IC's from Rohm (RPM7100). I had looked briefly at the datasheet for this chip and had understood that it included a amplifier circuit inside the chip. It actually is designed to detect and disseminate digital signals from a IR remote control which again I figured is good. However, after looking in more detail at the datasheet I discovered there were some things that may cause me problems. The chip includes a OpAmp, demodulator, and comparator which will take any signal it detects and digitize it.
The problem is that:
So eventually these may come in handy and ill play around with them....but until I do I went to the store and got some simple Z1956 IR receiving diodes (matched to the z3235 IR LED). While are actually diodes they work a lot like a transistor, where instead of having a gate voltage you have a light intensity. So as the light intensity increases the voltage drop across the diode.
Now to change this analogue signal to a nice digital triggered value. I used a LM311 comparator because its nice and simple, cheap and easy. A comparator has 2 input pins an inverting input and a non inverting input. Basically the comparator"adds" these 2 voltages (the inverted pin is changed to a negative voltage) and if the result is positive then the output goes HIGH and if the result is negative then the output is LOW. In our case we have set the inverting input to be controlled by a 50kohm multi-turn variable resistor so we can fine tune the trigger voltage. Its probably almost essential that we use a multi-turn variable resistor for this as anything else will not give us fine enough control.
I was looking into using a OpAmp As well to increase the sensitivity, however a normal OpAmp requires a positive and negative voltage supply and at this stage I didn't really want to change my whole power scheme to add extra voltage controllers and batteries. I figured that if I wasn't getting the sensitivity required then I would look into adding an OpAmp later...Ill burn that bridge when I come to it.
The circuit design that I am using here is from the datasheet and I haven't figured out all of what they are doing yet ;-)

So I finished wiring up the system and connected my multimeter......and the results....BAM a 4.5V drop across the receiver diode from a piece of paper 10cm....WOW, so I try again....this time no voltage change....so I sat there playing with it, checking loose solder joints etc...finally I discovered what was happening, when I was testing I picked up the robot to hold the multi meter easier, and in doing this pointed it strait at my halogen desk lamp. Halogens release TONNS of IR radiation so that is what I was detecting. How once id overcome this the results were quite good. In tests I have got anywhere from a 0.5V to a 2V drop across the receiving diode depending on the reflecting material. However, I cannot get the comparator to trigger properly. It seems to stay at 5V no matter what the input pin voltages....hmmm Ill look into this some more later.
So the diagram for my full sensor array looks like the following, with the IR transmitter and receiver As well as 2 of the feelers wired on the same board and interfaced to the main board with a 8-pin plug.


Every person that ever builds a robot one day has dreams of building a ultrasonic rangefinder...but not too many actually go and build them because they are hard and usually expensive. So when I saw pezzo ultrasonic transducers (either transmitter or receiver) sitting in a bucket at Jay Car electronics I had to resist a shudder of excitement. Not only were they available, but they were also only $5 each....awsome.
Now it becomes more...hmmm....interesting....after buying these little beauties I went to download the datasheet....unfortunately there is no data sheet on the internet. So I emailed their support....no reply....so I emailed them again....no reply....basically this reflects really badly on a company I hold in high regard. So I assume that there is no datasheet for these and they don't actually acknowledge that these devices exist. Below is a photo of the transducer and all the included documentation.

So playing around with them. I wired them up to an old oscillator and oscilloscope that we grabbed out of a skip at uni. Now when you fire-up the oscillator and ramp the frequency up to the optimal level you go through the audible range and produce the most annoying sound know to man kind....so much fun ;-) When I connect the oscilloscope and tap the transducer then you get a nice signal coming off it. Unfortunately the oscilloscope is so old that it cant handle the suggested 40 kHz frequency that is requested.
Power is the center of all things robotic....without power you aint got a robot (unless you use a clockwork robot...but if you do then you are a smart arse and just trying to prove me wrong).
So, where do you start? Well your chip needs a 5V and a 0V input so the obvious thing to do is to use a LM7805 voltage regulator chip which is what I did....the juice originally came from a 9V battery, however I soon noticed that my motors were draining so much power that my power LED kept dimming when the motors come on. This makes sense and I'm sure you are all going "what a moron...of coarse the motor is going to draw too much power" but if you do say that then I will come around and burn your house down (please email me your address).
So I broke the system into 2 power supplies, one comes from a 6xAA battery pack for the motors and another from a 9V battery goes to the motherboard supply.
In hind site I would recommend putting all the power circuits on a separate board for ease of modification and adding things, but I didn't, so shit happens.
I also discovered (by burning my self on one of the LM7805 chips) that the motors are drawing 1A each....since the LM7805 is rated to 1A I needed 2 in parallel to handle this much current.
The power supply layout is as follows

The power is switched using a double-pole, double-throw switch and the negative sides are connected to a common ground. the inputs to the voltage regulators are protected with diodes 1N5819 or similar diode so that if I accidently put the battery terminals in the wrong way then I dont fry everything. Finally I wired a little LED onto the motherboard voltage to act as a Power-On LED. The capacitors are used for power conditioning and fluctuation smoothing.
The Robot Room - This site rocks, there is so much here...you can learn everything you ever need to know from this guy. Especially helpful are the links to manufacturers.
RobotOz - They sell some hella cool robot parts, DC driver chips, motors, IR rangefinders, ultrasonic's etc...also has instructions for one of the cutest photovores I've ever seen
Oatley Electronics - sell some crazy shit. My favorite was a russian microwave range finder, without shielding....oh yeah baby. They also sell bags of second hand components...you want some transistors, you go buy a 1kg bag of them...or diodes etc. A friend of mine bought a bag of power transistors for $20 so he can make a rail gun...hopefully he will let me mount it on a robot :-)