So I got this motor, and I need to be able to control its angle with a raspberry pi; its okay if there is a little inaccuracy, but I don't want it to lose precision over time.

Any tips on how to periodically resynchronize it (it is pulling a string in a motion sort of like this.)

Any general advice on motor synchronization would be helpful.

  • 1
    That looks like a 5V device so you'll need something in the middle.
    – goldilocks
    Commented Feb 8, 2016 at 17:47
  • @goldilocks I know (I bought a MOSFET.) Commented Feb 8, 2016 at 19:48
  • Dunno if this might be useful: adafruit.com/products/820 -> If that doesn't make sense, it probably isn't.
    – goldilocks
    Commented Feb 8, 2016 at 19:54
  • @goldilocks it does. Will a MOSFET transistor work? Commented Feb 8, 2016 at 20:15
  • I do not know, but I'd think so -- transistors should respond on a far, far finer time scale than motors. Adafruit has a tutorial about using a darlington array with stepper motors, and this seems like much the same idea except you need more current. But I'm not an electrician -- you might want to ask on Electrical Engineering or just try it, I can't see how anything is going to get damaged (did I mention not being an electrician?).
    – goldilocks
    Commented Feb 8, 2016 at 20:24

2 Answers 2


You will need to add some sort of feedback. A rotary encoder like this could be attached to the other end of the shaft. You would then need to have the Raspberry Pi continuously monitor that input to know the position.

If you need continuous rotation and angular precision I you probably should look at a stepper motor instead of a DC motor or servo. With a stepper you can control the rotation in precise increments (steps).


It's a servo. It goes to the commanded angle. There is need to resynchronise (unless you strip the gears).

You command an angle by sending electrical pulses 50 times per second. If the pulse is 1.5 ms long it goes to the centre, if the pulse is shorter it goes to an angle more counterclockwise, if the pulse is longer it goes to an angle more clockwise.

The amount of turn in degrees from most counterclockwise to most clockwise and range of allowable pulse widths varies from servo to servo. You will need to calibrate your software against the servo.

  • 2
    Not a servo, its a motor in a servo body. Commented Feb 8, 2016 at 17:34
  • 2
    If you look at the link provided, the text states that it is not a servo. It looks like a servo but with the feedback circuit removed.
    – lwr20
    Commented Feb 8, 2016 at 17:37
  • 2
    @PyRulez My mistake. However in that case why don't you by a servo?
    – joan
    Commented Feb 8, 2016 at 18:02
  • 1
    Because that one is $4 more from the same source? >_<
    – goldilocks
    Commented Feb 8, 2016 at 18:59
  • 1
    Looking at the reciprocating motion machine from from the OP, you do probably need something with continuous rotation. I'd think you could figure out exactly how many pulses of a certain width will turn it how far -- but then I don't know if it will be possible to control it that precisely with the pi.
    – goldilocks
    Commented Feb 8, 2016 at 19:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.