Rank: 454031 based on 0 downloads (last 30 days) and 0 file submitted
photo

uavc

E-mail

Personal Profile:
Professional Interests:

 

Watch this Author's files

 

Comments and Ratings by uavc View all
Updated File Comments Rating
23 Mar 2014 Device Drivers Developing Simulink Device Driver Blocks: Step-By-Step Guide and Examples Author: Giampiero Campa

In case anyone wanted to compare the Output Driver S-Function Block to Arduino code, here is the arduino code:

#include <Arduino.h>

int xD[0];
int pin[] = {12};
int in[0];

void setup()
{
//xD[0]=0;
if (xD[0]!=1) {

/* don't do anything for MEX-file generation */
pinMode(pin[0],OUTPUT);

/* initialization done */
xD[0]=1;
}
}

void loop()
{
/* wait until after initialization is done */
if (xD[0]==1) {

/* don't do anything for mex file generation */
digitalWrite(pin[0],in[0]);
}
}

24 Nov 2013 Device Drivers Developing Simulink Device Driver Blocks: Step-By-Step Guide and Examples Author: Giampiero Campa

23 Nov 2013 Device Drivers Developing Simulink Device Driver Blocks: Step-By-Step Guide and Examples Author: Giampiero Campa

found the problem. the libraries I had to include in the simulink s-function builder was

# ifndef MATLAB_MEX_FILE
# include <Arduino.h>
# endif

in that order. I accidentally put the second line first as I thought these were just regular includes, without recognizing that the include was running an if loop (ifndef.... end if) to check:

#ifndef

The #ifndef operator checks whether something has not been defined using the #define keyword. It must be followed by#endif.

Problem solved. XD

22 Nov 2013 Device Drivers Developing Simulink Device Driver Blocks: Step-By-Step Guide and Examples Author: Giampiero Campa

SITUATION:

I'm trying to build the output block according to the tutorial. I'm sure this is a basic question but I couldn't quite build the S-function.

EXACT ERROR:

sfcn_exout_slsp_wrapper.c
c:\docs\avr/io.h(330) : fatal error C1021: invalid preprocessor command 'warning'

C:\PROGRA~1\MATLAB\R2013A\BIN\MEX.PL: Error: Compile of 'sfcn_exout_slsp_wrapper.c' failed.

EXPLANATION IN DETAIL:

I had earlier problems that the s-function builder wasn't compiling because it couldn't find Arduino.h, inttypes.h avr/io.h, avr/pgmspace.h, avr/sfr_defs

Arduino.h is the only .h file that is called directly from the s-function builder library so I guess the other files are being called by Arduino.h etc. I included the entire path of the Arduino library on the stock c:\program files(x86) directory but it didn't compile still. Hence, I just copied the whole folder into my working directory, still wouldn't work. What made it work was that I had to copy every single .h file (mentioned above) into the working directory (the answer to MATLAB command "pwd") before it would compile and then it led to this error above. I think it's an include error, so how do I ask the s-function builder to look everywhere within my working directory (which is especially important for the avr/xxx.h files.

any idea how to solve it? thanks!

Contact us