My first robot

Well, here he is:

/*MAEP 2.0 Navigation
by Noah Moroze, aka GeneralGeek
This code has been released under a Attribution-NonCommercial-ShareAlike license, more info at http://creativecommons.org/licenses/
PING))) code by David A. Mellis and Tom Igoe http://www.arduino.cc/en/Tutorial/Ping
*/

#include <Servo.h> //include Servo library

const int RForward = 0; 
const int RBackward = 180; 
const int LForward = RBackward; 
const int LBackward = RForward; 
const int RNeutral = 97; 
const int LNeutral = 90; //constants for motor speed
const int pingPin = 12;
const int irPin = 13;  //Sharp infrared sensor pin
const int dangerThresh = 10; //threshold for obstacles (in cm)
int leftDistance, rightDistance; //distances on either side
Servo panMotor;  
Servo leftMotor;
Servo rightMotor; //declare motors
long duration; //time it takes to recieve PING))) signal

void setup()
{
  rightMotor.attach(11);
  leftMotor.attach(10);
  panMotor.attach(6); //attach motors to proper pins
  panMotor.write(90); //set PING))) pan to center
}

void loop()
{
  int distanceFwd = ping();
  if (distanceFwd>dangerThresh) //if path is clear
  {
    leftMotor.write(LForward); 
    rightMotor.write(RForward); //move forward
  }
  else //if path is blocked
  {
    leftMotor.write(LNeutral);
    rightMotor.write(RNeutral); 
    panMotor.write(0); 
    delay(500);
    rightDistance = ping(); //scan to the right
    delay(500);
    panMotor.write(180);
    delay(700);
    leftDistance = ping(); //scan to the left
    delay(500);
    panMotor.write(90); //return to center
    delay(100);
    compareDistance();
  }
}
  
void compareDistance()
{
  if (leftDistance>rightDistance) //if left is less obstructed 
  {
    leftMotor.write(LBackward); 
    rightMotor.write(RForward); //turn left
    delay(500); 
  }
  else if (rightDistance>leftDistance) //if right is less obstructed
  {
    leftMotor.write(LForward);
    rightMotor.write(RBackward); //turn right
    delay(500);
  }
   else //if they are equally obstructed
  {
    leftMotor.write(LForward); 
    rightMotor.write(RBackward); //turn 180 degrees
    delay(1000);
  }
}

long ping()
{
  // Send out PING))) signal pulse
  pinMode(pingPin, OUTPUT);
  digitalWrite(pingPin, LOW);
  delayMicroseconds(2);
  digitalWrite(pingPin, HIGH);
  delayMicroseconds(5);
  digitalWrite(pingPin, LOW);
  
  //Get duration it takes to receive echo
  pinMode(irPin, INPUT);
  duration = pulseIn(irPin, HIGH);
  
  //Convert duration into distance
  return duration / 29 / 2;
}

The right motor is pin 11
The left motor is pin 10
the scanning servo is pin 6

the trig is pin 12
the echo is pin 13

I just powered the servo motors with a 5V regulator with a heat sink and the SR04 off the Arduino.

I guess I'll take him apart now. I really need several boards for tinkering...

Nice job! It looks like the object avoidance is working. It might work a little quicker if it turned when backing-up. I have a similar Tamiya track set-up and I want it to work similar to yours someday.

Keep it up!

Thanks! His vision is a little narrow and the he tends to lose his tracks XD The toy I built him from wasn't really designed to have power running to the wheels. It was a fun little project though!

The Tamiya track platform I built has the same problem of loosing it's tracks. The only answer for me was to only do slow or partial turns. On a slick floor it is not bad but, put it on carpet and the first 90 degree turn will pull the track off.

Tracks are fun but, I think I am going to a wheeled project next.

Hi,

Same here, the Tamiya tracks work well on tiled floors but are hopless on stone/concrete/tarmac/carpet etc.

Here is a more off road orientated Tamiya of mine -

Its a rock crawler so slow enough to convert to autonomous operation, its also supports front and rear steering. I image that the turning circle of wheeled vehicles would be a bit frustrating without this front/rear steering capability to tighten the turn radius.

It also supports crab steering so you could sort of 'side step' obstacles - might add another dimension to a project, when to turn and when to crab steer.

Duane B

rcarduino.blogspot.com

Cool jeep DuaneB!

I have the running gear of a 1/10th scale Tamiya Clod Buster. I am considering using it. I need to get a reversing speed control though, one that would be real cheap.

Good Job! Looks good. There are momentary switches you could try to add to it. They can help guide the robot. I think someone already mentioned the PING Sensor.

i see your instrument photo for build robot projects.
i am also interest build user friendly robots.

Generator on rent

Good to know the tamiya also throws it's tracks. I was considering one but I would have been disappointed. I wonder if the dagu rover 5 has the same problem?

This is the third page of a thread about the Dagu, Nick Gammon says his tracks tend to come off. http://arduino.cc/forum/index.php/topic,82618.30.html

Interesting bot, the thread has videos.

Do operators of tanks/other tracked vehicles often "turn in place"? In videos of operation of such vehicles, I don't think I've ever seen this. If it isn't done often, perhaps the reason why is to prevent the throwing of the track due to the huge side-loading?

Even so, it can be seen that the kit was not really designed to be used the way the hoff70 is using it - with driven tracks. What you might do is get another one of those kits (if you haven't already - if it were me, and I saw that, I'd buy out every last one), and add extra wheels in between the end wheels. Try two extra, first, then four. You'd have to redesign your chassis, of course, to handle this.

Another thing to try would be to lower the speed of the servos (if possible) when turning. Finally, you could just avoid 90 degree turns...

You may be right cr0sh. At first I noticed that it threw the track when I turned using 1 motor. It was better with 2 running opposite but still not great. Since other tracked bots have the same problem the side loading must be the issue.

Kind of a bummer because I want to do a better tracked bot in the future.

And yea, they only had 1 of the bulldozer kits but I picked up a few more kits that had wheels. Not as cool as the dozer though :stuck_out_tongue:

Because the chassis has no suspension, the load is not even across all of the wheels. Depending on weight placement, some wheels will only barely touch the track. On a modern tank, they seem to use air ride and each wheel has some force on it all of the time.

After running it stock out of the box, I modified my track chassis, I got a plank of wood similar to the original but longer. I have the motors hanging off the back instead of in the middle of the chassis. I used all of the track that came with the track chassis kit. So, wheel base is about 1 inch longer and I have the small idler wheels spread out towards the ends with one in the middle of the track run.

I have not yet tested my lengthened version yet so, I don't know if it will help or not.

Do operators of tanks/other tracked vehicles often "turn in place"? In videos of operation of such vehicles, I don't think I've ever seen this. If it isn't done often, perhaps the reason why is to prevent the throwing of the track due to the huge side-loading?

Real tracked equipment have tracks with raised splines and split bogie wheels to prevent side slippage of the tracks under the bogies. Most big equipment have somewhat smooth tracks to allow some slippage on the surface they are on when turning. The exception are the bulldozers that have cleated tracks. In my young days I got to operate both a large tracked front end loader and a bulldozer on a construction project. The front end loader skidded around easily on smooth surfaces. The bulldozer was a different animal. The cleats lock it to the ground and turning it was somewhat like tightly turning a 4 wheel drive manual transmission vehicle on pavement (aka, gear train lockup). When a bulldozer is spun around, the engine loads down and what ever is under it gets totally ground up (that includes pavement!).

With the Tamiya tracks, you have to mount them using a little more tension
than you might be comfortable with, and make the turns [on carpet] by
driving the treads in opposite directions, and usually not use max speed.
If you try to turn by driving only one track, it'll likely come right off.

Well, he looked so sad sitting there with no brains or batteries that I decided to work on him some more. I didn't want to use another Arduino to run him so I figured I'd attempt to use a stand alone chip. Here's a thread on that project:

http://arduino.cc/forum/index.php/topic,114057.0.html

Now that I have a little 8 pin arduino (I call it the retarduino, after it's creator :P) I can, hopefully, get my bot working. And a little more permanent.

When I had him breadboarded I used the Arduino to run 5 pins which ran the 3 servos and the US sensor. For servo power I just had a 5V regulator supplying voltage to the servos and an 8XAA battery pack. I noticed that the heat sink on the regulator got pretty hot so I'd like some input on that. Maybe use fewer batteries so the regulator doesn't have to deal with so much voltage?

I noticed that the servo plugs would line up with the ground and 5V side of the regulator so I did this little pinout:

The 2 servo power wires (From the 3 servos) will go straight to the regulator and the 3rd pin will be the signal from the retarduino. Does anyone see any problems with this? I was also planning on putting a power LED on it and maybe a capacitor across the battery leads.

Here's another mockup:

I think the heatsink looks pretty cool 8) Like an engine exhaust or something.

I still need to do some more breadboard testing and I may redoux the chassis because I found another dozer kit 8) I'll move on to that when/if I get the electronics sorted.

Any input, advise? I'm just making this up as I go so any help would be welcome!

Nice work! Good idea moving to a breadboard is a cool way to go!

If you are using alkaline batteries, each on puts out 1.5volts. You need at least 7 volts for a 7805 regulator to operate properly. Therefore, you need 5 cells to produce 7.5 volts which will be plenty.

Thanks! I still have some work to do on the little controller board. I want to add a switch and a power LED on the bottom board plus break out the programming pins and the 3 unused pins in case I want to upgrade the sketch in the future. Maybe add some lights or make him talk :stuck_out_tongue: The red LED is a power indicator for the retarduino and the green is hooked to pin 13 which is also the echo input.

I'm also a little stuck on bringing the power from the battery pack to the board. I'm not sure if I want to just solder the leads in place or use a barrel jack or 9V adapter or something... I haven't tested it with the bot sketch yet but all the pins work with "blink" so I hope it's OK.

Sounds like a good plan. If you have screw terminals available, they would work well for temporary wiring like your battery pack.

I finally went with a 9V battery adapter plugged into the 8XAA holder I had. I tried using a 4XAA but it didn't work. I know, you told me so :stuck_out_tongue: It lit the LED's but the chip wasn't working.

I'm hoping this is the final version:

The header plug is off some old computer cables I had around and they are connected to the pins needed to program the chip, I also added main power led and a switch.

Here's my little programming deal hooked up:

In the pic the chip is in the Arduino but I have to remove it in order to program the bot.

I have 10 pins broken out and the way the bot is now I only need 5 so I can maybe add some functions in the future.

If all the electronics check out OK I'm going to redo the chassis and give him a shorter wheel base. I'm hoping that will help the tread throwing problems by (hopefully) reducing the side loading on the tracks when turning.