Hi all, I'm experimenting the Arduino programming using Simulink.
I want to build custom blocks to entirely program my boards with Simulink.
So I'm trying to build an S-Function block and I've done this with success to create a blinking led (simple example to start with).
Now I have some question because I don't find anything useful with google.
How can I write blocks to use only for Serial purposes (for example Serial.print(), Serial.available(), etc..)? I'm growing mad on how to do that so I'll appreciate some help!
Is there a possibility to have serial monitor (or similar) on Simulink?
In my block I've done something like this.
This under Libraries-> Includes:
# ifndef MATLAB_MEX_FILE
# include <Arduino.h>
# endif
This under Discrete Updates (I've 1 state that update itself from 0 to 1, this is for initialization purposes):
I know how to insert code for the voidSetup() and for the voidLoop() using those formats but I don't know how to use Serial functions.
For specific functions like Servo functions I suppose I have to just include the Servo.h library under the Libraries->Includes tab.
I freely admit that I know nothing about Simulink but your examples look just as complicated as writing or using the functions directly on the Arduino. What is the advantage of using Simulink ?
UKHeliBob:
I freely admit that I know nothing about Simulink but your examples look just as complicated as writing or using the functions directly on the Arduino. What is the advantage of using Simulink ?
I've to build a more complicated project which involve integrals and derivatives and many more.
We are four engineering students and everyone has to build a part of the code, doing this in Simulink is a better and easy way to do this.
Using Matlab and Simulink is the best way to do complicated mathematical operations and Simulink is more intuitive to build big algorithms.
Throw away the difficult to use crutch and write some functions, or even a library, for the Arduino. There are literally millions more people that can give help on writing C++ for the Arduino than the number able to provide help with using Simulink.
What is it exactly that you want the program to do ?
UKHeliBob:
Throw away the difficult to use crutch and write some functions, or even a library, for the Arduino. There are literally millions more people that can give help on writing C++ for the Arduino than the number able to provide help with using Simulink.
What is it exactly that you want the program to do ?
Well, I would be able to view a serial monitor trough Simulink as I can do with the Arduino IDE and I would be able to make blocks for every part of code I want to write.
Everyone of us has to write a part of the code, using simulink block makes easier to put code parts together!
We have to build an autonomous vehicle so we have to write a differential model, and many sensors interfaces. I can't be more precise at the moment because we are still thinking on how to write the code.