Author Topic: Hardware PWM delay between updating servo  (Read 2779 times)

0 Members and 1 Guest are viewing this topic.

Offline airman00Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,650
  • Helpful? 21
  • narobo.com
    • Narobo.com - Mechatronics and related
Hardware PWM delay between updating servo
« on: February 21, 2009, 05:05:48 PM »
I am using hardware PWM on the axon
I want to control a servo and want to know how much delay,if any, I need before setting a new value for PWM

Lets say I'm doing this

while(1) {
    pwmSetE4(i);
    delay_us(???); // delay
     i = i+10;
}
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

Offline pomprocker

  • Supreme Robot
  • *****
  • Posts: 1,431
  • Helpful? 16
  • Sorry miss, I was giving myself an oil-job.
    • Nerdcore - Programming, Electronics, Mechanics
Re: Hardware PWM delay between updating servo
« Reply #1 on: February 21, 2009, 08:33:06 PM »
Did you read the tutorial?

http://www.societyofrobots.com/actuators_servos.shtml

Look in the tutorial and on your servos datasheet (whichever servo it is since you didnt' tell us :P ) regarding dead band width

Offline airman00Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,650
  • Helpful? 21
  • narobo.com
    • Narobo.com - Mechatronics and related
Re: Hardware PWM delay between updating servo
« Reply #2 on: February 21, 2009, 09:06:11 PM »
OK I understand the deadband now, thanks pomprocker

Would I be damaging my servo if I had no delay , and what delay would I need so as to not damage it.

I am using the HS-322BB servo.
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,165
  • Helpful? 111
    • Webbot stuff
Re: Hardware PWM delay between updating servo
« Reply #3 on: February 21, 2009, 10:23:09 PM »
Hold on a sec - maybe I'm having a senior moment.
Your using PWM - so lets say that your PWM is set up with a 50Hz, ie 20ms, frequency.  Then your pwmSetE4 is just changing the duty cycle - so if the value you use is in the 1ms to 2ms (approx) band then it is still waiting for 20ms before the next pulse begins.
You can update the PWM duty cycle as quickly as you like so delay_us could be delay_us(0) or that line could even be deleted.
Or am I missing something obvious.
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline pomprocker

  • Supreme Robot
  • *****
  • Posts: 1,431
  • Helpful? 16
  • Sorry miss, I was giving myself an oil-job.
    • Nerdcore - Programming, Electronics, Mechanics
Re: Hardware PWM delay between updating servo
« Reply #4 on: February 22, 2009, 01:22:51 AM »
Digital servos  have  a tighter deadband width allowing their PWM to be updated more frequently, which in turn provides more torque. if there wasn't a dead band, the servo would "hunt" around at a given point and the motor would never stop trying to correct any small differences


I'm attaching a screen shot from the book "Robot Builder's Bonanza" 3rd Edition. I hope this is not illegal.



Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,165
  • Helpful? 111
    • Webbot stuff
Re: Hardware PWM delay between updating servo
« Reply #5 on: February 22, 2009, 01:43:14 PM »
Thanks for the attachment

The deadband just dictates how the servo reacts to the 'error' between where it 'is' and where it 'should be'. If its smaller than the deadband then it doesn't react - and that stops it buzzing back and fwds.

But since the PWM has a fixed 20ms frequency you can still change the duty cycle as often as you want - because the PWM will only use the new figure you have set once per 20ms. You can keep changing the value as often as you want it will still give a 50Hz signal - the deadband of the servo just effects how the servo reacts if the new position is similar to its current physical position.

If the servo has a large deadband then incrementing the required position (as per Airmans code) may just mean that the first few changes are deemed insignificant but then the next one is significant and so the servo moves to the new position. If the deadband is smaller then the servo will consider every change as significant. But the changes are still only coming in to the servo every 20ms.

So I'm still not sure what the connection is, if any, between how often you change the PWM duty cycle and the deadband of the servo. Surely the deadband just dictates how accurate the servo is.

Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: Hardware PWM delay between updating servo
« Reply #6 on: February 25, 2009, 10:31:26 AM »
That buzzing mentioned in Robot Builder's Bonanza is the motor reversing direction at a high frequency - cause large power surges. Power surges result in over-heating and wasted energy.

That being said, if you are using an analog servo, it takes about 3 pulses for it to respond properly. If you mess up just one pulse, nothing noticeable will happen. A digital servo will probably see a single inappropriate power spike.

 


Get Your Ad Here

data_list