Hello NVIDIA Developers,
I’m working on a project with the Jetson Orin Nano Super Developer Kit, running JetPack 6.1, and encountering issues while interfacing with the GPIO pins. My aim is to control an L298N motor driver and an IR obstacle detection sensor, but I am facing consistent problems when reading and writing to the GPIO pins. Below are the details:
Project Details
• Jetson Device: Orin Nano Super Dev Kit
• JetPack Version: 6.1
• Peripherals:
1. L298N Motor Driver
• Connected to GPIO pins for IN1, IN2, and optionally ENA.
2. IR Obstacle Detection Sensor
• Connected to a GPIO pin to detect digital HIGH/LOW signal for obstacle presence.
• Programming Environment:
• GPIO Library: Python gpiod (latest version installed).
Problems Observed
1. GPIO Pin Always LOW:
• When using the IR sensor, the GPIO pin reads as 0 (LOW) even when no sensor is connected to the pin. This issue occurs even after enabling pull-up resistors programmatically.
• Tested this with multiple pins (e.g., Line 4, Line 316) from the gpiochip1 and gpiochip0 configurations.
2. GPIO Pin Mapping Unclear:
• It’s difficult to consistently map physical pins to gpiochip1/gpiochip0 lines for specific functionality. For instance:
• Physical Pin 7 should map to GPIO09 (PAA.04), but the program behaves as if the pin is not configured or floating.
3. Inconsistent Behavior with Motor Driver:
• The L298N motor driver connections (IN1, IN2, ENA) fail to function reliably. Despite the pins being configured as output, the motor does not respond to HIGH/LOW signals.
4. Behavior When GPIO Pins Are Floating:
• Unconnected GPIO pins return unpredictable values. This persists even after programmatically enabling pull-up/down resistors.
System Observations
From gpioinfo and /sys/kernel/debug/gpio, here are the configurations:
• gpiochip1 (316–347):
• Example: Line 316 (PAA.00) is unused and configured as input.
• Some pins (e.g., PEE.04) are reserved for internal use (Power or Force Recovery).
• gpiochip0 (348–511):
• Includes pins like gpio-349 (PA.01), which are unused but fail to toggle when set as output.
Testing Setup
IR Sensor Testing Program
import gpiod
import time
GPIO chip and line configuration
chip_name = “gpiochip1”
sensor_line = 316 # Line for PAA.00 (physical Pin 7)
chip = gpiod.Chip(chip_name)
line = chip.get_line(sensor_line)
line.request(consumer=“IRSensor”, type=gpiod.LINE_REQ_DIR_IN, flags=gpiod.LINE_FLAG_BIAS_PULL_UP)
try:
while True:
value = line.get_value()
if value == 0: # LOW: Obstacle detected
print(“Obstacle detected!”)
else: # HIGH: No obstacle
print(“No obstacle.”)
time.sleep(0.5)
except KeyboardInterrupt:
print(“Exiting…”)
finally:
line.release()
Issue:
• The line.get_value() always returns 0 even when the IR sensor is disconnected or no obstacle is present.
Motor Driver Testing Program
import gpiod
import time
GPIO chip and line configuration
chip_name = “gpiochip1”
IN1_line = 316 # Line for PAA.00
IN2_line = 317 # Line for PAA.01
chip = gpiod.Chip(chip_name)
IN1 = chip.get_line(IN1_line)
IN2 = chip.get_line(IN2_line)
IN1.request(consumer=“MotorDriver”, type=gpiod.LINE_REQ_DIR_OUT)
IN2.request(consumer=“MotorDriver”, type=gpiod.LINE_REQ_DIR_OUT)
try:
while True:
# Forward direction
IN1.set_value(1)
IN2.set_value(0)
print(“Motor running forward”)
time.sleep(3)
# Stop motor
IN1.set_value(0)
IN2.set_value(0)
print("Motor stopped")
time.sleep(2)
# Backward direction
IN1.set_value(0)
IN2.set_value(1)
print("Motor running backward")
time.sleep(3)
except KeyboardInterrupt:
print(“Exiting…”)
finally:
IN1.release()
IN2.release()
Issue:
• The motor does not respond to HIGH/LOW signals on the GPIO lines. Multimeter measurements show no change in voltage.
Attempts to Fix
1. Verified GPIO functionality using gpioget:
• Command: gpioget gpiochip1 316
• Result: Always returns 0 even when toggled manually.
2. Manually enabled pull-up resistors using Python and gpiod.
3. Tried different GPIO lines from gpiochip1 and gpiochip0 with no change in behavior.
4. Tested the hardware (sensor, motor driver) independently with Arduino, and they work as expected.
Any documentation related to this will be very helpful.
Thanks,
Alok