|
@@ -71,6 +71,7 @@ void health_init(void){
|
|
|
void health_log(void){
|
|
void health_log(void){
|
|
|
health_debug("soft short:%d\n", error_counts.soft_current_short);
|
|
health_debug("soft short:%d\n", error_counts.soft_current_short);
|
|
|
health_debug("hard short:%d\n", error_counts.hard_current_short);
|
|
health_debug("hard short:%d\n", error_counts.hard_current_short);
|
|
|
|
|
+ health_debug("work temp: %d\n", _health.is_work_temp_normal);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
bms_health_t *bms_health(){
|
|
bms_health_t *bms_health(){
|
|
@@ -311,13 +312,13 @@ void check_voltage_state(void) {
|
|
|
|
|
|
|
|
/* 检测温度情况,看是否过高温,或者过低温 */
|
|
/* 检测温度情况,看是否过高温,或者过低温 */
|
|
|
|
|
|
|
|
-static debounce_t _charger_over_temp = {.count = 0, .max_count = 8, .init_count = 0};
|
|
|
|
|
-static debounce_t _charger_lower_temp = {.count = 0, .max_count = 8, .init_count = 0};
|
|
|
|
|
-static debounce_t _charger_normal_temp = {.count = 0, .max_count = 8, .init_count = 0};
|
|
|
|
|
-static debounce_t _discharger_over_temp = {.count = 0, .max_count = 8, .init_count = 0};
|
|
|
|
|
-static debounce_t _discharger_lower_temp = {.count = 0, .max_count = 8, .init_count = 0};
|
|
|
|
|
-static debounce_t _discharger_normal_temp = {.count = 0, .max_count = 8, .init_count = 0};
|
|
|
|
|
-static debounce_t _work_lower_temp = {.count = 0, .max_count = 8, .init_count = 0};
|
|
|
|
|
|
|
+static debounce_t _charger_over_temp_count = {.count = 0, .max_count = 8, .init_count = 0};
|
|
|
|
|
+static debounce_t _charger_lower_temp_count = {.count = 0, .max_count = 8, .init_count = 0};
|
|
|
|
|
+static debounce_t _charger_normal_temp_count = {.count = 0, .max_count = 8, .init_count = 0};
|
|
|
|
|
+static debounce_t _discharger_over_temp_count = {.count = 0, .max_count = 8, .init_count = 0};
|
|
|
|
|
+static debounce_t _discharger_lower_temp_count = {.count = 0, .max_count = 8, .init_count = 0};
|
|
|
|
|
+static debounce_t _discharger_normal_temp_count = {.count = 0, .max_count = 8, .init_count = 0};
|
|
|
|
|
+static debounce_t _work_lower_temp_count = {.count = 0, .max_count = 8, .init_count = 0};
|
|
|
|
|
|
|
|
static int _is_over_temp(int8_t *temps){
|
|
static int _is_over_temp(int8_t *temps){
|
|
|
for (int i = 0; i < PACK_TEMPS_NUM; i++){
|
|
for (int i = 0; i < PACK_TEMPS_NUM; i++){
|
|
@@ -395,93 +396,93 @@ void health_process_aux_lock(void){
|
|
|
void check_temp_state(void){
|
|
void check_temp_state(void){
|
|
|
if (!_health.over_temp_deny_charger){
|
|
if (!_health.over_temp_deny_charger){
|
|
|
if (_is_over_temp(charger_higher_high_temp)) {//超过允许的最高温度
|
|
if (_is_over_temp(charger_higher_high_temp)) {//超过允许的最高温度
|
|
|
- debounce_inc(_charger_over_temp);
|
|
|
|
|
|
|
+ debounce_inc(_charger_over_temp_count);
|
|
|
}else {
|
|
}else {
|
|
|
- debounce_reset(_charger_over_temp);
|
|
|
|
|
|
|
+ debounce_reset(_charger_over_temp_count);
|
|
|
}
|
|
}
|
|
|
- if (debounce_reach_max(_charger_over_temp)){
|
|
|
|
|
|
|
+ if (debounce_reach_max(_charger_over_temp_count)){
|
|
|
_health.over_temp_deny_charger = 1;
|
|
_health.over_temp_deny_charger = 1;
|
|
|
- debounce_reset(_charger_over_temp);
|
|
|
|
|
|
|
+ debounce_reset(_charger_over_temp_count);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
if (!_health.lower_temp_deny_charger){
|
|
if (!_health.lower_temp_deny_charger){
|
|
|
if (_is_low_temp(charger_lower_low_temp)) {//低于允许的最低温度
|
|
if (_is_low_temp(charger_lower_low_temp)) {//低于允许的最低温度
|
|
|
- debounce_inc(_charger_lower_temp);
|
|
|
|
|
|
|
+ debounce_inc(_charger_lower_temp_count);
|
|
|
}else {
|
|
}else {
|
|
|
- debounce_reset(_charger_lower_temp);
|
|
|
|
|
|
|
+ debounce_reset(_charger_lower_temp_count);
|
|
|
}
|
|
}
|
|
|
- if (debounce_reach_max(_charger_lower_temp)) {
|
|
|
|
|
|
|
+ if (debounce_reach_max(_charger_lower_temp_count)) {
|
|
|
_health.lower_temp_deny_charger = 1;
|
|
_health.lower_temp_deny_charger = 1;
|
|
|
- debounce_reset(_charger_lower_temp);
|
|
|
|
|
|
|
+ debounce_reset(_charger_lower_temp_count);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
if (_health.lower_temp_deny_charger || _health.over_temp_deny_charger) {
|
|
if (_health.lower_temp_deny_charger || _health.over_temp_deny_charger) {
|
|
|
if (!_is_over_temp(charger_normal_high_temp) && !_is_low_temp(charger_normal_low_temp)){
|
|
if (!_is_over_temp(charger_normal_high_temp) && !_is_low_temp(charger_normal_low_temp)){
|
|
|
- debounce_inc(_charger_normal_temp);
|
|
|
|
|
|
|
+ debounce_inc(_charger_normal_temp_count);
|
|
|
}else {
|
|
}else {
|
|
|
- debounce_reset(_charger_normal_temp);
|
|
|
|
|
|
|
+ debounce_reset(_charger_normal_temp_count);
|
|
|
}
|
|
}
|
|
|
- if (debounce_reach_max(_charger_normal_temp)){
|
|
|
|
|
|
|
+ if (debounce_reach_max(_charger_normal_temp_count)){
|
|
|
_health.over_temp_deny_charger = 0;
|
|
_health.over_temp_deny_charger = 0;
|
|
|
_health.lower_temp_deny_charger = 0;
|
|
_health.lower_temp_deny_charger = 0;
|
|
|
- debounce_reset(_charger_normal_temp);
|
|
|
|
|
|
|
+ debounce_reset(_charger_normal_temp_count);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (!_health.over_temp_deny_discharger){
|
|
if (!_health.over_temp_deny_discharger){
|
|
|
if (_is_over_temp(discharger_higher_high_temp)) {//超过允许的最高温度
|
|
if (_is_over_temp(discharger_higher_high_temp)) {//超过允许的最高温度
|
|
|
- debounce_inc(_discharger_over_temp);
|
|
|
|
|
|
|
+ debounce_inc(_discharger_over_temp_count);
|
|
|
}else {
|
|
}else {
|
|
|
- debounce_reset(_discharger_over_temp);
|
|
|
|
|
|
|
+ debounce_reset(_discharger_over_temp_count);
|
|
|
}
|
|
}
|
|
|
- if (debounce_reach_max(_discharger_over_temp)){
|
|
|
|
|
|
|
+ if (debounce_reach_max(_discharger_over_temp_count)){
|
|
|
_health.over_temp_deny_discharger = 1;
|
|
_health.over_temp_deny_discharger = 1;
|
|
|
- debounce_reset(_discharger_over_temp);
|
|
|
|
|
|
|
+ debounce_reset(_discharger_over_temp_count);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (!_health.lower_temp_deny_discharger){
|
|
if (!_health.lower_temp_deny_discharger){
|
|
|
if (_is_low_temp(discharger_lower_low_temp)) {//低于允许的最低温度
|
|
if (_is_low_temp(discharger_lower_low_temp)) {//低于允许的最低温度
|
|
|
- debounce_inc(_discharger_lower_temp);
|
|
|
|
|
|
|
+ debounce_inc(_discharger_lower_temp_count);
|
|
|
}else {
|
|
}else {
|
|
|
- debounce_reset(_discharger_lower_temp);
|
|
|
|
|
|
|
+ debounce_reset(_discharger_lower_temp_count);
|
|
|
}
|
|
}
|
|
|
- if (debounce_reach_max(_discharger_lower_temp)) {
|
|
|
|
|
|
|
+ if (debounce_reach_max(_discharger_lower_temp_count)) {
|
|
|
_health.lower_temp_deny_discharger = 1;
|
|
_health.lower_temp_deny_discharger = 1;
|
|
|
- debounce_reset(_discharger_lower_temp);
|
|
|
|
|
|
|
+ debounce_reset(_discharger_lower_temp_count);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
if (_health.lower_temp_deny_discharger || _health.over_temp_deny_discharger) {
|
|
if (_health.lower_temp_deny_discharger || _health.over_temp_deny_discharger) {
|
|
|
if (!_is_over_temp(discharger_normal_high_temp) && !_is_low_temp(discharger_normal_low_temp)){
|
|
if (!_is_over_temp(discharger_normal_high_temp) && !_is_low_temp(discharger_normal_low_temp)){
|
|
|
- debounce_inc(_discharger_normal_temp);
|
|
|
|
|
|
|
+ debounce_inc(_discharger_normal_temp_count);
|
|
|
}else {
|
|
}else {
|
|
|
- debounce_reset(_discharger_normal_temp);
|
|
|
|
|
|
|
+ debounce_reset(_discharger_normal_temp_count);
|
|
|
}
|
|
}
|
|
|
- if (debounce_reach_max(_discharger_normal_temp)){
|
|
|
|
|
|
|
+ if (debounce_reach_max(_discharger_normal_temp_count)){
|
|
|
_health.over_temp_deny_discharger = 0;
|
|
_health.over_temp_deny_discharger = 0;
|
|
|
_health.lower_temp_deny_discharger = 0;
|
|
_health.lower_temp_deny_discharger = 0;
|
|
|
- debounce_reset(_discharger_normal_temp);
|
|
|
|
|
|
|
+ debounce_reset(_discharger_normal_temp_count);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
if (!_health.is_work_temp_normal){
|
|
if (!_health.is_work_temp_normal){
|
|
|
if (_is_over_temp(work_lower_temp)){
|
|
if (_is_over_temp(work_lower_temp)){
|
|
|
- debounce_inc(_work_lower_temp);
|
|
|
|
|
- if (debounce_reach_max(_work_lower_temp)){
|
|
|
|
|
|
|
+ debounce_inc(_work_lower_temp_count);
|
|
|
|
|
+ if (debounce_reach_max(_work_lower_temp_count)){
|
|
|
_health.is_work_temp_normal = 1;
|
|
_health.is_work_temp_normal = 1;
|
|
|
- debounce_reset(_work_lower_temp);
|
|
|
|
|
|
|
+ debounce_reset(_work_lower_temp_count);
|
|
|
}
|
|
}
|
|
|
}else {
|
|
}else {
|
|
|
- debounce_reset(_work_lower_temp);
|
|
|
|
|
|
|
+ debounce_reset(_work_lower_temp_count);
|
|
|
}
|
|
}
|
|
|
}else {
|
|
}else {
|
|
|
if (_is_low_temp(work_lower_temp)){
|
|
if (_is_low_temp(work_lower_temp)){
|
|
|
- debounce_inc(_work_lower_temp);
|
|
|
|
|
- if (debounce_reach_max(_work_lower_temp)){
|
|
|
|
|
|
|
+ debounce_inc(_work_lower_temp_count);
|
|
|
|
|
+ if (debounce_reach_max(_work_lower_temp_count)){
|
|
|
_health.is_work_temp_normal = 0;
|
|
_health.is_work_temp_normal = 0;
|
|
|
- debounce_reset(_work_lower_temp);
|
|
|
|
|
|
|
+ debounce_reset(_work_lower_temp_count);
|
|
|
}
|
|
}
|
|
|
}else {
|
|
}else {
|
|
|
- debounce_reset(_work_lower_temp);
|
|
|
|
|
|
|
+ debounce_reset(_work_lower_temp_count);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
if (bms_state_get()->charging){
|
|
if (bms_state_get()->charging){
|