Cannot control servos through Nano

Hi! I am using a Jetson Nano to try to control a servo. I am using a PCA9685 servo control board, and I have verified that the wiring setup is correct. I have GND on the PCA9685 connected to pin 6 on the Jetson, VCC connected to pin 1, SDA connected to pin 3, and SCL connected to pin 5. “i2cdetect -y -r 1” returns that the Jetson does see the control board connected at address 0x40.

I have configured permissions correctly, to the best of my knowledge, with the three lines of code at the top below. Furthermore, I have confirmed that power is being supplied to the PCA9685 adequately; it is receiving 5V, and about 9A, of power, from a fully charged LiPo battery via a step-down regulator. Furthermore, I know that the servo itself is functional because I actually was able to get it to move once (only once) - I have not changed anything since, but now it does not work for whatever reason.

When I run the code below, straight out of the JetsonHacks tutorial, there is no error, but the servo does not turn at all. Can someone help me figure out what I may be doing wrong?

sudo usermod -aG i2c seaweedhorse
groupadd -f -r gpio
sudo usermod -a -G gpio seaweedhorse

from adafruit_servokit import ServoKit
kit = ServoKit(channels=16)
kit.servo[0].angle=60
quit()

Edit: I should add that if I run the following two lines, it returns “cp: cannot stat opt/nvidia/…etc: No such file or directory”. So I did not run these two lines, despite some tutorials using them.

sudo cp /opt/nvidia/jetson-gpio/etc/99-gpio.rules /etc/udev/rules.d/
sudo udevadm control --reload-rules && sudo udevadm trigger

Just guessing here: the servo might be underpowered and you need to increase the voltage that is delivered to the servo. What is the brand & type of servo you are using?

Again, just guessing: Maybe your servo got burned during your test. Do you have a servo tester to confirm the servo is still working?

I believe JetRacer uses the same IC to control a servo for steering. Could you run the Jetracer code and see if that can confirm you hardware is set up ok?

Hi, thanks for the replies! @dkreutz, I have actually tried two servos with it; the one that worked earlier was a Tiankongrc SG90 micro servo. The data sheet says it should be able to take 4.8-6V and only draws in the range of mA current. The one I’m trying currently is MG996R; not sure the manufacturer. It also says it should be able to take 5V, and only requires 1-2A. I have tried multiple of each type of servo; none of the ones I have tried are able to move, which makes me think it isn’t just one that is burned out. I don’t have a servo tester, though. I have also tried moving the servos to other pins (i.e. the 1st set of pins on the PCA9685, rather than the 0th); that doesn’t work either.

And @Dingo_aus: Looking through the JetRacer code, it looks like it uses continuous rotation servos, which mine unfortunately are not (they have max 180 degree rotation), meaning I can’t run that code on these servos. The JetRacer code does look extremely similar to mine otherwise, though.

Both servo types, SG90 and MG996, burn easily when stalling or hitting the outer position. When testing start with center position (90 degrees/1500 pwm) and then carefully move to the outer positions. Sometimes they are not able to reach the extreme outer positions (0 degrees/500 pwm and 180 degrees/2500 pwm).

I got it to work now! Used a different library other than ServoKit; used the PCA9685 library instead (Introduction — Adafruit PCA9685 Library 1.0 documentation). Now the servo is moving, but not going through the full range of motion; it goes to 0 successfully, but can’t reach a full 180 degrees; it stops around 120 degrees or so. Do you know of any way of being able to tell if a servo can actually reach the full range of motion it’s supposed to? I want to have a servo that can actually reach 180 degrees of motion (or more). Thanks again for your help; I appreciate it!

See the example of the PCA9685 docs, it says that by default the pulse range is 1000-2000 and you should adapt this to your servos range.

That’s it - the default pulse range wasn’t quite taking it through its full range of motion. Had to tweak it. Seems basic now, in hindsight! Thanks for the help!