Become a leader in the IoT community!
Join our community of embedded and IoT practitioners to contribute experience, learn new skills and collaborate with other developers with complementary skillsets.
Join our community of embedded and IoT practitioners to contribute experience, learn new skills and collaborate with other developers with complementary skillsets.
Hey guys, am developing a robotic arm control system using a BeagleBone Black running Embedded Linux using `AM335x ARM Cortex-A8`. The system needs to control the position of a servo motor(SG90) using `PWM`. I have ensured that the `Adafruit_BBIO` library is correctly installed and imported in my script, adjusted the duty cycle range if the servo motor does not reach the full range of motion (0-180 degrees).
But am getting the errorΒ
`warning: SG90 Servo motor jitter detected`
Β Β Β
Β Β Β import Adafruit_BBIO.PWM as PWM
Β Β Β import time
Β Β Β # Define PWM pin and servo parameters
Β Β Β PWM_PIN = "P9_14"
Β Β Β PWM_FREQUENCY = 50Β # Servo motors typically use a 50Hz frequency
Β Β Β # Initialize PWM
Β Β Β PWM.start(PWM_PIN, 7.5, PWM_FREQUENCY)Β # Start with 7.5% duty cycle (neutral position)
Β Β Β def set_servo_angle(angle):
Β Β Β Β Β Β Β # Convert angle to duty cycle
Β Β Β Β Β Β Β duty_cycle = (0.05 * angle) / 18 + 2.5
Β Β Β Β Β Β Β PWM.set_duty_cycle(PWM_PIN, duty_cycle)
Β Β Β try:
Β Β Β Β Β Β Β while True:
Β Β Β Β Β Β Β Β Β Β Β for angle in range(0, 181, 10):Β # Sweep from 0 to 180 degrees
Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β set_servo_angle(angle)
Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β print(f"Servo Angle: {angle} degrees")
Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β time.sleep(0.5)
Β Β Β Β Β Β Β Β Β Β Β for angle in range(180, -1, -10):Β # Sweep back from 180 to 0 degrees
Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β set_servo_angle(angle)
Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β print(f"Servo Angle: {angle} degrees")
Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β time.sleep(0.5)
Β Β Β except KeyboardInterrupt:
Β Β Β Β Β Β Β print("nExiting...")
Β Β Β finally:
Β Β Β Β Β Β Β PWM.stop(PWM_PIN)
Β Β Β Β Β Β Β PWM.cleanup()
Β Β Β
Really wanna dig into this albeit I don’t have elinux exp
I am also tuning the same motor
@superbike_z This are the materials I studied along with BeagleBone Black documentation for this project
https://www.electronics-tutorials.ws/blog/servo-motor.html
https://www.learnrobotics.org/blog/pwm-basics/
https://www.packtpub.com/product/advanced-robotics-projects-with-beaglebone-black/9781788627907
You can learn bash scripting on YouTube from
To get an extensive level of Linux experience
I am doing it on stm32 not on embedded linux
Ooh okay, I also came across these materials during my research but didn’t bother to go through them, they might be helpful to you
https://controllerstech.com/stm32-pwm-tutorial/
https://stm32-base.org/guides/servo-control
https://www.st.com/content/st_com/en/applications/industrial/motor-control-and-drives.html
Oh lovely thank you, yes currently paused because I haven’t wired up my power supply π¦
I should add I am not stuck with the same issue you are with, jitter could be caused by imprecise pwm
What do you suggest I do to fix this
Hey @bosslady0299 might be a bad motor do you have another sample to test?
There is a few things
either your timing is off
or your motor is bad
Lets explore a bit are you using an external power supply?
Yes, A 4xAA alkaline battery
If I remember correctly the beegleone Black as a very poor software
Sometimes the PWM does not work at all
CONTRIBUTE TO THIS THREAD