diff options
-rw-r--r-- | device-functions.c | 179 | ||||
-rw-r--r-- | error_utils.c | 17 | ||||
-rw-r--r-- | flash.c | 2 | ||||
-rw-r--r-- | globals.h | 5 | ||||
-rw-r--r-- | menus.c | 43 |
5 files changed, 156 insertions, 90 deletions
diff --git a/device-functions.c b/device-functions.c index e516419..421bda9 100644 --- a/device-functions.c +++ b/device-functions.c @@ -3500,104 +3500,125 @@ int Set_rise_time(int check_possible_only,int word_override,int range_override,i } } - /* find appropriate range/fine settings from piece-wise linear data in flash memory */ - if (word_override) { - word_out=word_override; - relay_range=range_override; - } else { - int status; - if ((status=Set_VI_Control(pwl_rise_time_values,channel,new_rise_time,&point_found, - &relay_range,&dummy,&UseNegData,&entry,&word_out,&actual_pol))) { - return status; - } - } - if (check_possible_only) { - if (point_found) { + if (globals.Flash.rise_time_min_max_only[channel]) { + if (check_possible_only) { return OK; - } else { - return CalibrationMinMaxError; } - } - - set_dac(globals.Flash.rise_time_dac[channel],word_out); - if (!globals.Flash.pcb_203a_rise_time[channel]) { - /* original AVRQ PCB */ - switch (relay_range) { - case 0: - range_control = (char) 0x01; - break; - case 1: - range_control = (char) 0x08; - break; - case 2: - range_control = (char) 0x10; - break; - case 3: - range_control = (char) 0x20; - break; - case 4: - range_control = (char) 0x40; - break; - case 5: - range_control = (char) 0x80; - break; - case 6: - case 7: - return HardwareError; - break; + if (word_override) { + return rise_time_confined_values; } - } else { - /* PCB 203A */ - switch (relay_range) { - case 0: - range_control = (char) 0x0f; - break; - case 1: - range_control = (char) 0x02; - break; - case 2: - range_control = (char) 0x04; - break; - case 3: - range_control = (char) 0x08; - break; - case 4: - range_control = (char) 0x10; - break; - case 5: - case 6: - case 7: - return HardwareError; - break; + + if (fabs(new_rise_time - globals.Flash.min_rise_time[channel]) < smallest_allowed_number) { + /* todo */ + (void)0; + } else { + /* todo */ + (void)0; } - } + } else { + /* find appropriate range/fine settings from piece-wise linear data in flash memory */ + if (word_override) { + word_out=word_override; + relay_range=range_override; + } else { + int status; + if ((status=Set_VI_Control(pwl_rise_time_values,channel,new_rise_time,&point_found, + &relay_range,&dummy,&UseNegData,&entry,&word_out,&actual_pol))) { + return status; + } + } - if (globals.Registers.last_rise_time_relay_setting != range_control) { - /* update range hardware */ - if (globals.ChannelState[channel].trigger_source!=source_hold) { - bus_setpin(O_GATE, 1); + if (check_possible_only) { + if (point_found) { + return OK; + } else { + return CalibrationMinMaxError; + } } + set_dac(globals.Flash.rise_time_dac[channel],word_out); + if (!globals.Flash.pcb_203a_rise_time[channel]) { - I2C_Write(PCF8574A+rise_time_port,range_control); + /* original AVRQ PCB */ + switch (relay_range) { + case 0: + range_control = (char) 0x01; + break; + case 1: + range_control = (char) 0x08; + break; + case 2: + range_control = (char) 0x10; + break; + case 3: + range_control = (char) 0x20; + break; + case 4: + range_control = (char) 0x40; + break; + case 5: + range_control = (char) 0x80; + break; + case 6: + case 7: + return HardwareError; + break; + } } else { - globals.Registers.avrq_reg = (range_control & 0x1f) | - (globals.Registers.avrq_reg & 0xe0); - I2C_Write(PCF8574A+rise_time_port,globals.Registers.avrq_reg); + /* PCB 203A */ + switch (relay_range) { + case 0: + range_control = (char) 0x0f; + break; + case 1: + range_control = (char) 0x02; + break; + case 2: + range_control = (char) 0x04; + break; + case 3: + range_control = (char) 0x08; + break; + case 4: + range_control = (char) 0x10; + break; + case 5: + case 6: + case 7: + return HardwareError; + break; + } } - g_usleep (5e5); - if (globals.ChannelState[channel].trigger_source!=source_hold) { - bus_setpin(O_GATE, 0); + + + if (globals.Registers.last_rise_time_relay_setting != range_control) { + /* update range hardware */ + if (globals.ChannelState[channel].trigger_source!=source_hold) { + bus_setpin(O_GATE, 1); + } + + if (!globals.Flash.pcb_203a_rise_time[channel]) { + I2C_Write(PCF8574A+rise_time_port,range_control); + } else { + globals.Registers.avrq_reg = (range_control & 0x1f) | + (globals.Registers.avrq_reg & 0xe0); + I2C_Write(PCF8574A+rise_time_port,globals.Registers.avrq_reg); + } + g_usleep (5e5); + + if (globals.ChannelState[channel].trigger_source!=source_hold) { + bus_setpin(O_GATE, 0); + } } + globals.Registers.last_rise_time_relay_setting = range_control; } globals.ChannelState[channel].rise_time = new_rise_time; - globals.Registers.last_rise_time_relay_setting = range_control; Set_Update_Chans(); diff --git a/error_utils.c b/error_utils.c index d159e50..395da81 100644 --- a/error_utils.c +++ b/error_utils.c @@ -272,6 +272,7 @@ void get_error_text(gchar **response, int error_num) break; case IllegalParameter: + case rise_time_confined_values: case amplitude_confined_values: format_error_text(response,-224,"Not in list of allowed values."); break; @@ -702,12 +703,6 @@ int Error_check(ChannelStruct ChannelStateToTest[max_channels]) break; } - - // check for channel-specific obsolete configurations - but allow further checks - if ( globals.Flash.ampl_min_max_only[i] ) { - report_error = obsolete_feature; - } - if (fabs(globals.Flash.ampl_zero_equiv[i] > 200.0)) { report_error = zero_equiv_ampl_too_large; } @@ -1398,6 +1393,16 @@ int Error_check(ChannelStruct ChannelStateToTest[max_channels]) /* disable amplitude checks if calibration is in progress */ if (!globals.Flash.fixed_rise_time[i]) if (!globals.Flags.extended_ampl_min_max) { + + if (globals.Flash.rise_time_min_max_only[i]) { + if ( !(fabs(ChannelStateToTest[i].rise_time - globals.Flash.min_rise_time[i]) < smallest_allowed_number ) + && + !(fabs(ChannelStateToTest[i].rise_time - globals.Flash.max_rise_time[i]) < smallest_allowed_number ) + ) { + report_error=rise_time_confined_values; + } + } + globals.Constraints.err_min_rise_time[i]=globals.Flash.min_rise_time[i]; if (ChannelStateToTest[i].rise_time<(0.999*globals.Constraints.err_min_rise_time[i])) { report_error=min_rise_time_error; @@ -714,7 +714,7 @@ static void initFlashValues(FlashStruct *mem) mem->switchable_load[i]=1; mem->monitor_enabled[i]=0; mem->use_pos_ampl_data_only[i]=0; - mem->ampl_min_max_only[i]=0; + mem->rise_time_min_max_only[i]=0; mem->eo_enabled[i]=1; mem->ext_amplify_enabled[i]=1; @@ -94,6 +94,7 @@ #define obsolete_feature 80 #define zero_equiv_ampl_too_large 81 #define GPIB_missing 82 +#define rise_time_confined_values 83 #define YES 1 @@ -514,7 +515,9 @@ typedef struct { char switchable_load[max_channels]; char monitor_enabled[max_channels]; /* addr 1906 */ char use_pos_ampl_data_only[max_channels]; - char ampl_min_max_only[max_channels]; /* no longer used - use fixed_ampl_points instead */ + char rise_time_min_max_only[max_channels]; /* addr 1910 + Formerly ampl_min_max_only. + Use fixed_ampl_points instead */ short zout_min[max_channels]; /* addr 1912 */ short os_pwl_Vc_norm4095[max_channels][os_ranges][os_polarities][points_in_range]; /* addr 1916 */ @@ -147,6 +147,9 @@ #define mode_route1 9100 #define mode_route2 9200 +#define mode_rise_time_min 9300 +#define mode_rise_time_max 9400 + #define Submenu_maximum_entries 10 /* what parameter to adjust */ @@ -1386,9 +1389,16 @@ static void Submenu_Display(int change_selection) break; case Submenu1_rise_time: - title = title_with_channel("Rise time (10%-90%)",globals.Flash.ChanKey_rise_time,channel); - Submenu_Numeric_Parameter=Show_rise_time+channel; - Submenu_max_entry=0; + title = title_with_channel("Rise time",globals.Flash.ChanKey_rise_time,channel); + + if (globals.Flash.rise_time_min_max_only[channel]) { + Submenu_max_entry=1; + Submenu_Structure[0]=mode_rise_time_min; + Submenu_Structure[1]=mode_rise_time_max; + } else { + Submenu_Numeric_Parameter=Show_rise_time+channel; + Submenu_max_entry=0; + } break; case Submenu1_slew: @@ -2051,6 +2061,21 @@ static void Submenu_Display(int change_selection) current_operating_mode=i; } break; + + case mode_rise_time_min: + String_Parameter_To_Text(globals.Flash.min_rise_time[channel],2,"","s",&mode_name,NO,LCD_col_width); + if (fabs(globals.ChannelState[channel].rise_time-globals.Flash.min_rise_time[channel]) < smallest_allowed_number) { + current_operating_mode=i; + } + break; + + case mode_rise_time_max: + String_Parameter_To_Text(globals.Flash.max_rise_time[channel],2,"","s",&mode_name,NO,LCD_col_width); + if (fabs(globals.ChannelState[channel].rise_time-globals.Flash.max_rise_time[channel]) < smallest_allowed_number) { + current_operating_mode=i; + } + break; + default: mode_name = g_strdup("??"); break; @@ -3172,6 +3197,18 @@ static int Submenu_Implement_Changes(void) } break; + case mode_rise_time_min: + if (error_num=Set_rise_time(0,0,0,channel,globals.Flash.min_rise_time[channel])) { + return error_num; + } + break; + + case mode_rise_time_max: + if (error_num=Set_rise_time(0,0,0,channel,globals.Flash.max_rise_time[channel])) { + return error_num; + } + break; + // hard-coded count of 10 - not ideal! case (mode_ampl_fixed_point0): if (error_num=Set_Amplitude(0,0,0,0,0,0,channel,globals.Flash.fixed_ampl_points[channel][0],0)) { |