How can I integrate the Arduino C++ Library files trough custom code setting and invoke the functions from the State flow states?
My questions are mainly addressed to someone who has experience with integration of Arduino into the Matlab/Simulink environment. I think explaining the entire situation would take huge volume.
The Arduino libraries partially are integrated into the Matlab/Simulink Arduino Support Package.
Only using of digital I/Os and analog inputs.
If you use only the premade elements you can make model in Simulink, simulate, build and download to Arduino directly similar to Arduino IDE .
So principally the code making and building works well in that tool chain too.
My aim is to expand the possibilities of that feature.
I found that the custom code integration trough the Simulink/Stateflow seems a convenient way:
The procedure called C / C++ Code Generation and Integration in State flow.
There are examples in State flow help with similar names. Here are the links.
As I said it works well with premade elements, but as I attempted to extended the model with invoking Arduino function from StateFlow chart I’ve got serious obstacles always.
There are two main direction of the attempts.
- Making wrapper function and using C coding.
- Using C++ codes directly
The failures have two main streams too ( loox to be independent to compiler settings).
- The build process mixed the C and C++ expressions but called the C compiler. Obvious, it is unavoidable at final compiling of the executable. The process stops with tons of unresolved symbol errors
- The build process mixed the AVR includes with the Visual Studio default includes and stops with tons of "duplicate definition" error
Finally I couldn’t get a status to have usable C source for building downloadable executable.
Every hint would help and welcomed.
If there would be an ultimate and mystic definition what solve it
#define ARDUINO IDKFA
or something like that.
In exchange I could worked out a very simple method to integrate all the Arduino functions into Simulink for the Arduino world. If Gods allow it.
Thanks in advance!
Arduino MEGA 2560
Matlab R215a With support package “Run models on ArduinoUno, Mega 2560,… ” Ver: 15.1.1
Visual Studio 2013 and/or SDK 7.1