LabVIEW Control Design and Simulation Module

EMI_CB_CalculateDiscreteStates (EMI Function)

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

EMI_CB_CalculateDiscreteStates (EMI Function)

Owning Class: Callbacks

Requires: Control Design and Simulation Module

Prototype

void EMI_CB_CalculateDiscreteStates(emiRef model);

Description

Calculates the next discrete states of an external model. You must define and export this function if the model has a non-zero discrete sample period.

The LabVIEW Control Design and Simulation Module calls this function only on discrete time steps. Use the EMI_SetDiscretePeriod and EMI_SetDiscreteSkew functions to determine the discrete time steps.

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_ModelInterface(emiRef model) {
   EMI_AddScalarInput(model, "Input");
   EMI_SetNumberOfDiscreteStates(model, 1);
   EMI_SetDiscretePeriod(model, 1.0);
   EMI_SetDiscreteSkew(model, 0.0);
}

void EMI_CB_CalculateDiscreteStates(emiRef model) {
   double* nextDiscreteStates = EMI_GetNextDiscreteStates(model);
   const double* discreteStates = EMI_GetDiscreteStates(model);
   const double* input = EMI_GetInput(model, 0);
   nextDiscreteStates[0] = discreteStates[0] + input[0];
}

Related Topics

EMI_GetDiscreteStates
EMI_GetNextDiscreteStates
EMI_SetDiscretePeriod
EMI_SetDiscreteSkew

Log in to get a better experience