BeagleBone Blue UART baudrate

Hello!

This is my first approach with the ODrive, so I am not particularly experienced. I am currently using the ODrive python library to control a motor in torque via UART. I am using a BeagleBone Blue to run the script and everything works fine as long as the frequency at which I send the torque setpoint from the BeagleBone to the ODrive is kept low (~50 Hz).

I would like to increase the frequency of update of the torque setpoint and I’ve searched in the documentation and in the forum but I couldn’t find a solution that works for me.

I found that a possible solution would be to increase the UART baudrate. I’ve tried to do that but it didn’t work. After updating the baudrate to 921600, I was no longer capable of establishing a connection between the BeagleBone and the ODrive. The message I got is the following: “downloading JSON data from odrive… (this might take a while)”, but then nothing happens. I checked for the maximum UARTx Transmit baud rate of the beaglebone and it appears to be 3.6864 MHz. Am I missing something? Should I manually set also the baud rate of the UART port I use? If yes, how can I do that?

Then I tried to use the USB connection but I wasn’t able to achieve better results.

I would appreciate any help in this regard. How do you manage to achieve a higher communication frequency?
Thank you!

1 Like

What firmware version are you using?

1 Like

Hmm, the UART should be able to communicate much faster than that, as should the USB.
You could try switching to the native UART orotocol which is faster, but even the ASCII protocol should be much faster than 50hz…
For example, at 115200 baud, sending c 1 0.123\n takes 10 characters or 80 bits (call it 100 bits) at 115200 baud, that’s 0.9 ms, so you could transmit that message a smidge faster than 1kHz. So I don’t think the baud rate is your issue.

What happens if (at 115200 baud) you try to send a message faster than 50 Hz ?

1 Like

I am using version 5.1.0 since I read that the newest version does no longer support the serial communication via UART. I was thinking to update it and try with the USB instead.

In that case you must also change the baudrate of the python functions. Sadly this isn’t customizable, you have to change the code. I also suggest using 2 stopbits instead of 1.

First you have to make this change in Firmware/fibre/python/fibre/serial_transport.py:

#DEFAULT_BAUDRATE = 115200
DEFAULT_BAUDRATE = 921600

class SerialStreamTransport(fibre.protocol.StreamSource, fibre.protocol.StreamSink):
    def __init__(self, port, baud):
        self._timeout = 1
        self._dev = serial.Serial(port, baud, timeout=self._timeout,
                                  stopbits=serial.STOPBITS_TWO)

You also need to recompile the firmware so it uses two stopbits:
Firmware/Board/v3/Src/usart.c:

  //huart4.Init.StopBits = UART_STOPBITS_1;
  huart4.Init.StopBits = UART_STOPBITS_2;

I am not using the ASCII protocol, I am using the native one with the python library provided by ODrive. The problem is that it is the function itself that requires a lot of time to run and I can’t send another message before it finishes.

Thank you for the help! Would it be customizable if I update the firmware to the latest version?

No, sorry. 0.5.2 and all later versions do not even support UART Native via Python. But if you don’t want to compile the firmware, you can try with 1 stopbit first.