So after 5 previous versions that had various flaws, I now have a robot that actually works – although there a probably a few more flaws so please point them out to me.
In order to catch up, please see my previous posts below, describing the problems that the other 5 versions had, how the h-bridge chip works and using the SRF05 ultrasound sensor.
larryBot – versions 0.1 to 0.5 lessons learned
Control a DC motor with Arduino and L293D chip
Arduino: Sonic range finder with SRF05
Now that you’re up to speed, lets start by fixing the flaws in the previous version, this was the case that my motors were drawing way too much current and the L293D chip from ST Micro couldn’t output enough current for each motor.
So, I replaced the chip with the snappy named ‘SN754410′ from Texas Instruments. This has EXACTLY the same 16 pin layout as the L293D chip and all of the same features except that it can output 1.2 amps per channel rather than the now tiny 0.6 amps of the L293D.
Great I’ve now got more current to my motors, but their stall current is still at over 2 amps, I could add a heatsink to the chip and pass more current through it, but instead I got some more efficient motors than the Mabuchi FA-130’s that came with the Tamiya gearbox. These motors are made by Solarbotics and are their RM3 series which fit perfectly, can handle 4 times the voltage but use a fraction of the current – typically at 9v they use just over 1 amp. Perfect.
Having corrected this, larryBot v0.6 was go! I still faced a lack of power to the motors – either because my batteries were running low or not able to supply the current. But since my new motors could run up to 12 volts (instead of the puny 3v of the originals) I decided to use a 9v battery to power them instead of my 4 AA’s.
Watching larryBot move is great, even on carpet and with the tank tracks 9 times out of ten he can climb small obstacles or has enough traction to shunt them out the way. Anyway enough waffling – here’s how he’s made…
The chassis.
You could use anything you want really - construction sets, your own custom fabricated chassis etc… But since I’m cheap I managed to get a pile of foamboard for my chassis. I can waste and reuse as much of this as I want so its no problem if I make a mistake or want to improve it. Also in theory this leads to rapid prototyping, so when I do decide to fabricate a chassis I know exactly where the best places are for holes, mounts etc…
The chassis parts and tools:
Small Phillips/ cross-head screwdriver
Gluegun
Craft knife
Pencil
Ruler
Assorted nuts and bolts – A good set of M series nuts and bolts
Foamboard 5mm thick – 1 A4 sheet is plenty
Tamiya gearbox 70097 – assembled in mode A
Tamiya track and wheel set 70100
Elastic bands (normally dropped by the postie)
Sizing up the chassis
First of all the size of our chassis design is dictated by a few things. The axle length: our tank tracks need about 5mm clearance so the space on the axle is roughly 65mm wide that I can mount on. Next we have the length of the tracks and how many wheels will be used, I kept my track footprint small so my chassis length didn’t need to be much bigger than the gearbox. Which leads on to gearbox positioning - the Tamiya gearbox I have is roughly 75mm in length and the shape of the tracks will dictate where to position the gearbox as the driving wheels are attached to this. The final consideration of course is mounting all the sensors, battery packs, breadboard and the Arduino board.
In my attempts so far I have a base that is just longer than twice the length of the gearbox (175mm) which gives me space at the front for sensors and space at the back for batteries. I then mount a smaller piece of foamboard on top of this that then houses the gearbox and spaces it far enough above the running wheels for the tracks at the bottom – also giving enough tension in the tracks for them not to slip off (unlike larryBot v0.4). From here I can continue to bolt on additional structures to position the breadboard and so on.
So using this knowledge you should be able to size up and cut the foamboard to the dimensions you need – a craft knife will be more than enough to cut this board. To make the holes needed for your screws and bolts just use a small Phillips/ Cross-head screwdriver to bodge a hole through – it won’t take any effort, then you can drive the screws through this guiding hole. If you have washers then use them but the foamboard seems to be able to support all the hardware fine.
Attaching the running wheels:
First mark out the position of where you want your wheels, very important as you don’t want them wonky!
To mount the running wheel axles on to the chassis I used a couple of small hexagonal bolts for each side of the axle and then used the glue gun to fix them to the chassis – the best way to do this is to put the bolts on to the axle, use a small amount of glue to hold the bolts in place and then use a shit load of glue over the bolts to secure them properly.
When adding the wheels to the axles, don’t push them all the way on as these axles are slightly shorter than the Tamiya gearbox which will cause you problems with the tracks.
Mounting the gearbox, sensors, breadboard, Arduino and batteries
To attach the gearbox I just used the screws supplied with the gearbox and bolted this to my smaller piece foamboard. I then in turn bolted this to the main chassis using 4 long bolts and a series of spacers and nuts in between the layers to given the correct spacing and adjustment for my drive wheels.
For the SRF05 ultrasound sensor I just used some blu-tack/ modelling plasticine to hold it in place for now.
The breadboard I mounted above the gearbox, which for this I just fixed it on top of 4 long bolts which then in turn attached the gearbox base. The Arduino board currently then sits on the breadboard held on by the multitude of wires running from it and the power supply cable.
And for the batteries, since I scrapped using the 4xAA’s to power the motor I only had to worry about two 9V batteries, 1 of which was my DC power supply for the board. I fixed them to the chassis just using an elastic band, since I’d want to get to them easily enough.
Electrical components and circuit.
The parts list doesn’t differ much from my other tutorials for motors and L293D. But I did find it was troublesome to get the parts from the same supplier, so be aware that you may need to look at multiple suppliers and postage may get expensive.
Components list
2 x Solarbotics RM3 motors
SN754410 motor driver chip
SRF05 Ultrasonic range finder
Arduino Deumilanove w/ ATMEGA328
Breadboard / Prototyping board
Jumper/ Connector wires
2x 220nF multilayer ceramic capacitor (Y5V)
2 x 50V 10uF Capacitor (although I’ve not used them here)
2.1 mm coaxial DC jack
2 x PP3 9Volt battery
PP3 9Volt Connector
9Volt battery holder
You can see that the circuit is pretty simple, nothing actually that fancy, I have the SRF05 using the +5v, GND and digital pins 12 and 13. The SN754410 then uses the digital pins 9 and 10 to control each channel – these can use PWM to do speed control, then there are the switch pins on the h-bridge that go to digital pins 3,4,5 and 6. The spare GND is used to join the GND connection between the motor power and Arduino power supply. The 9v battery DC supply instructions are here. If you want to use the extra 50v 10 uF capacitors then these sit on the power supply for pins 8 and 16 on the SN751140 respectively.
The sketch
Nothing much has changed from the larryBot v0.1-0.5 sketch except that I’ve altered the detection distances as I have a much faster response time from the robot.
const int numOfReadings = 10; // number of readings to take/ items in the array int readings[numOfReadings]; // stores the distance readings in an array int arrayIndex = 0; // arrayIndex of the current item in the array int total = 0; // stores the cumlative total int averageDistance = 0; // stores the average value // setup pins and variables for SRF05 sonar device int echoPin = 12; // SRF05 echo pin (digital 2) int initPin = 13; // SRF05 trigger pin (digital 3) unsigned long pulseTime = 0; // stores the pulse in Micro Seconds unsigned long distance = 0; // variable for storing the distance (cm) int motor1Pin1 = 3; // pin 2 on L293D int motor1Pin2 = 4; // pin 7 on L293D int enable1Pin = 9; // pin 1 on L293D int motor2Pin1 = 5; // pin 10 on L293D int motor2Pin2 = 6; // pin 15 on L293D int enable2Pin = 10; // pin 9 on L293D void setup() { // set the motor pins as outputs: pinMode(motor1Pin1, OUTPUT); pinMode(motor1Pin2, OUTPUT); pinMode(enable1Pin, OUTPUT); pinMode(motor2Pin1, OUTPUT); pinMode(motor2Pin2, OUTPUT); pinMode(enable2Pin, OUTPUT); // set enablePins high so that motor can turn on: digitalWrite(enable1Pin, HIGH); digitalWrite(enable2Pin, HIGH); pinMode(initPin, OUTPUT); // set init pin 3 as output pinMode(echoPin, INPUT); // set echo pin 2 as input // create array loop to iterate over every item in the array for (int thisReading = 0; thisReading < numOfReadings; thisReading++) { readings[thisReading] = 0; } } void loop() { digitalWrite(initPin, HIGH); // send 10 microsecond pulse delayMicroseconds(10); // wait 10 microseconds before turning off digitalWrite(initPin, LOW); // stop sending the pulse pulseTime = pulseIn(echoPin, HIGH); // Look for a return pulse, it should be high as the pulse goes low-high-low distance = pulseTime/58; // Distance = pulse time / 58 to convert to cm. total= total - readings[arrayIndex]; // subtract the last distance readings[arrayIndex] = distance; // add distance reading to array total= total + readings[arrayIndex]; // add the reading to the total arrayIndex = arrayIndex + 1; // go to the next item in the array // At the end of the array (10 items) then start again if (arrayIndex >= numOfReadings) { arrayIndex = 0; } averageDistance = total / numOfReadings; // calculate the average distance delay(10); // check the average distance and move accordingly if (averageDistance <= 10){ // go backwards digitalWrite(motor1Pin1, HIGH); digitalWrite(motor1Pin2, LOW); digitalWrite(motor2Pin1, HIGH); digitalWrite(motor2Pin2, LOW); } if (averageDistance <= 25 && averageDistance > 10) { // turn digitalWrite(motor1Pin1, HIGH); digitalWrite(motor1Pin2, LOW); digitalWrite(motor2Pin1, LOW); digitalWrite(motor2Pin2, HIGH); } if (averageDistance > 25) { // go forward digitalWrite(motor1Pin1, LOW); digitalWrite(motor1Pin2, HIGH); digitalWrite(motor2Pin1, LOW); digitalWrite(motor2Pin2, HIGH); } }
Troubleshooting
Some problems you may face – if like my you don’ t have a spare 9V battery connector to hand check this connection if nothing is happening – I used blu-tack to hold my wires in place so it’s a bit temperamental.
Check that your motor wires are properly in contact with the motor terminals if you haven’t soldered them again using some blu-tack or tape is handy for getting a good connection.
Motor’s are under strain – your tracks are too tight.
Tracks come away from the wheels – check your tracks are not too loose and that your running wheels are in line with the drive wheels – the Tamiya gearbox is slightly wider than the Tamiya track and wheel set axles.
Afterthoughts
I’ve gotten a fairly cheap robot that avoids obstacles, next plan is to extend it to sense various things – for instance detect motion and move towards it, or a light/ heat source. The robot costs are quite high if you factor in the Arduino board and if you don’t have any of the parts – but this can be broken down and used for many other projects so you’ll get a lot of reuse out of these bits, but I reckon that the total cost is around £70-80 in total, so fairly cheap when compared to other bots. Of course if you don’t want tracks (?) then you can just use wheels instead, Tamiya do also make wheels that will fit the gearbox.
Alternate sources for parts
Just in case you have trouble getting parts, here’s a small list of people that can supply the various bits – although none of them will have the full set. Shipping from the states is an option, but check the shipping costs as it may negate the cost savings. Please let me know of other sources, the list is in no particular order.
Sparkfun – USA: motor controller and Tamiya parts
Pololu – USA: Tamiya parts and motors
Techbotics – UK: Tamiya parts – just about cheaper than getting parts from Sparkfun/ Pololu in the USA
Active robots – UK: motors, SRF05 but generally overpriced on everything
Rapid Electronics – UK/EU/USA: most component parts and hardware
Farnell – UK/EU/USA: SN754410 chip and most components but shit for orders if your billing and delivery addresses are separate
Mouser – UK/EU/USA: SN754410 chip and most components
SK Pang – UK: SN754410 chip but dodgy VAT calculations (charges tax on shipping as well) few other parts here.
If you need an Arduino board, I reliably found a seller on ebay from Hong Kong that will sell and ship you aboard for far less than paying for it the UK – downside is it takes about a week to arrive.
This content is published under the Attribution-Noncommercial-Share Alike 3.0 Unported license.
- larryBot – versions 0.1 to 0.5 lessons learned
- Arduino: Controlling the Robot Arm
- Arduino: Modifying a Robot Arm
- Arduino + Processing: Make a Radar Screen to Visualise Sensor Data from SRF-05 – Part 2: Visualising the Data
- Arduino + Processing: Make a Radar Screen to Visualise Sensor Data from SRF-05 – Part 1: Setting up the Circuit and Outputting Values
- Control a DC motor with Arduino and L293D chip
- Arduino + Processing: Getting values from SRF05 ultrasound sensor & serial port
- Arduino: A Basic Theremin
- Arduino: Sonic range finder with SRF05
- Arduino: Basic Theremin meets Processing!
















hi
I Love it i have got stumpt by the breadboard, i cant work it out from the picture could you help. i have never don emuch with a breadboard since i studyed electronics.
i understand thet you are probably a busy person, so sorry for bothering you.
thank you
dan
Hi Dan,
What are you stuck on? I always start by breaking things down a bit on the breadboard. It took me a while to figure it out as there were so many other confusing things out there for similar topics and everyone just assumes you know.
If you let me know what you need to make it easier to understand I’ll update the tutorial/ answer questions.
thanks for the quick reply.
i am stuck with puting together the breadbord. I find it hard to distingush were the wires go. i have never done any thing like this befor on a breadbord, i studyed electronics for gcse but i never did complex things and it has been a wile since then. i don’ know what you can do to help but it would be greatly apriciated.
i also noticed that on your picture it looks like you have an extra colum on each side althoug i baght it from the link on your site. I know that dosent matter but i thaght i would point it out incase you try to put down cowardenats of each wire.
thanks again for your time
dan
OK, lets start with the breadboard and we can do it in stages. I guess take it so the shortest side of the breadboard is in front of you and we’ll name the columns. I’m assuming that what you have is one with essentially 4 columns?
Starting with the left side there should be a column of 2 holes wide (column A), then a column of 5 (column B), column of 5 (column C) and on the far right a final column of 2 (column D). The breadboard is divided into rails, so think of these as a wire strip running inside the breadboard linking the holes together. In columns A and D the rails run the length (longest side of the board). Yet in columns C and D they run across the width – this is important to note. So unless there is something linking these rails together power is never flowing through them and if it is it runs along the rail until you join them together.
The outside columns A and D (that are 2 holes wide) are going to be purely for our power supplies, so power is either going in to these columns/ rails to the circuit or it is returning via the GND/ Negative. And the power will be running up and down these rails. Lets make sure to designate which is positive and which is negative/ GND.
the left of column A will be + and the right of column A will be -. The same goes for column D, but really we only need column A for our power needs.
Starting with the H-bridge chip, you need to plug this in so that it straddles the very middle of the board, so that 8 pins are in column B and the other 8 are in column C, think of each column as a separate entity, unless you connect them thery are completely separate. If you look at the chip there should be an indentation at one end, this indicates were pin 1 is of the chip. So lets place the chip at the very top of our board with the indentation towards the top – also fits my picture better that way in the original post.
The chip straddles the 2 columns so that we can have 2 completely separate power sources/ motors unaffected by each other. If you don’t do this you won’t be able to control the chip effectively.
Ok, so we should have a chip inserted at the top of the board? It should have 16 pins, 8 in each side.
At the top left of the chip this is pin 1 based on this assumption we can explain each output of the chip.
PINS
1 to pin 9 on Arduino board
2 to pin 3 on Arduino board
3 to motor1 (either + or -) it wont matter as its DC
4 to the gnd rail on the breadboard
5 to the gnd rail on the breadboard
6 to motor1
7 to pin 5 Arduino
8 to power (+) rail.
9 to pin 9 Arduino
10 to pin 6 Arduino
11 to motor2
12 to GND rail
13 to GND rail
14 to motor2
15 to pin 5 Arduino
16 to power (+) rail.
The capacitors have only 2 wires each, and they sit in pins 3 and 6 BEFORE the wires for the motor and likewise for the other capacitor on pins 11 and 14 for motor2.
If you’ve got that working then we move to the other stuff. Essentially there is a 9v battery that connects to our power rails, everything else (the SRF05) I run off the Arduino board.
Hope that helps explain it a bit more – bit of a late night reply but if you’re still stuck then I’ll do step by step diagrams tomorrow.
Incidently I’m setting up a way to get all these parts together without having to pay multiple postage to numerous places if there’s anything that you need.
thank you again for the quick responce.
I think this is what i need, ill give it a go when my new jump wires come as i have ordered some more as i dident count how many was needed.
thanks dan
also i cant work out were the negitive from the 9v battery gose
dan
jab it into the ground rail on the breadboard
– same as the gnd connections from the L293D/SN75441 motor controller chip.
thanks,
i just realised that gnd stud for grond. i was going to past saying i workied it out. HaHa.
dan
heh – took me a while to get used it to – Ground, GND, -, negative they all probably mean totally different things but in this case they all mean the black wire from the 9v!
Thanks for the help, me n Dan just rewired the whole thing and reuploaded the Arduino code. Dan then realised that he had not conected the two grounds together… Nice blog, I need to look around here
Seriously you wouldn’t believe how much I struggled! Took me ages to realise that I was bridging connections between the chip at first (much more of a fundamental error than Dans).
I’ve just been playing more with the ultrasound sensor and realised that I’ve been doing some dodgy code :/
it may be a few days yet as i brock my glue gun so i haven’t been able to finish my chassie. i am geting a new one so ill send you the finished pics and vid’s then.
HEY CAN YOU PLEASE HELP ME to build a robot that works on image processing and avoid obstacles(STATIC VEHICLES).
You’ll need a web cam and some way of processing images e.g. laptop using the Processing langauge maybe to look at pixel difference between images to detect objects.
CAN YOU PLEASE HELP ME TO Build an automated robot that can traverse a complex arena consisting of Bi-lane roads with obstacles (static vehicles).
Has the robot got to find anything e.g. get to a certain point in the arena, or is it just purely obstacle avoidance?.
Obstacle avoidance isn’t too bad and depending up on the lane you can get a sensor to check and keep with in the lines.
yeh you’ll need a few jump wires… let me know how you get on.
hi
will i be able to test the circit befor i programed the Arduino?
thanks
dan
hi again i can’t work out what ive done rong. i have followed the steps to how i enterprited it but it does no work. i am realy confused. Do you have any ideas on what i could have done rong?
thanks
hmm. just talking about setting up the motor control chip right?
I’ll do step by step photos when I get in tonight/ over the weekend and do a diagram
hi sorry i diddn’t say what i was having problems with. I have put all the jump wires together and the chips and i also programed the adrino board, bu tit wont work
thanks
dan
ah ok, I’ll do the steps in more detail – make it a bit easier to follow
also… where are the “2 x 50V 10uF Capacitor” meant to be posisioned?
dan
p.s. sorry for all the hasle
hey man no hassle – i’m glad this all helping – took me ages to find any decent info myself so I’m happy to improve what I’ve written etc…
The 50V 10uF’s are optional should you want a smoother flow of power () theres’s some info at that link. Basically I stick ‘em on for each of the power supplies, so the positive pin of the capacitor goes in the positive power rail on the breadboard, the negative pin goes in the negative/ GND rail. The capacitor should have a minus sign on around the negative pin.
You gotta send me pics/ vid of this working
ok
thanks a lot
you have been brilliant.
ive managed to convince my mate to have a go. 8D
ill send some pics and vids when ive got it working well.
Dan
hi again i have spent ages trying to get it to work…
i find that it runs for a few seconds then just dies
i have been trying to get it to work i quite a few waya but have not managed to…
when the circit on its own with the moters worked but when it is all atached it dosent im wondering if i have the rong capaceters but they seam to be right
thanks
dan
Ah no this sounds like it will be down to the size of the motors and their stall current – I had the same issues. What motors are you using? and what motor controller chip are you using?
If you’re using the RM3 motors and SN754410 then are you using a 9volt battery to drive your motors? and are you using a 9V for the Arduino (2x batteries).
If thats all correct and its still stalling then check the layout of the chip and if its wired correct and send me a picture or mail it me at larry@ this website
hi
i have the 2 9v batterys, and i baught everything else from the list
dan
sounds like chip configuration – if you’ve got any pictures? Is the chip wired up like mine? Are you using tank tracks – Are they too tight? Sounds like something is stopping the motor when its under load or somethings not wired right from the motor control chip. I’m down near london if you’re still stuck – don’t mind meeting up to fix it.