I have an MG 996R Servo from DM DIY More hooked up to physical pin 18 of my raspberry pi 4b running python 2.7.16 with GCC 8.3.0 on Linux2. I am powering the servo with an external 5V supply capable of 2250mA, which should be plenty for the one servo. The supplie's and Raspberrie's grounds are connected.
Is someone familiar with these particular servos, as I just cannot get them to spin counterclockwise.
When I shoot a dutycyle of e.g. 10% of the 20ms PWM Period, that is suggested by the manufacturer, into the servo, it moves clockwise to the corresponding position if its initial position was all the way to the left. However, from that point on, it can only move further that way. In other words: It can always go further clockwise then the position it currently has, but never back counterclockwise.
This is the code I am using.
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BOARD)
GPIO.setup(18, GPIO.OUT)
from time import sleep
pwm = GPIO.PWM(18, 50)
pwm.start(10) #Puts the servo a little further clockwise than all the way to the left (but only if I carefully turned it all the way to the left manually before executing)
sleep(2)
pwm.ChangeDutyCycle(6) # Puts the Servo at about the middle.
sleep(2)
pwm.ChangeDutyCycle(10) # Should put it back to the left, but does absolutely nothing*
sleep(2)
pwm.stop()
GPIO.cleanup()
- If I turn the servo back manually however, I feel that the servo is stalling at the position corresponding to the cycle of 10%, however it doesn't go there itself. The same happens for any duty cycle that corresponds to a position to the left of the current position.
I tried 4 different new MG996Rs from that brand, and this behavior replicates for all of them.
Could this be the servos, or am I doing something wrong?
This code works perfectly with SG90 9G Micro Servos (with code adjusted to those smaller servos).
Thanks to anyone who can point out my knowledge gap or suggest a fix.
I know those servos are virtually garbage, but I thought I might try to search for the error on my side before blaming it on them.
sudo pigpiod
thenpigs s 24 1000
,pigs s 24 1500
,pigs s 24 2000
– joan Oct 25 '21 at 08:49