UART communication with MyRio

Hi all,

I’m trying to send the ‘odrv0.axis0.Iq_measured’ value to MyRio through UART communication.

The LabVIEW block diagram is shown below and I checked it properly sends the message (r axis0.motor.foc.Iq_measured\n ) by receiving the message at RX in the same MyRio.

Then I connected the RX, TX, 5V, and GND pins to ODrive’s TX(G13), RX(G12), ISO VDD, and ISO GND pins respectively as shown in the below picture.

Also set the enabling uart a port, GPIO12,13pins as UART A, and baudrates as 115200 which is the same as the myRio Tx, RX baudrates.

However, If I connect the VDD and ground, I don’t get any response at the MyRio’s RX port. If I disconnect the VDD and ground, I can get the very short hexadecimal values but it’s gone. (I need to delete the TX input values and put them again to get the new values)

Does anyone know why I couldn’t receive any values when I connected the VDD and GND and got the hexadecimal numbers?

Thanks for your help!

Hi there,

VDD and GND should always be connected. My guess is that you’re receiving random noise when they’re not connected.

It looks like on that Labview screeenshot you posted the termination char is at 9600 baud, unless I’m misreading the configuration? Does the VISA Configuration override the baudrate? Note that the ODrive doesn’t use the VISA protocol, so you should just use raw UART communications.

Do you have a logic analyzer or similar that you can use to see the raw data the myRIO and ODrive are sending?

Hi solomondg

Thanks for your response!
I tried to check the signal through the oscilloscope and get the proper TX from Odrive.
The issue was becaise I set the position control mode as the analog input.

My motor setting code is below. (ODrive does not response from MyRIO’s TX signal)

odrv0.axis0.controller.config.input_mode = 1 #InputMode.PASSTHROUGH
odrv0.axis0.controller.config.control_mode = 3 #ControlMode.POSITION_CONTROL
odrv0.config.enable_uart_a = True
odrv0.config.gpio12_mode = 4 #GpioMode.Tx
odrv0.config.gpio13_mode = 4 #GpioMode.Rx
odrv0.config.uart_a_baudrate = 115200
odrv0.config.uart0_protocol = 3
odrv0.config.gpio15_mode = 3 #GpioMode.ANALOG_IN
odrv0.config.gpio15_analog_mapping.min = -0.5
odrv0.config.gpio15_analog_mapping.max = 0.5
odrv0.config.gpio15_analog_mapping.endpoint = odrv.axis0.controller._input_pos_property
odrv0.axis0.config.torque_soft_min = -1
odrv0.axis0.config.torque_soft_max = 1
odrv0.axis0.controller.config.input_filter_bandwidth = 20

After I changed it to the position closed loop control mode, it’s working well.
Do you know why UART does not work in Analog input position control mode?

odrv0.axis0.controller.config.control_mode = 3 #ControlMode.POSITION_CONTROL
odrv0.axis0.controller.config.input_mode = 3 #InputMode.POS_FILTER
odrv0.axis0.controller.config.input_filter_bandwidth = 20
odrv0.axis0.controller.config.pos_gain = 20
odrv0.config.enable_uart_a = True
odrv0.config.gpio12_mode = 4 #GpioMode.Tx
odrv0.config.gpio13_mode = 4 #GpioMode.Rx
odrv0.config.uart_a_baudrate = 115200
odrv0.config.uart0_protocol = 3

Hey TexGu,

If you have the analog endpoint mapping setup, then it’ll override the commands given over UART. I’d recommend disabling that endpoint - it’s really one or the other.

Are you able to read the iq_measured and everything correctly?

Hey solomondg,

Now I tried the analog input position control setting and it’s working well.
I don’t know why the previous setting didn’t work because I tested the old code and it’s working well now.

I added the below code at the beginning of the code and I suspect that It would clear the all previous error.


Thank you for helping me!

Hey TexGu,

I’d generally recommend against using the analog position input if you’re already using UART for feedback - you can just use UART for sending position setpoints directly, it’s much more precise. That being said, I’m glad what you have is working for you!