C function call

Post Reply
kevin1025
Posts: 1
Joined: Fri Oct 05, 2007 7:47 am

C function call

Post by kevin1025 » Mon Oct 08, 2007 3:43 am

Hi,
I have a problem about "C funtion call".I don't know how to add the .c file.Can you explain more?
Thanks.

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

Post by LubinKerhuel » Wed Oct 10, 2007 9:24 pm

My advice is to place the c file in the same directory as your mdl file.

You must add the C file in
Simulation >> Configuration Parameters >> Custom Code >> include directory >> type the directory of your mdl file.

and

Simulation >> Configuration Parameters >> Custom Code >> Sources files >> type the filename : something.c

I will post an example soon.

Note however that this block is not functionnal in the evaluation version of the toolbox.

jebobrow
Posts: 6
Joined: Fri Feb 29, 2008 7:01 pm

Re: C function call

Post by jebobrow » Mon May 19, 2008 3:27 am

I can't make the c function call work. Did you ever make further instructions or an example on this?

I made the two changes you suggested in this thread: 1) added the source code name to the configuration parameters, and I put it in the same directory that my mdl file is 2) I tried to add the path to the include directories, but it did not seem to like what I put in there. It was "C:\Documents and Settings\Jim\My Documents\PicMicro\InvertedPendulum_3030" but matlab complained about that. It did not complain as much when I removed that, but I get the error below



pic30-coff-cc1.exe: warning: Options have been disabled due to expired license
test2.c:31: error: syntax error before '.' token
gmake: *** [test2.o] Error 255
### Real-Time Workshop build procedure for model: 'test2' aborted due to an error.

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

Re: C function call

Post by LubinKerhuel » Mon May 19, 2008 6:15 pm

Hi,

Up to now, some bugs were reported about the C call function

One bug appears when using C Function Call with one input and No output.
Most of these bugs are now fixed and will be released very soon in the next version (0.98)
Anyway, it may greatly help if you could upload on the forum a simple example (mdl + c files).

If the c file is in your model directory, you do not need to add the path of the c file.
Note anyway that any path you provide must be in the format "8.3" (old dos format with ~1 or ~x at the end of long directory name.
The matlab instruction rtw_alt_pathname('C:\Program files\zzz\...') convert a long name to its 8.3 name.
(but you should not need that)

Few thread about C function Call and with some examples:

Implementing the C Function Call
Passing a Vector to the C-Function Call block
C Function Call error for output size != 1
How much RAM area can a program use?


Lubin

jebobrow
Posts: 6
Joined: Fri Feb 29, 2008 7:01 pm

Re: C function call

Post by jebobrow » Fri May 23, 2008 5:23 pm

Your QEI example solved my problem. I put my source code file name in the wrong box in the "custom code" configuration paramters. I had originally placed it in "Include custom c code in generated" instead of "Include list of addional" where it worked fine. Strange.

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 13 guests