pietari-poika
Posts: 6
Joined: Wed Feb 08, 2012 1:01 pm

Controlling servos with Pi/python, I2C? (mechanical hand)

Mon Mar 18, 2013 4:02 pm

Hi! I need some help with this project I'm planning. I have already found out about some stuff, so I may be answering to myself here... It would be great though if someone would comment on the project, if there's anything in particular I need focus my attention to.

So, I've decided to entertain and educate myself with a fun electronics/mechanics/coding project. I have a 256MB model B Raspberry Pi and a basic understandment of DC electronics and python. My goal is to make a servo-controlled mechanical hand (and possibly a full arm later). The servos would be controlled via the Raspberry Pi, perhaps with an Xbox 360 controller. With my current hand-plan, I would need at least 7 (maybe 8) servos to make five flexing/extending fingers and some wrist movement (flexion, extension, pronation and supination). The arm-plans would require at least 4 more servos (elbow flexion/extension; shoulder flexion/extension, abduction/adduction and medial/lateral rotation). The Pi has only one PWM pin, so something else is needed as well.

I did some googling and found out about this nifty I2C interface thingy that should allow the Pi to control a servo controller, such as this: http://www.robot-electronics.co.uk/htm/sd21tech.htm
There's also a code example, in C though: http://www.robot-electronics.co.uk/htm/ ... amples.htm
Even though I don't know C, controlling the servo looks quite simple and I2C should be accessible with python as well, as far as I know.

Is that it? I still need to make the Xbox 360 controller to work with python but it should be possible with Pygame.

Some questions:

-Is the I2C the way to go or are there perhaps better alternatives?
-What about the servo controller board, are there better (or cheaper) boards than the SD21? (It costs about 30€ here in Finland.)
-Do you know any good tutorials concerning the technical stuff I need to overcome during this project? (mainly I2C with python/raspi)

User avatar
joan
Posts: 14935
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Controlling servos with Pi/python, I2C? (mechanical hand

Mon Mar 18, 2013 4:50 pm

The Pi can be programmed to provide servo/PWM pulses on any of the user gpio (using the DMA hardware).

One of several possibilities. https://www.youtube.com/watch?v=2vq0Q4dD6KE
Last edited by joan on Fri Dec 20, 2013 9:34 am, edited 1 time in total.

pietari-poika
Posts: 6
Joined: Wed Feb 08, 2012 1:01 pm

Re: Controlling servos with Pi/python, I2C? (mechanical hand

Tue Mar 19, 2013 3:48 pm

joan wrote:The Pi can be programmed to provide servo/PWM pulses on any of the user gpio (using the DMA hardware).

One of several possibilities. http://www.youtube.com/watch?v=-sfzIygVQVM
Okay... So this ( http://www.raspberrypi.org/phpBB3/viewt ... 2&p=306397 ) is probably what you're talking about?

Are there any significant improvements or drawbacks using a Pi directly versus via an external controller? Of course using the Pi directly saves some money. In the forum post that I linked it says that 1 µs resolution is possible so the accuracy should be the same. The coding part looks very simple, which is great. The servos probably need an external power supply. I've heard that you shouldn't use the Pi's gpio power too much. So I'll just plug the servos' PWM wires to the Raspberry Pi's GPIOs and then the grounds + lines (or whatever they're called) to an external power supply?

So, if the amount of servos (15?) is the only drawback versus the SD21 controller, I think I'm going to try controlling the servos directly from the Pi. 15 servos should be enough and I can always buy a controller board later if I need one.

Thank you for answering. :)

ThomasH
Posts: 5
Joined: Wed Mar 06, 2013 9:06 pm

Re: Controlling servos with Pi/python, I2C? (mechanical hand

Wed Mar 20, 2013 9:29 pm

I used a Stepper Motor instead of a servo
Much cheaper at 2.50 EUR which can be Controlled via I2C

http://www.forum-raspberrypi.de/Thread- ... tor-am-i2c
The Post there is in German but the Code in Python with English comments.

In Addition a found an interesting IC
http://www.hoeser-medien.de/?s=Servo&submit=Search
I have ordernd One but Not yes tested.

Thomas

Return to “Automation, sensing and robotics”