Jetson NX GPIO Connection to RoboClaw Motor Controllers

I have built the NASA JPL Open Source Rover project and tested everything working on a Raspberry Pi. I have since swapped over to a Jetson NX and everything seems to be working including my added sensors except my packetized serial connection to the RoboClaw motor controllers. The code is setup to look for /dev/serial0 but that is not on this device and I believe it is a link from /dev/ttyS0 on the RPi. I have started running basic commands to try and see which device the RoboClaws might be attached to and I am having very little luck. I did add my user to the dialout group but that did not change anything. I feel like I am missing something pretty simple, but I appreciate any help I can get.

The RoboClaw documentation is here with the Packetized Serial information on page 57.

The specific code from JPL that is being used is here. For my testing, I am basically trying to run the following commands in a Python terminal:

rc = Roboclaw(“/dev/ttyS0”,115200)
rc.Open()
rc.ReadVersion()

I have tried with multiple /dev/ttyS* and /dev/ttyTHS* devices.

hello astronav,

tegra serial driver register uart devices as ttyTHS* during kernel initial stage.
you may check kernel messages for details,
for example,

$ dmesg | grep THS
[    1.533725] 3100000.serial: ttyTHS0 at MMIO 0x3100000 (irq = 47, base_baud = 0) is a TEGRA_UART
[    1.535029] 3110000.serial: ttyTHS1 at MMIO 0x3110000 (irq = 48, base_baud = 0) is a TEGRA_UART
[    1.535982] 3140000.serial: ttyTHS4 at MMIO 0x3140000 (irq = 49, base_baud = 0) is a TEGRA_UART

you may access L4T sources via download center, check below device tree for definitions.
thanks

$L4T_Sources/r32.4.3/Linux_for_Tegra/source/public/hardware/nvidia/soc/t19x/kernel-dts/tegra194-soc/tegra194-soc-uart.dtsi

I do see basically exactly that, but am unsure what to do with this information.

[    1.630530] 3100000.serial: ttyTHS0 at MMIO 0x3100000 (irq = 47, base_baud = 0) is a TEGRA_UART
[    1.631576] 3110000.serial: ttyTHS1 at MMIO 0x3110000 (irq = 48, base_baud = 0) is a TEGRA_UART
[    1.632367] 3140000.serial: ttyTHS4 at MMIO 0x3140000 (irq = 49, base_baud = 0) is a TEGRA_UART

hello astronav,

there should be an additional message shown if you register devices to a serial console.
you may refer to NX GPIO Header J12 pinout, for wiring your device with 40-pin header.
please also refer to Configuring the 40-Pin Expansion Header session for the pin configuration.
thanks

Just getting back to working on this. I don’t see any additional messages from dmesg. I am trying to connect to the UART pins (8,10) and have also connected a ground. I am pretty sure the wiring is done fine (no power, GND to GND, TX to RX, RX to TX) and the Roboclaw motor is configured for packetized serial with an address of 0x80 (or 128) and baud rate of 115200. From my reading, the UART pins are set and do not need to be and can’t be configured. I tried to reach out to Basic Micro, but they have no experience with the Jetson though I am sure someone has used it before. Any additional thoughts would be welcome.

Did you make any more progress ? I followed Jetson Nano - UART - JetsonHacks for UART setup and am using the roboclaw python code with python3 . I am able to able to successfully send commands to the roboclaw through /dev/ttyTHS1, but when trying to read data from the roboclaw I am getting timeouts and checksum errors and only occasionally, correct data.

I did make progress with it. I was able to get the Roboclaw working on a bench test, but then ran into some pull down resistor changes I needed to make with my actual board. I stepped away from the project for a while, but was hoping to pick it up again in the next couple of months. Unfortunately, I don’t have a good recommendation on how to resolve it at this time since it has been a little while since I have looked at it.

It happens that I just got it to work ( roboclaw connected to Jetson Nano via UART for 2-way communication, following guidance from Jetson Nano - UART - JetsonHacks and using python3 and pyserial ) . After seeing a note on stop bits ( see https://www.realtimes.cn/Uploads/download/JetsonNano_DataSheet.pdf, note 4.7.3 ) I configured the jetson-side python code for 2 stop bits. That did the trick- communication is now reliable, both reads and writes, at standard baud rates ( eg, 115200 ) . The device name to use is /dev/ttyTHS1 . I had a look at the Nasa JPL Open Source Rover project - very cool !

Glad to hear! I will check out those resources when I have a chance! It sounds like you are using the Nano though? I was trying to get this working with the NX and I think there are slight differences that I was running into. It would be good to try your suggestion though!

Yes, this was for Jetson Nano so I guess this has no relevance for the NX … In any case to close the loop on this - ultimately I found that a reliable and repeatable fix ( for being able to read data such as encoder values from roboclaw though the jetson nano uart without running into timeouts and crc errors ) was to specify a baud rate in the jetson nano side roboclaw library that is slightly higher than the baudrate that is set on the roboclaw itself. Eg, if the roboclaw itself is setup for 38400 then specify 40500 in the jetson nano side roboclaw python library. On my setup I found the safe range for this baudrate to be something between 39500 and 41000. Hope this helps someone.

1 Like