Page 1 of 1

how to use custom c source code

Posted: Thu Jan 05, 2012 9:59 pm
by resodad
Hi Lubin,
The help for the c function call block says:
"The .c file containing the code of the function should be placed in the same directory as the .mdl file. If the c file is in another directory, it must be manually added in the "Simulation Parameters -> Real time workshop -> additional C file"
Can you please clear this up for me?
instead of "Simulation Parameters -> Real time workshop -> additional C file"
what would be the effect of putting the name of the c file in "Simulation Target > Custom Code > include custom c code in generated > source file?"
thanks,
John

Re: how to use custom c source code

Posted: Thu Jan 12, 2012 10:36 am
by LubinKerhuel
Hi John,

I couldn't find "Simulation Parameters -> Real time workshop -> additional C file" on matlab 2011b.
The help file seems not up to date (or I write something wrong, anyway, I think this comes from an older matlab version...)

The correct place to add the file is the one you provided. Please do not hesitates to update directly the wiki help page when you noticed this kind of remarks.

Lubin

Re: how to use custom c source code

Posted: Thu Jan 12, 2012 2:39 pm
by resodad
Hi Lubin,
The attached screen image shows the configuration parameters and where I enter the names of the custom c files. Instead of "Simulation Target" they might also go under "Code Generation." Please verify--do I have it right? Does it work just as well to put the file names under"Code Generation?" Regards, John

Re: how to use custom c source code

Posted: Thu Jan 12, 2012 3:17 pm
by LubinKerhuel
Hi John,

That's not correct.
File reference must be included into "Include list of additional". Otherwise, simulink will just add the name on the file within the generated code, that would create an error!

Then, the files should be included into the Code Generation panel. Not the Simulation Target (did not notice this earlier)

Lubin

Re: how to use custom c source code

Posted: Thu Jan 12, 2012 4:34 pm
by resodad
Like this?

Re: how to use custom c source code

Posted: Thu Jan 12, 2012 5:59 pm
by LubinKerhuel
Correct.
you might also add the folder where they are in the "include directory" box if the compiler did not find theses files.

Lubin

Re: how to use custom c source code

Posted: Sat Jan 14, 2012 6:30 pm
by salemimoh
Lubin,
I imagine this does not work with the demo version does it.

Re: how to use custom c source code

Posted: Sat Jan 14, 2012 9:02 pm
by LubinKerhuel
It works with the demo version or at least it should work ;-)

Re: how to use custom c source code

Posted: Mon Jan 16, 2012 3:48 pm
by resodad
Lubin,
LubinKerhuel wrote:Correct.
you might also add the folder where they are in the "include directory" box if the compiler did not find theses files.

Lubin
Like this? I ask because this produces an error (see my other post about GenericTypeDefs.h)
John

Re: how to use custom c source code

Posted: Wed Jan 18, 2012 9:26 pm
by LubinKerhuel
See the other post