Shop OBEX P1 Docs P2 Docs Learn Events
Using SERIN and SEROUT to control a PicoPic SCC — Parallax Forums

Using SERIN and SEROUT to control a PicoPic SCC

burgessburgess Posts: 3
edited 2005-03-28 17:58 in BASIC Stamp
I am trying to use the serout command to control a PicoPic servo
controller card. The variables MSB and LSB in the code below
represent most significant and least significant bytes for the
controller. I want to convert a pulse width command such as 1500ms
into this format. For example, 1500 in hex is "05DC" so I need to go
from the 1500 to MSB = $05 and LSB = $DC. The debug commands in the
code below indicate that the correct value is being assigned to the
MSB variable, but the serout command is not working because the servo
controller card gives an error signal. Thanks for any help or advice
you can give.


' {$STAMP BS2}
' {$PBASIC 2.5}
Address CON 120 'our address as a constant
OutPin CON 8 'Pin 8 used as transmit pin
Baud CON 84 'Baud rate set at inverted 9600/8/N/1
PortNum VAR Byte ' the servo to move
Speed CON 0 'speed of rotation
serial CON 16

MSB VAR Word
LSB VAR Word
LSB = $DC

SERIN serial,84,[noparse][[/noparse]DEC MSB]
DEBUG CLS, "MSBbefore = ", DEC MSB
PAUSE 1000
PortNum = 15
SEROUT OutPin, Baud, [noparse][[/noparse]Address, PortNum, IHEX MSB, LSB, Speed] 'Send
the servo command for 1 ms
DEBUG CLS, "MSBafter = ", IHEX MSB

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-03-28 17:58
    See this discussion: http://forums.parallax.com/showthread.php?p=521372

    The problem you're creating in your code is that you're sending text (when using formatters like DEC and HEX) instead of sending bytes (do not use formatters so the values will go out as numbers).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
Sign In or Register to comment.