Serial Commands

Hey guys,

I’m starting to plan my hexy exploits, which involve hooking it up to a raspberry pi and implementing my own control system. To do this I’ve been going through pomoco to learn how it controls the servotor32.

Is there a formal definition of the serial protocol the servotor32 uses? It would help me so I don’t have to reverse engineer the pomoco code just to get those details as I’m not very familiar with python.

Also, do you know if the servotor32 is capable of moving 2 or more servos at the same time?

Thanks!

I haven’t seen any official docs, but I did do some reverse engineering myself, so maybe I can save you some trouble.

PoMoCo has some of the commands, but there was more to learn from the Arduino software itself. This is just from me looking at the loop function in v1.5.

All the data is sent via serial writes.

‘#’ indicates the start of server pin number. Valid servo pins are 0 through 31.
‘P’ indicates the start of the servo position number. Valid positions are 500 through 2500, 1500 is centered.
‘\r’ and ‘\n’ will commit sent servo position data.

As an example: “#6P1500\r" will center the servo plugged into pin 6.

‘V’ will print back the servotor version string on the serial stream. PoMoCo uses this to test the existing COM ports to see if they have a Servotor connected.
‘C’ will center all servos.
‘K’ will kill all servos

‘L’ … it looks like this will kill a single servo indicated by ‘#’ first. For example “#22L” would kill the servo plugged into pin 22.

I saw in PoMoCo that there was the use of ‘T’, but as far as I can tell that’s unused. It sort of looks like it’s meant to be used for setting a time for how long the command sent should run for, but now I’m just reading into it… or spoiling roboalchemist’s surprise.

I noticed ‘K’ sets all servos to position 0 while ‘L’ sets a single servo to position -1… I don’t know enough about servos to know the difference, but from what I gather they both kill the connection to the servo.

Also as a Disclaimer, the only commands that I’ve actually tried so far are the ‘#’, ‘P’ and ‘\r’, everything else I mentioned was just my analysis of the code.

I hope this helps!

Is there anything further required to get the servos to move with the ‘#[servo Number]P[Servo Position in Microseconds]’ command?

i.e. I was trying serial commands via the Arduino Serial Monitor (as described here: https://github.com/ArcBotics/Hexy/wiki/Servotor32

But I can’t seem to get any servos to move.

Other commands, e.g. C, K, D, V work fine.

And the command to kill a server, e.g. #7L work fine.

But I can’t seem to get any move servo command to do anything, i.e. like #7P500 or #15P2000 etc.

Have tried on both USB and Bluetooth with various servos and various P values…

(am guessing I’m just doing something wrong since PoMoCo does work with the hexy…)

Try terminating the command with T0

for example #7P1500T0

That’s T(zero) right?

It’s weird I did try it and its hit and miss (mostly miss) but once in a while I do feel like it’s responding when I add T0 on the end.

I’m looking at the process function in Servotor32.cpp where it switches on these #,D etc characters and I don’t see anything about “T” or “T0”?

(I guess it doesn’t really matter I just was trying the Arduino Serial Monitor thing in preparation of writing some code of my own I’m just worried if I can’t make it work this way I won’t be able to do it thru code either… but like I say PoMoCo works fine so something doesn’t add up)

Oh for Pete sake! :slight_smile:

There’s a drop down at the lower right of the Arduino Serial Monitor window where you set “No line ending”, “Newline”’, etc.

Mine had defaulted (of course wouldn’t you know) to “No line ending”.

I changed it to “Newline” and everything’s fine.

Live and learn…

Not sure about the T but I think the 0 (zero) is a string terminator.

I also send an ascii 13 after the string has been sent.

I have set up a propeller board to send the commands and it is working for me.

When you are using PoMoCo take a look at the command line screen behind it. You can see the commands that are sent.

I’m new to servo controllers but my guess is the T0 is actually anticipating a future enhancement where T is specifying the time it takes to do he move (so indirectly it’s saying how fast to move).

I can’t remember if I read that in the arcbotics stuff somewhere but I’ve started a second hexapod project using a servo controller I got off eBay and it seems to use the same command syntax (maybe it’s some kind of standard?)- you can see the “T” part of the command described on page 6 here http://www.torobot.com/down/usc_en.pdf

Thanks that’s a good tip.