Maintaining Servo position
I am controlling a RC Servo by inputing the RC receiver signal into a BOE with a BS2. The BOE then outputs pulses to the servo. I have everything·working OK. But now I want the Servo to maintain its rotation position if I let the RC signal go back to center (750 pulses). Then if I move the RC transmitter so that the Servo reverses pass center, then it would go in·that direction. Likewise if I let the RC signal go back to center the Servo would maintain it position. What I am controlling is a Robotic arm. Attached is a pBasic program, but it does not do things right. Can anyone
help.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
······ Joe Fishback
-Robots are my friends-
help.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
······ Joe Fishback
-Robots are my friends-


Comments
' {$STAMP BS2} ' {$PBASIC 2.5} 'File name "C:\Robots\Moving Servo Position 'RC INPUT TO RECEIVER AND IF DIRECTION OR ROTATION POSITION IS CHANGED, SERVO WILL MOVE. ' IF UNCHANGED SERVO RETAINS POSITION. '------Variables------- reps VAR Word RCpulse VAR Word ServoPulseLast VAR Word ServoPulse VAR Word ServoPulseLast = 750 ServoPulse = 750 tmprcpulse var word DO tmprcpulse=rcpulse 'save last reading PULSIN 8,1, RCPulse 'RC receiver pulse is measured by pin 8 and stored as variable "RCPulse" DEBUG DEC RCPulse, CR DEBUG DEC ServoPulseLast,CR IF servopulselast>rcpulse THEN servopulslast=servopulslast-1 'move twards RCpulse IF servopulselast<rcpulse THEN servopulslast=servopulslast+1 'move twards RC pulse PULSOUT 15,servopulslast 'every 20 mS will hold position if servopulslast doesn't change PAUSE 20 LOOPMaby you are trying to do this: (psudo code)
do
Read RCsignal
If iRCsignal>lastposition then rotate twards rc signal last=last+1
if rcsignal <750 then rotate twards rcsignal last=last-1
hold servo position at lastposition
loop