123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488 |
- //
- // File: PmsmSimUt.h
- //
- // Code generated for Simulink model 'PmsmSimUt'.
- //
- // Model version : 1.18
- // Simulink Coder version : 9.4 (R2020b) 29-Jul-2020
- // C/C++ source code generated on : Tue Aug 1 23:42:37 2023
- //
- // Target selection: ert.tlc
- // Embedded hardware selection: Intel->x86-64 (Windows64)
- // Code generation objectives: Unspecified
- // Validation result: Not run
- //
- #ifndef RTW_HEADER_PmsmSimUt_h_
- #define RTW_HEADER_PmsmSimUt_h_
- #include <cfloat>
- #include <cmath>
- #include "rtwtypes.h"
- #include "PmsmSimUt_types.h"
- #include "rt_nonfinite.h"
- #include "rtGetInf.h"
- // Macros for accessing real-time model data structure
- #ifndef rtmGetErrorStatus
- #define rtmGetErrorStatus(rtm) ((rtm)->errorStatus)
- #endif
- #ifndef rtmSetErrorStatus
- #define rtmSetErrorStatus(rtm, val) ((rtm)->errorStatus = (val))
- #endif
- // Class declaration for model PmsmSimUt
- class PmsmSimUtModelClass {
- // public data and function members
- public:
- // Block signals (default storage)
- typedef struct {
- real_T Fcn; // '<S26>/Fcn'
- real_T Fcn1; // '<S26>/Fcn1'
- real_T Fcn_a; // '<S25>/Fcn'
- real_T Fcn1_p; // '<S25>/Fcn1'
- real_T DiscreteTimeIntegrator; // '<S20>/Discrete-Time Integrator'
- real_T Iq_ref; // '<S20>/Saturation2'
- real_T DiscreteTimeIntegrator1; // '<S19>/Discrete-Time Integrator1'
- real_T Fcn_g; // '<S14>/Fcn'
- real_T Fcn1_e; // '<S14>/Fcn1'
- real_T Fcn_b; // '<S13>/Fcn'
- real_T Fcn1_n; // '<S13>/Fcn1'
- } B_PmsmSimUt_T;
- // Block states (default storage) for system '<Root>'
- typedef struct {
- real_T DiscreteTimeIntegrator_DSTATE;// '<S18>/Discrete-Time Integrator'
- real_T DiscreteTimeIntegrator1_DSTATE;// '<S17>/Discrete-Time Integrator1'
- real_T DiscreteTimeIntegrator_DSTATE_c;// '<S17>/Discrete-Time Integrator'
- real_T DiscreteTimeIntegrator_DSTATE_j;// '<S16>/Discrete-Time Integrator'
- real_T DiscreteTimeIntegrator_DSTATE_g;// '<S15>/Discrete-Time Integrator'
- real_T DiscreteTimeIntegrator_DSTATE_n;// '<S20>/Discrete-Time Integrator'
- real_T DiscreteTimeIntegrator1_DSTAT_d;// '<S19>/Discrete-Time Integrator1'
- real_T Memory_PreviousInput; // '<S7>/Memory'
- boolean_T Relay1_Mode; // '<S7>/Relay1'
- boolean_T Relay2_Mode; // '<S7>/Relay2'
- boolean_T Subsystem_MODE; // '<Root>/Subsystem'
- } DW_PmsmSimUt_T;
- // External inputs (root inport signals with default storage)
- typedef struct {
- InputBus CtrlIn; // '<Root>/CtrlIn'
- ObsInputBus ObsIn; // '<Root>/ObsIn'
- ICtrlInputBus ICtrlIn; // '<Root>/ICtrlIn'
- } ExtU_PmsmSimUt_T;
- // External outputs (root outports fed by signals with default storage)
- typedef struct {
- OutputBus Out; // '<Root>/Out'
- } ExtY_PmsmSimUt_T;
- // Parameters (default storage)
- struct P_PmsmSimUt_T {
- struct_tYah6PAnMSQyhFn3I8nH0C Params;// Variable: Params
- // Referenced by:
- // '<Root>/Constant1'
- // '<Root>/Constant2'
- // '<Root>/Constant3'
- // '<Root>/Constant4'
- // '<Root>/Gain1'
- // '<S2>/Constant4'
- // '<S6>/Constant1'
- // '<S6>/Constant2'
- // '<S6>/Constant3'
- // '<S7>/Gain'
- // '<S15>/Gain'
- // '<S15>/Kp4'
- // '<S15>/Kp5'
- // '<S16>/Gain'
- // '<S16>/Kp4'
- // '<S16>/Kp5'
- // '<S17>/Constant'
- // '<S17>/Constant1'
- // '<S17>/Constant2'
- // '<S17>/Constant3'
- // '<S17>/Discrete-Time Integrator'
- // '<S17>/Gain'
- // '<S17>/Gain1'
- // '<S17>/Gain2'
- // '<S18>/Gain'
- // '<S18>/Gain1'
- // '<S20>/Gain'
- // '<S20>/Kp4'
- // '<S20>/Kp5'
- // '<S19>/Constant1'
- // '<S19>/Gain'
- // '<S19>/Gain1'
- real_T AlphaBetaZerotodq0_Alignment;
- // Mask Parameter: AlphaBetaZerotodq0_Alignment
- // Referenced by: '<S1>/Constant'
- real_T AlphaBetaZerotodq0_Alignment_e;
- // Mask Parameter: AlphaBetaZerotodq0_Alignment_e
- // Referenced by: '<S21>/Constant'
- real_T Subsystem_Init; // Mask Parameter: Subsystem_Init
- // Referenced by: '<S20>/Discrete-Time Integrator'
- real_T Subsystem1_Init; // Mask Parameter: Subsystem1_Init
- // Referenced by: '<S16>/Discrete-Time Integrator'
- real_T Subsystem_Init_c; // Mask Parameter: Subsystem_Init_c
- // Referenced by: '<S15>/Discrete-Time Integrator'
- real_T CompareToConstant_const; // Mask Parameter: CompareToConstant_const
- // Referenced by: '<S11>/Constant'
- real_T CompareToConstant1_const; // Mask Parameter: CompareToConstant1_const
- // Referenced by: '<S12>/Constant'
- real_T CompareToConstant_const_a;
- // Mask Parameter: CompareToConstant_const_a
- // Referenced by: '<S23>/Constant'
- real_T CompareToConstant1_const_o;
- // Mask Parameter: CompareToConstant1_const_o
- // Referenced by: '<S24>/Constant'
- real_T dq_Y0[2]; // Expression: [0,0]
- // Referenced by: '<S13>/dq'
- real_T dq_Y0_e[2]; // Expression: [0,0]
- // Referenced by: '<S14>/dq'
- real_T Wm_Y0; // Computed Parameter: Wm_Y0
- // Referenced by: '<S19>/Wm'
- real_T DiscreteTimeIntegrator1_gainval;
- // Computed Parameter: DiscreteTimeIntegrator1_gainval
- // Referenced by: '<S19>/Discrete-Time Integrator1'
- real_T DiscreteTimeIntegrator1_IC; // Expression: 0
- // Referenced by: '<S19>/Discrete-Time Integrator1'
- real_T Gain3_Gain; // Expression: pi/30
- // Referenced by: '<S18>/Gain3'
- real_T Iq_ref_Y0; // Computed Parameter: Iq_ref_Y0
- // Referenced by: '<S5>/Iq_ref'
- real_T DiscreteTimeIntegrator_gainval;
- // Computed Parameter: DiscreteTimeIntegrator_gainval
- // Referenced by: '<S20>/Discrete-Time Integrator'
- real_T DiscreteTimeIntegrator_UpperSat;// Expression: Limits(1)
- // Referenced by: '<S20>/Discrete-Time Integrator'
- real_T DiscreteTimeIntegrator_LowerSat;// Expression: Limits(2)
- // Referenced by: '<S20>/Discrete-Time Integrator'
- real_T Saturation2_UpperSat; // Expression: Limits(1)
- // Referenced by: '<S20>/Saturation2'
- real_T Saturation2_LowerSat; // Expression: Limits(2)
- // Referenced by: '<S20>/Saturation2'
- real_T Constant5_Value; // Expression: 0
- // Referenced by: '<Root>/Constant5'
- real_T Constant6_Value; // Expression: 1
- // Referenced by: '<Root>/Constant6'
- real_T Saturation2_UpperSat_o; // Expression: Limits(1)
- // Referenced by: '<S16>/Saturation2'
- real_T Saturation2_LowerSat_o; // Expression: Limits(2)
- // Referenced by: '<S16>/Saturation2'
- real_T Saturation2_UpperSat_b; // Expression: Limits(1)
- // Referenced by: '<S15>/Saturation2'
- real_T Saturation2_LowerSat_j; // Expression: Limits(2)
- // Referenced by: '<S15>/Saturation2'
- real_T dq_Y0_l[2]; // Expression: [0,0]
- // Referenced by: '<S25>/dq'
- real_T dq_Y0_f[2]; // Expression: [0,0]
- // Referenced by: '<S26>/dq'
- real_T DiscreteTimeIntegrator_gainva_p;
- // Computed Parameter: DiscreteTimeIntegrator_gainva_p
- // Referenced by: '<S18>/Discrete-Time Integrator'
- real_T DiscreteTimeIntegrator_IC; // Expression: 0
- // Referenced by: '<S18>/Discrete-Time Integrator'
- real_T Constant_Value; // Expression: 2*pi
- // Referenced by: '<S18>/Constant'
- real_T DiscreteTimeIntegrator1_gainv_b;
- // Computed Parameter: DiscreteTimeIntegrator1_gainv_b
- // Referenced by: '<S17>/Discrete-Time Integrator1'
- real_T DiscreteTimeIntegrator1_IC_a;// Expression: 0
- // Referenced by: '<S17>/Discrete-Time Integrator1'
- real_T DiscreteTimeIntegrator_gainv_pq;
- // Computed Parameter: DiscreteTimeIntegrator_gainv_pq
- // Referenced by: '<S17>/Discrete-Time Integrator'
- real_T Constant_Value_e; // Expression: 0
- // Referenced by: '<S10>/Constant'
- real_T K1_Gain; // Expression: K1
- // Referenced by: '<S30>/K1'
- real_T K2_Gain; // Expression: K2
- // Referenced by: '<S30>/K2'
- real_T Switch2_Threshold; // Expression: 0
- // Referenced by: '<Root>/Switch2'
- real_T Switch_Threshold; // Expression: 0
- // Referenced by: '<S18>/Switch'
- real_T Switch3_Threshold; // Expression: 0
- // Referenced by: '<Root>/Switch3'
- real_T Gain1_Gain; // Expression: -1
- // Referenced by: '<S6>/Gain1'
- real_T Switch5_Threshold; // Expression: 0
- // Referenced by: '<Root>/Switch5'
- real_T Switch4_Threshold; // Expression: 0
- // Referenced by: '<Root>/Switch4'
- real_T DiscreteTimeIntegrator_gainva_b;
- // Computed Parameter: DiscreteTimeIntegrator_gainva_b
- // Referenced by: '<S16>/Discrete-Time Integrator'
- real_T DiscreteTimeIntegrator_UpperS_b;// Expression: Limits(1)
- // Referenced by: '<S16>/Discrete-Time Integrator'
- real_T DiscreteTimeIntegrator_LowerS_l;// Expression: Limits(2)
- // Referenced by: '<S16>/Discrete-Time Integrator'
- real_T Switch1_Threshold; // Expression: 0
- // Referenced by: '<Root>/Switch1'
- real_T Memory_InitialCondition; // Expression: 0
- // Referenced by: '<S7>/Memory'
- real_T Saturation2_UpperSat_p; // Expression: 10000
- // Referenced by: '<Root>/Saturation2'
- real_T Saturation2_LowerSat_f; // Expression: -10000
- // Referenced by: '<Root>/Saturation2'
- real_T DiscreteTimeIntegrator_gainva_c;
- // Computed Parameter: DiscreteTimeIntegrator_gainva_c
- // Referenced by: '<S15>/Discrete-Time Integrator'
- real_T DiscreteTimeIntegrator_UpperS_k;// Expression: Limits(1)
- // Referenced by: '<S15>/Discrete-Time Integrator'
- real_T DiscreteTimeIntegrator_LowerS_a;// Expression: Limits(2)
- // Referenced by: '<S15>/Discrete-Time Integrator'
- real_T Switch6_Threshold; // Expression: 0
- // Referenced by: '<Root>/Switch6'
- real_T Constant_Value_p; // Expression: 0
- // Referenced by: '<S9>/Constant'
- real_T K1_Gain_j; // Expression: K1
- // Referenced by: '<S28>/K1'
- real_T K2_Gain_b; // Expression: K2
- // Referenced by: '<S28>/K2'
- real_T Gain3_Gain_j[9];
- // Expression: [ 1 -1/2 -1/2; 0 sqrt(3)/2 -sqrt(3)/2; 1/2 1/2 1/2 ]
- // Referenced by: '<S22>/Gain3'
- real_T Gain1_Gain_e; // Expression: 2/3
- // Referenced by: '<S22>/Gain1'
- real_T Gain2_Gain; // Expression: 30/pi
- // Referenced by: '<S18>/Gain2'
- real_T DeadZone_Start; // Expression: -0.01
- // Referenced by: '<S7>/Dead Zone'
- real_T DeadZone_End; // Expression: 0.01
- // Referenced by: '<S7>/Dead Zone'
- real_T Relay1_OnVal; // Expression: 0.1
- // Referenced by: '<S7>/Relay1'
- real_T Relay1_OffVal; // Expression: 0
- // Referenced by: '<S7>/Relay1'
- real_T Relay1_YOn; // Expression: 1000
- // Referenced by: '<S7>/Relay1'
- real_T Relay1_YOff; // Expression: 0
- // Referenced by: '<S7>/Relay1'
- real_T Relay2_OnVal; // Expression: 0
- // Referenced by: '<S7>/Relay2'
- real_T Relay2_OffVal; // Expression: -0.1
- // Referenced by: '<S7>/Relay2'
- real_T Relay2_YOn; // Expression: 0
- // Referenced by: '<S7>/Relay2'
- real_T Relay2_YOff; // Expression: -1000
- // Referenced by: '<S7>/Relay2'
- uint8_T ManualSwitch1_CurrentSetting;
- // Computed Parameter: ManualSwitch1_CurrentSetting
- // Referenced by: '<Root>/Manual Switch1'
- };
- // Real-time Model Data Structure
- struct RT_MODEL_PmsmSimUt_T {
- const char_T * volatile errorStatus;
- };
- // Tunable parameters
- static P_PmsmSimUt_T PmsmSimUt_P;
- // External inputs
- ExtU_PmsmSimUt_T PmsmSimUt_U;
- // External outputs
- ExtY_PmsmSimUt_T PmsmSimUt_Y;
- // model initialize function
- void initialize();
- // model event function
- void PmsmSimUt_reset();
- // model step function
- void step();
- // model terminate function
- void terminate();
- // Constructor
- PmsmSimUtModelClass();
- // Destructor
- ~PmsmSimUtModelClass();
- // Block parameters get method
- const PmsmSimUtModelClass::P_PmsmSimUt_T & getBlockParameters() const
- {
- return PmsmSimUt_P;
- }
- // Block parameters set method
- void setBlockParameters(const P_PmsmSimUt_T *pPmsmSimUt_P)
- {
- PmsmSimUt_P = *pPmsmSimUt_P;
- }
- // Root-level structure-based inputs set method
- // Root inports set method
- void setExternalInputs(const ExtU_PmsmSimUt_T* pExtU_PmsmSimUt_T)
- {
- PmsmSimUt_U = *pExtU_PmsmSimUt_T;
- }
- // Root-level structure-based outputs get method
- // Root outports get method
- const PmsmSimUtModelClass::ExtY_PmsmSimUt_T & getExternalOutputs() const
- {
- return PmsmSimUt_Y;
- }
- // Real-Time Model get method
- PmsmSimUtModelClass::RT_MODEL_PmsmSimUt_T * getRTM();
- // private data and function members
- private:
- // Block signals
- B_PmsmSimUt_T PmsmSimUt_B;
- // Block states
- DW_PmsmSimUt_T PmsmSimUt_DW;
- // Real-Time Model
- RT_MODEL_PmsmSimUt_T PmsmSimUt_M;
- };
- //-
- // These blocks were eliminated from the model due to optimizations:
- //
- // Block '<Root>/Constant' : Unused code path elimination
- // Block '<S17>/Scope' : Unused code path elimination
- // Block '<S17>/Scope1' : Unused code path elimination
- // Block '<S18>/Scope' : Unused code path elimination
- // Block '<Root>/Scope' : Unused code path elimination
- // Block '<Root>/Scope1' : Unused code path elimination
- // Block '<Root>/Scope3' : Unused code path elimination
- // Block '<Root>/Scope4' : Unused code path elimination
- // Block '<Root>/Scope5' : Unused code path elimination
- //-
- // The generated code includes comments that allow you to trace directly
- // back to the appropriate location in the model. The basic format
- // is <system>/block_name, where system is the system number (uniquely
- // assigned by Simulink) and block_name is the name of the block.
- //
- // Use the MATLAB hilite_system command to trace the generated code back
- // to the model. For example,
- //
- // hilite_system('<S3>') - opens system 3
- // hilite_system('<S3>/Kp') - opens and selects block Kp which resides in S3
- //
- // Here is the system hierarchy for this model
- //
- // '<Root>' : 'PmsmSimUt'
- // '<S1>' : 'PmsmSimUt/Alpha-Beta-Zero to dq0'
- // '<S2>' : 'PmsmSimUt/Initialize Function'
- // '<S3>' : 'PmsmSimUt/PI Controller'
- // '<S4>' : 'PmsmSimUt/PM_Motor in dq frame '
- // '<S5>' : 'PmsmSimUt/Subsystem'
- // '<S6>' : 'PmsmSimUt/Subsystem1'
- // '<S7>' : 'PmsmSimUt/Subsystem2'
- // '<S8>' : 'PmsmSimUt/abc to dq0'
- // '<S9>' : 'PmsmSimUt/dq to abc'
- // '<S10>' : 'PmsmSimUt/dq to abc1'
- // '<S11>' : 'PmsmSimUt/Alpha-Beta-Zero to dq0/Compare To Constant'
- // '<S12>' : 'PmsmSimUt/Alpha-Beta-Zero to dq0/Compare To Constant1'
- // '<S13>' : 'PmsmSimUt/Alpha-Beta-Zero to dq0/Subsystem - pi//2 delay'
- // '<S14>' : 'PmsmSimUt/Alpha-Beta-Zero to dq0/Subsystem1'
- // '<S15>' : 'PmsmSimUt/PI Controller/Subsystem'
- // '<S16>' : 'PmsmSimUt/PI Controller/Subsystem1'
- // '<S17>' : 'PmsmSimUt/PM_Motor in dq frame /Electrical Modelling'
- // '<S18>' : 'PmsmSimUt/PM_Motor in dq frame /Mechanical Modelling'
- // '<S19>' : 'PmsmSimUt/PM_Motor in dq frame /Mechanical Modelling/Subsystem'
- // '<S20>' : 'PmsmSimUt/Subsystem/Subsystem'
- // '<S21>' : 'PmsmSimUt/abc to dq0/Alpha-Beta-Zero to dq0'
- // '<S22>' : 'PmsmSimUt/abc to dq0/abc to Alpha-Beta-Zero'
- // '<S23>' : 'PmsmSimUt/abc to dq0/Alpha-Beta-Zero to dq0/Compare To Constant'
- // '<S24>' : 'PmsmSimUt/abc to dq0/Alpha-Beta-Zero to dq0/Compare To Constant1'
- // '<S25>' : 'PmsmSimUt/abc to dq0/Alpha-Beta-Zero to dq0/Subsystem - pi//2 delay'
- // '<S26>' : 'PmsmSimUt/abc to dq0/Alpha-Beta-Zero to dq0/Subsystem1'
- // '<S27>' : 'PmsmSimUt/dq to abc/An_Park'
- // '<S28>' : 'PmsmSimUt/dq to abc/Inverse Clarke Transform2'
- // '<S29>' : 'PmsmSimUt/dq to abc1/An_Park'
- // '<S30>' : 'PmsmSimUt/dq to abc1/Inverse Clarke Transform2'
- #endif // RTW_HEADER_PmsmSimUt_h_
- //
- // File trailer for generated code.
- //
- // [EOF]
- //
|