Set "iq_measured" value as GPIO digital output value

Hi everyone,

I’m looking for a way to set the “axis0.Iq_measured” as the GPIO digital output pin.

However, it is difficult to find it. Can I get any advice on this?

Thank you!

Hi TexGu,

Iq_measured is a continuous analog value, it can’t be written to a GPIO digital pin - there’s no digital to analog circuitry on the ODrive. Can you explain more as to your use case and requirements? There may be another solution possible.

Hi solomondg,

Thanks for your response!
Although the Iq_measured is a continuous analog value, Isn’t the measured value digital?
In my opinion, if we measure it in discrete time(for example, 100Hz), it can be transmitted via UART. (Is this possible?)

My system setup is the multiple motors (4 motors) using four ODrives and one MyRio.
I give the analog output command(0~3.3V) from MyRio to Odrive and do the position control.

The issue is, I’d like to include the Iq_measured values to control the motor in MyRio to give the new desired position value.
Would it be possible the ODrive keeps reading the Iq_measured value and send it to MyRio through UART?

Thanks!

Hey TexGu,

Apologies, I assumed you were trying to output the value of Iq_measured as an analog signal or similar.

Yes, you can access Iq_measured over UART - all parameters listed here can be accessed by any of USB, UART, or CAN.

I’d generally recommend having the MyRIO command position over UART as well - that’s much more reliable/predictable than transmitting the position command over analog.

You can see the information on the UART connections here, and the ASCII protocol used over UART here. tldr - there’s a shorthand command for setting position and another for getting pos/vel feedback, and you can read the Iq_measured via the general parameter read/write syntax - here you’d just transmit r axis0.motor.foc.Iq_measured\n and the ODrive would respond with the floating-point value.

Note the default UART baudrate is 115200 baud, you may want to increase this to 921600 for higher bandwidth communications. You can additionally use the checksum to add reliability to incoming and outgoing messages.

As another note - you’ll require one UART per ODrive from the MyRIO. A quick look at the datasheet implies it only has a single UART peripheral, which may be an issue. May I ask why you’re using the MyRIO in the first place? It seems even a common microcontroller would be easier and more flexible for this task.

Generally we recommend using CAN bus for any application requiring reliability, especially with multiple ODrives – it’s faster and more reliable. Just a note for the future.

Hey solomondg,

Thanks for your quick suggestion!
In the case of an Analog output signal from MyRio, I can use the FPGA with high frequency but I’m worried about the situation that shows the latency or I need to reduce the control frequency of the system. (I would need to keep reading the foc.Iq_measured value and sending the position control signal to the motor.)

My original plan is
FPGA high-frequency analog output from MyRio → ODrive Position control
Independent low-frequency UART reading Iq signal & position signal → TX → Odrive → RX → MyRio

Do you think this plan is reasonable?

Since MyRio has two UART ports (Connector A and Connector B), I might be able to control up to two motors. If this works, I plan to move the system to the CRIO setup to control four motors in same time.

Do you recommend the Arduino to control the motors? (I tried but not for the high-frequency RT control and difficult to control multiple motors).

Yes, CAN bus would be the ideal communication method but it’s too expensive. (If I move to CRIO then I would be able to purchase CAN BUS module in the future.)

Currently, I’ve tried to send the r axis0.motor.foc.Iq_measured\n to ODrive and get the Hexadecimal feedback from ODrive and I would need to take a look at how to convert it to the float value.

Thank you again for your help!

Best,