diff options
-rw-r--r-- | flash.c | 2 | ||||
-rw-r--r-- | globals.h | 6 | ||||
-rw-r--r-- | menus.c | 2 | ||||
-rw-r--r-- | monitor.c | 8 |
4 files changed, 12 insertions, 6 deletions
@@ -887,6 +887,8 @@ static void initFlashValues(FlashStruct *mem) mem->cap_for_pw_rc_limit[i] = 0.0; mem->hvps_avg_curr_limit[i] = 0.0; + + mem->max_mon_steps_before_reset_average[i] = DEFAULT_MAX_STEP_DEV_FROM_AVG; } mem->relay_delay_in_sec=0.5; @@ -351,7 +351,7 @@ typedef struct { #define CURR_MON_MAX_OLD_COUNTS 50 // monitor readings are around 50/sec, average over one second -#define MAX_STEP_DEV_FROM_AVG 5 // reset monitor average if more than N steps difference +#define DEFAULT_MAX_STEP_DEV_FROM_AVG 5 // reset monitor average if more than N steps difference typedef struct { float frequency; /* the global frequency variable */ @@ -830,7 +830,9 @@ typedef struct { float cap_for_pw_rc_limit[max_channels]; // size 8, addr 37396 - for AVR-8F-B float hvps_avg_curr_limit[max_channels]; // size 8, addr 37404 - for AVR-8F-B - char flash_end; // addr 37412 + float max_mon_steps_before_reset_average[max_channels]; // size 8, addr 37412 - 5 steps for AVO-8E3, maybe more for 156A? + + char flash_end; // addr 37420 } FlashStruct; #pragma pack(pop) @@ -2810,7 +2810,7 @@ static void Nonstd_menu_default_rs232(void) static void Nonstd_menu_model_info(void) { - gchar *message = g_strdup_printf ("Avtech Electrosystems Ltd., since 1975. Model %s, S/N %s, FW v%s.", + gchar *message = g_strdup_printf ("Avtech Electrosystems Ltd., Model %s, S/N %s, FW v%s. Since 1975.", globals.Flash.model_num, globals.Flash.serial_num, globals.HWDetect.firmware); @@ -155,7 +155,7 @@ int I2C_Get_Monitor_Word(int channel) int I2C_Check_Monitors(void) { int monitor_word; - float new_val, avg_val, step_size; + float new_val, avg_val, step_size, max_dev_in_steps; int channel; int ampl_range,point_found,UseNegData,entry,word_out,atten_range; @@ -218,8 +218,10 @@ int I2C_Check_Monitors(void) step_size=globals.Flash.monitor_step[channel]; - /* reset average if change is bigger than MAX_STEP_DEV_FROM_AVG steps */ - if (fabs((new_val-avg_val)/step_size) > MAX_STEP_DEV_FROM_AVG) { + /* reset average if change is bigger than DEFAULT_MAX_STEP_DEV_FROM_AVG steps */ + + max_dev_in_steps = MAX(globals.Flash.max_mon_steps_before_reset_average[channel], DEFAULT_MAX_STEP_DEV_FROM_AVG); + if (fabs((new_val-avg_val)/step_size) > max_dev_in_steps) { globals.ChannelState[channel].num_mon_vals = 1; avg_val = new_val; } |