Problem
I’m currently migrating from a Raspberry Pi Model 4B to a Jetson Nano. I’ve ran into some issues using my DC motor with the Jetson GPIO pins. I’ve included a drawing of my current configuration.
The issue I’m running into is that I can’t get the motor to spin at all. As seen in my drawing, I’m using pin 16 and pin 18. All that is needed to get this motor spinning is alternating pin 16 and pin 18 between HIGH and LOW. I’ve written a script that does this for me as seen here:
import Jetson.GPIO as GPIO
import time
# Pin Definitions
motor_pin_a = 18
motor_pin_b = 16
def main():
# Pin Setup:
# Board pin-numbering scheme
GPIO.setmode(GPIO.BOARD)
# Set both pins LOW to keep the motor idle
# You can keep one of them HIGH and the LOW to start with rotation in one direction
GPIO.setup(motor_pin_a, GPIO.OUT, initial=GPIO.LOW)
GPIO.setup(motor_pin_b, GPIO.OUT, initial=GPIO.HIGH)
print("Starting demo now! Press CTRL+C to exit")
curr_value_pin_a = GPIO.HIGH
curr_value_pin_b = GPIO.LOW
try:
while True:
time.sleep(5)
# Toggle the output every second
print("Outputting {} to pin {} AND {} to pin {}".format(curr_value_pin_a, motor_pin_a, curr_value_pin_b, motor_pin_b))
GPIO.output(motor_pin_a, curr_value_pin_a)
GPIO.output(motor_pin_b, curr_value_pin_b)
curr_value_pin_a ^= GPIO.HIGH
curr_value_pin_b ^= GPIO.HIGH
finally:
GPIO.cleanup()
if __name__ == '__main__':
main()
Using the same exact configuration with the same exact code on the Raspberry Pi works perfectly fine, but not on the Jetson. Any ideas on how to resolve this?
Things I Tried
My first thought was that maybe pins 16 and 18 were not actually outputting HIGH and LOW. I tested this theory with a multimeter and saw that both pins were oscillating every 5 seconds between 0V and 3.3V, which I assume is good.
I also tried getting rid of the battery pack and just powering the L9110 Motor driver directly with the Jetson Nano via pin 2(5V) and pin 41(GND). When I did this, the DC motor would move ever so slightly on GPIO.Cleanup().
Lastly, I tried following this guide to help setup the GPIO pins: https://docs.nvidia.com/jetson/l4t/index.html#page/Tegra%20Linux%20Driver%20Package%20Development%20Guide/hw_setup_jetson_io.html. I clicked on “Confiugre 40-pin expansion header”, and I activated the following:
- pwm0
- pwm1
- spi1
- spi2
Please let me know if there is anything I forgot to add that would help resolve this issue.