Current servo position

Hi!

I require your help regarding a problem I’m encountering.

I want to find the current position of a servo:

Analog servos, SSC-32U, Raspberry PI:

Python:

Thank you so much in advance for your help!

Can you clarify if you mean the servo’s position when holding or while in motion? If you have a normal RC servo without analog feedback, then the servo’s actual position (which is obtained via the internal potentiometer) cannot be “read” by other electronics. Some RC servos include a fourth wire to allow this however. If you want to query the pulse being sent to the servo, the SSC-32U allows you to query the movement status as well as the pulse width of any of the servo pins:

SSC-32U manual, page 33:

Although found in the SSC-32U manual, the code from the SSC-32 guide is the same:
http://www.lynxmotion.com/images/html/build136.htm#qmovest
http://www.lynxmotion.com/images/html/build136.htm#qpwidth

This was written a while ago, but seems to be missing a bit of detail, which is likely that the servo being queried needs to be identified, for example:

#5QP might return 150, which represents 1500us.

We don’t have any specific Python code for this, but the command is simply sent via serial (you need to set a baud rate which matches the baud rate set on the SSC-32U) and your code needs to read the reply.

1 Like

So I am running a program with two arms (5 servos each arm). When I restart the program, I want to ensure the servos stay in the last place when energized. Also I am using a gamepad to input which servo to move and to what position. Example:

if control_code == ‘ABS_HAT0X’ and int(controller_input[‘ABS_HAT0X’]) == -1:
sp.write(("#17" + “P1800” + “S200” + “\r”).encode())

which moves servo #17 to position 1800 and will hold that position; now if I select another servo to move (with the gamepad) and then come back to move #17 to another position, I need to be able to start that action at the last known position of #17 in order for the servo not to move until I command it to another position. Does that make better sense? So the issue is how to keep track of the last commanded position of any servo to begin the next action.

It seems to be related to your code as opposed to the communication protocol or functionality of the SSC-32U. Your software will need to be reading and recording all positions (overwriting the last one perhaps) and storing it somewhere. When you start the program, it needs to read these positions. Not really a programmer to be able to provide the code to go about that, so perhaps other members of the community might be able to offer some insights.

ok thanks, will standby for others to comment