PDA

View Full Version : Is there a time limit between servo position changes?



Ragtop
08-31-2011, 06:17 PM
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.

Mike Green
08-31-2011, 06:43 PM
All R/C servos are designed for a 20ms interval between control pulses. Your delay should be: waitcnt(clkfreq/50 + cnt)

W9GFO
08-31-2011, 06:44 PM
The standard frequency for servo pulses is 50Hz, or clkfreq/50.

What happens when volume is below 30 or above 70?

Ragtop
08-31-2011, 07:19 PM
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.

Publison
08-31-2011, 07:35 PM
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