Sample time C-function Call

Create new topics, add your comment, remark, bugs...
catia
Posts: 2
Joined: Thu Aug 13, 2009 2:54 am

Sample time C-function Call

Postby catia » Thu Sep 10, 2009 2:48 am

Hi Lubin,

I currently use the C function call blockset as initialization, I would like to know what i have to put for the sample time for this blockset to be called only once. I have tried with 'inf' but it seems to call this blockset at every cycle.

Cathia

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

Re: Sample time C-function Call

Postby LubinKerhuel » Thu Sep 10, 2009 10:51 am

Hi Cathia,

C function call is only working on registred version of the blockset.
Thus, check that you have a registred version (are you working in ASU team that use a registred version ?)
Else, you may be using the blockset build (or copied !) by Microchip.

Anyway, inf time should activate the block only once at initialization. Else, you could use a triggered subsystem and place the c call function block inside this subsystem. (There are few examples like that on the forum).

It may help to get the mdl file. Could you post it ?

Lubin

catia
Posts: 2
Joined: Thu Aug 13, 2009 2:54 am

Re: Sample time C-function Call

Postby catia » Thu Sep 10, 2009 11:24 pm

Hi Lubin,

I am working in an ASU laboratory. So i must have the right version. Maybe i made a mistaske somewhere else, that would be why i have the impression to initialize at every cycle.

Cathia
Attachments
ecan2essai.mdl
(74.31 KiB) Downloaded 190 times

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

Re: Sample time C-function Call

Postby LubinKerhuel » Fri Sep 11, 2009 8:23 am

Hi Cathia,

Could not compile to test (no c files attached).
However, you could try this :

in Simulation ==> Configuration Parameters ==> Optimization (left) ==> Check box Inline parameters.

Tips : You may have a better view of what's happening with : Format ==> Sample Time Display ==> Color
(update then the diagram, with or without the Optimization checked).

This should works fine, however, if you prefere, you might use triggered subsystem with a step or so on... (browse the forum for examples)

Let me know...

another Tip : Simulink has binary shift blocks and you should rather use them instead of the Embedded MATLAB Function (which probably makes theses calculation with double data type ? this should be checked )

If you are working on the ECAN peripheral (as your model's name suggest), it may be very useful to post results provided you have the rights to do so...

Lubin

coolj
Posts: 16
Joined: Mon Nov 29, 2010 7:31 pm

Re: Sample time C-function Call

Postby coolj » Fri Jan 21, 2011 6:10 pm

Hi Lubin,

I had a similar issue with version 3.4b of your blockset. My inf time functions that were supposed to run only once were being called every time step.

Once I enabled Simulation -> Configuration -> Optimization -> Inline parameters, the inf-time initialization C functions were correctly called only once.

Might want to add to the documentation, along with "inf" allowing for "run once".

coolj
Posts: 16
Joined: Mon Nov 29, 2010 7:31 pm

Re: Sample time C-function Call

Postby coolj » Mon Jan 24, 2011 3:34 am

Here is some background for inline parameters needing to be enabled to prevent inf-time functions from being called every time step.

http://www.kxcad.net/cae_MATLAB/toolbox/simulink/ug/f7-9753.html

inf

The meaning of this sample time depends on whether the active model configuration's inline parameters optimization (see Inline parameters) is enabled.

If the inline parameters optimization is enabled, inf signifies that the block's output can never change (see Constant Sample Time). This speeds up simulation and the generated code by eliminating the need to recompute the block's output at each time step. If the inline parameters optimization is disabled or the block with inf sample time drives an output port of a conditionally executed subsystem, Simulink treats inf as -1, i.e., as inherited sample time. This allows you to tune the block's parameters during simulation.

jannypan
Posts: 3
Joined: Sat Mar 05, 2011 7:05 am

Re: Sample time C-function Call

Postby jannypan » Sat Mar 05, 2011 7:07 am

Anyway, inf time should activate the block only once at initialization. Else, you could use a triggered subsystem and place the c call function block inside this subsystem. (There are few examples like that on the forum).


Return to “General Remark and Questions”

Who is online

Users browsing this forum: No registered users and 1 guest