How to control a servo from Jetson Orin Nano?

I am trying to control a servo motor from a Jetson Orin Nano’s header pins. I realized that the signal pins on the Orin Nano only output 3.3V so I bought a TXS0108E Level shifter to increase the voltage from 3.3V to 5V. I used this script to test the servo.

import Jetson.GPIO as GPIO
import time

servo_pin = 15
GPIO.setmode(GPIO.BOARD)

GPIO.setup(servo_pin, GPIO.OUT, initial=GPIO.HIGH)

while True:
     print("LOW")
     GPIO.output(servo_pin, GPIO.LOW)
     time.sleep(2)
     print("HIGH")
     GPIO.output(servo_pin, GPIO.HIGH)
     time.sleep(2)
GPIO.cleanup()

However, nothing happened to the servo. Right now, I can only see two potential issues, either the level shifter does not work, OR the code is wrong, is there a way to control the angle of a servo rather than just set the pin to high or low?
Please help me with this.

Hi anay.gokhale123,

Are you using the devkit or custom board for Orin Nano?
What’s the Jetpack version in use?

Are you using the following on GPIO of J12?
imageg
If so, have you configured it as Output in pinmux spreadsheet?

I am using the devkit
Jetpack 5.1.3 (I cannot change this as I need to use the Intel RealSense d435i that does not work on Jetpack 6 without some driver which has a complicated installation process)
I used both pin 15 and pin 33. I followed these instructions and turned on both of these pins as well as the other pwm ones and pin 13.

Additionally I something that is probably causing this issue. When I setup a breadboard with the 3.3V power from pin 1 into VA of the TXS0108E, the 5V power from pin 2 to VB, a common ground from pin 6 to GND through the breadboard, and 3.3V power to OE through the breadboard from pin 1, all of the voltages are fine, but as soon as I connect a wire from pin 15 or pin 33 (I have not tried anything else) to A1 of the level shifter, the 5V from pin 2 drops down to 2.4V even if there is no code running to affect the GPIO pin and it is set to 0V.

What might be the issue?

Hi anay.gokhale123,

Do you want to use PIN15 as GPIO or PWM?
If you want to use it as GPIO and control it manually, you should configure it as Output in pinmux spreadsheet.
If you want to use it as PWM, then using Jetson-IO to configure its pinmux and the steps in Unable to generate PWM with Nvidia Jetson AGX Orin Development Kit - #6 by KevinFFF should work to generate the PWM output.

It sounds like another issue, please open another topic to discuss in details.

The servo motor I want to control is used to open and close a claw. Since I just want it to open to the max angle and then close all the way, setting the pin to HIGH and LOW should be fine right?
How can I configure it as output in pinmux spreadsheet?

Yes, it should be fine if you just want to control it ON/OFF.

let me share an example for PIN15 of 40-pins header.

From Table 3-3 of Jetson Orin Nano Developer Kit Carrier Board Specification as following, you would know it is PN.01
image

In pinmux spreasheet, please just configure it as following:
image

what is the pinmux spreadsheet and what do I do with it once I have configured it as shown?

since you are on jetpack5.x

sudo /opt/nvidia/jetson-io/jetson-io.py

Select the config for pwm and save and reboot option.
This works fine on jp5.x, jp6.x has issues

sudo echo 0 > /sys/class/pwm/pwmchip0/export
echo 20000000 > /sys/class/pwm/pwmchip0/pwm0/period
echo 10000000 > /sys/class/pwm/pwmchip0/pwm0/duty_cycle
echo 1 > /sys/class/pwm/pwmchip0/pwm0/enable

This is not working for me. I have used this same command before and setup some pins however when I am trying to do it again, the terminal page becomes a dark green color and then goes back to normal terminal after less than half a second

I don’t know what to say, not sure what is going on with this. Had to back peddle to 5.x to get it to work and the pwm does work on 5.x. They turned off sysf in 6.x so pwm is not going work until you rebuild build the kernel with it turned back on.

What I do is have several NVMe drives and swap them out. Because every time you flash it lays down a fresh os and everything is lost. SD card is way too slow.

Pinmux spreadsheet is an excel file that can help you to generate pinmux/gpio dtsi.
Please refer to Jetson Orin NX and Nano Series — Jetson Linux Developer Guide documentation for details.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.