diff --git a/users/Src/provalctrl.c b/users/Src/provalctrl.c index 14085ae..b4fb51f 100644 --- a/users/Src/provalctrl.c +++ b/users/Src/provalctrl.c @@ -123,6 +123,12 @@ void analog_ctrl(void) ee_writefloats(AO_1_SAVE_ADDR, AO_1_table); ee_writefloats(AO_2_SAVE_ADDR, AO_2_table); + AO_init_flag[AO_0] = 0; + AO_init_flag[AO_1] = 0; + AO_init_flag[AO_2] = 0; + + current_output_calibrate_init(); + ao_ee_save_flag = 0; } @@ -227,6 +233,7 @@ void analog_ctrl(void) } +int8_t AO_init_flag[3] = {0}; void current_output_calibrate_init(void) { ao_cal_interval = ( (float)(AO_CAL_END - AO_CAL_START) ) / ( (float)SECTION_NUM ); @@ -242,15 +249,15 @@ void current_output_calibrate_init(void) if( abs_bias( AO_0_table[0] - AO_table[0] ) > 1) { - AO_0_table[0] = -1; + AO_init_flag[AO_0] = -1; } if( abs_bias( AO_1_table[0] - AO_table[0] ) > 1) { - AO_1_table[0] = -1; + AO_init_flag[AO_1] = -1; } if( abs_bias( AO_2_table[0] - AO_table[0] ) > 1) { - AO_2_table[0] = -1; + AO_init_flag[AO_2] = -1; } } @@ -264,7 +271,7 @@ float current_output_calibrate(uint8_t tag, float target) { case AO_0: { - if(AO_0_table[0] == -1) + if(AO_init_flag[AO_0] == -1) { result = target; return result; @@ -287,7 +294,7 @@ float current_output_calibrate(uint8_t tag, float target) case AO_1: { - if(AO_1_table[0] == -1) + if(AO_init_flag[AO_1] == -1) { result = target; return result; @@ -310,7 +317,7 @@ float current_output_calibrate(uint8_t tag, float target) case AO_2: { - if(AO_2_table[0] == -1) + if(AO_init_flag[AO_2] == -1) { result = target; return result;