Shop OBEX P1 Docs P2 Docs Learn Events
Servo Controller (Serial) — Parallax Forums

Servo Controller (Serial)

JimTheProgrammerJimTheProgrammer Posts: 44
edited 2007-12-23 20:27 in BASIC Stamp
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

Comments

  • FranklinFranklin Posts: 4,747
    edited 2007-12-23 18:29
    What type of data do you get when you run your program? It would help diagnose your problem.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • JimTheProgrammerJimTheProgrammer Posts: 44
    edited 2007-12-23 18:56
    The output looks like this and all the time I am flipping the gear switch on my transmittor and never see a state change in the output.

    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
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2007-12-23 19:27
    Hi Jim, page 6 of the PSC manual at this link

    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.
  • JimTheProgrammerJimTheProgrammer Posts: 44
    edited 2007-12-23 19:40
    So your saying that even though I am trying to read in the value from a receiver, not control a servo, I needto send a serout command to the receiver?
    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
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2007-12-23 20:27
    Jim, my observations were on the code you said you were working with, you are transmitting a position command from a Stamp (SEROUT Sdat, Baud+$8000,[noparse][[/noparse]"!SC", ch, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]) to the servo controller without assigning a valid value to pw.

    If you are not controlling a servo then this command is not needed.

    Sorry can't help with the Futaba reciever.

    Jeff T.
Sign In or Register to comment.