In the following repository [1], you can find the steps to create a real-time environment. Principally, the host computer will be used for control implementations at 10 Hz of loop-rate, while the Arduino is used only as an IO server (or a data acquisition device). Officially, in MATLAB Simulink, this is known as the “Connected IO”. Visit [2] for more information on the “Connected IO in MATLAB” topic.

Besides using MATLAB Simulink, another alternative is to use LabVIEW with LINX libraries [3]. Another more advanced alternative is to make your own firmware implementation such that you can use C/C++ or Python in the host computer. There are off-the-shelf firmware available, such as pyFirmata [4] for Python. However, a self-made firmware is also possible since basically we only need to do two things: 1) read from two ADC channels and 2) write to two digital ports that have PWM capabilities.

References:

[1] https://github.com/auralius/soft-rt-simulink-arduino

[2] https://www.mathworks.com/help/supportpkg/arduino/ug/connected-io.html

[3] https://www.labviewmakerhub.com/doku.php?id=libraries:linx:start

[4] https://github.com/tino/pyFirmata

Normal priority:

Untitled

Realtime priority:

Untitled