Shop OBEX P1 Docs P2 Docs Learn Events
the Parallax serial servo controller — Parallax Forums

the Parallax serial servo controller

FireHopperFireHopper Posts: 180
edited 2006-09-10 00:31 in Robotics
My question is thus. I know the command for sending serial info to it from a basic stamp, what I need to know is the acutal structure of the command so I can duplicate it via a visual basic application.

I thought I had it but the SSC would not respond.. Please help?

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-08-30 22:42
    Hello,

    ·· You can find a complete command reference in the following PDF file (PSC Documentation).· I hope this helps.· Take care.

    http://www.parallax.com/dl/docs/prod/motors/ServoController.pdf

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • PARPAR Posts: 285
    edited 2006-08-31 01:48
    FireHopper said...
    ...I need to know·... the acutal structure of the command so I can duplicate it via a visual basic application.

    I thought I had it but the SSC would not respond.. Please help?

    Here's a regurgitation, somewhat modified, of key points about the commands found in the Parallax documentation. (I've omitted the information about Responses from the PSC·to commands sent to it.)

    Also, note that you may be having a problem with the communications bps rate(s), and not with your data (commands). Check the documentation (cited by Chris), esp. the "note" and code example found in the SBR command.

    Also, by "not respond", do you mean that the PSC green·LED doesn't flash either when sending it a command, or that you don't receive back a command's response, or that the servos don't move when commanded to do so?

    PAR

    Parallax ServoController Serial Command Format· (Rev. B)

    The PSC (Rev B)·supports FOUR documented commands that are sent to it via RS-232 serial protocol. The voltage swing of
    this serial line is 0-5 VDC (TTL level).

    Each serial command must be preceded with an exclamation point, “!”, and the pair of letters, “SC”.
    The “SC” portion is an identifier that pertains to the PSC. Together, the “!” and the “SC” form a preamble, “!SC”.

    After the preamble is sent, the command and associated parameters are sent.

    The eighth and final character sent is $0D, (CR), used to terminate the string.

    (If the following text lines are folded, widen your browser's window to unfold them, for easier reading.)

    ···············Command structure
    1 2 3 4 5 6 7 ·8···· 8 Bytes Sent to ServoController
    ! S C a b c d $0D··· Contents of Bytes: "a,b,c,d" vary from command to command

    ·············· ·Here are the four PSC Commands
    ! S C V E R ? $0D··· 8 Bytes of constant (char) data ($0D is the CR ascii char)
    ! S C S B R x $0D··· x = a byte-sized (binary)·variable value
    ! S C c r· p· $0D··· c,r = two byte-sized (binary) variable values,
    ·······················p = one 16-bit (binary) word-sized variable
    ! S C R S P x $0D··· x = a byte-sized (binary) variable value
    ·


    VER? Command – Identify Firmware Version Number

    Syntax: “!SCVER?” $0D

    SBR Command – Set the Baudrate (to either 2400 or 38K4 Baud)

    Syntax: “!SCSBR” x $0D·· (where x is either 0 for 2400, or 1 for 38K4)


    Position Command – Set the Position of a Servo Channel

    Syntax: “!SC” C R pw.LOWBYTE, pw.HIGHBYTE, $0D

    To control a servo, you must write a position command to the PSC. Each position command is comprised
    of a header, three parameters: C, R, and PW, and a command terminator.

    The Header: “!SC” is the header. The header signifies to all devices on the same wire that this is a
    command for a Servo Controller.

    The C parameter is a binary number 0-31 corresponding to the servo channel number. The servo
    channel number should be 0-15 with no jumper present on the PSC, or 16-31 with the jumper present.
    With a jumper present on the PSC, servo channel 0 become channel 16, channel 1 becomes 17, etc.

    The R parameter is a binary number 0 – 63 that controls the ramp function for each channel. If the ramp
    parameter is set to 0, ramping is disabled and the pulse width will be set to the P parameter sent
    immediately. Ramp values of 1-63 correspond to speeds from ¾ of a second up to 60 seconds for a full
    500uSec to 2.50 mSec excursion.

    The P parameter is a 16-bit Word that corresponds to the desired servo position. The range, (250-1250),
    corresponds to 0 to 180 degrees of servo rotation with each step equaling 2 uSec.

    The command terminator, $0D, (CR), must not be omitted.

    RSP Command – Report the Position of a Servo Channel

    Syntax: “!SCRSP” x $0D·· (where x, a byte-sized (binary) variable of value 1 - 32, is the channel number)


    The rest of the Parallax documentation needs to be consulted to complete this abbreviated description of the PSC commands.
  • FireHopperFireHopper Posts: 180
    edited 2006-09-01 03:16
    okay.. so if my dirty method still works..

    to chunk a 16 bit value into 2 8 bit value..

    p = 16 bit value

    highbyte = int(p/256)
    lowbyte = (p-(highbyte*256))

    I think.. I can't remember now..
    Cause I don;t think visual basic has a method to do that..
  • PARPAR Posts: 285
    edited 2006-09-01 06:50
    FireHopper said...
    okay.. so if my dirty method still works..

    to chunk a 16 bit value into 2 8 bit value..

    p = 16 bit value

    highbyte = int(p/256)
    lowbyte = (p-(highbyte*256))

    I think.. I can't remember now..
    Cause I don;t think visual basic has a method to do that..
    What you want to use in VB is a 16-bit·unsigned integer·variable for "p", as you note above (with "p", which _is_ two bytes long). And so you need to· "declare" such a variable for the P parameter· (a 16-bit unsigned·integer --"UShort" in VB?) or convert·some other type of appropriate variable to such a data type,·that corresponds to the desired servo position. The range of P is (should·be constrained to) between·250-1250. (Or, you can work some magic, as you and Parallax suggest,·to break up the 16-bit binary into a·upper/lower 8 bits and then send those two bytes out.)

    The data you write out to the PSC for that command will contain 8 bytes, starting with 5 one-char ("Byte" type in VB ?) bytes, 1 16-bit (2-byte) "UShort" binary type, and 1 last byte (the CR char).· (All the other 3 PSC commands take 8 byte-sized values in the output data.)

    See your VB reference manual/help for how to declare (DIM) and/or otherwise generate _your version_ ·of MS/VB's data types for 8-bit char data and 16-bit unsigned integer data. E.g., http://windowssdk.msdn.microsoft.com/en-us/library/47zceaw7.aspx·Also, this is the form in which the data need to be transferred to the PSC; the data can not be "formatted" by some "print" or other inappropriate output statement. What goes out needs to be 8 bytes constructed as described earlier.

    (16-bit unsigned integer data type is a bit "variable" in how its (un)supported in various incarnations of VB, so do pay attention to your version's idiosyncracies.)

    PAR
    ·
  • KB3JJGKB3JJG Posts: 95
    edited 2006-09-01 15:28
    Here is a link to a post in which a user wrote a .net class to interface with the stamp. Should be quite usefull in your application.
    http://forums.parallax.com/showthread.php?p=546069

    ·
  • AImanAIman Posts: 531
    edited 2006-09-10 00:31
    Just a reminder -

    If you are going between two languages VBA's PUBLIC decleration makes life considerably easier.
Sign In or Register to comment.