Servo Controller (Serial)
JimTheProgrammer
Posts: 44
I am trying to use my servo controller with serout and serin commands to retrieve the signals from a futaba receiver.
So far I have been unsuccessful. Has anyone done this successfully? I have seen alot of examples using the pulsin command but I want to retrieve the pulse via my servo control instead.·
I run servo extention from a channel on the receiver to ch0 on the serial controller. My serila controller is connected to pin 15 on the BOE.
Any code snippets would be helpful.
Here is the one I have been working with:
' {$STAMP BS2}
'{$PBASIC 2.5}
·ch VAR Byte
pw VAR Word
ra VAR Byte
x VAR Byte
Buff VAR Byte(3)
Sdat CON 15
baud CON 396
Init:
ra = 15: ch = 0
DO
SEROUT Sdat, Baud+$8000,[noparse][[/noparse]"!SC", ch, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
SEROUT Sdat, Baud+$8000, [noparse][[/noparse]"!SCRSP", ch, CR]
SERIN· Sdat, Baud, 1000, Init,[noparse][[/noparse]STR Buff\3]
DEBUG "Servo ", DEC pw, "··· :" ,DEC buff(0), " ", HEX2 buff(1), " :", HEX2 buff(2), CR
LOOP
WRservo:
'SEROUT Sdat, Baud+$8000,[noparse][[/noparse]"!SC", ch, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
FOR x = 0 TO 4
'PAUSE 1000
SEROUT Sdat, Baud+$8000, [noparse][[/noparse]"!SCRSP", ch, CR]
SERIN Sdat, Baud, 1000, Init,[noparse][[/noparse]STR Buff\3]
DEBUG "Servo ", DEC buff(0), " ", HEX2 buff(1), " :", HEX2 buff(2), CR
NEXT
RETURN
So far I have been unsuccessful. Has anyone done this successfully? I have seen alot of examples using the pulsin command but I want to retrieve the pulse via my servo control instead.·
I run servo extention from a channel on the receiver to ch0 on the serial controller. My serila controller is connected to pin 15 on the BOE.
Any code snippets would be helpful.
Here is the one I have been working with:
' {$STAMP BS2}
'{$PBASIC 2.5}
·ch VAR Byte
pw VAR Word
ra VAR Byte
x VAR Byte
Buff VAR Byte(3)
Sdat CON 15
baud CON 396
Init:
ra = 15: ch = 0
DO
SEROUT Sdat, Baud+$8000,[noparse][[/noparse]"!SC", ch, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
SEROUT Sdat, Baud+$8000, [noparse][[/noparse]"!SCRSP", ch, CR]
SERIN· Sdat, Baud, 1000, Init,[noparse][[/noparse]STR Buff\3]
DEBUG "Servo ", DEC pw, "··· :" ,DEC buff(0), " ", HEX2 buff(1), " :", HEX2 buff(2), CR
LOOP
WRservo:
'SEROUT Sdat, Baud+$8000,[noparse][[/noparse]"!SC", ch, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
FOR x = 0 TO 4
'PAUSE 1000
SEROUT Sdat, Baud+$8000, [noparse][[/noparse]"!SCRSP", ch, CR]
SERIN Sdat, Baud, 1000, Init,[noparse][[/noparse]STR Buff\3]
DEBUG "Servo ", DEC buff(0), " ", HEX2 buff(1), " :", HEX2 buff(2), CR
NEXT
RETURN
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
Servo 0 :0 00 :00
Servo 0 :0 02 :E9
Servo 0 :0 02 [noparse]:D[/noparse]0
Servo 0 :0 02 :B7
Servo 0 :0 02 :9E
Servo 0 :0 02 :85
Servo 0 :0 02 :6C
Servo 0 :0 02 :53
Servo 0 :0 02 :3A
Servo 0 :0 02 :21
Servo 0 :0 02 :08
Servo 0 :0 01 :EF
Servo 0 :0 01 [noparse]:D[/noparse]6
Servo 0 :0 01 :BD
Servo 0 :0 01 :A4
Servo 0 :0 01 :8B
Servo 0 :0 01 :72
Servo 0 :0 01 :59
Servo 0 :0 01 :40
Servo 0 :0 01 :27
Servo 0 :0 01 :0E
Servo 0 :0 00 :FA
Servo 0 :0 00 :FA
Servo 0 :0 00 :FA
http://www.parallax.com/Portals/0/Downloads/docs/prod/motors/ServoControllerManualRevBv2_4.pdf
has the code you want.
A couple of observations, you will never exit the DO - LOOP unless the SERIN times out. The sub routine WRservo is never called and most importantly you never give a valid position value for the servo to move to. The word variable pw should be assigned a value between 250 and 1250 before sending the position command.
Jeff T.
Do I need to use a different preamble when trying to read back from the Futaba Receiver, it s FPR-R127DF FM.
I tried the code on page 6 and still did not get a observable response. Just a bunch of random results.
I can get this to work if I use a pulsein command but I want to read in the pulsewidth from the servo controller do to the lack of pins on the BOE.
Thanks for your assistance so far! [noparse]:)[/noparse]
Jim
If you are not controlling a servo then this command is not needed.
Sorry can't help with the Futaba reciever.
Jeff T.