Просмотр исходного кода

判断温感是否未接或者异常

Signed-off-by: huhui <huhui@sharkgulf.com>
huhui 2 лет назад
Родитель
Сommit
f6c6add3e4
2 измененных файлов с 3 добавлено и 3 удалено
  1. 2 2
      Applications/foc/limit.c
  2. 1 1
      Applications/foc/ntc.c

+ 2 - 2
Applications/foc/limit.c

@@ -97,7 +97,7 @@ static u16 _motor_limit(void) {
 	static int temp_sensor_err = 0;
 	static u16 lim_value  = HW_LIMIT_NONE;
 	s16 temp = get_motor_temp_raw();
-	if (ABS(temp - mot_temp) >= 20) {
+	if ((temp == 300) || ABS(temp - mot_temp) >= 20) {
 		if (temp_sensor_err < 20) {
 			temp_sensor_err++;
 		}else {
@@ -154,7 +154,7 @@ static u16 _mos_limit(void) {
 	static int temp_sensor_err = 0;
 	static u16 lim_value  = HW_LIMIT_NONE;
 	s16 temp = get_mos_temp_raw();
-	if (ABS(temp - mos_temp) >= 20) {
+	if ((temp == -40) || ABS(temp - mos_temp) >= 20) {
 		if (temp_sensor_err < 20) {
 			temp_sensor_err++;
 		}else {

+ 1 - 1
Applications/foc/ntc.c

@@ -47,7 +47,7 @@ s16 ntc_get_motor_temp(u16 r) {
 	if (i == 0) {
 		return -10;
 	}else if (i >= ARRAY_SIZE(kty_table)) {
-		return 301;
+		return 300;
 	}else if (r == kty_table[i]) {
 		return (s16)((i - KTY_TEMP_OFFSET) * KTY_TEMP_INTVAL);
 	}