Effacer les filtres
Effacer les filtres

How do I translate an ARDUINO IDE Code to Simulink blocks?

6 vues (au cours des 30 derniers jours)
Nathan Miguel
Nathan Miguel le 24 Mar 2024
Réponse apportée : Suman le 20 Juin 2024
We are required to program an Arduino using simulink blocks as part of a university requirement.
It wasn't really taught to us in-depth, and most resources I was able to find didn't go deeper than programming an LED light to blink.
I did install the Arduino support package and I've finished coding using Tinkercad and was wondering how do I translate this to simulink. External resources are appreciated.
How it works is there are 3 buttons which I'll refer to as Button 1,2,3 from left -> right.
It starts by pressing Button 3 which acts as a start/restart button. The red flashing LED indicates that the board is ready to receive further instructions.
Button 2 is pressed for a period of time to represent the dots and dashes, holding the button for 200ms or less indicates a dot, and pressing for more than that represents a dash. A buzzer gives feedback indicating the button is being pressed.
Button 1 is pressed after you've set the character using button 2 to appear on the I2C.
After being idle for 3 seconds, a the yellow LED lights up indicating that the next character will have a space before it.
Other features include skipping to the next line once 16 characters in inputted and resetting after 32 characters are inputted.
The code is taken from https://www.hackster.io/492608/morse-code-converter-bec9a9 which I optimized due to some problems, e.g. spaces inputting at incorrect time, double spacing, ending the line in a space requires a reset.
I'll be sure to answer any questions you might have. Thank you in advance.

Réponses (1)

Suman
Suman le 20 Juin 2024
Hi Nathan,
It is not possible to automatically convert Arduino code to an equivalent Simulink model. You need to take a manual approach. As per my understanding the goal here to to create a Simulink model that interacts with Arduino in the same way the code does.
To do that, you can utilize the blocks provided by the Simulink Support Package for Arduino Hardware as well as the common Simulink blocks to implement the logic equalvalent to the Arduino code.
Please go through these examples to see how Simulink is used to interact with Arduino hardwares:

Produits

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by