larryBot – Arduino robot versions 0.1 to 0.5 lessons learned

So I’ve decided to build a robot using Arduino to control the sensors. Here’s my progress so far – I am hoping that my mistakes here and over the coming...

So I’ve decided to build a robot using Arduino to control the sensors. Here’s my progress so far – I am hoping that my mistakes here and over the coming posts will guide people in more detail about what to avoid. Also I won’t provide a parts list until I have a working robot…

The purpose of my early version of larryBot is to create a basic robot that can be controlled with Arduino and that can be made from minimal materials and costs – I aimed with the Arduino included for this cost to be about £60-70 in total depending on what you can scrounge and providing you have the tools and some parts already. Also I wanted to make a robot from scratch rather than hacking together existing things, like modifying a RC car chassis for example. So far all larryBots aim is to do is to avoid obstacles and move around them.

First off I looked at using the L293D chip to control 2 DC motors and this would operate my steering and I would use the SRF05 ultrasound range finder as a proximity sensor. I had no problem with this circuit when I first started until today.

My first consideration was the chassis, now I figure that most people like me have spent the money on the Arduino board, which is worth every penny, and you probably have a few motors and bits with which to do this. However, like me, you looked at chassis and what to build one from to mount all the electronics. Theres the Tamiya erector set (if you can get it in the UK), Meccano, Lego and of course specific robot chassis’s not to mention designing your own and getting it made.

All very expensive (unless you have it already) and requires effort. I am lazy and karma happened to bless me with finding a stash of 5mm thick foamboard for me to use. If you aren’t aware foamboard is used for modelling and mounting work for display – if you need any then get a design agency to come and quote for work at your company and keep their foamboard :)

Anyway, the foamboard is excellent for my uses so far as my robots aren’t massive and their weight is minimal. It also allows me to rapidly prototype a chassis and layout without any costs – you can just push screws and bolts through to mount motors and use a glue gun to join parts. Another bonus is that you only need a craft knife to cut it.

To connect everything I just brought a set of various nuts and bolts to use along with a glue gun and thats it.

My circuit throughout has basically remained the same, I use a 6v power supply to power the L293D and the motors, and a 9V DC power supply to power the Arduino, which controls the L293D and reads the Ultrasound sensor. My changes so far have been on the chassis, motors, movement and gearing. The sketch for these versions has also remained the same which you can see detailed below:

larryBot v0.1-05 Arduino Robot Sketch

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 <= 25){
    // go backwards
    digitalWrite(motor1Pin1, HIGH);
    digitalWrite(motor1Pin2, LOW);
    digitalWrite(motor2Pin1, HIGH);
    digitalWrite(motor2Pin2, LOW);    

  } 

  if (averageDistance <= 45 && averageDistance > 25) {
    // turn
    digitalWrite(motor1Pin1, HIGH);
    digitalWrite(motor1Pin2, LOW);
    digitalWrite(motor2Pin1, LOW);
    digitalWrite(motor2Pin2, HIGH);
  }
  if (averageDistance > 45)   {
    // go forward
    digitalWrite(motor1Pin1, LOW);
    digitalWrite(motor1Pin2, HIGH);
    digitalWrite(motor2Pin1, LOW);
    digitalWrite(motor2Pin2, HIGH);     

  }
}

I’ve gone down the route so far of using differential steering, this means that to turn left 1 motor goes forward while the other goes in reverse. I did look at using a servo to mimic an RC cars steering but this added to complexity which for now I want to avoid.

larryBot v0.1 – 0.2

This version had two rear mounted wheels that turned either way via the L293D motor driver giving me differential steering. I also mounted a single axle at the front with 2 wheels on this. At first this one moved fine on a smooth floor but then I noticed the motor mounted wheels were slipping so I bonded them to the axle using some araldite (strong glue). This was going fine but then I noticed that when used on a different surface larryBot couldn’t turn as effectively.

larryBot v0.3

So I figured that perhaps it was the fact that the steering would be limited by having 2 front wheels, so I removed these and built in a single wheel at the front for the bot to pivot on to aid steering. Saddly this wasn’t happening and larryBot still had problems on carpet. Next I looked at the motors, essentially they were just tranferring power to the wheels via a worm gear. This isn’t really any good to get any decent torque out of the motors, so perhaps a better gear system would help me out here. I also figured that realistically wheels may not be that great for the best transport, so I looked instead at getting some tracks.

larryBot 0.4

To keep costs down I spent a while looking for a small gearbox system and track set. Logically and costwise I arrived at the decision to get a Tamiya gearbox (Tamiya part No. 70097) with motors included and a Tamiya track and wheel set (70100), the total for which including postage was about £25 you can order from the states but there are a few places in the UK that you can order from too.

I created a long wheel base much like a standard tank and mounted everything on to a new chassis cut from foamboard – nothing complicated, just a rectangle with some bolts to hold the gear box on. To add the axles to the chassis, I used some nuts and glued them on to the chassis with the glue gun to create a way to hold the axles in place.

This worked out great – larryBot conquered the carpet! Hooray! But now with the gearbox he was too fast and kept throwing his tracks off the wheels when ever he turned so he never seemed to run for more than a few seconds – no where near as long as the previous versions. Back now to rethink the wheel base and track setup.

larryBot v0.5

So today I made a new chassis, much shorter wheel base and the tracks are much tighter, tested it with the motors wired up to the battery directly and larryBot now turns fine!

I added in the circuit board and larryBot started to run BUT… the motors began to cut out frequently and the L293d chip began to get very hot. Hmmmm…. It turns out that the motors supplied with the Tamiya gear box which are Mabuchi FA-130′s draw up to 2.2A stall current per motor! the L293D chip can only deliver a maximum of 0.6A to the motor which is barely enough to freely run the motor and with tracks on this will run the motor for less than 5 seconds before cutting out

So now it looks like I have 2 choices and I think I will do both – firstly I’ll look at a new motor driver chip which can handle higher current loads and secondly I’m going to replace the gearbox motors with a motor which has a much lower stall current than the huge 2A! This will also have a nice bonus of making my batteries last longer as well as my components – perhaps also allowing me to use just 1 power supply.

Now I need new motors/ control chip

Now I need new motors/ control chip, he

This content is published under the Attribution-Noncommercial-Share Alike 3.0 Unported license.

Technorati Tags: , , , , , , , , , , , ,

  1. Obstacle avoidance Arduino robot – build your own larryBot
  2. Arduino: Controlling the Robot Arm
  3. Arduino – Redefining the TV Remote
  4. Arduino + Processing: Make a Radar Screen to Visualise Sensor Data from SRF-05 – Part 2: Visualising the Data
  5. Arduino + Processing – Make a Radar Screen to Visualise Sensor Data from SRF-05 – Part 1: Setting up the Circuit and Outputting Values
  6. Arduino & Processing – Getting values from SRF05 ultrasound sensor & serial port
  7. Arduino – Basic Theremin meets Processing!
  8. Arduino – A Basic Theremin
  9. Arduino – Modifying a Robot Arm
  10. Control a DC motor with Arduino and L293D chip