0

I have a Miuzei MG90S 9G Micro Servo connected to a Raspberry Pi 4.

I am powering the servo through the Pi's 5V pin.

The Pi itself is powered by the CanaKit 3.5A USB-C Raspberry Pi 4 Power Supply, intermediated with the CanaKit USB-C PiSwitch.

Here's how I configure the servo in python:

from gpiozero import AngularServo
from gpiozero.pins.pigpio import PiGPIOFactory

min_pulse_width = 0.0005  #  0.5ms
max_pulse_width = 0.0025  #  2.5ms
factory = PiGPIOFactory() #  reduces jitter

servo = AngularServo(
    17, 
    min_pulse_width=min_pulse_width, 
    max_pulse_width=max_pulse_width, 
    min_angle=0, 
    max_angle=180,
    pin_factory=factory
)

def set_servo_angle(angle): 
    print(f"[servo] set angle {angle}")
    # the servo is physically positioned 
    # in such a way, that the angle 0 looks 
    # like the angle 180.
    servo.angle = 180 - angle 

# set_servo_angle runs perhaps once or twice every 30 minutes.

This works great, but I notice that after a few hours of operation, the servo tends to "freeze" up. If I nudge the servo, it "slots" into the right place and continues to work.

From what I've read online, people say it could be a power supply problem. But I am not sure why this would be the case (the specs for the servo seem to align with what the Pi can do).

Is there a way I can debug this further? Apologies if this a noob question, I am primarily a software engineer playing with servos for fun.

5
  • yes, follow up on the could be a power supply problem
    – jsotola
    Commented Feb 3 at 20:00
  • @jsotola what would be a way for me to confirm this? Is there some way I could "print" the voltage the servo is receiving? Commented Feb 3 at 20:10
  • 1
    You probably want to check the current with an ammeter, but the easiest way to get one is in a multimeter, which also includes a volt meter (unfortunately, they can't be used at the same time). A cheap one is ~$25 at the nearest chain hardware or big box store, or whereever online. Beware never to use the probes directly on the Pi breakout, it is way too easy to accidentally short something. Instead connect them to leads connected to your circuit.
    – goldilocks
    Commented Feb 3 at 20:17
  • @StepanParunashvili use a separate power supply for the servo, four AA cells in series would work... monitor the voltage
    – jsotola
    Commented Feb 3 at 20:26
  • These small servos draw little current so this is unlikely to be the cause (some people suggest power supply problem to many question even without evidence). I have old SG90 which often get stuck until nudged.
    – Milliways
    Commented Feb 4 at 5:20

1 Answer 1

1

In your case the Pi provides the servo power and the servo pulses.

Check that the servo pulses are still being sent around the time you notice the problem. To do this you could run piscope or monitor.py.

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.