I want to control the servo motor with Jetson GPIO PWM using python code. I installed this GPIO repo for Jetson using sudo pip install Jetson.GPIO. I am trying to check the GPIO Pin with following code but it is not working. Any Idea how I can make it work
import Jetson.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)
channel = 15
GPIO.setup(channel, GPIO.OUT,initial=GPIO.HIGH)
while True:
GPIO.output(channel, GPIO.LOW)
time.sleep(1)
GPIO.output(channel, GPIO.HIGH)
time.sleep(1)
I checked it with multimeter but it is not working. I checked other GPIO pins by changing channel but still it has no output. Any Idea how to use it in Python.
First: You will never get good enough control of a PWM servo using GPIO pins driven by Python, unless there’s a specific Python function that sets up a hardware-driven PWM signal. These servos are quite sensitive to the signal duration, and trying to toggle on/off at user level is pretty hard to get right even in raw C code, and will essentially never work reliably with Python.
Second, did you also install the udev rules and reload the service (or reboot the jetson)?
Third, are you sure you’re looking at the right pin? The pin numberings are all confusing and it’s easy to get it wrong. I have, myself, many times.
Fourth, do any of the included examples, like test_all_pins.py, or simple_out.py, perform as expected?
I checked it multiple times but I am not able to solve it.
I followed all the procedures mentioned to run the GPIO pins but I am not able to run it. What can be the issue can you guide me? What am I missing or doing wrong? Any help will be appreciated.
The procedure I followed is as shown below:
1. Configure the GPIO expansion header for PWM or any other PIN, To configure run the following command. sudo /opt/nvidia/jetson-io/jetson-io. and follow this link
2. Install GPIO Jetson using command sudo pip3 install Jetson.GPIO 3. Copy new rules sudo cp lib/python/Jetson/GPIO/99-gpio.rules /etc/udev/rules.d/ 4. Run the following python code to toggle the voltage value. Check with a multimeter with GND and PWM (or whatever enabled) PINs
import Jetson.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)
channel = 15
GPIO.setup(channel, GPIO.OUT)
while True:
GPIO.output(channel, GPIO.HIGH)
time.sleep(1)
GPIO.output(channel, GPIO.LOW)
time.sleep(1)
GPIO.cleanup()