Hello everyone.
For the context of this topic, I am robotics software engineer, used to “high level” software on linux (with lot of CPU, memory, threads, etc).
I am developping a sensor+actuators board with a STM32H7 as main controller.
The STM32 has to read a dozen of sensors (on I2C, UART, analog), send data and received orders @50Hz from a computer, and has to write on a SD Card + update PWM + write on UART.
Each sensor has a different refresh time, some sensors push data, some sensors has to be triggered (for instance trigger ADC, wait, read), each sensor has a different refresh rate (from 1 to 500 Hz).
Actuator loop has to be as real-time as possible @ 50Hz (to update PWM outputs + send UART command).
As I said previously, my past experiences directed me to mbed as this framework is simple and easy to use (for me at least), and the few tests I have done with some sensors are successful.
So I may have newbie questions, but I want to have pointers or answers on this points, based on your embedded developpers skill exeperience that I don’t have (yet). I think my 'high level" linux developper approach is not the good one here.
-
Since there are a lot of sensors, is a multithread approach can be considered ? (Like 1 thread per task or per refresh rate?)
-
If I have one single loop, reading each sensors when it’s time, it means that all functions calls have to return as fast as possible (+non blocking call). A lot of sensors drivers I have tested have sleep times in them (for instance: trigger ADC read, wait 1ms, read result), which is not possible in that case. What are the good practices here ?
-
I will have a lot of TX UART to stream all data to a computer periodically. I can not block the main thread with that. Is there a UART TX-queue or send buffer or something like this on mbed ? If I have to do this myself, is a thread the good solution ?
Thank you !