├── Inverter with Deadtime model └── SVPWM_deadtime系列.slx ├── README.md ├── TI_offical_Anti-windup_for_PI regulator_code ├── pid_reg3.h └── pid_reg3.pdf └── TI_offical_sliding model observer_code ├── smopos.h └── smopos.pdf /Inverter with Deadtime model/SVPWM_deadtime系列.slx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Seanxinyuan/Resources/b9551a5b2b39a2f5bcb2411bb4bfc2e589367d93/Inverter with Deadtime model/SVPWM_deadtime系列.slx -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Resources 2 | The model for the related motor control issues 3 | * Add TI offical code for sliding mode oberver and PI regulator with anti-windup 4 | * Add Inverter with deadtime model 5 | 6 | I will push more codes here in the near future. 7 | -------------------------------------------------------------------------------- /TI_offical_Anti-windup_for_PI regulator_code/pid_reg3.h: -------------------------------------------------------------------------------- 1 | /* ================================================================================= 2 | File name: PID_REG3.H (IQ version) 3 | 4 | Originator: Digital Control Systems Group 5 | Texas Instruments 6 | 7 | Description: 8 | Header file containing constants, data type, and macro definitions for the PIDREG3. 9 | ===================================================================================== 10 | History: 11 | ------------------------------------------------------------------------------------- 12 | 10-15-2009 Version 1.0 13 | ------------------------------------------------------------------------------*/ 14 | #ifndef __PIDREG3_H__ 15 | #define __PIDREG3_H__ 16 | 17 | typedef struct { _iq Ref; // Input: Reference input 18 | _iq Fdb; // Input: Feedback input 19 | _iq Err; // Variable: Error 20 | _iq Kp; // Parameter: Proportional gain 21 | _iq Up; // Variable: Proportional output 22 | _iq Ui; // Variable: Integral output 23 | _iq Ud; // Variable: Derivative output 24 | _iq OutPreSat; // Variable: Pre-saturated output 25 | _iq OutMax; // Parameter: Maximum output 26 | _iq OutMin; // Parameter: Minimum output 27 | _iq Out; // Output: PID output 28 | _iq SatErr; // Variable: Saturated difference 29 | _iq Ki; // Parameter: Integral gain 30 | _iq Kc; // Parameter: Integral correction gain 31 | _iq Kd; // Parameter: Derivative gain 32 | _iq Up1; // History: Previous proportional output 33 | } PIDREG3; 34 | 35 | typedef PIDREG3 *PIDREG3_handle; 36 | /*----------------------------------------------------------------------------- 37 | Default initalizer for the PIDREG3 object. 38 | -----------------------------------------------------------------------------*/ 39 | #define PIDREG3_DEFAULTS { 0, \ 40 | 0, \ 41 | 0, \ 42 | _IQ(1.3), \ 43 | 0, \ 44 | 0, \ 45 | 0, \ 46 | 0, \ 47 | _IQ(1), \ 48 | _IQ(-1), \ 49 | 0, \ 50 | 0, \ 51 | _IQ(0.02), \ 52 | _IQ(0.5), \ 53 | _IQ(1.05), \ 54 | 0, \ 55 | } 56 | 57 | /*------------------------------------------------------------------------------ 58 | PID Macro Definition 59 | ------------------------------------------------------------------------------*/ 60 | 61 | 62 | #define PID_MACRO(v) \ 63 | v.Err = v.Ref - v.Fdb; /* Compute the error */ \ 64 | v.Up= _IQmpy(v.Kp,v.Err); /* Compute the proportional output */ \ 65 | v.Ui= v.Ui + _IQmpy(v.Ki,v.Up) + _IQmpy(v.Kc,v.SatErr); /* Compute the integral output */ \ 66 | v.OutPreSat= v.Up + v.Ui; /* Compute the pre-saturated output */ \ 67 | v.Out = _IQsat(v.OutPreSat, v.OutMax, v.OutMin); /* Saturate the output */ \ 68 | v.SatErr = v.Out - v.OutPreSat; /* Compute the saturate difference */ \ 69 | v.Up1 = v.Up; /* Update the previous proportional output */ 70 | #endif // __PIDREG3_H__ 71 | 72 | // Add the lines below if derivative output is needed following the integral update 73 | // v.Ud = _IQmpy(v.Kd,(v.Up - v.Up1)); 74 | // v.OutPreSat = v.Up + v.Ui + v.Ud; 75 | -------------------------------------------------------------------------------- /TI_offical_Anti-windup_for_PI regulator_code/pid_reg3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Seanxinyuan/Resources/b9551a5b2b39a2f5bcb2411bb4bfc2e589367d93/TI_offical_Anti-windup_for_PI regulator_code/pid_reg3.pdf -------------------------------------------------------------------------------- /TI_offical_sliding model observer_code/smopos.h: -------------------------------------------------------------------------------- 1 | /* ================================================================================= 2 | File name: SMOPOS.H (IQ version) 3 | 4 | Originator: Digital Control Systems Group 5 | Texas Instruments 6 | 7 | Description: 8 | Header file containing constants, data type definitions, and 9 | function prototypes for the SMOPOS. 10 | ==================================================================================== 11 | History: 12 | ------------------------------------------------------------------------------------- 13 | 04-15-2010 Version 1.1 14 | ------------------------------------------------------------------------------*/ 15 | 16 | typedef struct { _iq Valpha; // Input: Stationary alfa-axis stator voltage 17 | _iq Ealpha; // Variable: Stationary alfa-axis back EMF 18 | _iq Zalpha; // Output: Stationary alfa-axis sliding control 19 | _iq Gsmopos; // Parameter: Motor dependent control gain 20 | _iq EstIalpha; // Variable: Estimated stationary alfa-axis stator current 21 | _iq Fsmopos; // Parameter: Motor dependent plant matrix 22 | _iq Vbeta; // Input: Stationary beta-axis stator voltage 23 | _iq Ebeta; // Variable: Stationary beta-axis back EMF 24 | _iq Zbeta; // Output: Stationary beta-axis sliding control 25 | _iq EstIbeta; // Variable: Estimated stationary beta-axis stator current 26 | _iq Ialpha; // Input: Stationary alfa-axis stator current 27 | _iq IalphaError; // Variable: Stationary alfa-axis current error 28 | _iq Kslide; // Parameter: Sliding control gain 29 | _iq Ibeta; // Input: Stationary beta-axis stator current 30 | _iq IbetaError; // Variable: Stationary beta-axis current error 31 | _iq Kslf; // Parameter: Sliding control filter gain 32 | _iq Theta; // Output: Compensated rotor angle 33 | 34 | } SMOPOS; 35 | 36 | typedef SMOPOS *SMOPOS_handle; 37 | /*----------------------------------------------------------------------------- 38 | Default initalizer for the SMOPOS object. 39 | -----------------------------------------------------------------------------*/ 40 | #define SMOPOS_DEFAULTS { 0,0,0,0,0,0,0,0,0,0, \ 41 | 0,0,0,0,0,0,0, \ 42 | } 43 | 44 | /*------------------------------------------------------------------------------ 45 | Prototypes for the functions in SMOPOS.C 46 | ------------------------------------------------------------------------------*/ 47 | 48 | _iq E0 =_IQ(0.5); 49 | _iq invE0=_IQ(2.0); 50 | 51 | #define SMO_MACRO(v) \ 52 | \ 53 | /* Sliding mode current observer */ \ 54 | v.EstIalpha = _IQmpy(v.Fsmopos,v.EstIalpha) + _IQmpy(v.Gsmopos,(v.Valpha-v.Ealpha-v.Zalpha)); \ 55 | v.EstIbeta = _IQmpy(v.Fsmopos,v.EstIbeta) + _IQmpy(v.Gsmopos,(v.Vbeta-v.Ebeta-v.Zbeta)); \ 56 | \ 57 | /* Current errors */ \ 58 | v.IalphaError = v.EstIalpha - v.Ialpha; \ 59 | v.IbetaError= v.EstIbeta - v.Ibeta; \ 60 | \ 61 | /* Sliding control calculator */ \ 62 | if (_IQabs(v.IalphaError) < E0) \ 63 | v.Zalpha = _IQmpy(v.Kslide,_IQmpy2(v.IalphaError)); /* (v.Kslide*(v.IalphaError)/E0) */ \ 64 | else if (v.IalphaError >= E0) \ 65 | v.Zalpha = v.Kslide; \ 66 | else if (v.IalphaError <= -E0) \ 67 | v.Zalpha = -v.Kslide; \ 68 | if (_IQabs(v.IbetaError) < E0) \ 69 | v.Zbeta = _IQmpy(v.Kslide,_IQmpy2(v.IbetaError)); /* (v.Kslide*(v.IbetaError)/E0) */ \ 70 | else if (v.IbetaError >= E0) \ 71 | v.Zbeta = v.Kslide; \ 72 | else if (v.IbetaError <= -E0) \ 73 | v.Zbeta = -v.Kslide; \ 74 | \ 75 | /* Sliding control filter -> back EMF calculator */ \ 76 | v.Ealpha = v.Ealpha + _IQmpy(v.Kslf,(v.Zalpha-v.Ealpha)); \ 77 | v.Ebeta = v.Ebeta + _IQmpy(v.Kslf,(v.Zbeta-v.Ebeta)); \ 78 | \ 79 | /* Rotor angle calculator -> Theta = atan(-Ealpha,Ebeta) */ \ 80 | v.Theta = _IQatan2PU(-v.Ealpha,v.Ebeta); 81 | 82 | -------------------------------------------------------------------------------- /TI_offical_sliding model observer_code/smopos.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Seanxinyuan/Resources/b9551a5b2b39a2f5bcb2411bb4bfc2e589367d93/TI_offical_sliding model observer_code/smopos.pdf --------------------------------------------------------------------------------