Controlling Maxon EPOS motor from Jetson Orin Nano Devkit's USB port using RS232-USB converter

Hello,

Hardware used: Jetson Orin Nano Developer Kit, Maxon EPOS 50/15 Positioning Controller, RS232-USB Converter (CH340)
Jetpack Version: 5.0 DP

I’m trying to control Maxon Motor with EPOS 50/15 Positioning Controller. The link is here: Maxon 500 Error Page.

I’m using an RS232 to USB converter with the CH340 chip. The interface is working on my Windows PC, and I’m able to control the motor with Maxon’s Software, EPOS Studio as well as Python code.
On Jetson, I was previously using USB directly to control the same EPOS controller which was working fine. However, now I want to use the RS232 interface which is not working. To verify the working of the converter, I tried communication with Arduino Nano using the same converter and that works fine. The converter shows up as /dev/ttyUSB0, I have added myself to the dialout group and have given 777 permission. I’m not able to figure out why the Maxon controller is not communicating with Jetson via RS232-USB converter when the Arduino Nano is able to do so.
Please note that I’m using Python code to control the motor with Maxon’s Communication library. I have also checked with Maxon’s support team and they do not have any further inputs on this. Kindly point me to possible sources of error.

Hi trisRHere,

What is 5.0 DP?
It seems we don’t have this release. Is there any typo?
Or please share the result of the following command on your board.

$ cat /etc/nv_tegra_release

Please share the block diagram of your connection from Jetson device.

And also provide the full dmesg for further check.

What is 5.0 DP?
It seems we don’t have this release. Is there any typo?
Or please share the result of the following command on your board.

5.0 DP was displayed on SDK Manager while installing the OS. The result of the command is below:

tris@jetson513:~$ cat /etc/nv_tegra_release
# R35 (release), REVISION: 5.0, GCID: 35550185, BOARD: t186ref, EABI: aarch64, DATE: Tue Feb 20 04:46:31 UTC 2024

The block diagram is below.
jetson_rs232.drawio

The dmesg log:
dmesg_log.txt (65.8 KB)

The DSO image of Rx and Tx lines of HL340 converter when used with Windows 10:

The DSO image of Rx and Tx lines of HL340 converter when used with Jetson:

The code for interfacing with Maxon on Windows:

import serial
import time
from ctypes import *

# EPOS Command Library path
path=r".\EposCmd64.dll"

# Load library
cdll.LoadLibrary(path)
epos = CDLL(path)

# Defining return variables from Library Functions
ret = 0
pErrorCode = c_uint()
pDeviceErrorCode = c_uint()

# Defining a variable NodeID and configuring connection
nodeID = 2
baudrate = 115200
timeout = 500

# Configure desired motion profile
acceleration = 30000 # rpm/s, up to 1e7 would be possible
deceleration = 30000 # rpm/s

# Query motor position
def GetPositionIs():
    pPositionIs=c_long()
    pErrorCode=c_uint()
    ret=epos.VCS_GetPositionIs(keyHandle, nodeID, byref(pPositionIs), byref(pErrorCode))
    return pPositionIs.value # motor steps

# Move to position at speed
def MoveToPositionSpeed(target_position,target_speed):
    while True:
        if target_speed != 0:
            epos.VCS_SetPositionProfile(keyHandle, nodeID, target_speed, acceleration, deceleration, byref(pErrorCode)) # set profile parameters
            epos.VCS_MoveToPosition(keyHandle, nodeID, target_position, True, True, byref(pErrorCode)) # move to position
        elif target_speed == 0:
            epos.VCS_HaltPositionMovement(keyHandle, nodeID, byref(pErrorCode)) # halt motor
        true_position = GetPositionIs()
        if true_position == target_position:
            break

if __name__ == "__main__":
    # Initiating connection and setting motion profile
    keyHandle = epos.VCS_OpenDevice(b'EPOS4', b'MAXON SERIAL V2', b'RS232', b'COM9', byref(pErrorCode)) # specify EPOS version and interface
    print("Connected: ", keyHandle, pErrorCode)
    val = epos.VCS_SetProtocolStackSettings(keyHandle, baudrate, timeout, byref(pErrorCode)) # set baudrate
    print("Set protocol: ", val, pErrorCode)
    epos.VCS_ClearFault(keyHandle, nodeID, byref(pErrorCode)) # clear all faults
    print("clear fault: ", val, pErrorCode)
    epos.VCS_ActivateProfilePositionMode(keyHandle, nodeID, byref(pErrorCode)) # activate profile position mode
    print("activate profile pos: ", val, pErrorCode)
    epos.VCS_SetEnableState(keyHandle, nodeID, byref(pErrorCode)) # enable device
    print("Set enable state: ", val, pErrorCode)
    MoveToPositionSpeed(20000,5000) # move to position 20,000 steps at 5000 rpm/s
    print('Motor position: %s' % (GetPositionIs()))
    time.sleep(1)

    MoveToPositionSpeed(0,2000) # move to position 0 steps at 2000 rpm/s
    print('Motor position: %s' % (GetPositionIs()))
    time.sleep(1)

    epos.VCS_SetDisableState(keyHandle, nodeID, byref(pErrorCode)) # disable device
    epos.VCS_CloseDevice(keyHandle, byref(pErrorCode)) # close device

Changes on Jetson:

path="/home/tris//libEposCmd.so.6.7.1.0"
keyHandle = epos.VCS_OpenDevice(b'EPOS4', b'MAXON SERIAL V2', b'RS232', b'/dev/ttyUSB0', byref(pErrorCode)) # specify EPOS version and interface

Thanks.

Okay, It seems you are using Jetpack5.1.3 (L4T R35.5.0).

[  631.368899] usbcore: registered new interface driver ch341
[  631.368923] usbserial: USB Serial support registered for ch341-uart
[  631.368961] ch341 1-2.2:1.0: ch341-uart converter detected
[  631.375527] ch341-uart ttyUSB0: break control not supported, using simulated break
[  631.375919] usb 1-2.2: ch341-uart converter now attached to ttyUSB0

From your dmesg, it seems there’s no error when you plug the converter on USB port.
Is there any errors when you run that python script on Jetson?

Sorry that we don’t have your converter and RS232 transceiver to verify it locally.
Could you short TX/RX to verify loopback test before connecting to your motor?

Sorry that we don’t have your converter and RS232 transceiver to verify it locally.
Could you short TX/RX to verify loopback test before connecting to your motor?

I have done the Loopback test and it is working fine. Additionally, I’m also able to communicate with a Windows 10 PC’s COM port from the Jetson via the converter. It is only with the Maxon’s EPOS controller that the interface is not working.

The issue has been resolved.
Controlling EPOS Controller is now working with both an RS232-USB converter and Jetson’s UART port with an additional RS232 transceiver.
The key was to rename the automatically assigned port name such as ttyUSB0 for the converter, and ttyTHS0 for the UART port to the format of ttyS*.
I believe this has something to do with Maxon’s API. Thank you for your time.

1 Like

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