Arduino Forum

Using Arduino => Project Guidance => Topic started by: husein06 on Feb 22, 2013, 05:42 pm

Title: Autonomous Robot, motor driver
Post by: husein06 on Feb 22, 2013, 05:42 pm
Hello all,

So, long story short, I made an autonomous robot.

2 Problems: Wont drive when put on the ground and everything shuts down when not using CPU power.

My robot works perfectly when not put on any surface, the wheels are spinning very well, then the first time I tried it on a surface it worked for 10 seconds only, then after that every-time I put the robot on any floor surface it can't drive, then I lift it it works fine, and so on. My robot all together only weighs 4lbs.
Using a 7.2V rechargeable Battery
Motors: Motor Ratings (at 7.2 VDC):
No-load Current: 0.27 A @ 310 RPM
Stall Current: 4.8 A
Max Torque: 4.6 lb-inch (5.3 kg-cm)

Motor Driver:
Operating voltage: 5-28 V
Maximum PWM frequency: 10 kHz
Current sense: 0.59 V/A
Time to overheat at 5 A*: 2 s
Time to overheat at 4 A*: 21 s
Time to overheat at 3 A*: 165 s
Current for infinite run time*: 2.5 A

What seems to be the problem, wrong motor driver, motors too weak?
Title: Re: Autonomous Robot, motor driver
Post by: HazardsMind on Feb 22, 2013, 05:57 pm
What you using to power it on the ground?
Title: Re: Autonomous Robot, motor driver
Post by: husein06 on Feb 22, 2013, 06:15 pm

What you using to power it on the ground?

Using a 7.2V rechargeable Battery for the motors, and arduino 9v and laptop cord for the rest of the project, but the main problem is the motors spin perfectly when not on the ground.
Title: Re: Autonomous Robot, motor driver
Post by: JimboZA on Feb 22, 2013, 06:27 pm
It might be a simple mechanical problem to do with (lack of) gearing.

Have you got a motor driver chip in the mix somewhere though?- if you have say a 298 in there you'll be losing volts at the best of times but even more if the current is high with a motor trying to get the robot started. What's the voltage at the motors?
Title: Re: Autonomous Robot, motor driver
Post by: HazardsMind on Feb 22, 2013, 06:40 pm
Your motors probably dont have enough torque, in which case you will some kind of gear system.
Title: Re: Autonomous Robot, motor driver
Post by: afremont on Feb 22, 2013, 07:09 pm
The stall current of the motors is such that they would overheat the controller pretty fast, but I assume that you aren't just turning them on at 100% duty cycle from a stand-still, are you?  What PWM frequency are you using, 10kHz is pretty high.  Depending upon your motors, they might have too much inductance to actually draw much power at that frequency.
Title: Re: Autonomous Robot, motor driver
Post by: husein06 on Feb 22, 2013, 07:23 pm

The stall current of the motors is such that they would overheat the controller pretty fast, but I assume that you aren't just turning them on at 100% duty cycle from a stand-still, are you?  What PWM frequency are you using, 10kHz is pretty high.  Depending upon your motors, they might have too much inductance to actually draw much power at that frequency.

Your motors probably dont have enough torque, in which case you will some kind of gear system.

It might be a simple mechanical problem to do with (lack of) gearing.

Have you got a motor driver chip in the mix somewhere though?- if you have say a 298 in there you'll be losing volts at the best of times but even more if the current is high with a motor trying to get the robot started. What's the voltage at the motors?


I'm using these motors,
http://www.parallax.com/StoreSearchResults/tabid/768/List/0/SortField/4/ProductID/587/Default.aspx?txtSearch=motor+wheel+kit
and this motor driver
http://www.pololu.com/catalog/product/1213
Title: Re: Autonomous Robot, motor driver
Post by: husein06 on Feb 22, 2013, 07:25 pm

The stall current of the motors is such that they would overheat the controller pretty fast, but I assume that you aren't just turning them on at 100% duty cycle from a stand-still, are you?  What PWM frequency are you using, 10kHz is pretty high.  Depending upon your motors, they might have too much inductance to actually draw much power at that frequency.


I'm not sure what you mean, I'm using the arduino PWM 155/255 so .58 duty ratio.
Title: Re: Autonomous Robot, motor driver
Post by: JimboZA on Feb 22, 2013, 07:31 pm
Are you accelerating the motors gradually from standstill? Those look to me like large wheels to run without gearing.... (without doing any calculations that is.)

Edit.... ah, I see those are geared motors, but still might be prudent to accelerate gradually
Title: Re: Autonomous Robot, motor driver
Post by: husein06 on Feb 22, 2013, 07:35 pm

Are you accelerating the motors gradually from standstill? Those look to me like large wheels to run without gearing.... (without doing any calculations that is.)


Would accelerating be considered doing PWM?
not sure what you mean by accelerating. I'm using an Arduino and just sending a PWM signal.
Title: Re: Autonomous Robot, motor driver
Post by: JimboZA on Feb 22, 2013, 07:46 pm
I mean are you sending just one PWM value to set it to 155, or are you looping through a pwm command and increasing the value from 0 to 155 in steps of say 10.

Title: Re: Autonomous Robot, motor driver
Post by: husein06 on Feb 22, 2013, 08:01 pm

I mean are you sending just one PWM value to set it to 155, or are you looping through a pwm command and increasing the value from 0 to 155 in steps of say 10.




This is how I'm doing it.

Code: [Select]
if ( turn == 128 ){
  drive_forward(); 
  analogWrite(PWMR, 255);// speed control
  analogWrite(PWML, 255);// speed control
  }
void drive_forward()
     {
  digitalWrite(RFWD,HIGH);// right wheel foward h-bridge
  digitalWrite(RRVS,LOW);
  digitalWrite(LFWD,HIGH);//left wheel foward h-bridge
  digitalWrite(LRVS,LOW);
  return;
     }
Title: Re: Autonomous Robot, motor driver
Post by: JimboZA on Feb 22, 2013, 08:10 pm
Looks to me that you're blasting it straight to full speed immediately? (You need to post more of the code)

It might be worthwhile to have a speedstep of say 10 and a speed of 0, then loop through a section of code that sets speed = speed + speedstep and pwms it the new value of speed, and do the loop until the speed is the value you want.
Title: Re: Autonomous Robot, motor driver
Post by: husein06 on Feb 22, 2013, 08:20 pm

Looks to me that you're blasting it straight to full speed immediately? (You need to post more of the code)

It might be worthwhile to have a speedstep of say 10 and a speed of 0, then loop through a section of code that sets speed = speed + speedstep and pwms it the new value of speed, and do the loop until the speed is the value you want.

I don't understand how would i include that?. My issue is, the code works perfectly, as long as the car isn't on the ground.  I can hold it up in the air, and the drive motor does what it is supposed to, and the turn motor works when it is supposed to.  But when I put it down, it works on a nice flat surface for a few seconds.  It wont move at all on carpet.

Code: [Select]
 if (errorSum < 25)
 {
   drive_stop();
 }
 else {
 if ( Stotal> 2100 )
 {
 drive_stop();
 }
 else {
 if ( turn == 128 ){
 drive_forward();  
 analogWrite(PWMR, 255);// speed control
 analogWrite(PWML, 255);// speed control
 }

 if ( turn > 129 ){
 drive_right();
 analogWrite(PWMR, 255);// speed control
  }
  if ( 127 > turn ){
  drive_Left();
 analogWrite(PWML, 255);// speed control
  }
}
 }
//delay(100);
}

void drive_forward()
    {
 digitalWrite(RFWD,HIGH);// right wheel foward h-bridge
 digitalWrite(RRVS,LOW);
 digitalWrite(LFWD,HIGH);//left wheel foward h-bridge
 digitalWrite(LRVS,LOW);
 return;
    }
   
void drive_Left()
    {
 digitalWrite(RFWD,HIGH);// right wheel foward h-bridge
 digitalWrite(RRVS,LOW);
 digitalWrite(LFWD,LOW);//left wheel foward h-bridge
 digitalWrite(LRVS,HIGH);
 return;
    }
   
void drive_right()
    {
 digitalWrite(RFWD,LOW);// right wheel foward h-bridge
 digitalWrite(RRVS,HIGH);
 digitalWrite(LFWD,HIGH);//left wheel foward h-bridge
 digitalWrite(LRVS,LOW);
 return;
    }
   
void drive_stop()
    {
 digitalWrite(RFWD,LOW);// right wheel foward h-bridge
 digitalWrite(RRVS,LOW);
 digitalWrite(LFWD,LOW);//left wheel foward h-bridge
 digitalWrite(LRVS,LOW);
 return;
    }
Title: Re: Autonomous Robot, motor driver
Post by: JimboZA on Feb 22, 2013, 08:26 pm
Yes the code may works perfectl, but it seems to run the motors at 255 which is full speed. When you try to get the wheels to move the robot at full speed immediately, it stalls. But if you do an analogWrite(pin, 10) followed by a short delay and an analogWrite(pin, 20) etc etc it might start moving.

But instead of hard-coding the 10 and 20 etc into a zillion analogWrites, you would increment a variable called speed and have analogWrite(pin, speed) to get it up to speed gradually.
Title: Re: Autonomous Robot, motor driver
Post by: husein06 on Feb 22, 2013, 08:33 pm

Yes the code may works perfectl, but it seems to run the motors at 255 which is full speed. When you try to get the wheels to move the robot at full speed immediately, it stalls. But if you do an analogWrite(pin, 10) followed by a short delay and an analogWrite(pin, 20) etc etc it might start moving.

But instead of hard-coding the 10 and 20 etc into a zillion analogWrites, you would increment a variable called speed and have analogWrite(pin, speed) to get it up to speed gradually.


Thanks for the help, I'm going to try it now, I understood the concept but where would I increment "speed"? in what part of my code would i place it I'm just confused there?

also, my professor stated "The problem is too much load. If it works fine with the wheels off the ground the you know what the problem is.  adding a fan will help. " what do you think?
Title: Re: Autonomous Robot, motor driver
Post by: husein06 on Feb 22, 2013, 09:05 pm

Yes the code may works perfectl, but it seems to run the motors at 255 which is full speed. When you try to get the wheels to move the robot at full speed immediately, it stalls. But if you do an analogWrite(pin, 10) followed by a short delay and an analogWrite(pin, 20) etc etc it might start moving.

But instead of hard-coding the 10 and 20 etc into a zillion analogWrites, you would increment a variable called speed and have analogWrite(pin, speed) to get it up to speed gradually.


Code: [Select]

int speeds=0;
int speedstep=10;
if ( 127 > turn ){
   drive_Left();
   for (i=0; i < 255; i++)
   {
   speeds=speeds+speedstep;
  analogWrite(PWML, speeds);// speed control
  }
  }


correct?
Title: Re: Autonomous Robot, motor driver
Post by: HazardsMind on Feb 22, 2013, 09:09 pm
You should add a small delay in there to see the change. Also for that particular segment, I would swap analogWrite(PWML, speed), with analogWrite(PWML, i);//
Title: Re: Autonomous Robot, motor driver
Post by: husein06 on Feb 22, 2013, 09:26 pm

You should add a small delay in there to see the change. Also for that particular segment, I would swap analogWrite(PWML, speed), with analogWrite(PWML, i);//


I just tried it, worked in the Air, again put it on the carpet and it stalled.

Attached are the pictures of my bot. Did I install the motors the wrong way? Should the motor and bracket be above the chassis?

WHY THE STALL! lol its getting frustrating
Title: Re: Autonomous Robot, motor driver
Post by: HazardsMind on Feb 22, 2013, 09:33 pm
My guess would be the mass of the chassis. And the fact that your on carpet doesn't help either.
Title: Re: Autonomous Robot, motor driver
Post by: husein06 on Feb 22, 2013, 09:40 pm

My guess would be the mass of the chassis. And the fact that your on carpet doesn't help either.


The weight of the whole robot is 5.7 pounds, each motor weighs 1 pound, so the chassis is 3.7 pounds very light material.

The motors are supposedly powerful, I thought they will handle something like this.

Is the weight appropriate? maybe the chassis is too long?
Title: Re: Autonomous Robot, motor driver
Post by: HazardsMind on Feb 22, 2013, 09:45 pm
Try this, pick the robot up and run the motors. Then using your finger try to slowly apply pressure to the wheel and see how much pressure it takes to stop it. Do you or can you post a schematic of your design? It is possible that your motors are not getting enough current, so you will need another or better battery.
Title: Re: Autonomous Robot, motor driver
Post by: husein06 on Feb 22, 2013, 10:10 pm

Try this, pick the robot up and run the motors. Then using your finger try to slowly apply pressure to the wheel and see how much pressure it takes to stop it. Do you or can you post a schematic of your design? It is possible that your motors are not getting enough current, so you will need another or better battery.

http://www.robotshop.com/bat-04-7-2v-ni-mh-rechargeable-battery.html
Im using that battery, 7.2V / 2800 mAH Ni-MH Rechargeable Battery , its fully charged for the motors.

For my entire circuit and arduino I'm using a 9 volt battery, (I gotta find a replacement for that, its running out every 10 minutes)

My professor keeps stating "You do not have enough torque. Use a motor operated fan to cool the motor driver"
Title: Re: Autonomous Robot, motor driver
Post by: afremont on Feb 22, 2013, 11:28 pm
Quote from: husein06
My professor keeps stating "You do not have enough torque. Use a motor operated fan to cool the motor driver"
[/quote


Don't you think you might ought to listen to him?  I also told you that it wouldn't take much to overheat that controller.  One important thing you need to take into consideration is derating your parts as temperatures go up.  Those specs you gave are likely for the controller when it is at 25C. 
Title: Re: Autonomous Robot, motor driver
Post by: husein06 on Feb 22, 2013, 11:46 pm

[quote author=husein06
My professor keeps stating "You do not have enough torque. Use a motor operated fan to cool the motor driver"

Don't you think you might ought to listen to him?  I also told you that it wouldn't take much to overheat that controller.  One important thing you need to take into consideration is derating your parts as temperatures go up.  Those specs you gave are likely for the controller when it is at 25C.  

I just cant grasp how a fan over my motor driver will help my robot drive? will a fan really cool off the warming of current that much?
and I'm just trying to learn and ask here dont fight me lol
Title: Re: Autonomous Robot, motor driver
Post by: HazardsMind on Feb 23, 2013, 12:12 am
Ok try this, bypass the motor controller altogether. Wire the motors directly to the battery and see if it is able to move.

If your 7.2V battery is only powering the motors and it is able to move with a direct connection, then the problem is with your motor controller.

If it still does not work, even with a direct connection, then it is your battery.

Do this little test, and you will finally find the culprit to your problem.
Title: Re: Autonomous Robot, motor driver
Post by: husein06 on Feb 23, 2013, 01:35 am

Ok try this, bypass the motor controller altogether. Wire the motors directly to the battery and see if it is able to move.

If your 7.2V battery is only powering the motors and it is able to move with a direct connection, then the problem is with your motor controller.

If it still does not work, even with a direct connection, then it is your battery.

Do this little test, and you will finally find the culprit to your problem.

I'm going to do that right now!! check back for my reply!

Thank you for your help!
Title: Re: Autonomous Robot, motor driver
Post by: husein06 on Feb 23, 2013, 02:00 am

Ok try this, bypass the motor controller altogether. Wire the motors directly to the battery and see if it is able to move.

If your 7.2V battery is only powering the motors and it is able to move with a direct connection, then the problem is with your motor controller.

If it still does not work, even with a direct connection, then it is your battery.

Do this little test, and you will finally find the culprit to your problem.

GREAT NEWS!!!! I put that battery directly to those motors and it went forward about 10 yards in 1 second! lol So on the bright side we now know the problem is the motor driver, this is the one I was using:
http://www.pololu.com/catalog/product/1213
What do you think is the problem, I'm trying to find a better motor driver!

Thanks for pointing out this simple test!
Title: Re: Autonomous Robot, motor driver
Post by: HazardsMind on Feb 23, 2013, 03:44 am
I am not familiar with the one you have so I have no clue what the problem is. How about this one.
http://www.ebay.com/itm/L298N-Dual-H-Bridge-IC-Stepper-Motor-Driver-Controller-Board-Module-for-Arduino-/300864612676?pt=LH_DefaultDomain_2&hash=item460ceda944 (http://www.ebay.com/itm/L298N-Dual-H-Bridge-IC-Stepper-Motor-Driver-Controller-Board-Module-for-Arduino-/300864612676?pt=LH_DefaultDomain_2&hash=item460ceda944)
Title: Re: Autonomous Robot, motor driver
Post by: zoomkat on Feb 23, 2013, 04:59 am
The below is from the pololu 33926 page.

Unlike other H-Bridges, the 33926 has a feature that allows it to gracefully reduce current as the current exceeds 5 A or as the chip temperature approaches its limit. This means that if you push the chip close to its limit, you will see less power to the motor, but it might allow you to avoid a complete shutdown.
Title: Re: Autonomous Robot, motor driver
Post by: JimboZA on Feb 23, 2013, 05:21 am

I am not familiar with the one you have so I have no clue what the problem is. How about this one.
http://www.ebay.com/itm/L298N-Dual-H-Bridge-IC-Stepper-Motor-Driver-Controller-Board-Module-for-Arduino-/300864612676?pt=LH_DefaultDomain_2&hash=item460ceda944 (http://www.ebay.com/itm/L298N-Dual-H-Bridge-IC-Stepper-Motor-Driver-Controller-Board-Module-for-Arduino-/300864612676?pt=LH_DefaultDomain_2&hash=item460ceda944)


With a 298 in there he's going to lose 2-3 volts at the motors straight off the top....

Btw, have you tried to code the acceleration in, as I suggested and as you elaborated in code earlier?

And tried it on a floor with no carpet? As the wheel sinks in the pile, as it moves off it has to flatten the pile in front and that takes energy.
Title: Re: Autonomous Robot, motor driver
Post by: husein06 on Feb 23, 2013, 07:44 am


I am not familiar with the one you have so I have no clue what the problem is. How about this one.
http://www.ebay.com/itm/L298N-Dual-H-Bridge-IC-Stepper-Motor-Driver-Controller-Board-Module-for-Arduino-/300864612676?pt=LH_DefaultDomain_2&hash=item460ceda944 (http://www.ebay.com/itm/L298N-Dual-H-Bridge-IC-Stepper-Motor-Driver-Controller-Board-Module-for-Arduino-/300864612676?pt=LH_DefaultDomain_2&hash=item460ceda944)


With a 298 in there he's going to lose 2-3 volts at the motors straight off the top....

Btw, have you tried to code the acceleration in, as I suggested and as you elaborated in code earlier?

And tried it on a floor with no carpet? As the wheel sinks in the pile, as it moves off it has to flatten the pile in front and that takes energy.


Yes I did it didn't work, the problem is not accelerate or the code. The motor driver kept shutting off from over heating, I guess the motors were drawing more than 2.5 amps, and the motor driver couldn't handle it.
Title: Re: Autonomous Robot, motor driver
Post by: cr0sh on Feb 23, 2013, 08:13 am

Yes I did it didn't work, the problem is not accelerate or the code. The motor driver kept shutting off from over heating, I guess the motors were drawing more than 2.5 amps, and the motor driver couldn't handle it.


First off, what you need to do is quit guessing, and start measuring. Let's go over the specs of your motors and the driver, shall we?

First off, the motors - based on the link you gave, here are the pertinent specs:

Motor Ratings (at 7.2 VDC):

    No-load Current: 0.27 A @ 310 RPM
    Stall Current: 4.8 A
    Max Torque: 4.6 lb-inch (5.3 kg-cm)

So - with no load, these motors will only pull 270 mA - but once stalled, they pull 4.8 amps. Furthermore, they only provide 4.6 inch-lbs of torque.

We know your motors are pulling a lot of current, and that they can pull way more than your motor driver can handle (more on that later), so let's look at the torque. What "4.6 inch-lbs" means is that the motor can move (or lift, if you will) 4.6 lbs if a lever were lifting that mass one (1) inch away from the center of the shaft. If the lever were 2 inches long, you could move 2.3 lbs, if 3 inches long - 1.53 lbs - and so on.

So, what this means is that the motor can move 4.6 lbs if you have a wheel 2 inches in diameter. How big are the wheels that come with the motor? Well, according to the specs, the wheels are 4.875 inches in diameter; so that gives you a lever of 2.44 inches - giving you the ability to move 1.89 lbs (4.6 / 2.44). See how that works?

Now of course, that would be a "dead-lift" weight - rolling on the ground (carpet, floor, whatever) that number may well be enough to move the weight of the motors, batteries, platform, etc without approaching the limits of the motor, but the more weight you have (and friction with the ground, etc) - the closer to that number (and the greater the current draw) will occur.

There are ways to figure out mathematically how much torque would be required to move the mass sideways for a given mass (and things change when going uphill, of course), but you can do it empirically using a fishing scale or similar - simply hook one end onto your platform, and pull it, measuring the amount of lbs needed to pull it (ideally with free-rolling wheels and the same weight as with the motors and real wheels installed). You should attempt to do this.

Now - with the motor driver - it's specs indicate that it "...can supply up to almost 3 A continuous current per channel...and it can tolerate peak currents up to 5 A per channel for a few seconds". Ok - well, we don't know what kind of current the motors your using are pulling. Maybe you should measure that. You can do it with a digital multimeter put into current measuring mode and inserted in series with the motor; hook it directly to the battery, run it on your surface, and measure the current draw.

I'd be willing to bet that your motor is exceeding (or coming close) to it's 2.5 amp rating:

http://www.pololu.com/catalog/product/1213/specs

Now note something about the above specs - see the number "4" next to that amperage rating? Look down at the bottom - note what it says for note "4":

"4 Can be improved by addition of heat sink or forced air flow."

Hmm - sound familiar? You might want to try adding a heatsink and a fan to those ICs - glue it on with some Artic Silver or similar heatsink glue, then add a small fan to move some air and get the heat out. Note, though, that if you find that those motors are pulling more than 2.5 amps, the driver is probably going into thermal shutdown mode, which is would explain what you're seeing.

So do your measurements, and figure out where the problem lies. You may need to purchase a more capable motor driver.
Title: Re: Autonomous Robot, motor driver
Post by: afremont on Feb 23, 2013, 09:47 am


I just cant grasp how a fan over my motor driver will help my robot drive? will a fan really cool off the warming of current that much?
and I'm just trying to learn and ask here dont fight me lol


Yes, it can really make that kind of difference and so can heatsinks.  Cooling is not optional and starts with simply moving the air.

I have a linear 25A power supply that I've had for many years now.  It ran so hot just idling that you'd get second degree burns if you touched the output transistor cases.  I put a tiny computer fan inside and now the whole thing stays at almost room temperature.  A huge difference.
Title: Re: Autonomous Robot, motor driver
Post by: ravenx99 on Feb 23, 2013, 06:50 pm
I built a RepRap 3D printer using Pololu stepper drivers with heat-sinks.  Even with the heat-sink, the motors would draw enough current to overheat the driver chips, causing them to go into fail-safe mode... they stopped operating until they'd cooled down.  While this was only a second or two at a time, this caused the motors to randomly skip steps, which is a real problem with 3D printing.  The heat-sinks, on top of chips barely 1/4" square, got nearly hot enough to burn my finger.

A tiny CPU fan over the controller board solved that problem.  So yes...  a fan can quite literally make your robot's motors run more smoothly.
Title: Re: Autonomous Robot, motor driver
Post by: husein06 on Feb 24, 2013, 07:01 am
Now - with the motor driver - it's specs indicate that it "...can supply up to almost 3 A continuous current per channel...and it can tolerate peak currents up to 5 A per channel for a few seconds". Ok - well, we don't know what kind of current the motors your using are pulling. Maybe you should measure that. You can do it with a digital multimeter put into current measuring mode and inserted in series with the motor; hook it directly to the battery, run it on your surface, and measure the current draw.

I'd be willing to bet that your motor is exceeding (or coming close) to it's 2.5 amp .
So do your measurements, and figure out where the problem lies. You may need to purchase a more capable motor driver.
[/quote]

So, I did some calculations.. Long story short.. The motors are drawing 3.7 amps when at stall mode..
And basically the motor driver is not giving enough for the motors to get started.. When I gave the robot a small push, it drove fine.. So, in conclusion I'm getting a motor driver that would allow such continuous current to be achieved ..