Author Topic: DC motor torque control with PWM?  (Read 9620 times)

0 Members and 1 Guest are viewing this topic.

Offline mstachoTopic starter

  • Supreme Robot
  • *****
  • Posts: 363
  • Helpful? 10
DC motor torque control with PWM?
« on: December 30, 2010, 08:54:29 AM »
Not sure if this is the right forum to post this in, but I have a project that I'd love to simplify by just using Pulse Width Modulation (PWM)...

I'm making a robot hand.  Once the fingers come into contact with the object, I need to be able to supply a given amount of force at the finger tip -- so I need to be able to control the amount of torque coming from the motors.  I'm going to have a force sensor mounted to the fingertip, so I can do all the control stuff "easily".

I'm just wondering: if I'm using PWM, is it possible to create a signal that acts as though I were controlling the current to the motor directly?  Or do I have to make some kind of circuit that controls the current into the motor directly?  If the latter  is the case, can anyone point me in the direction of what  that circuit is called?   I can't seem to find much when I search for "digital current control", but I could be looking in the wrong place.

I do realize that using PWM still means I have to actually  come up with the control laws and software to achieve the desired torque control, but I'm way better as software than I am at hardware, so I'd like to just hook the robot up to an axon or something with built-in PWM and do some code...

Thanks,

MIKE
Current project: tactile sensing systems for multifingered robot hands

Offline mstachoTopic starter

  • Supreme Robot
  • *****
  • Posts: 363
  • Helpful? 10
Re: DC motor torque control with PWM?
« Reply #1 on: December 30, 2010, 11:22:47 AM »
If anyone was wondering, after a few hours on the internet and playing around in simulink, the answer is this little circuit here:

http://controls.ame.nd.edu/microcontroller/main/node40.html

By controlling the voltage with PWM, I can effectively control the current through the motor.  This is probably going to take a lot of tuning, though, so if anyone knows of a better way, I'm all ears :-)

MIKE
Current project: tactile sensing systems for multifingered robot hands

Offline waltr

  • Supreme Robot
  • *****
  • Posts: 1,938
  • Helpful? 98
Re: DC motor torque control with PWM?
« Reply #2 on: December 30, 2010, 11:57:20 AM »
That is correct. The motor's current is really controlled by the voltage applied and can be done with PWM to an driver (H-bridge, etc).

What you will need is feed-back from the pressure sensors to the PWM duty generation. This would be very similar to a speed control feed-back where the code doesn't directly set the PWM duty but sets a desired speed. The feed-back then adjusts the PWM duty to obtain and hold that speed.
It will take some tuning to get the best response but it is very doable.

Offline mstachoTopic starter

  • Supreme Robot
  • *****
  • Posts: 363
  • Helpful? 10
Re: DC motor torque control with PWM?
« Reply #3 on: December 30, 2010, 12:20:34 PM »
So to make sure I understand it properly:

I use the output of the circuit from the webpage I posed to be the voltage input to the motor through an H-Bridge, and I spend some time working with my control design to get the correct response at the force sensor, is that right?  I'll probably have to make sure I don't go outside the voltage limits of the motor, but that's secondary to getting the force controller working properly :-P

Thanks for the reply!

MIKE
Current project: tactile sensing systems for multifingered robot hands

Offline waltr

  • Supreme Robot
  • *****
  • Posts: 1,938
  • Helpful? 98
Re: DC motor torque control with PWM?
« Reply #4 on: December 30, 2010, 02:18:39 PM »
No, don't even bother with that circuit.
Just use a PWM controlled H-bridge (you do want to move the motors in both direction, don't you?). The Pulsed voltage out of the H-bridge will become 'averaged' when applied to the motor. So the force sensor feed-back just needs to adjust the PWM duty cycle width to maintain the desire force (torque).

This is really much simpler than you are making it.
Try thinking of this:
Have a Bot on a slight incline. Start the PWM duty at 1%. This will not create enough torque to move the Bot.
Now increase the PWM duty (pulse width) until the Bot moves up the incline at a steady (constant) speed.
Now decease the angle of the incline and the Bot will speed up. To return to the previous speed the PWM duty must be decreased to adjust the torque.
If the incline is increased then the PWM duty must increase to maintain the speed.

The same is done to maintain a constant force with the fingers of the hand.

Offline mstachoTopic starter

  • Supreme Robot
  • *****
  • Posts: 363
  • Helpful? 10
Re: DC motor torque control with PWM?
« Reply #5 on: December 30, 2010, 03:08:43 PM »
Awesome, thanks.  I had a feeling it would be that simple. 

MIKE
Current project: tactile sensing systems for multifingered robot hands

Offline Snowslip

  • Beginner
  • *
  • Posts: 1
  • Helpful? 0
Re: DC motor torque control with PWM?
« Reply #6 on: December 30, 2010, 11:50:37 PM »
It is NOT a good idea to use a DC motor the way you want.
What you'll end up with is a stalled motor. Yes, you'll control the torque/current by varying the duty cycle, but you'll eventually fry either the motor or/and its driver.

Use a servo motor plus a flexible "fingers": you'll control the angle the servo turns to and the "fingers" will transmit the pressure.
A solenoid would be another solution.

Offline mstachoTopic starter

  • Supreme Robot
  • *****
  • Posts: 363
  • Helpful? 10
Re: DC motor torque control with PWM?
« Reply #7 on: December 31, 2010, 08:19:51 AM »
I'd like to avoid flexibility, though -- it's the beginnings of a PhD project, and I just need a hand to play with that doesn't cost $11K :-P  Plus, robot hands exist that seem to do what I'm planning, and I need multiple links and the ability to exactly control the force (that will take some time...). 

How do they do it?  I'm really quite curious about this -- I hadn't intended to build the hand in the first place, but when we saw how much a hand costs commercially we decided it would be better to just build something workable and move on.  Hands with rigid fingers can apply a set amount of force at the finger tips.  If they don't use PWM, then they must just use a current controller?

MIKE
Current project: tactile sensing systems for multifingered robot hands

Offline waltr

  • Supreme Robot
  • *****
  • Posts: 1,938
  • Helpful? 98
Re: DC motor torque control with PWM?
« Reply #8 on: December 31, 2010, 08:34:53 AM »
It is NOT a good idea to use a DC motor the way you want.
What you'll end up with is a stalled motor. Yes, you'll control the torque/current by varying the duty cycle, but you'll eventually fry either the motor or/and its driver.

Use a servo motor plus a flexible "fingers": you'll control the angle the servo turns to and the "fingers" will transmit the pressure.
A solenoid would be another solution.

A servo is nothing more than a PWM controlled DC motor with a gear train and position feed-back.
The motor does not fry since the duty of the PWM pulses become small and the "average" voltage and current is also small.

MIKE,
 Prototype a single motor and force sensor as a proof of concept. Then you will know the details.

Offline mstachoTopic starter

  • Supreme Robot
  • *****
  • Posts: 363
  • Helpful? 10
Re: DC motor torque control with PWM?
« Reply #9 on: January 17, 2011, 12:46:00 PM »
I Know this is an old topic, but a final update is that the prototype single motor + force sensor worked like a charm, much better than I expected it to.

For those of you wondering how to do this, here is my axon code:

Code: [Select]
void control(void)
{
int se0, set, er, PWMPct;

PWMPct = 0;
set = 50;
se0 = a2dConvert8bit(0); //reads the 0th analog input, which is where my sensor is
er = set - se0;

//Initialize the PWM timer
PWM_Init_timer2_H6(10);

//Turn the PWM timer on
PWM_timer2_On_H6();

//Set the direction port to +5V
PORT_ON(PORTH,4);


while(1) //Loop here instead of in main
{

PWMPct = PWMPct + er/10;
if(PWMPct < 0)
PWMPct = 0;
if(PWMPct > 200) //bit of a safety factor...
PWMPct = 200;

PWM_timer2_Set_H6(PWMPct);
delay_us(1000); //Necessary, or else the control law won't work (theoretically a smaller gain would fix this, but
        //Then I'd need better resolution timers
se0 = a2dConvert8bit(0);
er = set - se0;

//Now we need to output to hyperterminal...but I'd rather not do it
//every timestep :-(  I guess I could just use timers and count, but it doesn't matter for now
rprintf("Error: %d PWMPct %d ANALOG %d \n",er, PWMPct, se0);
}
[\code]
Current project: tactile sensing systems for multifingered robot hands

Offline waltr

  • Supreme Robot
  • *****
  • Posts: 1,938
  • Helpful? 98
Re: DC motor torque control with PWM?
« Reply #10 on: January 17, 2011, 01:42:02 PM »
Great. Thanks for closing the question with your results and code.

 


Get Your Ad Here