Sample time C-function Call
Sample time C-function Call
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
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
-
- Site Admin - Expert
- Posts: 616
- Joined: Wed Mar 07, 2007 11:23 pm
- Location: Bayonne- France
- Contact:
Re: Sample time C-function Call
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
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
Re: Sample time C-function Call
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
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 1413 times
-
- Site Admin - Expert
- Posts: 616
- Joined: Wed Mar 07, 2007 11:23 pm
- Location: Bayonne- France
- Contact:
Re: Sample time C-function Call
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
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
Re: Sample time C-function Call
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".
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".
Re: Sample time C-function Call
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 ... -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.
http://www.kxcad.net/cae_MATLAB/toolbox ... -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.
Re: Sample time C-function Call
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).
Who is online
Users browsing this forum: No registered users and 12 guests