pca9685 digital servo problem

Active yesterday
Viewed 36 times

I have several servos plugged into a PCA9685 board and controlling them with PCA9685.py, and at the end of the script at pwm.cancel() my SF3218MG (270 degree) and 6221MG (180 degree) servos turn off the PWM without any problem, but the DS3218MG (180 degree) servos stay locked in place. What is different about this servo that makes it continue to draw current? All of these servos are digital servos.

share  edit  follow  close  flag
  • Well, my first troubleshooting trick is swap 6221 with 3218 and see if situations get vice versa. You might also list the pca9685.py for everybody to debug. – tlfong01 yesterday   
  • 1
    Edited to link to the pca9685.py download, and regardless of channel it functions normally for the SF3218MG and 6221MG servos, but the DS3218MG servos still want to hold their position. – pinkie pAI yesterday
  • Ah. if the other two servos behave well, but only the bad guy DS3218 gets stuck at the end of the program, then it is likely that the python program is also OK. I usually write a little “swing back and forth” program to test the servos. For example, if I say swing(servo1), swing(servo2) and they swing happily, but if I say swing(servo3), and the servo3 gets stuck at the end, then we can narrow down to servo3 at the end of the program. Usually when you clean up stuff, something does not do what you expected. Anyway, let me think harder and come back to you later. – tlfong01 yesterday   
  • So I skimmed your pca9685.py but find it a bit higher level. Apparently you import pigpio.py which includes a module called pca9685.py. In other words, you are using two higher level modules which sets up I2C stuff and manipulate PCA9658 register etc. There is a possibility that the I2C level stuff is not compatible to your Rpi3B+/Rpi4B stretch/buster. I searched my old PCA9685 program to refresh my memory and found that I import smbus.py and write my own pca9685 functions. In other words, I only talk at I2C level. BTW, do you use any of the Rpi GPIO clock pins? – tlfong01 yesterday   
  • 1
    Thanks for your suggestion, I’ll look into using smbus! And the only pins I’m using on the RPi are SDA1, SCL1, power and ground. I think when Joan was writing PCA9685.py he intended the main function to be as an example, which explains why the function imports its own file, if that’s what you’re referring to when you say “two higher level modules”. – pinkie pAI yesterday
  • Ah, yes, I fully agree with you that the library’s main function importing pca9685 module is just an example. And as I said earlier, if two servos behave OK, and only the third servo does not stop properly, it is very likely the your python program and the pca9685 library imported are OK. I looked at the library again found everything looking OK, except two things: (1) the I2C/smbus setup and read/write functions etc are hidden/handled by pigpio, which is a daermon, and a bit complicated for daemon newbie like me to look into to troubleshoot the bad servo, (2) / to continue, …. – tlfong01 19 hours ago   
  • (2) The library provides all the basic PCA9685 PWM functions. It would be nice it it also gives examples such a CALIBRATION of servos, like the AdaFruit PCS9685 broad’s libraries (which I don’t recommend, because AdaFruit is using Circuit/Micro python which is not friendly to Rpi users.). So on second thought, I don’t recommend to try to import the smbus module and reinvent the wheels (read/write register function) to do troubleshooting. Now I would think that you might like to check out your calibration procedure, to make sure / to continue, … – tlfong01 19 hours ago   
  • … to make sure that your problematic servo is correctly calibrated. I vaguely remember that once I wrongly calibrated a servo and asked it to swing outside range and strange things happened (trembling or locked up, I forgot). BTW, if you show us the application program, like how you set the PWM frequency to 300Hz for digital servo, instead of the usual 50Hz for analog servo, how you swing the servo etc, then perhaps I might see other things that might cause the servo go wrong. Anyway, good luck and cheers. – tlfong01 19 hours ago    

Categories: Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: