var.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*
  2. * var.h
  3. *
  4. * Created on: 2023Äê5ÔÂ17ÈÕ
  5. * Author: wangd
  6. */
  7. #ifndef USERSOURCE_VAR_H_
  8. #define USERSOURCE_VAR_H_
  9. #include "IQmathLib.h"
  10. #include "DSP2803x_Device.h" // DSP2803x Headerfile Include File
  11. #include "pi.h" // Include header for the PIDREG3 object
  12. #include "speed_pr.h" // Include header for the SPEED_MEAS_REV object
  13. #include "rmp_cntl.h" // Include header for the RMPCNTL object
  14. #include "f2803xbldcpwmstruct.h"
  15. #include "f2803xhall_gpio_struct.h" // Include header for the HALL object
  16. #ifndef DSP28_DATA_TYPES
  17. #define DSP28_DATA_TYPES
  18. typedef int int16;
  19. typedef long int32;
  20. typedef unsigned int Uint16;
  21. typedef unsigned long Uint32;
  22. typedef float float32;
  23. typedef long double float64;
  24. #endif
  25. #define SOFTCURlIMIT 8 //A
  26. #define MAINLOOPRATE 8 //Khz
  27. #define MAINLOOPTIME 125 //US
  28. #define VOLTAGEUP 350 //V
  29. #define VOLTAGELOW 200 //V
  30. #define SPEEDUP 3800 //RPM
  31. #define MOTORTEMPLIMIT 70 //
  32. #define MOTORTEMPOVER 90 //
  33. #define IGBTTEMPOVER 70 //
  34. #define MAINLOOPFREQ 8000
  35. struct FAULTFLAG_STR
  36. {
  37. Uint16 OverMotTempFlag:1;
  38. Uint16 IgbtTempFaultFlag:1;
  39. Uint16 LowVolFlag:1;
  40. Uint16 SoftOverCurFlag:1;
  41. Uint16 LimitMotTempFlag:1;
  42. Uint16 rsv1:3;
  43. Uint16 OverVolFlag:1;
  44. Uint16 CanErrFlag:1;
  45. Uint16 OverCurFlag:1;
  46. Uint16 Ipmfault:1;
  47. Uint16 OverRpmFlag:1;
  48. Uint16 HallFlag:1;
  49. Uint16 rsv2:3;
  50. };
  51. union FAULTFLAG_UNI
  52. {
  53. Uint16 all;
  54. struct FAULTFLAG_STR bit;
  55. };
  56. extern union FAULTFLAG_UNI FaultFlag;
  57. extern Uint32 IsrTime;
  58. extern _iq test ;
  59. extern int16 test2;
  60. extern int16 test3;
  61. extern int16 test4;
  62. extern int16 Tmotor;
  63. extern PI_CONTROLLER pid1_idc;
  64. extern PI_CONTROLLER pid1_spd;
  65. extern RMPCNTL rc1;
  66. extern PWMGEN pwm1;
  67. extern SPEED_MEAS_CAP speed1;
  68. extern HALL3 hall1;
  69. extern int32 pwmlimit;
  70. extern _iq SpeedRef;
  71. extern int16 Direction;
  72. extern _iq BemfA;
  73. extern _iq BemfB;
  74. extern _iq BemfC;
  75. extern _iq Iphase;
  76. extern Uint16 DCbus_voltage;
  77. extern _iq12 DC_current_real ;
  78. extern _iq DC_current_filer;
  79. extern int16 Tvot ;
  80. extern int16 Tmotor ;
  81. extern _iq CurrentSet;
  82. extern int32 DC_current_avr;
  83. extern int32 DC_current_filter_avr;
  84. extern Uint16 Fault_clear;
  85. extern int32 XintTime;
  86. extern int16 t4;
  87. extern volatile Uint16 EnableFlag;
  88. extern volatile Uint16 Enable_ALLOW;
  89. extern void InitVar(void);
  90. extern void OverVoltage(void);
  91. extern void FaultTreat(void);
  92. extern void OverMotCtrTemp(void);
  93. extern void OverMotorRpm(void);
  94. extern void OpenPwm(void);
  95. extern void Fault_clear_fuc(void);
  96. extern int16 LimitMotCtrTemp(int32 period);
  97. extern void SoftOverCurFlag(void);
  98. extern void speed_cal_filter(void);
  99. extern void carveData2();
  100. #endif /* USERSOURCE_VAR_H_ */