Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8082

Interfacing (DSI, CSI, I2C, etc.) • strange behavior of pigpio PWM output on Pi Zero 2W

$
0
0
Dear Experts.

I'm not sure if this topic is appropriate for this thread, but I post it.

I'm controlling 8 of servo motors by directly from GPIO driven by pigpio.

On RPi4, the PWM pulse is what I'm expecting like below.

Image

And when move to Pi Zero 2W, I see irregular pulse periodically like below.

Image

Is there any differences from the programming point of the view?
The code is below.

Code:

#!/usr/bin/python3###import webiopiimport pigpioimport timeimport syspi = pigpio.pi()FL_A = 16       # (SE-SERVO-HAT01-0) GPIO16FL_B = 17       # (SE-SERVO-HAT01-1) GPIO17FR_A = 22       # (SE-SERVO-HAT01-2) GPIO22FR_B = 23       # (SE-SERVO-HAT01-3) GPIO23RL_A = 24       # (SE-SERVO-HAT01-4) GPIO24RL_B = 25       # (SE-SERVO-HAT01-5) GPIO25RR_A = 26       # (SE-SERVO-HAT01-6) GPIO26RR_B = 27       # (SE-SERVO-HAT01-7) GPIO27#--------------------------------------------------------------------##--------------------------------------------------------------------def servo_ctrl(servo_no, degree):  val = 500 + ((2000 * degree) / 180)  print(servo_no, degree, val)  pi.set_servo_pulsewidth(servo_no, val)  time.sleep(0.01)#--------------------------------------------------------------------##--------------------------------------------------------------------def main(degree):  print(degree)  servo_ctrl(FL_A, degree)  servo_ctrl(FL_B, degree)  servo_ctrl(FR_A, degree)  servo_ctrl(FR_B, degree)  servo_ctrl(RL_A, degree)  servo_ctrl(RL_B, degree)  servo_ctrl(RR_A, degree)  servo_ctrl(RR_B, degree)#--------------------------------------------------------------------##--------------------------------------------------------------------if __name__ == '__main__':  av = sys.argv  ac = len(av)  if (ac == 1):      main(90)  else:      main(int(av[1]))
Thank you very much for your kind help in advance.

sohonomura2020

Statistics: Posted by sohonomura2020 — Wed Mar 27, 2024 12:42 am



Viewing all articles
Browse latest Browse all 8082

Trending Articles