I want to use Simulink to create programs for Arduino Uno hardware. But I would like to use existing libraries, like liquidcrystal, to handle output to an LCD display. How can I create an s-function that incorporates the liquidcrystal class file?
I think the s-function is the way to go, because the existing Simulink Arduino library blocks are actually s-functions that are masked. I am using the Simulink student version so I don't think I can compile C code from a model and incorporate it into a project in the Arduino IDE.
I'll turn my comment into an answer ... :)
Okay so to create a program from Simulink you'll need code generation tools installed. ver
will tell you if you have Simulink Coder, and optionally Embedded Coder. If you're using an older version of MATLAB then it's called Real-time Workshop. Without one of those you're not going to be code-generating anything.
So assuming you can code-generate:
S-functions are they way to go: http://www.mathworks.co.uk/help/simulink/s-function-basics.html
... although there are various tools to assist with creating S-functions.
In short, the process is:
All of those steps can be expanded on a lot. The process is a bit of a haul the first time, but you'll learn a lot about S-functions, the model.RTW file, TLC and debugging all of the above.
Oh yes, debugging the S-function can be a ball-acher. Be prepared to use something like visual studio to "attach" to the matlab process to debug it.
Rich
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With