123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- /*
- * var.c
- *
- * Created on: 2023Äê5ÔÂ17ÈÕ
- * Author: wangd
- */
- #include "var.h" // DSP2803x Examples Include File
- #ifndef TRUE
- #define FALSE 0
- #define TRUE 1
- #endif
- union FAULTFLAG_UNI FaultFlag;
- Uint16 DCbus_voltage=0;
- Uint32 IsrTime = 0;
- _iq test =0;
- int16 test2 =0;
- int16 Tmotor = 0;
- PI_CONTROLLER pid1_idc = PI_CONTROLLER_DEFAULTS;
- PI_CONTROLLER pid1_spd = PI_CONTROLLER_DEFAULTS;
- RMPCNTL rc1 = RMPCNTL_DEFAULTS;
- int32 pwmlimit = 32768;
- _iq SpeedRef=_IQ(0.0);//³õʼËÙ¶È
- int16 Direction = 1;
- _iq BemfA=0;
- _iq BemfB=0;
- _iq BemfC=0;
- _iq Iphase=0;
- _iq DC_current_real = 0;
- _iq DC_current_filer = 0;
- int32 DC_current_avr = 0;
- int32 DC_current_filter_avr = 0;
- int16 Tvot = 0;
- _iq CurrentSet = _IQ(0.0);
- Uint16 Fault_clear = 0;
- int32 XintTime = 60000000;
- volatile Uint16 EnableFlag = FALSE;
- void InitVar(void){
- FaultFlag.all = 0;
- // Initialize the PI module for dc-bus current
- pid1_idc.Kp = _IQ(0.05);
- pid1_idc.Ki = _IQ(0.0002);
- pid1_idc.Umax = _IQ((float)pwmlimit/32767);
- pid1_idc.Umin = _IQ((float)(-pwmlimit)/32767);
- // Initialize the PI module for speed
- pid1_spd.Kp = _IQ(1.0);
- pid1_spd.Ki = 360;//_IQ(0.0002);
- pid1_spd.Umax = _IQ(1.0);
- pid1_spd.Umin = _IQ(0.0);
- // Initialize RMPCNTL module
- rc1.RampDelayMax = 5;
- rc1.RampLowLimit = _IQ(-1.0);
- rc1.RampHighLimit = _IQ(1.0);
- }
- void FaultTreat(void){
- OverVoltage();
- OverMotorRpm();
- OverMotCtrTemp();
- }
- void OverVoltage(void)
- {
- static int16 i = 0;
- static int16 j = 0;
- if (DCbus_voltage >= 360)
- {
- i = 20000;
- FaultFlag.bit.OverVolFlag = 1;
- }
- else if (DCbus_voltage <= 200) //80
- {
- j = 10000;
- FaultFlag.bit.LowVolFlag = 1;
- }
- else
- {
- if (FaultFlag.bit.OverVolFlag == 1)
- {
- i--;
- if (i <= 0)
- {
- i = 0;
- FaultFlag.bit.OverVolFlag = 0;
- }
- }
- else
- {
- i = 0;
- }
- if (FaultFlag.bit.LowVolFlag == 1)
- {
- j--;
- if (j <= 0)
- {
- j = 0;
- FaultFlag.bit.LowVolFlag = 0;
- }
- }
- else
- {
- j = 0;
- }
- }
- }
- void OverMotorRpm(void)
- {
- if (speed1.BaseRpm >= 3800)
- {
- FaultFlag.bit.OverRpmFlag = 1;
- }
- else if (speed1.BaseRpm < 100)
- {
- FaultFlag.bit.OverRpmFlag = 0;
- }
- }
- void OverMotCtrTemp(void)
- {
- if (Tmotor >= 85)
- {
- FaultFlag.bit.OverMotTempFlag = 1;
- }
- else if (Tmotor < 50)
- {
- FaultFlag.bit.OverMotTempFlag = 0;
- }
- if (Tvot >= 85)
- {
- FaultFlag.bit.IgbtTempFaultFlag = 1;
- }
- else if (Tvot < 50)
- {
- FaultFlag.bit.IgbtTempFaultFlag = 0;
- }
- }
|