soft_poweramp.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. #ifndef SOFT_POWERAMP_H
  2. #define SOFT_POWERAMP_H
  3. #include "stdint.h"
  4. #include "stdbool.h"
  5. #include "common.h"
  6. ///////////////////
  7. #define POWERAMP_CRC8_KEY (0x2A)
  8. /*
  9. Number Item Data Index Remark
  10. 1 电池总电压 Data[0-1] unsigned int, 16bits, mV,Range: 0 – 60000mV
  11. 2 充放电电流 Data[2-3] signed int, 16bits, 10mA
  12. Range: – 300000 to 80000mA
  13. Positive for charging
  14. Negative for discharging.
  15. 3 Max allowable charging current
  16. Data[4-5] signed int, 16bits, 10mA
  17. Range: – 300000 to 80000mA
  18. Positive for charging
  19. Negative for discharging.
  20. Remark:
  21. If communicating with UAV, this value
  22. will be 0.
  23. 4 最大电芯温度 Data[6-7] signed int, 16bits, 0.1 Degree C, range: -40 to 125 degree C
  24. 5 最小电芯温度 Data[8-9] signed int, 16bits, 0.1 Degree C, range: -40 to 125 degree C
  25. 6 相对充电状态 Data[10-11] unsigned int, 16bits, 0.1% 0 to 1000 (0 to 1000‰)
  26. 7 绝对充电状态 Data[12-13] unsigned int, 16bits, 0.1% 0 to 1000 (0 to 1000‰)
  27. 8 剩余容量 Data[14-15] unsigned int, 16bits, mAH 0 mA to 20000 mAH
  28. 9 最大电芯压差 Data[16-17] unsigned int, 16bits, mV, 0mV to 1000mV
  29. 10 Cell 1 电压 Data[18-19] unsigned int, 16bits, mV 0 to 4500mV
  30. 11 Cell 2 电压 Data[20-21] unsigned int, 16bits, mV 0 to 4500mV
  31. 12 Cell 3 电压 Data[22-23] unsigned int, 16bits, mV 0 to 4500mV
  32. 13 Cell 4 电压 Data[24-25] unsigned int, 16bits, mV 0 to 4500mV
  33. 14 Cell 5 电压 Data[26-27] unsigned int, 16bits, mV 0 to 4500mV
  34. 15 Cell 6 电压 Data[28-29] unsigned int, 16bits, mV 0 to 4500mV
  35. 16 Cell 7 电压 Data[30-31] unsigned int, 16bits, mV 0 to 4500mV
  36. 17 Cell 8 电压 Data[32-33] unsigned int, 16bits, mV 0 to 4500mV
  37. 18 Cell 9 电压 Data[34-35] unsigned int, 16bits, mV 0 to 4500mV
  38. 19 Cell 10 电压 Data[36-37] unsigned int, 16bits, mV 0 to 4500mV
  39. 20 Cell 11 电压 Data[38-39] unsigned int, 16bits, mV 0 to 4500mV
  40. 21 Cell 12 电压 Data[40-41] unsigned int, 16bits, mV 0 to 4500mV
  41. 22 Cell 13 电压 Data[42-43] unsigned int, 16bits, mV 0 to 4500mV
  42. 23 Warning level Data[44-45] Unsigned char, 8 bits,
  43. Value:
  44. 0: no warning
  45. 1: level 1 warning, UAV shall return
  46. 2: level 2 warning, UAV shall land
  47. 24 系统状态 Data[46-47] unsigned int, 16 bits
  48. Permanent Fault Alarm:
  49. Bit0: 1:电芯压差大, 0: 正常
  50. Bit1: 1:循环寿命结束, 0: 正常
  51. Bit2: 1:电芯温度高, 0: 正常
  52. Bit3: 1:其他失效, 0: 正常
  53. Cell Fault Alarm:
  54. Bit4: 1: 电芯压差较大, 0: 正常
  55. Discharging Alarm:
  56. Bit5: 1:电池放电过温, 0: 正常
  57. Bit6: 1:电池放电低温, 0: 正常
  58. Bit7, Bit8: 放电低压告警
  59. value: 0: 正常
  60. value: 1: level 1, 电芯电压 3.4V 或
  61. SOC 30%, See Spec for details.
  62. value: 2: level 2, 电芯电压 3.0V 或
  63. SOC 20%, See Spec for details.
  64. value: 3: level 3, 电芯电压 2.8V 或
  65. SOC 10%, See Spec for details.
  66. Bit9: 1:放电过流, 0: 正常
  67. Charging Alarm:
  68. Bit10: 1:充电过温, 0: 正常
  69. Bit11: 1:充电低温, 0: 正常
  70. Bit12: 1:充电过压, 0: 正常
  71. Bit13: 1:充电过流, 0: 正常
  72. Bit14: 1:充电满, 0: 正常
  73. Remark:
  74. For charger: when BMS encounters
  75. the Charging Alarm or Cell fault
  76. alarm, BMS will turn off the charging
  77. MOSFET to stop charging.For UAV: when BMS encounters the
  78. Discharging Alarm or Cell fault alarm
  79. (UAV not in operation), BMS will turn
  80. off the discharging MOSFET.
  81. */
  82. #pragma pack(1)
  83. typedef struct
  84. {
  85. short amp_data[24]; //
  86. }_POWERAMP_INF;
  87. #pragma pack()
  88. extern _POWERAMP_INF poweramp_inf;
  89. /*
  90. Number Item Data Index Remark
  91. 1 软件版本号 Data[0-1] unsigned char, 2 bytes.
  92. Data[0]: major version
  93. Data[1]: minor version
  94. e.g.: v02.60, Data [0]=2, Data[1]=60
  95. 2 硬件版本号 Data[2-3] unsigned char, 2 bytes.
  96. Data[0]: major version
  97. Data[1]: minor version
  98. e.g.: v02.60, Data [0]=2, Data[1]=60
  99. 3 通信协议版本号 Data[4-5] unsigned char, 2 bytes.
  100. Data[0]: major version
  101. Data[1]: minor version
  102. e.g.: v02.60, Data [0]=2, Data[1]=60
  103. */
  104. #pragma pack(1)
  105. typedef struct
  106. {
  107. unsigned char amp_ver[6]; //
  108. }_POWERAMP_VER;
  109. #pragma pack()
  110. extern _POWERAMP_VER poweramp_ver;
  111. /*
  112. Number Item Data Index Remark
  113. 1 BMS 设计容量 Data[0-1] unsigned int, 16bits, 0.1AH Max value 6553.5 AH
  114. 2 电池串数 Data[2] unsigned char, 8bits, unit: 1 Value: 13
  115. 3 电池健康度 Data[3-4] unsigned int, 16bits, 0.1% Range: 0 to 1000 (0 to 1000‰)
  116. 4 电池循环次数 Data[5-6] unsigned int, 16bits, unit: 1 time
  117. 5 电池过充次数 Data[7-8] unsigned int, 16bits, unit: 1 time
  118. 6 电池过放次数 Data[9-10] unsigned int, 16bits, unit: 1 time
  119. 7 电池过温次数 Data[11-12] unsigned int, 16bits, unit: 1 time
  120. 8 电池过流次数 Data[13-14] unsigned int, 16bits, unit: 1 time
  121. 9 单体电池满充电压 Data[15-16] unsigned int, 16bits, mV
  122. 10 单体电池过放电压 Data[17-18] unsigned int, 16bits, mV
  123. 11 电池编号 Data[19-25] 7 bytes,
  124. Data [19-20]: ‘J’’M’
  125. Data [21]: year, 19-50, offset 2000,
  126. 2019-2050
  127. Data [22]: month, 0-12
  128. Data [23]: day,0-31max
  129. Data [24-25]: unsigned int, production
  130. line SN
  131. 12 年 Data[26] unsigned char, 8 bits, offset 2000 E.g.: 19+2000 = 2019
  132. 13 月 Data[27] unsigned char, 8 bitsRange: 0 - 12
  133. 14 日 Data[28] unsigned char, 8 bitsRange: 0 – 31 max
  134. 15 时 Data[29] unsigned char, 8 bitsRange: 0 - 23
  135. 16 分 Data[20] unsigned char, 8 bitsRange: 0 - 59
  136. 17 秒 Data[31] unsigned char, 8 bitsRang
  137. */
  138. #pragma pack(1)
  139. typedef struct
  140. {
  141. uint16_t amp_cap; //容量
  142. uint8_t amp_cellnum; //串数
  143. uint16_t amp_soh; //健康度
  144. uint16_t amp_cycle; //循环次数
  145. uint16_t amp_chg_count; //
  146. uint16_t amp_dsg_count;
  147. uint16_t amp_otp_count;
  148. uint16_t amp_ocp_count;
  149. uint16_t amp_fullchg_cellvolt;
  150. uint16_t amp_uvd_cellvolt;
  151. uint8_t amp_sn[14]; //编号
  152. uint8_t amp_year;
  153. uint8_t amp_month;
  154. uint8_t amp_day;
  155. uint8_t amp_hour;
  156. uint8_t amp_min;
  157. uint8_t amp_sencond;
  158. }_POWERAMP_SYS;
  159. #pragma pack()
  160. extern _POWERAMP_SYS poweramp_sys;
  161. extern Connect_check Poweramp_Link;
  162. void PowerAmpCanRecvHookFunction(uint32_t cellCanID, uint8_t* data, uint8_t len);
  163. void send_msg_to_poweramp(void);
  164. void check_poweramp_link(void);
  165. extern uint32_t time_poweramp_lastrecv;
  166. #endif