Page 1 of 1

Recommendations for servo motors library

Posted: Tue Jul 02, 2013 12:13 pm
by nuclearwessels
I am looking to control a servo motor using a RPi. Right now, I've come across a few libraries (ServoBlaster, WiringPi, etc), but I cannot tell if they are for servo motors or a toy servo. (I want to build up to create a robotic arm or something like that, but right now I'm just starting at the basics.) I know it needs to do PWM, and I want to work in C or C++ (even though most stuff for RPi is in python). Any help? Thanks!

Re: Recommendations for servo motors library

Posted: Tue Jul 02, 2013 1:03 pm
by joan
How are your servo motors driven?

Re: Recommendations for servo motors library

Posted: Tue Jul 02, 2013 1:24 pm
by nuclearwessels
So, I'm trying to do servo control of a direct brush-type motor, either using direct analog output or PWM analog output.

Re: Recommendations for servo motors library

Posted: Tue Jul 02, 2013 1:26 pm
by joan
The Pi doesn't have any analogue outputs. Have you got a link to the specs of your servos?

Re: Recommendations for servo motors library

Posted: Tue Jul 02, 2013 2:12 pm
by nuclearwessels
For analog: http://www.adafruit.com/products/856
Motor discussed: http://datasheets.globalspec.com/ds/235 ... CAED52DC3C

I'm using other, smaller motors as well, but the one listed is the one I'm interested in the long-term.

Re: Recommendations for servo motors library

Posted: Tue Jul 02, 2013 2:26 pm
by joan
That looks like an ordinary DC motor, not a servo motor.

You would need a motor driver board to drive that from the Pi. The specs don't seem onerous, 1 amp, 24 V is well within the capabilities of an inexpensive motor driver board. You could use the Pi to control the speed of the motor by supplying a PWM signal to the motor driver board.

From C I'd suggest my own pigpio library. http://abyz.co.uk/rpi/pigpio/

Re: Recommendations for servo motors library

Posted: Tue Jul 02, 2013 3:00 pm
by nuclearwessels
It is an ordinary DC brush motor. I'm trying to do this: http://en.wikipedia.org/wiki/Servomechanism using the first picture, not the second. I just know that a lot of "servo libraries" (2nd picture) will not work well for a DC motor (1st picture) doing servo positioning. I'm really new to this and just want to make sure I'm doing the right thing so I don't "let the smoke out" of anything. :)

Re: Recommendations for servo motors library

Posted: Tue Jul 02, 2013 3:18 pm
by PiGraham
nuclearwessels wrote:It is an ordinary DC brush motor. I'm trying to do this: http://en.wikipedia.org/wiki/Servomechanism using the first picture, not the second. I just know that a lot of "servo libraries" (2nd picture) will not work well for a DC motor (1st picture) doing servo positioning. I'm really new to this and just want to make sure I'm doing the right thing so I don't "let the smoke out" of anything. :)
Do you have a specific servomotor in mind?
You would need a drive stage, have you found one?
What encoder signals will you have?
What response do you need from the control loop for what sort of loads?
Could things get nasty if the control went wrong? (then don't use a RasPi)

In principle the Pi could implement a servo control loop via PWM and encoder feedback, but it won't be suitable for all servomotor applications. Give us some clues.

Some people hack RC servos and connect the control to a beefier output stage and link the feedback pot so they can drive bigger motors as if they were RC servos.

Re: Recommendations for servo motors library

Posted: Wed Jul 03, 2013 1:39 pm
by nuclearwessels
I am a college engineering student working on this for a project. We have some resources of our own, but it's more of a time constraint issue as much as anything. I am not an electrical engineer nor do I have a huge amount of experience with programming, so I'm mainly focused on finding a C/C++ library that I can use and adapt to our needs. I have found a ton of stuff for python but am having issues with finding C stuff. If we cannot find something in C, I will try to create my own I guess (using similar GPIO libraries in C and python), but I would much rather not reinvent the wheel if possible.
PiGraham wrote: Do you have a specific servomotor in mind?
These will be various DC brush type motors with gear heads for low grade servo positioning, but generally 24VDC in the 3 - 5A range.
PiGraham wrote: You would need a drive stage, have you found one?
We will make or buy a drive stage for it. The readily available servoamps in the $200 range are out of our price bracket for this project.
PiGraham wrote: What encoder signals will you have?
Initially it will be a pot less than 330 degrees rotation is all that is needed); later versions may use low grade/cheaper resolvers if we can manage the conversion hardware in a price package that is compatible with the RPi prices (not easy). We are not using optical encoders.
PiGraham wrote: What response do you need from the control loop for what sort of loads?
Mechanical system bandwidth will be in the 1 - 10 hz range so the control loop rate will be in the 10 - 100 hz range depending on the application. We might like 200 hz max but don't want to push our luck on what the RPi can do. Load will vary greatly depending on application. For now we will be looking at relatively simple servo positioning using PID control code that we will write later.
PiGraham wrote: Could things get nasty if the control went wrong? (then don't use a RasPi)
The purpose of this work is specifically to look at what we can do with the RPi (what are the practical limits?) so that's not really a concern at this point. This is more of an experimental exercise.
PiGraham wrote:In principle the Pi could implement a servo control loop via PWM and encoder feedback, but it won't be suitable for all servomotor applications. Give us some clues.
We do want to look at using the RPi to drive a motor (via output stage) with the PWM and with analog pot feedback. The application is to look at limits of what we can do with the RPi and not so much a specific application, but we are headed towards using the RPi for light duty teleoperated and robotic manipulator control on a scale where RC servos are not practical. The key missing element is/are the interface library/libraries necessary to drive the low level. We're assuming that Python won't be sufficient and that C/C++ will be required. We'll take care of the servo positioning code.
PiGraham wrote: Some people hack RC servos and connect the control to a beefier output stage and link the feedback pot so they can drive bigger motors as if they were RC servos.
We're not interested in using RC servos at this time, but we do think that this is an interesting approach and would like to look at it in the future. However it is not in the current scope of our project.

Re: Recommendations for servo motors library

Posted: Wed Jul 03, 2013 2:13 pm
by mikerr
So you're essentially making your own servo, a servo is generally

1. Motor and gearbox
2. Motor driver electronics
3. Positioning feedback (potentiometer/encoder)
4. An MCU to position and hold based on incoming PWM.

(all in one nice box)

AIUI you want to basically create step 4 on the Pi ?

A "servo library" won't help you since that's meant to talk to the servo MCU (step 4) just by sending a position pulse.
On top of that, do you want to have the Pi receive incoming PWM - to emulate a servo to an external device ?