Chris Feng
Chris Feng

Reputation: 199

Why the servo keep shaking when I used PWM to control it on raspberry pi

I am trying use GPIO to simulate pwm output to control a servo on my raspi B board. But the servo keep shaking and can't stop in a expect postion. Any one know the reason about that?


The source code may like below:

import RPi.GPIO as GPIO

GPIO.setmode(GPIO.BCM)
GPIO.setup(12, GPIO.OUT)
vertical = GPIO.PWM(12, 50)
vertical.start(14)
time.sleep(0.2)
vertical.ChangeDutyCycle(0)

Upvotes: 0

Views: 1056

Answers (1)

Chris Feng
Chris Feng

Reputation: 199

I add a PCA9685 which is an I²C-bus controlled 16-channel PWM output between Raspi and servo. The servo can works correctly. My guess is that Linux run on Raspi is not RTOS. So PWM output may not stable.

Upvotes: 2

Related Questions