how to use custom c source code

Create new topics, add your comment, remark, bugs...
resodad
Posts: 71
Joined: Tue Jul 07, 2009 1:06 pm
Location: West Point, New York

how to use custom c source code

Postby resodad » Thu Jan 05, 2012 9:59 pm

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

LubinKerhuel
Site Admin - Expert
Posts: 616
Joined: Wed Mar 07, 2007 11:23 pm
Location: Marseille - France
Contact:

Re: how to use custom c source code

Postby LubinKerhuel » Thu Jan 12, 2012 10:36 am

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

resodad
Posts: 71
Joined: Tue Jul 07, 2009 1:06 pm
Location: West Point, New York

Re: how to use custom c source code

Postby resodad » Thu Jan 12, 2012 2:39 pm

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
Attachments
configScreen.jpg
configScreen.jpg (56.88 KiB) Viewed 4463 times

LubinKerhuel
Site Admin - Expert
Posts: 616
Joined: Wed Mar 07, 2007 11:23 pm
Location: Marseille - France
Contact:

Re: how to use custom c source code

Postby LubinKerhuel » Thu Jan 12, 2012 3:17 pm

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

resodad
Posts: 71
Joined: Tue Jul 07, 2009 1:06 pm
Location: West Point, New York

Re: how to use custom c source code

Postby resodad » Thu Jan 12, 2012 4:34 pm

Like this?
Attachments
configScreen2.jpg
configScreen2.jpg (53.68 KiB) Viewed 4462 times

LubinKerhuel
Site Admin - Expert
Posts: 616
Joined: Wed Mar 07, 2007 11:23 pm
Location: Marseille - France
Contact:

Re: how to use custom c source code

Postby LubinKerhuel » Thu Jan 12, 2012 5:59 pm

Correct.
you might also add the folder where they are in the "include directory" box if the compiler did not find theses files.

Lubin

salemimoh
Posts: 23
Joined: Tue Apr 08, 2008 1:01 pm

Re: how to use custom c source code

Postby salemimoh » Sat Jan 14, 2012 6:30 pm

Lubin,
I imagine this does not work with the demo version does it.

LubinKerhuel
Site Admin - Expert
Posts: 616
Joined: Wed Mar 07, 2007 11:23 pm
Location: Marseille - France
Contact:

Re: how to use custom c source code

Postby LubinKerhuel » Sat Jan 14, 2012 9:02 pm

It works with the demo version or at least it should work ;-)

resodad
Posts: 71
Joined: Tue Jul 07, 2009 1:06 pm
Location: West Point, New York

Re: how to use custom c source code

Postby resodad » Mon Jan 16, 2012 3:48 pm

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
Attachments
configInclude.jpg

LubinKerhuel
Site Admin - Expert
Posts: 616
Joined: Wed Mar 07, 2007 11:23 pm
Location: Marseille - France
Contact:

Re: how to use custom c source code

Postby LubinKerhuel » Wed Jan 18, 2012 9:26 pm

See the other post


Return to “General Remark and Questions”

Who is online

Users browsing this forum: No registered users and 2 guests