Shop OBEX P1 Docs P2 Docs Learn Events
Is there a time limit between servo position changes? — Parallax Forums

Is there a time limit between servo position changes?

RagtopRagtop Posts: 406
edited 2011-08-31 11:35 in General Discussion
Thanks to octanetripledax I am trying to move the mouth of my halloween project in relation to audio that is being processed through a ADC.
repeat while routine < 90        'servo mouth action
             routine++
             if routine == 50
               outa[barking] := 0    'give the pin a period of being on to trigger mp3 and reset to zero now
             waitcnt(clkfreq/15 + cnt) 
             volume := ADC.getval(0)
              case volume
                  30..46:   mouthposition := 158 + (43-volume) 'closed
                  43..49:   mouthposition := 155 'center
                  50..70:   mouthposition := 155 - (2*(volume-49)) 'open

I know the servo is limited to how fast it can move from position to position, but at times it just seems locked up. The longer I make waitcnt(clkfreq/15 + cnt) the better it gets, but it still seems to not move as often as mouthposition is changing.

I am assuming because the servo is reading pulses, there has to be some time period between changing the pulse widths?

I am using a JrSport ST126MG at 6v.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2011-08-31 10:43
    All R/C servos are designed for a 20ms interval between control pulses. Your delay should be: waitcnt(clkfreq/50 + cnt)
  • W9GFOW9GFO Posts: 4,010
    edited 2011-08-31 10:44
    The standard frequency for servo pulses is 50Hz, or clkfreq/50.

    What happens when volume is below 30 or above 70?
  • RagtopRagtop Posts: 406
    edited 2011-08-31 11:19
    Thank you both.

    It should keep the last valid position. The audio file I am sending it had a high of 70 and a low of 30 with ~46 when no sound is being played when I viewed the value changes in viewport.

    I could add two more case lines to cover values outside that range with a set fully closed or open value.
  • PublisonPublison Posts: 12,366
    edited 2011-08-31 11:35
    Although I would like to see this tweaked for the propeller, might I suggest a component approach that I believe I got from JonnnyMac a while ago:

    http://www.scary-terry.com/audioservo/audioservo.htm

    Works very well, and there are some upgrades and a way to edit your audio to produce better results.

    Jim
Sign In or Register to comment.