LabVIEW Control Design and Simulation Module

EMI_CB_CalculateZeroCrossingSignals (EMI Function)

  • Updated2023-03-14
  • 1 minute(s) read

EMI_CB_CalculateZeroCrossingSignals (EMI Function)

Owning Class: Callbacks

Requires: Control Design and Simulation Module

Prototype

void EMI_CB_CalculateZeroCrossingSignals(emiRef model);

Description

Calculates the signals you want the ordinary differential equation (ODE) solver to monitor for zero crossings. You must define and export this function if the external model has any zero crossings.

If you use a variable step-size ODE solver, the solver attempts to use a step size that straddles the time of the zero crossing. If a zero crossing occurs, the LabVIEW Control Design and Simulation Module calls the EMI_CB_CalculateResetStates function to calculate the values to which to reset the continuous states.

Examples

Inputs

Name Description
model Specifies a reference to the external model. Use this reference as an input to other EMI functions. Do not modify model directly.

Examples

void EMI_CB_CalculateZeroCrossingSignals(emiRef model) {
   double* zc = EMI_GetZeroCrossingSignals(model);
   const double* xc = EMI_GetContinuousStates(model);

   /* check whether a zero crossing occurs for the first signal */
   zc[0] = xc[0];
}

Refer to the EMI_BouncingBall example, accessible by navigating to the labview\examples\Control and Simulation\Simulation\External Model Interface\EMI_BouncingBall\Source directory and opening EMI_BouncingBall.c, for a detailed example of how to handle zero crossings.

Related Topics

EMI_CB_CalculateResetStates
EMI_GetZeroCrossingOffsets
EMI_GetZeroCrossingSignals
EMI_GetZeroCrossingTriggers