How to create custom blocks in Simulink for Arduino
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Hi, My name is Samanth, I want to create my own custom blocks like the servo motor write and read in simulink. I want to use these custom blocks in Arduino microcontroller boards.
I have already tried this stuff and I am getting linkage errors so, I just want to check whether I am doing the things properly. So, I am requesting you guys to help me find some references which would explain the procedure step-by-step.
I am thinking that I am doing some mistake in the parameters pane part (Which appears by double clicking the S-Function builder).
I was doing like this
I have placed the following part under Libraries pane #ifndef MATLAB_MEX_FILE #include "Arduino.h" #include "Servo.h" #endif
I have seen some reference material and placed #if condition if I have removed it I am getting errors as
C:\Users\Nani\Desktop\samanth\simulonk models\avr/pgmspace.h(211) : error C2061: syntax error : identifier '__attribute__'
I have not modified anything in the header file which was in Arduino package.
Under the outputs pane I have kept the code as follows
if(xD[0]==1) { /*don't do anything for MEX-file generation*/ #ifdef MATLAB_MEX_FILE
//Custom code #endif }
I have followed a site to place the #if condition at the top.
Under the Discreete update pane I have kept the code as follows
if(xD[0]!=1) { #ifdef MATLAB_MEX_FILE // Custom code
#endif }
Can anyone correct me if I am doing wrong please.
Any step by step reference would be a lot helpful.
Thank you for the help in advance.
1 comentario
Kaustubha Govind
el 1 de Mayo de 2013
I pointed to some resources on your other question: http://www.mathworks.com/matlabcentral/answers/73598-which-compiler-should-i-use-to-create-custom-blocks-which-i-intend-to-build-in-to-arduino-microcontr
Respuestas (2)
Ryan G
el 2 de Mayo de 2013
When creating a custom block for the first time I would recommend something simple like making the LED blink so you know you're doing it right.
0 comentarios
Mohith Prabhu
el 21 de Mayo de 2021
Refer the below documentation links for creating a custom Simulink Device Driver block using Arduino library.
• Create Custom Device Driver Block for Arduino Library
• Create a device driver block to access specific features of your hardware board
0 comentarios
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!