Nvidia Xaiver NX with l298n motor driver

Hello everyone,
I have nvidia jetson xaiver nx card and l298n motor driver card. I want to control 4 servo motors. How can I do this using GPIO pins. There are examples for Jetson nano but I couldn’t find any examples for xaiver nx. Can you help me, how should I follow a path?

Hi umittix_3040,

Are you using the devkit or custom board for Xavier NX?
What’s your Jetpack version in use?

What’s the interface you used for your l298n motor?
Is that only controlled by GPIO high/low?
Or please share how you get it work in Jetson Nano.

I am using the above JNX30D model, JetPack 4.6 installed.

I use the above model as a motor driver.


Jetson nano ile bu şekilde kullanılmış. Xaiver Nx için hangi pinleri kullanmam gerekli

Okay, it seems a custom carrier board from Auvidea.

The following figure is the 40-pins expansion header for Jetson Nano.

Are you using them(33,32,35,36,37,38) just as GPIO on Jetson Nano?

Please share the device tree and the dmesg from Jetson Nano to let me know more details how you get it work before.

I don’t have Jetson Nano, I’m following the example I left in the following. Considering only this example, which pins should I use for Xaiver Nx.

Okay, I thought you’ve verified it working on Jetson Nano so that I asked you more details about that.

From the example you shared, it seems just using the pins as GPIO.
So, you can just select some unused GPIOs from Xavier NX to work with your motor driver.

It does not work when I try with the code I gave below. How should I define GPIO pins

import Jetson.GPIO as GPIO
import time

Define pin numbers

INA = 33
INB = 32
IN1 = 35
IN2 = 36
IN3 = 37
IN4 = 38

Set up GPIO mode

GPIO.setmode(GPIO.BOARD)

Set pins as outputs

GPIO.setup([INA, INB, IN1, IN2, IN3, IN4], GPIO.OUT)

try:
# Move Motor A forward
GPIO.output(INA, GPIO.HIGH)
GPIO.output(INB, GPIO.LOW)
GPIO.output(IN1, GPIO.HIGH)
GPIO.output(IN2, GPIO.LOW)
print(“Motor A moving forward.”)

time.sleep(2)

# Move Motor A backward
GPIO.output(INA, GPIO.LOW)
GPIO.output(INB, GPIO.HIGH)
GPIO.output(IN1, GPIO.LOW)
GPIO.output(IN2, GPIO.HIGH)
print("Motor A moving backward.")

time.sleep(2)

# Uncomment the following lines to control Motor B
# Move Motor B forward
# GPIO.output(IN3, GPIO.HIGH)
# GPIO.output(IN4, GPIO.LOW)
# time.sleep(2)

# Move Motor B backward
# GPIO.output(IN3, GPIO.LOW)
# GPIO.output(IN4, GPIO.HIGH)
# time.sleep(2)

finally:
# Clean up GPIO settings
GPIO.cleanup()
print(“GPIO cleaned up.”)

Is there any error showing in dmesg or reported in console?

Have you configured those pins as GPIO/output in pinmux before using Jetson.GPIO to control them?


echo 424 > /sys/class/gpio/export
echo 393 > /sys/class/gpio/export
echo 448 > /sys/class/gpio/export
echo 429 > /sys/class/gpio/export
echo 482 > /sys/class/gpio/export
echo 447 > /sys/class/gpio/export


echo out > /sys/class/gpio/gpio424/direction
echo out > /sys/class/gpio/gpio393/direction
echo out > /sys/class/gpio/gpio448/direction
echo out > /sys/class/gpio/gpio429/direction
echo out > /sys/class/gpio/gpio482/direction
echo out > /sys/class/gpio/gpio447/direction

I’m not getting any error codes, but no engine is responding. I have activated pins 32-33-35-36-37-38 with the above commands.

 dmesg | grep gpio
[    0.776626] gpio gpiochip0: gpio-line-names specifies 240 line names but there are 224 lines on the chip
[    0.778166] gpiochip_setup_dev: registered GPIOs 288 to 511 on device: gpiochip0 (tegra-gpio)
[    0.785333] gpio gpiochip1: gpio-line-names specifies 21 line names but there are 40 lines on the chip
[    0.785512] GPIO line 265 (suspend-led-gpio) hogged as output/high
[    0.785856] gpiochip_setup_dev: registered GPIOs 248 to 287 on device: gpiochip1 (tegra-gpio-aon)
[    0.964843] GPIO line 246 (gpio_default) hogged as output/high
[    0.966231] GPIO line 247 (gpio_default) hogged as output/high
[    0.966607] gpiochip_setup_dev: registered GPIOs 240 to 247 on device: gpiochip2 (max77620-gpio)
[    0.977330] gpio tegra-gpio wake61 for gpio=201(Z:1)
[    0.977418] extcon-gpio-states external-connection:extcon@1: Cable state:0, cable id:0
[    1.612198] gpio tegra-gpio wake63 for gpio=97(M:1)
[    2.090686] FAN:gpio request success.
[    2.090696] FAN: can't find tach_gpio
[    2.151286] gpio tegra-gpio wake51 for gpio=130(Q:2)
[    3.592590] gpio tegra-gpio wake67 for gpio=48(G:0)
[    3.592664] gpio tegra-gpio-aon wake29 for gpio=36(EE:4)
[    3.592800] input: gpio-keys as /devices/gpio-keys/input/input6
[    8.864106] gpio tegra-gpio wake20 for gpio=52(G:4)

dmesg this way

Are you trying to control GPIO through sysfs?
Is there any reaction from your motor if you control GPIO as it want?

# Move Motor B forward
# GPIO.output(IN3, GPIO.HIGH)
# GPIO.output(IN4, GPIO.LOW)
# time.sleep(2)

Would motor B move forward if you pull IN3 high and IN4 low?
If not, please get a scope to check if their are pulled as expected.

It’s just that the battery doesn’t provide enough power. Thank you!

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