#define MDL_CHECK_PARAMETERS
/* Function: mdlCheckParameters =============================================
* Abstract:
* Validate our parameters to verify they are okay.
*/
static void mdlCheckParameters(SimStruct *S) { }
/* Function: mdlInitializeSizes ===============================================
* Abstract:
* The sizes information is used by Simulink to determine the S-function
* block's characteristics (number of inputs, outputs, states, etc.).
*/
static void mdlInitializeSizes(SimStruct *S) {
ssSetNumSFcnParams(S, 1); /* Number of expected parameters */
if(ssGetNumSFcnParams(S) == ssGetSFcnParamsCount(S)){
mdlCheckParameters(S);
if(ssGetErrorStatus(S) != NULL)return;
}else{ return; // Parameter mismatch will be reported by Simulink
}
// setall1 parameter(s) as not tunable
ssSetSFcnParamTunable(S, 0 ,0); //
#define MDL_UPDATE
/* Function: mdlUpdate ========================================================
* Abstract:
* This functionis called once for every major integration time step.
* Discrete states are typically updated here, but this functionis useful
* for performing any tasks that should only take place once per integration
* step.
*/
static void mdlUpdate(SimStruct *S, int_T tid) {
real_T *x = ssGetRealDiscStates(S);
InputRealPtrsType uPtrs = ssGetInputPortRealSignalPtrs(S,0);
// time to latch new duty and modulus
if(TimeHit_index == 0){
DiskState_Modulus = (real_T)((uint16_T)Inp_Modulus);
DiskState_PwmVal = (real_T)((uint16_T)Inp_PwmVal);
if((Inp_PwmVal < 0) || (Inp_Modulus < 0)){
ssSetErrorStatus(S,"sfunc_pmf.c/mdlUpdate(): Input(s) Reload and CmpVal must be > 0!\n");
} }
/* Function: mdlTerminate =====================================================
* Abstract:
* No termination needed, but we are required to have this routine.
*/
static void mdlTerminate(SimStruct *S) { }
#ifdef MATLAB_MEX_FILE /* Is this file being compiled as a MEX-file? */
#include "simulink.c" /* MEX-file interface mechanism */
#else
#include "cg_sfun.h" /* Code generation registration function */
#endif
Man muss die global-variable mit Work-vektor realisieren.
Einstellungen und Berechtigungen
Du kannst Beiträge in dieses Forum schreiben. Du kannst auf Beiträge in diesem Forum antworten. Du kannst deine Beiträge in diesem Forum nicht bearbeiten. Du kannst deine Beiträge in diesem Forum nicht löschen. Du kannst an Umfragen in diesem Forum nicht mitmachen. Du kannst Dateien in diesem Forum posten Du kannst Dateien in diesem Forum herunterladen
MATLAB, Simulink, Stateflow, Handle Graphics, Real-Time Workshop, SimBiology, SimHydraulics, SimEvents, and xPC TargetBox are registered trademarks and The MathWorks, the L-shaped membrane logo, and Embedded MATLAB are trademarks of The MathWorks, Inc.