Shop OBEX P1 Docs P2 Docs Learn Events
parallax servo controller, code? — Parallax Forums

parallax servo controller, code?

magimagi Posts: 35
edited 2006-03-23 17:26 in General Discussion
Hi

I have a Mini SSC and to control it I send hexa decimal code "FF0240"
FF - is activationcode for Mini SSC
02 -is number two of eight servos that will react
40 - is the angel the servo is to move to.

Can somebody tell be what kind of code I must send to a parallax servo controller #28023
in hexa dec code?

or in byte?

how do i for instandce translate the first "!SC" and last "CR" to byte or hexa

and what about "pw.lowbyte" and "pw.highbyte"

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Please start United Religions , UR , for gods sake.. [noparse]:)[/noparse]
«1

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-03-05 22:28
    Why do you need to translate the values?· Why can't you just send them as they are in the documentation?· The CR in HEX is $0D.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-03-05 22:29
    There is demonstration code in the PSC documentation -- have you not tried it? You do not need to use hex mode (hex is just a convenient numbering system; the PSC deals with bytes and those are always transmitted as 1s and 0s).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • magimagi Posts: 35
    edited 2006-03-05 23:19
    Can somebody tell me what it would look like?

    Or dont you know?

    would it look like this:

    [noparse][[/noparse]"!SC", 11, 7, 1250, 1250, 0D] = [noparse][[/noparse]?? 0B 07 4E2 4E2 0D]

    So I dont need to send CR or $0D ?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Please start United Religions , UR , for gods sake.. [noparse]:)[/noparse]

    Post Edited (magi) : 3/5/2006 11:22:26 PM GMT
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-03-05 23:25
    Again, there is ample demo code in the documentation that can be downloaded from our web site; start there. And you do not need to use hex notation unless that's the most comfortable for you. You'll see in the documentation that the demo code mixes ASCII text for ease of use with ASCII characters and even defined constants where things are simpler.· Hence a typical output to the PSC looks like this:
    · SEROUT Sio, PscBaud, [noparse][[/noparse]"!SC", ch, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]

    Note that with serial communications everything is byte-oriented, so the position value (in pw) is sent as two bytes -- PBASIC variable modifiers make this easy.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • magimagi Posts: 35
    edited 2006-03-05 23:33
    I have all the documents about it from the PSC site, but I cant see what the !SC is in hex or byte any were.

    Or maybe someone can give me a link to the document where the info is?

    I need the documentation about the code in byte or hex to control the PSC.

    Can somebody tell me what the code(SEROUT Sio, PscBaud, [noparse][[/noparse]"!SC", ch, ra, pw.LOWBYTE, pw.HIGHBYTE, CR])
    would look like in hex?


    So I dont need to send CR (or $0D) ???


    Peace and Love

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Please start United Religions , UR , for gods sake.. [noparse]:)[/noparse]

    Post Edited (magi) : 3/5/2006 11:36:01 PM GMT
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-03-05 23:36
    Why do you want to convert to hex? -- this is not necessary.· The PSC documentation can be downloaded from...

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

    As you'll see, the demo code is quite straightforward, and there's no need to make it harder than it has to be.· The code in that documentation will work as it's presented.· Remember that numeric systems (binary, decimal, hex) are for us humans; internally, the values are all 1s and 0s and looks the same, no matter how we choose to express them.

    · "A" = %01000001
    · 65· = %01000001
    · $41 = %01000001

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax

    Post Edited (Jon Williams (Parallax)) : 3/5/2006 11:40:51 PM GMT
  • magimagi Posts: 35
    edited 2006-03-05 23:43
    Thanks, I have that document. [noparse]:)[/noparse]

    I am coding in machine code and if it is possible to get the information of a

    control string in hex or byte I would be happy.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Please start United Religions , UR , for gods sake.. [noparse]:)[/noparse]
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-03-05 23:44
    Will your assembler not allow you to use ASCII characters and decimal values? This is very odd indeed. The only thing you'll have to do is keep track of the msb and lsb of the position value yourself. Most of the values in the PSC string are variables, aside from the header and the terminating CR (which you can code as $0D).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • magimagi Posts: 35
    edited 2006-03-06 00:20
    So I dont need to send CR (or $0D) in the end?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Please start United Religions , UR , for gods sake.. [noparse]:)[/noparse]
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-03-06 00:27
    Yes, you need to terminate the string with CR -- this is predefined in PBASIC, but you'll need to use whatever your assembler supports.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • magimagi Posts: 35
    edited 2006-03-06 00:55
    [noparse][[/noparse]"!SC", ch, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]

    I still would like to know what "!SC", pw.LOWBYTE and pw.HIGHBYTE is in hex.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Please start United Religions , UR , for gods sake.. [noparse]:)[/noparse]
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-03-06 01:00
    The string "!SC" is composed of the three hex·bytes: 0x21, 0x53, 0x43

    The variable pw is just that, a variable, so you will designate it as such in your source code.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • magimagi Posts: 35
    edited 2006-03-06 01:02
    Ok, now I think I got it.

    Thanks.

    Regards Magi

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Please start United Religions , UR , for gods sake.. [noparse]:)[/noparse]
  • magimagi Posts: 35
    edited 2006-03-06 01:44
    From this link
    http://www.cs.mun.ca/~michael/c/ascii-table.html

    "!" stand for "0x01" and not "0x21"

    What is correct? [noparse]:)[/noparse]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Please start United Religions , UR , for gods sake.. [noparse]:)[/noparse]
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-03-06 02:48
    Please check your references more carefully... I've highlighted the section of that chart that shows the ASCII code in hex for "!" is in fact·0x21 -- you seem to be reading from the wrong column.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax

    Post Edited (Jon Williams (Parallax)) : 3/6/2006 2:56:28 AM GMT
    706 x 833 - 916K
  • magimagi Posts: 35
    edited 2006-03-06 09:35
    Sorry.

    Thanks... [noparse]:)[/noparse]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Please start United Religions , UR , for gods sake.. [noparse]:)[/noparse]
  • magimagi Posts: 35
    edited 2006-03-06 23:31
    Hi again.

    I can send this code to a Mini SSC to move a servo:
    Hexa decimal code "FF0240"
    FF - is activationcode for Mini SSC
    02 -is number two of eight servos that will react
    40 - is the angel the servo is to move to.

    To control the Mini SSC it needs three bytes.
    Byte 1 = sync marker
    Byte 2 = servo nr
    Byte 3 = position

    Can somebody tell be what kind of code I must send to a parallax servo controller #28023
    in hexa dec code or byte to move a servo?

    I try to send this:
    21534300071901900d

    215343 is !SC
    00 is servo nr
    07 is ramp speed
    190 is hex for pos 400 lowbite
    190 is hex for pos 400 highbite
    0d is CR

    I guess its the lowbite, highbite that is missing in hex or something..

    Does anybody know why it doesnt react?

    Can somebody give me the code in bits or bytes so I can transform it to hex code?

    What does basic stamp send in bytes or hex when it set a servo?

    Regards Magi

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Please start United Religions , UR , for gods sake.. [noparse]:)[/noparse]

    Post Edited (magi) : 3/7/2006 12:26:27 AM GMT
  • PARPAR Posts: 285
    edited 2006-03-07 00:41
    magi said...
    I am coding in machine code and if it is possible to get the information of a
    control string in hex or byte I would be happy.
    Can you post your "machine code" program, or at least indicate in what programming environment (i.e., product, IDE, language...) you are writing/running this machine code (which downloads the data to the PSC)?

    PAR
    ·
  • magimagi Posts: 35
    edited 2006-03-07 01:08
    Its in CGI (Common Gateway Interface).

    A send command looks like:

    /com/serial.cgi?write=FF0240

    for the Mini SSC

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Please start United Religions , UR , for gods sake.. [noparse]:)[/noparse]

    Post Edited (magi) : 3/7/2006 1:14:13 AM GMT
  • PARPAR Posts: 285
    edited 2006-03-07 02:30
    magi said...
    ...I try to send this:
    21534300071901900d

    215343 is !SC
    00 is servo nr
    07 is ramp speed
    190 is hex for pos 400 lowbite
    190 is hex for pos 400 highbite
    0d is CR
    I'm not at all sure what is required by the PSC. But, for the (decimal) value for POSITION=400,
    if it is indeed supposed to be sent to the PSC from a PBasic "VAR WORD" as the Parallax documentation states, in two parts, low.byte and hi.byte order, then I get
    90 for the low.byte and 01 for the hi.byte· (not 190 for each as you stated above).

    (Your serial.cgi?write command requires hex-coded· (x= 0-->F)·byte-sized (xx)·data, I believe, as you stated).

    Jon also mentioned the matter of lsb / msb (endian?) which might be an issue in your particular coding environement --dunno?

    I don't recall you mentioning how you get the comm port data rate coordinated between your program and the board?

    And, have you tried to get the board to tell you what version it is (that command sends all ascii char string data, so you should be able to represent the byte hex encoding of it straight-forward).

    PAR
  • magimagi Posts: 35
    edited 2006-03-07 02:48
    Thanks PAR.

    I sent

    /com/serial.cgi?write=215343000790010d

    but i got no reaction. [noparse]:([/noparse]

    I dont understand what lsb / msb (Least Significant Bit, Most Significant Bit) have to do with this.
    Can somebody explain?

    I sent this to set baudrate as high as possible.

    /com/serial.cgi?write=215343534252010d

    The Mini SSC is set to recieve 9600 and it just works.
    I have not set the speed of the transmitter. It just works betwen transmitter and Mini SSC. Transmitter can send up to 115 kbps.

    Anybody got any idea?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Please start United Religions , UR , for gods sake.. [noparse]:)[/noparse]

    Post Edited (magi) : 3/7/2006 3:39:15 AM GMT
  • PARPAR Posts: 285
    edited 2006-03-07 07:50
    magi said...
    ...
    I sent this to set baudrate as high as possible.

    /com/serial.cgi?write=215343534252010d

    ...I have not set the speed of the transmitter.· Transmitter can send up to 115 kbps. ...

    Anybody got any idea?
    So, what bitrate is "53425201" supposed to represent? I.e., what is "x" (below) equal to?

    The PSC documentation states:
    ···· Syntax: “!SCSBR” x $0D
    ····· where x is either 0 for 2400, or 1 for 38K4
    So, it seems you need to send a suitable representation of "0" or "1" (when using your serial.cgi?..., I think you have to send the hex byte representation of 0 or 1· -- 00 or 01)
    But, initially, you need to talk to the PSC at 2400bps; the documentation states:
    ····· The PSC does not support Auto-Baud. When your PSC starts up, the default
    ····· baudrate is 2400.
    Once communication is established, then you can change to the higher bps rate (38400).
    However, even before all this, note that the documentation states that communcations signal levels used with the PSC·are (swinging between) 0 and 5 volts (ttl levels). How are you connecting your PSC to your programming device?
    PAR

  • magimagi Posts: 35
    edited 2006-03-07 10:54
    "53425201"
    "53" is "S"
    "42" is "B"
    "52" is "R"
    "01" is "1" for 38K4

    I have connected it just like the Mini SSC that works. [noparse]:)[/noparse]
    www.seetron.com/pdf/ssc2_mnl.pdf
    Page 4. Top picture.
    "Figure 2. Wiring DB9 serial connector to a modular cable for use with SSC."

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Please start United Religions , UR , for gods sake.. [noparse]:)[/noparse]

    Post Edited (magi) : 3/7/2006 11:29:33 AM GMT
  • Shawn LoweShawn Lowe Posts: 635
    edited 2006-03-07 14:37
    Magi-

    Lets take this slow. Are you sending the SBR (set baud rate) command at 2400 baud? In hex, to change the Baud rate you would send:

    21 (!),53 (S),43 (C),53 (S),42 (B),52 (R),1 (to set the Servo controller to 38K4 rate),0D (CR)

    but this must be sent at 2400 baud. The controller would then send back at 38k4 baud:

    42 (B), 52 (R), 01 (indicating baud rate of 38k4)

    If this doesn't happen, I would try just asking the Servo Controller for it's version number to verify you are communicating with the Controller.

    Hope this helps.smile.gif

    P.S. Looking at the PDF for the SSC, it looks like you will also have to hook a +5V to the Servo controller, as the documentation indicates (Parallax Servo Controller documentation, page 2 "A three-conductor cable connects ground, +5VDC, and serial I/O line....)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Shawn Lowe


    Remember - No matter where you go
    There you are.
  • magimagi Posts: 35
    edited 2006-03-07 15:51
    Hi Shawn Lowe.

    When I send
    21 (!),53 (S),43 (C),53 (S),42 (B),52 (R),1 (to set the Servo controller to 38K4 rate),0D (CR)
    21534353425210d
    I get an error "#Error#Bad char in dataout# "
    but with "01" instead of "1" I dont get an error, but no reaction.
    21 (!),53 (S),43 (C),53 (S),42 (B),52 (R),01 (to set the Servo controller to 38K4 rate),0D (CR) [noparse]:)[/noparse]
    215343534252010d

    I have 5+ to both Mini SSC and PSC

    Still no reaction. [noparse]:([/noparse]

    Is this right code to set a servo?
    215343000790010d for sure.
    21 (!),53 (S),43 (C),00 (Servo nr 00),07 (Ramp rate 7),90 (LowBite of hex pos 190),01 (HighBite of hex pos 190),0D (CR)

    Can somebody at Parallax confirm?

    When I turn the PSC on the servo goes to midle position as it is supposed to.
    So it can control a servo.

    Maybe best to get some Mini SSC instead if nobody have an idea.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Please start United Religions , UR , for gods sake.. [noparse]:)[/noparse]

    Post Edited (magi) : 3/7/2006 4:30:18 PM GMT
  • Shawn LoweShawn Lowe Posts: 635
    edited 2006-03-07 17:06
    Magi-
    If you are sure your power connections are right, then the code looks good. Do you have a Basic Stamp you can test the PSC with? If so, try the Servo controller with commands from the Basic Stamp. If not, I'm not sure what your next step should be.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Shawn Lowe


    Remember - No matter where you go
    There you are.
  • PARPAR Posts: 285
    edited 2006-03-07 23:26
    magi said...
    Hi Shawn Lowe.

    When I send
    21 (!),53 (S),43 (C),53 (S),42 (B),52 (R),1 (to set the Servo controller to 38K4 rate),0D (CR)
    21534353425210d
    I get an error "#Error#Bad char in dataout# "
    but with "01" instead of "1" I dont get an error, but no reaction.

    ...

    I have 5+ to both Mini SSC and PSC
    By sending only one character, you are sending 4 bits ("bad char" in your output stream). You need to send 8 bits (a byte of hex, which for 1 is hex "01" or "0000 0001" bits).

    Once you send the correct "01", then you get no reaction probably because your PSC is not receiving what it needs, either in electrical signalling and/or in logical data?

    Earlier I responded,
    "However, even before all this, note that the documentation states that communcations signal levels used with the PSC·are (swinging between) 0 and 5 volts (ttl levels). How are you connecting your PSC to your programming device?"

    You have not indicated yet how your communications cable is connected to the PSC. The wiring diagram you cited from the Mini SSC document, to connect between a PC comm port and the Mini SSC suggests that the Mini SSC "understands" RS-232 level voltage signalling (which swings widely + and - ). The PSC's signal communications responds to swings only between 0 and +5 volts.

    So, again, what signal source (not power source)·is _your_ PSC connected to?

    The PSC is not a Mini SSC, and so following the Mini SSC documentation·for how to connect the PSC to a PC (or other non BS2 device) is just not going to help. And, the PSC documentation doesn't tell *how*· to build the electrical circuitry to connect it to non-BS2 signalling sources.

    PAR
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-03-08 00:35
    PAR said...


    The PSC is not a Mini SSC, and so following the Mini SSC documentation·for how to connect the PSC to a PC (or other non BS2 device) is just not going to help. And, the PSC documentation doesn't tell *how*· to build the electrical circuitry to connect it to non-BS2 signalling sources.

    PAR
    While not in our documentation, we have made that circuit available for those [noparse][[/noparse]advanced] customers who want to build it.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Ryan ClarkeRyan Clarke Posts: 738
    edited 2006-03-08 00:48
    You would also need to be more specific on the "non-BS2 signalling sources"- if the device is simply using TTL Serial communication it is fairly straight forward. If it is RS232 level, it is simply a matter of level shifting to TTL-

    Ryan

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Ryan Clarke
    Parallax Tech Support

    RClarke@Parallax.com
  • magimagi Posts: 35
    edited 2006-03-08 01:13
    I have now changed the transmitter to send 2400 baud, 8 data bits, 2 stop bits and no parity bit.
    But it didnt help eighter.

    But I dont need to send SBR.

    I have a IF232
    http://www.equinox-tech.com/test/details.asp?ID=102
    and I will try to use it between rs232 and PSC.

    Maybe it fix the problem. [noparse]:)[/noparse]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Please start United Religions , UR , for gods sake.. [noparse]:)[/noparse]

    Post Edited (magi) : 3/8/2006 1:52:10 AM GMT
Sign In or Register to comment.