Shop OBEX P1 Docs P2 Docs Learn Events
Question about servo PWM — Parallax Forums

Question about servo PWM

lardomlardom Posts: 1,659
edited 2010-12-26 10:54 in General Discussion
I can't read PASM yet so I'm looking for Spin solutions. In the servo code I've seen the pulse rate changes because the pulse width is added to the value of the PWM. For ex.; 150us + 20ms = 21.5ms. I don't see how you can keep a servo horn steady with that math. I'm not an expert but am I missing something? Does it require a 2-cog solution?

Comments

  • Mike GMike G Posts: 2,702
    edited 2010-12-26 09:58
    I believe a standard servo requires a pulse at least every 20ms to hold position. While 150us + 20ms is 21.5ms, the 150us pulse is received within or at the 20ms requirement.
  • lardomlardom Posts: 1,659
    edited 2010-12-26 10:23
    Thanks Mike G. So that means there is no drift inside 22ms. I did see a pulse rate of 10ms. That helps.
  • Mike GMike G Posts: 2,702
    edited 2010-12-26 10:38
    You're thinking frequency? The requirement is a pulse every 20ms. Not that the end of the pulse has to occur within 20ms. You could always decrease 20ms to 18ms with no affect on the result. You could also do some math to keep the pulse and idle time to a 20ms period if you like. Knowing the 20ms boundary let's you do deterministic stuff besides wasting that time on waiting. 20ms is 1,600,000 clock ticks at 80Mhz or about 400,000 PASM instructions.
  • localrogerlocalroger Posts: 3,452
    edited 2010-12-26 10:54
    Servos don't work on duty cycle; they don't care how often pulses arrive (as long as a certain minimum number do), only what the width is. So if you send a pulse every 2 milliseconds or every 20 milliseconds you will get the same result, as long as the width is the same.
Sign In or Register to comment.