Hello,
I am trying to control a servo motor attached to GPIO pin33 on 40 pin header of Jetson Nano.
I followed this document
I also did change the gpio pin to pwm output by
$ sudo /opt/nvidia/jetson-io/jetson-io.py
Here is the code I modified for testing the servo motor.
import Jetson.GPIO as GPIO
import timeoutput_pins = {
‘JETSON_XAVIER’: 18,
‘JETSON_NANO’: 33,
‘JETSON_NX’: 33,
‘CLARA_AGX_XAVIER’: 18,
‘JETSON_TX2_NX’: 32,
}
output_pin = output_pins.get(GPIO.model, None)
if output_pin is None:
raise Exception(‘PWM not supported on this board’)def main():
# Pin Setup:
# Board pin-numbering scheme
GPIO.setmode(GPIO.BOARD)
# set pin as an output pin with optional initial state of HIGH
GPIO.setup(output_pin, GPIO.OUT, initial=GPIO.HIGH)
print(GPIO.model)
print(GPIO.JETSON_INFO)
print(GPIO.VERSION)
print(“PWM PIN:{0}”.format(output_pin))
p = GPIO.PWM(output_pin, 100)
val = 0.1
incr = 0.01
p.start(val)print("PWM running. Press CTRL+C to exit.") try: while True: time.sleep(0.2) if val >= 0.2: incr = -incr if val <= 0.1: incr = -incr val += incr if val<0.1: val = 0.1 print(val) p.ChangeDutyCycle(val) finally: p.stop() GPIO.cleanup()
if name == ‘main’:
main()
When I run above code I see changes in pwm2 pin as
$ sudo cat /sys/kernel/debug/pwm
platform/70110000.pwm, 1 PWM device
pwm-0 (pwm-regulator ): requested enabled period: 2500 ns duty: 0 ns polarity: normalplatform/7000a000.pwm, 4 PWM devices
pwm-0 (sysfs ): requested period: 20000 ns duty: 10000 ns polarity: normal
pwm-1 (pwm-regulator ): requested enabled period: 8000 ns duty: 4320 ns polarity: normal
pwm-2 (sysfs ): requested enabled period: 10000000 ns duty: 20000 ns polarity: normal
pwm-3 (pwm-fan ): requested enabled period: 45334 ns duty: 45333 ns polarity: normal
I also checked memory at 0x700031fc
$ sudo devmem2 0x700031fc b:
/dev/mem opened.
Memory mapped at address 0x7fb0614000.
Value at address 0x700031FC (0x7fb06141fc): 0x1
But the servo is not moving nor my scope shows any signal on the pin.
What else should I check to make the output working?