Braking a DC motor

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
sdo
 
Posts: 25
Joined: Thu Apr 10, 2014 11:31 pm

Braking a DC motor

Post by sdo »

Is it possible to brake a DC motor with the Adafruit Motor Shield? I
gather the drivers in the original shield weren't up to it (according
to http://playground.arduino.cc/Main/AdafruitMotorShield). But what
about the v2 version of the shield?

Thanks

User avatar
adafruit_support_bill
 
Posts: 88086
Joined: Sat Feb 07, 2009 10:11 am

Re: Braking a DC motor

Post by adafruit_support_bill »

There is no support for it built into the library. Braking has not been tested with the V2 shield.

roboteach
 
Posts: 5
Joined: Thu Jun 05, 2014 6:32 pm

Re: Braking a DC motor

Post by roboteach »

To brake a DC motor, just set the speed of both motors to zero:

lftMtr->setSpeed(0); rtMtr->setSpeed(0);

roboteach
 
Posts: 5
Joined: Thu Jun 05, 2014 6:32 pm

Re: Braking a DC motor

Post by roboteach »

Forgot to mention that this works for the Adafruit Motor Shield version 2

User avatar
adafruit_support_bill
 
Posts: 88086
Joined: Sat Feb 07, 2009 10:11 am

Re: Braking a DC motor

Post by adafruit_support_bill »

To brake a DC motor, just set the speed of both motors to zero:
Setting the speed to zero will cut power to the motor. That is not the same thing as braking. To brake a DC motor, you effectively create a short circuit through the H-bridge between the motor terminals. This can result in a large spike of current flowing through the bridge. If the bridge is not designed to handle braking in this way, damage can result.

roboteach
 
Posts: 5
Joined: Thu Jun 05, 2014 6:32 pm

Re: Braking a DC motor

Post by roboteach »

It might not technically be the same as braking, but setting the motors to zero speed makes my robot comes to a dead stop instead of coasting (which occurs if you use the RELEASE command–see code fragment below):

lftMtr->setSpeed(150); rtMtr->setSpeed(150);
lftMtr->run(FORWARD); rtMtr->run(FORWARD);
delay(3000);
lftMtr->setSpeed(0); rtMtr->setSpeed(0); // brake
// lftMtr->run(RELEASE); rtMtr->run(RELEASE); // coast

User avatar
Solar_Granulation
 
Posts: 1
Joined: Thu Jan 01, 2015 6:06 am

Re: Braking a DC motor

Post by Solar_Granulation »

I realise it's been a few months but I think that this is with contributing. I hope nobody objects.

In the datasheet of the motor driver IC used in this shield the mode that roboteach describes is listed as "Short brake". It's probably not intended to prevent the motor from turning, due to the current spike mentioned by Bill, but can arrest motion under a light load. It's how speed is controlled.

In the same section of the datasheet a sperate Short brake mode is listed. Inputs 1 and 2 are set High, the PWM (speed) input may have any value. As Bill mentioned this has not been implemented in the shield library, but it would be a small hack to add it. A constant is defined, alongside FORWARD, BACKWARD, and RELEASE, for BRAKE mode but is not used in the run() switch block. If you decide to try it just add the following case statement.

Code: Select all

  // I have not tested this code. It is provided as is, USE AT YOUR OWN RISK.
  case BRAKE:
    MC->setPWM(PWMpin, 0); // Probably not necessary but a good precaution
    MC->setPin(IN1pin, HIGH);
    MC->setPin(IN2pin, HIGH);
    break;
Setting PWM to 0 is a precaution, probably unnecessary based on this from the datasheet:
To prevent penetrating current, dead time … is provided in switching to each mode in the IC.
This has the same result as roboteach's example, but allows greater flexibility in your sketch. With this method you can set speed while maintaining electrical braking.

DO NOT rely on electrical braking to resist outside force, be it momentum, gravity or a push. To provide breaking against these conditions you need a physical mechanism.

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Braking a DC motor

Post by adafruit_support_mike »

Good information.. thanks for posting! ;-)

User avatar
project_zero
 
Posts: 86
Joined: Tue Sep 10, 2013 11:22 pm

Re: Braking a DC motor

Post by project_zero »

My apologies for bringing an old topic, but it seemed to make more sense than starting a new one.

Has anybody tested Solar Granulation's code for electrical braking? I need my motors to move to a certain orientation and then brake - as I need them to not be backdriven.

User avatar
adafruit_support_bill
 
Posts: 88086
Joined: Sat Feb 07, 2009 10:11 am

Re: Braking a DC motor

Post by adafruit_support_bill »

I have not tested it. But electrical braking alone is not enough to stop a DC motor from being back-driven. The nature of electrical braking dictates that the braking force will be proportional to the speed. So, when the speed goes to zero - there is no more braking. If you have a fairly high-reduction gear-motor, there might be enough drivetrain friction to hold things. But you might be better off considering something like a stepper motor.
https://learn.adafruit.com/adafruit-mot ... -of-motors

User avatar
project_zero
 
Posts: 86
Joined: Tue Sep 10, 2013 11:22 pm

Re: Braking a DC motor

Post by project_zero »

Ah, I see. I was thinking that electrical braking could help hold a motor in place, but if I recall, dynamic braking is when current generated by the back EMF causes current to flow in a loop that resists the rotation of the motor. No speed, no back EMF, no braking. This is what you meant by electrical braking being proportional to the speed, yes?

I may consider stepper motors. Its true that moving them to a certain position and holding that position is much more suited to steppers, but I've found they're usually pretty weak and it's easy to overcome their coil-powered "hold" position by hand. Maybe I've been using the wrong steppers?

User avatar
adafruit_support_bill
 
Posts: 88086
Joined: Sat Feb 07, 2009 10:11 am

Re: Braking a DC motor

Post by adafruit_support_bill »

That is correct. We are talking about a form of dynamic braking. The only other type of 'electrical' braking you could apply on a DC motor would be some electrically actuated friction brake.

Stepper holding torque (at least with simple drivers such as the shield) is generally stronger than the turning torque - unless you explicitly reduce the holding current. You can increase both by using a geared stepper.

User avatar
project_zero
 
Posts: 86
Joined: Tue Sep 10, 2013 11:22 pm

Re: Braking a DC motor

Post by project_zero »

Thanks Bill. Another question about the motorshield -

I misplaced the power jumper. I want to run both the arduino and the robot from a DC power jack. Is it enough for me to connect those two pins together, say with a f/f jumper wire? I'm assuming that's what the power jumper does.

User avatar
adafruit_support_bill
 
Posts: 88086
Joined: Sat Feb 07, 2009 10:11 am

Re: Braking a DC motor

Post by adafruit_support_bill »

Yes. A F/F jumper wire will work.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino Shields from Adafruit”