var.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. #define PIXHAWK 1
  17. //#define DEBUG_CAN 1
  18. #define ESC_NUMBER 0x08
  19. #define SPEEDCLOSED 1
  20. //#define MOTORLEFT 1
  21. #ifndef DSP28_DATA_TYPES
  22. #define DSP28_DATA_TYPES
  23. typedef int int16;
  24. typedef long int32;
  25. typedef unsigned int Uint16;
  26. typedef unsigned long Uint32;
  27. typedef float float32;
  28. typedef long double float64;
  29. #endif
  30. #define SOFTCURlIMIT 8 //A
  31. #define MAINLOOPRATE 8 //Khz
  32. #define MAINLOOPTIME 125 //US
  33. #define VOLTAGEUP 370 //V
  34. #define VOLTAGELOW 250 //V
  35. #define SPEEDUP 4200 //RPM
  36. #define MOTORTEMPLIMIT 70 //
  37. #define MOTORTEMPOVER 85 //
  38. #define IGBTTEMPOVER 65 //
  39. #define MAINLOOPFREQ 8000
  40. struct FAULTFLAG_STR
  41. {
  42. Uint16 OverMotTempFlag:1;
  43. Uint16 IgbtTempFaultFlag:1;
  44. Uint16 LowVolFlag:1;
  45. Uint16 SoftOverCurFlag:1;
  46. Uint16 LimitMotTempFlag:1;
  47. Uint16 rsv1:3;
  48. Uint16 OverVolFlag:1;
  49. Uint16 CanErrFlag:1;
  50. Uint16 OverCurFlag:1;
  51. Uint16 Ipmfault:1;
  52. Uint16 OverRpmFlag:1;
  53. Uint16 HallFlag:1;
  54. Uint16 rsv2:2;
  55. };
  56. union FAULTFLAG_UNI
  57. {
  58. Uint16 all;
  59. struct FAULTFLAG_STR bit;
  60. };
  61. extern union FAULTFLAG_UNI FaultFlag;
  62. extern int16 PwmSet ;
  63. extern Uint32 startuptimer;
  64. extern Uint32 IsrTime;
  65. extern _iq test ;
  66. extern int16 test2;
  67. extern int16 test3;
  68. extern int16 test4;
  69. extern int16 test5;
  70. extern int16 test7;
  71. extern int16 Tmotor;
  72. extern PI_CONTROLLER pid1_idc;
  73. extern PI_CONTROLLER pid1_spd;
  74. extern RMPCNTL rc1;
  75. extern PWMGEN pwm1;
  76. extern SPEED_MEAS_CAP speed1;
  77. extern HALL3 hall1;
  78. extern int32 pwmlimit;
  79. extern _iq SpeedRef;
  80. extern int16 Direction;
  81. extern _iq BemfA;
  82. extern _iq BemfB;
  83. extern _iq BemfC;
  84. extern _iq Iphase;
  85. extern Uint16 DCbus_voltage;
  86. extern _iq12 DC_current_real ;
  87. extern _iq DC_current_filer;
  88. extern int16 Tvot ;
  89. extern int16 Tmotor ;
  90. extern _iq CurrentSet;
  91. extern int32 DC_current_avr;
  92. extern int32 DC_current_filter_avr;
  93. extern Uint16 Fault_clear;
  94. extern int32 XintTime;
  95. extern int16 t4;
  96. extern volatile Uint16 EnableFlag;
  97. extern volatile Uint16 Enable_ALLOW;
  98. extern void InitVar(void);
  99. extern void OverVoltage(void);
  100. extern void FaultTreat(void);
  101. extern void OverMotCtrTemp(void);
  102. extern void OverMotorRpm(void);
  103. extern void OpenPwm(void);
  104. extern void Fault_clear_fuc(void);
  105. extern int16 LimitMotCtrTemp(int32 period);
  106. extern void SoftOverCurFlag(void);
  107. extern void speed_cal_filter(void);
  108. extern void carveData2();
  109. #endif /* USERSOURCE_VAR_H_ */