Shop OBEX P1 Docs P2 Docs Learn Events
How to drive a parallax continuous rotation servo with a raspberry pi — Parallax Forums

How to drive a parallax continuous rotation servo with a raspberry pi

luisnaranjo733luisnaranjo733 Posts: 1
edited 2013-05-13 00:51 in General Discussion
I'd like to drive this servo with a raspberry pi.

The servos require 4 to 6 VDC at 15 -200 mA.

If I understood what I've read correctly, raspberry pi can safely source at max 16mA at 3.3V.

I plan on powering both the raspberry pi and the servos in parallel with a 5V battery.

I understand that two of the three wires for the servo (red and black) go to a constant power source (+ and -, respectively). So I should be ok wiring these two to my 5V battery.

The third white wire is the one intended for I/O, and according to the specs, that one takes 3.3V min, and about 6.2V max, with 5V being typical voltage.
I think that PWM (the control system for the servo) varies the voltage.

I'm pretty sure I can't safely power the servos from the pi, or control the signal wire with PWM directly from the pi.

How would I do this? I've thought about using a transistor that draws current directly from the 5V battery, but I have no idea how to pick the right one or how to use it.

Thanks!

Comments

  • FranklinFranklin Posts: 4,747
    edited 2013-05-12 19:02
    Take a look at the way the Parallax Propeller does it as that is also a 3.3v chip. I don't think you will have a problem driving the signal line from the pi but you need to understand what it is you need to send.
  • ercoerco Posts: 20,256
    edited 2013-05-12 19:28
    Welcome, luis! Back to servo basics. This is a Parallax forum, but we still don't want you to blow up your RasPi right away :) . Yes, your 5V supply should be fine if it can deliver high current. Servos want a separate 4.8-6 VDC high-current supply since some servos can pull over an amp (yes, over 1000 mA) at startup or under load. You'll want to ask your question on a RasPi forum to learn how to generate the 1-2 ms pulse stream to control servos.

    http://www.societyofrobots.com/actuators_servos.shtml
  • Heater.Heater. Posts: 21,230
    edited 2013-05-13 00:45
    luisnaranjo733

    First of all. Don't think about driving the servo PWM signal by bit-banging on a GPIO pin on the Pi. At least not if you are using Linux on it as you probably are. It's too slow. And anyway Linux is a multiuser multi tasking OS with no real-time guarantees so your PWM can be interrupted and stalled all the time. I would not even want to do it if you set up real-time scheduling in Linux.

    A quick solution is use something like this serve driver for the Pi: http://adafruit.com/products/815

    If you only have one servo then a Pi has a PWM output you can use as shown here http://learn.adafruit.com/adafruits-raspberry-pi-lesson-8-using-a-servo-motor/overview

    Of course the correct answer:) is to use a Propeller chip to drive your servos PWM signals. Then command those server positions via a serial or other link from Prop to Pi.
    You can drive 28 servos from the Propeller using ready made software found in the Propeller Object Exchange (OBEX)
  • Heater.Heater. Posts: 21,230
    edited 2013-05-13 00:51
    Having said all that, this guy http://www.raspberrypi.org/phpBB3/viewtopic.php?f=37&t=15011 is driving up to 8 servos from the Pi GPIO pins.
    To do it he had to write a Linux kernel module.
    I wonder how much of the Pi's performance gets used up running that. Might have to give it a go myself...
Sign In or Register to comment.