BS2 Missing Pulse Detector?
fiveslo
Posts: 40
I have a project that I'm working on which has a device·that outputs three signals, each of which are the same, basically a square wave of something like approximately 4.5-5Hz when the output is high and/or active.....When output 1 is high I'd like to move a servo to the left most position, when output 2 is high move servo to center position and when output 3 is high move the servo to the rightmost position... signals 1 and 2· as well as 2 and 3 may be present at the same time.... I've tried to sample and move the servo to the designated positions using if IN1=1 then PULSOUT 15,500, IF IN2=1 THEN PULSOUT 15,750, & IF IN3=1 THEN PULSOUT15,1000....· but the servo actually jitters.... a feature which is definitely not acceptable.... yes I've added the PAUSE 20 after the PULSOUT commands....· I'm under the impression that the BS2 is responding to the actual pulse input meaning that as the pulsed input is varying at 4.5-5Hz, the Stamp reads it as a zero and/or one and responds accordingly... yes/no????· I've decided to try to use a missing pulse detector... watch the incoming pulses and when the pulse requirement is reached output a high and when its not present output a low.... however is it possible to use the Stamp to discern when a specific frequency of my magnitude·is reached??? In other words when the 4.5-5Hz signal is present go to a loop where the servo will move to the designated position and when· the signal is not present go to another loop or part of the program where it moves the servo to another position etc.... The servo is will be moving a hydraulic valve lever and the jitter part I've got to eliminate....· Anyone have any ideas and/or code to help.... Rob
Comments
I suspect that you will need to separate the functions of detecting the signals and the function of controlling the servo. You could have something like:
Pulse var word
Pulse = 750
Loop:
PULSOUT 15,Pulse
GOSUB Check
PAUSE 20
GOTO Loop
Check:
if IN1 = 1 then Pulse = 500
if IN2 = 1 then Pulse = 750
if IN3 = 1 then Pulse = 1000
return
This prioritizes the inputs with 3 taking precedent over 2 and 1, and 2 taking precedent over 1. If that's not what you want, you'll have to modify this. One problem with this is that it can change suddenly and, if the inputs change quickly or are noisy, the servo could become jittery. Another option would be to have another variable called Goal that is changed by Check. Each time through the Loop, the routine could add or subtract 10 from Pulse based on whether Pulse is greater than Goal or the opposite. The result would be to move closer to the Goal, but over a half to one second time interval.
R/C servos must be updated on a regular basis so that they can firmly maintain their position. You must send each servo a 'PULSOUT' of 1 to 2 mSec, repeated every 20 to 50 mSecs. Failing to do that on a regular basis can cause the jitter you seem to be experiencing.
Either your program must do this (if it is capable of doing so) or you will need to use an off-board servo controller which will maintain a number of servos on a set-it and forget-it basis. Such devices can be found here:
Control 16 servos - Parallax PSC: http://www.parallax.com/detail.asp?product_id=28023
Control 8 servos - PAK VIII: http://www.awce.com/pak8.htm
Control 5 servos - Ferretronics FT-639: http://www.elabinc.com/
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<!--StartFragment -->