Beginner here, looking to implement UART communication with an stm32 microcontroller for a quadruped robot. I have a few questions:
What kind of control bandwidth could I reasonably attain through UART? My control rate on the stm is 1 kHz, would I be able to read the motor position and velocity and send a corresponding command in 1 ms, and if not might I be able to over USB?
Is there an existing workaround to using Arduino.h on non-Arduino microcontrollers? I’m guessing I just need to find an open source copy of the Arduino source code and include it somehow?
I’m curious about this too. The latest firmware has an ‘f’ command that requests motor position and velocity (you send “f 0” for motor zero). Looking on an oscilloscope, it takes about 4ms to return the values, so that may limit your bandwidth unless you find another way.
Sometime ago I tried to do this with a stm32, Arduino for stm32 software, a V3.4 and I encountered lot of bugs. BUT now new things are available.
You can try the binarie librarie maybe faster as said on this topic
You can try to increase the baudrate as did here
On the forum you will can find some topics on the UART.
I am really interested to know your results.
I had some trouble reading two floats in a row in Arduino with the f command. It seems that the odrive_serial.readFloat() cannot be used to parse multiple floats with spaces between them.
I got it to work by changing the ODriveArduino.cpp library readString() function to check for tabs and spaces as well as new lines like this:
if (c == ‘\n’ || c == ‘\t’ || c == ’ ')
Here’s my arduino code that uses it:
odrive_serial << "f " << axis << '\n';
angle_m = odrive.readFloat();
omega_m = odrive.readFloat();
Serial << angle_m << '\t';
Serial << omega_m << '\n';
It works, but I’m not sure if the library change will hurt anything else. Is there a better way? Thanks!