Problem with Update Methode in S-Function Builder (R2006B)

Hey,
I've modeled a really simple function in Simulink (Version 6.5) which contains a "Unit Delay" block. After that I used Real Time Workshop (Version 6.5) to build C-Code from my model. All I want to do now, is to include my C-Code back with a S-Function builder.
My Problem is, that I don't know where to put the update-methode. If I include the update methode in the Outputs-pane of the S-Function Builder, I get a segmentation fault. If I manually insert the code contained in the Update Function (Funktion_DWork.UnitDelay1_DSTATE = Funktion_B.Add1;), everything is fine.
So my basic question is, where to put the update-methode, to update my Unit-Delay blocks?
The generated Update Funktion looks like this:
/* Model update function */
static void Funktion_update(int_T tid)
{
/* Update for UnitDelay: '<Root>/Unit Delay1' */
Funktion_DWork.UnitDelay1_DSTATE = Funktion_B.Add1;
/* Update absolute time for base rate */
if (!(++Funktion_M->Timing.clockTick0))
++Funktion_M->Timing.clockTickH0;
Funktion_M->Timing.t[0] = Funktion_M->Timing.clockTick0 *
Funktion_M->Timing.stepSize0 + Funktion_M->Timing.clockTickH0 *
Funktion_M->Timing.stepSize0 * 4294967296.0;
UNUSED_PARAMETER(tid);
}
Edit: I just found out, that the lower part after "/* Update absolute time for base rate */" causes the segmentation fault.

 采纳的回答

Meh found the solution! :) I had to call another initialze function first. I somehow missed that.

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Modeling 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by