Protect.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #ifndef __Protect_H_
  2. #define __Protect_H_
  3. #include <Myproject.h>
  4. typedef enum
  5. {
  6. FaultNoSource = 0, // 无故障
  7. FaultHardOVCurrent = 1, // 硬件过流
  8. FaultSoftOVCurrent = 2, // 软件过流
  9. FaultUnderVoltage = 3, // 欠压保护
  10. FaultOverVoltage = 4, // 过压保护
  11. FaultLossPhase = 5, // 缺相保护
  12. FaultStall = 6, // 堵转保护
  13. FaultStart = 7, // 启动保护
  14. FaultIpmTemp = 9, // IPM温度保护
  15. FaultIbusOffset = 11, // pianzhi
  16. FaultshuruLoss = 14,
  17. } FaultStateType;
  18. typedef struct
  19. {
  20. uint16 SecondStartTimes; // 二次启动保护的次数
  21. uint16 StallTimes; // 堵转保护次数
  22. uint16 LossPHTimes; // 缺相保护次数
  23. uint16 CurrentPretectTimes; // 过流保护次数
  24. uint8 StartFlag; // 启动保护的标志位,用于判断哪个方法起作用
  25. uint8 StallFlag; // 堵转保护的标志位,用于判断哪个方法起作用
  26. uint8 IbusOffsetProtectTimes; //偏执电压保护次数
  27. uint8 shurulossTimes;
  28. }ProtectVarible;
  29. typedef struct
  30. {
  31. uint8 segment; // 分段执行
  32. //voltage protect
  33. uint16 OverVoltDetecCnt; // 过压检测计数
  34. uint16 UnderVoltDetecCnt; // 欠压检测计数
  35. uint16 VoltRecoverCnt; // 过压恢复计数
  36. uint16 OverTempDetecCnt; // 过温检测计数
  37. uint16 OverHuantempDetecCnt; // 过温检测计数
  38. uint16 OverGuantempDetecCnt; // 过温检测计数
  39. uint16 TempRecoverCnt; // 过温恢复计数
  40. uint16 HuantempRecoverCnt; // 过温恢复计数
  41. uint16 GuantempRecoverCnt; // 过温恢复计数
  42. uint32 CurrentRecoverCnt; // 过流保护恢复计数
  43. uint8 IbusOffsetRecoverCnt; ///偏执电压保护恢复次数
  44. //stall protect
  45. uint16 StallDelayCnt; // 堵转延迟判断计时
  46. uint16 StallDectEs; // method 1,与ES相关
  47. uint16 StallDectEs2; // method 1,与ES相关
  48. uint16 StallDectSpeed; // method 2,与速度相关
  49. uint32 StallReCount; // 堵转保护恢复计数
  50. //Loss Phase protect
  51. uint16 Lphasecnt; // 缺相保护计时
  52. uint16 AOpencnt ; // A缺相计数
  53. uint16 BOpencnt ; // B缺相计数
  54. uint16 COpencnt ; // C缺相计数
  55. uint16 mcLossPHRecCount; // 缺相恢复计数
  56. uint16 shurulossRecCount; // 缺相恢复计数
  57. int16 shurulossCnt;
  58. int32 CurrentASum;
  59. int32 CurrentBSum;
  60. int32 CurrentCSum;
  61. int16 CurrentAAlign;
  62. int16 CurrentBAlign;
  63. int16 CurrentCAlign;
  64. //start protect
  65. int16 StartESCount; // 启动保护判断ES的计数
  66. int16 StartEsCnt; // 启动保护判断ES的计时
  67. int16 StartDelay; // 启动保护判断ES的延迟
  68. int16 StartFocmode; // 启动保护判断FOCMODE状态的计时
  69. int16 StartSpeedCnt; // 启动保护判断速度和ES的计时
  70. uint32 commu_time;
  71. }FaultVarible;
  72. extern FaultStateType xdata mcFaultSource;
  73. extern ProtectVarible xdata mcProtectTime;
  74. extern FaultVarible idata mcFaultDect;
  75. extern void Fault_OverUnderVoltage(void);
  76. extern void Fault_Overcurrent(void);
  77. extern void Fault_OverCurrentRecover(void);
  78. extern void Fault_Stall(void);
  79. extern void Fault_phaseloss(void);
  80. extern void Fault_IPMOverTemp(void);
  81. extern void PFCFault_OverUnderVoltage(void);
  82. extern void PFCFault_Overcurrent(void);
  83. extern void Fault_Detection(void);
  84. extern void PFCFault_Detection(void);
  85. #endif