Starting new crawler bot project.

i have an old crawler bot that my dad was working on, but has long since been forgotten and set aside. I've picked it up and i am going to replace the ic that was on it with an arduino. This will be my first arduino project, so i need some tips and pointers!

Some images first:

Ok. So for the following I/Os i have:

On/Off Switch - master power switch.
InfraRed Sensor –Sharp – GP2D12 49 - Sharp GP2D12 Datasheet by AIS Cube - Issuu
Buzzer – 8 ohm 3-128D 492Y – no information found online.
Yellow LED -
Green LED -
Motor Right -
Motor Left -
Leg POT Right – 308N 5k ohm -S Mexico 20 0503
Leg POT Left – 308N 5k ohm -S Mexico 20 0503

i want to alter the design to incorporate a 2 degree of freedom solution for the 'eyes', that range finder. thats 2 more motors. I was thinking about some sort of limit switch included in that to prevent the servo assembly from 'looking over the bots shoulder' and possibly crashing into the controller. There's not a lot of room on top of this rig.

I was also considering including a line follow under the chassis.

I have a few questions. I know that 5v is the key for all inputs, but, whats the difference between a analog input and a digital? if i wanted to include a screen, i know this is all digital outputs (and i do want to include a screen, before i forget again).

So i have 2 drive motors, 2 servos. These are outputs clearly, but the 2 drive motors i might need to 'turn backwards' inorder to turn the crawler on the spot. the motors in this case wouldn't just always be spinning in one direction

The same goes for teh servos, but i believe they are 3 wire, 1 being common, the other 2 waiting for a hot signal to turn one way or the other.

do analog signals interpert voltages? ie - my sharp range finder sends a voltage of 2.5v when something is 10 cm away, and 1v when something is 30cm away. If i can just go straight to the arduino with that information it'll save me quite a bit of aggravation. otherwise i need help understanding how to interface that data in.

The same goes for the POTS and each leg side. i'm going to be returning a value on one wire or the other in the form of a resisted 5 volt signal. W/ this signal (4 inputs total) i can montior the leg position at all times.

Lastly, 3 leds, 1 green for 'on', one yellow for 'running' and one red for 'obstacle detected'

Since the chassis and all the sensors and I/O stuff is already there, and the existing board doesnt' really work very well, i figured it would be good to go to put an arduino at the heart of this thing and make her go.

The plan is to go with a dueminlove, but i have to understand the arduino's I/O solutions more before i can really make that decision.

~~Dan Eakin
lansing mi usa

oh and before i forget, does anyone know where i can find another motor drive like the one in that last pic?

does anyone know where i can find another motor drive like the one in that last pic?

Looks similar to the Tamiya units sold by lots of hobby robotics shops. Like Pololu, which has some of them on sale at the moment.

Be sure you check the voltage and current requirements: I'm pretty sure I've seen complaints about the low-voltage models overheating motor shields because they draw mondo big mA.

Ran

Personally, I would leave it as-is. Put it in your "robot collection", and leave it alone. Remove the batteries (corrosion).

I guarantee you that some day your dad will die - this will be a "connection" to him; something you both enjoyed: hobbyist robotics.

You will kick yourself later if you don't.

haha... the poor thing doesnt' work. the chip driving it has trouble interrupting and subsequently responding to various input.

Dad stopped working on it becuase he's 1. way too busy (he just got a plane) 2. distracted with his own monster project. i'll take pics of it, but it really doesn't belong on an arduino forum. Its a 386 computer with mountains of hand built custom designed boards to drive motors and recieve signals from IR flag readers. its a trike, steel frame, welded together, runs on two deep cycle batteries. front tire is a front tire off of a law mower, rear tires are snowmobile track wheels. front tire drives, and turns for steering. There's a large wheel on the top that drives and turns, moving the lower half of a arm which is where the computer and a few more bits are stored. On the top right now is a 'eye' center, with 2 degrees of freedom for the housing, but each 'eye' has its own degree of freedom as well, the eyes can look independantly. I'll take some pictures, but like i said, this thing is definitively not arduino. :slight_smile:

The goal here is to segway into a more modern means of controlling robots, and to help my dad upgrade his old machine to overcome some of the headaches he's having with it.

To do that i need to understand arduino better, and to test my understanding, launch it onto a platform i already understand separate from the controller itself.

The problem i'm having is deciding HOW to pick an arduino, mostly because i'm trying to understand the capacities of the i/o, the difference between analog and digital, and in that, what sort of circuits i need to build for each of my i/o.

oh and before i forget, i will be reassembling this robot as it was before i started. i'm just gabbing the chassis out to build on. i like the little thing just the way it is... just wished it would work.

Alrighty, forging a head now.

Going to have to upgrade my arduino, i need more PWM output solutions on the board:
http://cgi.ebay.com/Arduino-Mega-ATmega ... 255b0ba223

so this is the I/O list:

1 Range Sensor - Analog Input, 0 to 2.55v
2 POTS, 4 leads total - analog input, 0 to 5v

3 LEDs - Digital Output, standard

2 VSS pins - Digital PWM output
1 enable pin per motor, 4 motors, 4 Digital PWM output
2 input pin per motor, 4 motors, 8 Digital PWM output

2 motors to drive the unit, 2 servos to give 2 degrees of freedom for the forward looking eye.

Will consider placing a IR emitter and reciever on the back to alert to obstacles behind the unit.

End tally of input output:
5 analog input
3 digital out
14 PWM output (exact limit of the board, incidentally)

This leaves me with approx 40 digital pins and 10 analog input pins to play with. i'm thinking the lcd screen and maybe a blue tooth module to communicate with a pc.

At typical motor drive like a h-bridge needs 2 digital pins (forward, backward, float and break) 1 pwm pin to change the turning speed.
The VSS comes from the battery.
Servo only need 1 pwm port. Or using servo library, then its 1 digital pin.
Potmeter need 1 analog port.
And the range sensor also 1 analog.

So you can do it with a normal arduino.

wiat what? lol.

i have 2 pins, either has to be high at one point or another. i don't see how you're getting it so that only 1 pin is needed. i can supply the 5 v for the enable pins and vss pin from the battery, sure, but i got 4 more inputs to control. 2 controllers, cause there's 2 drive motors and 2 servo motors.

are you saying to PWM the enable pin in order to get it to move slower or faster?

ok So. This is the chip. Pins 1 9 and 16, apparently could be all tied together and have enable on continuously. The input pins 2 6 10 and 15 can be all digital w/out pwm. I guess what i'm getting at is i could run 5 volts to 16 from the arduino, using something other than an I/O pin, and PWM the 1 and 9 pins to drive the motors fast or slow based on the pulse length.

Using that, i would need 4 pwm in order to enable 4 different motors (2 drive motors, 2 servo motors).

would that theory work?

oh and before i forget, i will be reassembling this robot as it was before i started. i'm just gabbing the chassis out to build on. i like the little thing just the way it is... just wished it would work.

Take a lot of pictures, and store all the parts in baggies with the robot, put it in a "special" container, if you can. So often we say "we'll get 'round to it" and often we don't - that's life. But keeping the parts together along with documentation is the best way to have a chance in the future of doing so.

I tend to be more nostalgic and romantic than some; I look on old devices as links to an almost forgotten past. Having such a common hobby with your dad (provided you like him, which it sounds like you do) - well, if it were me I know I would want something after he passed to "tell my kids about"; such shared experiences are worth keeping.

You should definitely post pictures of your dad's other creation (throw them up in bar/sport) - it sounds fascinating and interesting!

:slight_smile:

a buddy of mine just showed up with 2 .22 a 16ga shotgun and a 38, so we're going to put the comptuer and robots stuff on hold until we run outta sunlight.

i still need a solid answer on the pwm to enable pin question. if i can get away with a dueminlove for this rig, i'd love that.

Defiantely crosh, will be taking lots of pics, you've already seen most of them, and i'll make a point of linking to my dad's other project when i get the time to do so. he's been so distracted with building his experiemental class airplane that ... well... i don't see him much anymore. hopefully he starts to fly it so he runs outta money and we can tinker around with making stuff outta junk.

That chip is a dual h-bridge, is it a L293D?
2 digital, 1 pwm is for 1 motor, 2 motors you need ofcourse 4 digital and 2 pwm.

if its a L293D
On ENABLE 1 and 2 you put an PWM signal, this is for changing the turnin speed of the motors.
It can be the same pwm, but both motor will turn the same then, best is to use 2 PWM signals so you can set the individual speed of each motor.

Input 1 and 2 is to set the direction of the motor, this needs to be a digital pin. its something like this:
00 motor float both pins low
01 motor forward pin 1 high, pin 2 low
10 motor backward pin 1 low, pin 2 high
11 motor break pin 1 and 2 high

This is the same for input 3 and 4, but has to be 2 different pins.
VSS needs 5v and vc is the direct battery.

yup yup... we're slamming forward with this project!!! i've gotten quite a bit more information:

is the final diagram of the motor controller. i plan on incorporating LEDs in line with each motor lead however to show current, that way, if hte motor isn't turning, and the light is on, i know there's a problem, or that there's at least power there, even if i don't know why its not working

there'll be two of these on this bot. 1 for the legs, 1 for the pan and look up/down servos for the range finder.

Speaking of which, how do i know where the 'home' position is on a servo? is that what the third wire is?

i've started hacking out some code for it, its far from complete:

#include <Servo.h>

//open analog pins - 3 , 5. open digital pins - 8 10 11 12

//declare servos
Servo panhorizontal;
Servo panverticle;
int panhorizontalpos = 0;
int panverticlepos = 0;

//declare 'scan look positions'
int lookleft = 0;
int lookright = 0;
int lookforward = 0;
int lookdown = 1;

//set pins
//analog
int rangesensor = 0;
int motorspeed = 1;
int legpotleftextend = 2;
int legpotrightextend = 4;
//digital
int led1 = 13;
int led2 = 0;
int driveleft1 =1;
int driveleft2 =2;
int driveright1 =4;
int driveright2 =7;
//pwm
int driveleftenable = 3;
int driverightenable = 5;

void setup()
{
Serial.begin(9600); //???
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(driveleft1, OUTPUT);
pinMode(driveleft2, OUTPUT);
pinMode(driveright1, OUTPUT);
pinMode(driveright2, OUTPUT);
//PWM pins
pinMode(driveleftenable, OUTPUT);
pinMode(driverightenable, OUTPUT);
panhorizontal.attach(6);
panverticle.attach(9);

//motortest? via motortest();

}

void loop()
{

scansidetoside();
scandown();

if (lookdown == 1)
{
//turn 180
}

if (lookforward == 1 && lookright == 1 and lookleft == 1)
{
//turn 180
}

if (lookforward == 1 && lookright == 0 && lookleft == 0)
{
//turn right
}

if (lookforward == 1 && lookright == 1 && lookleft == 0)
{
//turn left
}

if (lookforward == 1 && lookleft == 1 && lookright == 0)
{
//turn right
}

//step once on each side
//monitor step pots to ensure no motor jams
}

void takestep(int side, int dir)
{

}

void scansidetoside()
{
for(panhorizontalpos = 0; panhorizontalpos < 90; panhorizontalpos += 1)
{
panhorizontal.write(panhorizontalpos);
delay(15);
}
lookright = scan();
for(panhorizontalpos = 90; panhorizontalpos > -90; panhorizontalpos-=1)
{
panhorizontal.write(panhorizontalpos);
delay(15);
}
lookleft = scan();
for(panhorizontalpos = -90; panhorizontalpos <= 0; panhorizontalpos+=1)
{
panhorizontal.write(panhorizontalpos);
delay(15);
}
lookforward = scan();
}

void scandown()
{
for(panverticlepos = 0; panverticlepos < 45; panhorizontalpos += 1)
{
panverticle.write(panhorizontalpos);
delay(15);
}
lookdown = scan();
for(panverticlepos = 45; panverticlepos > 0; panhorizontalpos -= 1)
{
panverticle.write(panhorizontalpos);
delay(15);
}
}

int scan()
{
//returns a value in cm = closest obstacle
int x = 1;
return x;
}

void turn180(){}
void turnright(){}
void turnleft(){}
void takestep(){}

void motortest(){}

Serial.begin(9600); //??? speaking of which, what is this??? it was in the example that i used to start building on, and i'm not sure what th heck it is.

i'm going ot start programming each of those functions here shortly. prolly have something working in theory by sunday, even though my arduino and prototype shield, motor controllers, and servos won't be here before monday at the soonest.

EDIT - i just found out 1 pwm is all you need for each servo. that just opened up abunch of pins. derp.

Second EDIT - took down my old code and put up the new. yay.

ok guys... i need some help.

i need to create a table w/ ranges and corresponding voltage readings for my range finder. its non-linear, so thats really not going to help me.

I then need a code solution to go to the closest value, as i really only need estimated distances in increments of 5cm.

help? its part of the scan routine, foundin the code below.

EDIT: Solution Found!:

www.basicxandrobotics.com/ir%20curve%20fit.pdf

we found this equation there:

IRValue = 4187.8(Range)-0.9042
Equation 1
where IRValue is the value returned by the infrared sensor, and Range is the actual distance to the object in units
of centimeters.

which they later show w/ algerbra being converted to this:
cm = pow((4187.8/averagevoltage), 1.1060); //applied to the IDE script.

#include <Servo.h>

//open analog pins - 3 , 5. open digital pins - 8 10 11 12

//declare servos
Servo panhorizontal;
Servo panverticle;
int panhorizontalpos = 0;
int panverticlepos = 0;

//declare 'scan look positions'
int lookleft = 0;
int lookright = 0;
int lookforward = 0;
int lookdown = 1;

int avgscan[2];
int avgvoltage = 0;
int cm = 0;

//motor drive speed
int stepspeedread = 0;
int outputValue = 0;

//set pins
//analog
int rangesensor = 0;
int motorspeed = 1;
int legpotleft = 2;
int legpotright = 4;
//digital
int led1 = 13;
int led2 = 0;
int driveleft1 =1;
int driveleft2 =2;
int driveright1 =4;
int driveright2 =7;
//pwm
int driveleftenable = 3;
int driverightenable = 5;

void setup()
{
Serial.begin(9600); //???
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(driveleft1, OUTPUT);
pinMode(driveleft2, OUTPUT);
pinMode(driveright1, OUTPUT);
pinMode(driveright2, OUTPUT);
//PWM pins
//pinMode(driveleftenable, OUTPUT);
//pinMode(driverightenable, OUTPUT);
panhorizontal.attach(6);
panverticle.attach(9);

//motortest? via motortest();

}

void loop()
{
scansidetoside();
scandown();

if (lookdown > 10){turn180();}

if (lookforward < 15 && lookright < 15 && lookleft < 15){turn180();}

if (lookforward < 15 && lookright > 15 && lookleft < 15){turnright();}

if (lookforward < 15 && lookright > 15 && lookleft > 15){turnleft();}

if (lookforward < 15 && lookleft > 15 && lookright > 15){turnright();}

takestep();
}

void takestep(int side, int dir, int delaytime)
{
// read the analog in value:
stepspeedread = analogRead(motorspeed);
// map it to the range of the analog out:
outputValue = map(stepspeedread, 0, 1023, 0, 255);

digitalWrite(dir, HIGH);
analogWrite(side, outputValue);
delay(delaytime);
digitalWrite(dir, LOW);
analogWrite(side, 0);
}

void scansidetoside()
{
for(panhorizontalpos = 0; panhorizontalpos < 90; panhorizontalpos += 1)
{
panhorizontal.write(panhorizontalpos);
delay(15);
}
lookright = scan();
for(panhorizontalpos = 90; panhorizontalpos > -90; panhorizontalpos-=1)
{
panhorizontal.write(panhorizontalpos);
delay(15);
}
lookleft = scan();
for(panhorizontalpos = -90; panhorizontalpos <= 0; panhorizontalpos+=1)
{
panhorizontal.write(panhorizontalpos);
delay(15);
}
lookforward = scan();
}

void scandown()
{
for(panverticlepos = 0; panverticlepos < 45; panhorizontalpos += 1)
{
panverticle.write(panhorizontalpos);
delay(15);
}
lookdown = scan();
for(panverticlepos = 45; panverticlepos > 0; panhorizontalpos -= 1)
{
panverticle.write(panhorizontalpos);
delay(15);
}
}

int scan()
{
cm = 0;
for (int i=0; i <= 2; i++){
avgscan *= analogRead(rangesensor); *

  • }*
  • int averagevoltage = (avgscan[0]+avgscan[1]+avgscan[2])/3;*
  • cm = pow((4187.8/averagevoltage), 1.1060);*
  • return cm;*
    }
    void turn180(){}
    void turnright(){}
    void turnleft(){}
    void takestep(){}
    void motortest(){}