From 7b128fb906887ea3837c355ccb7960deccedee21 Mon Sep 17 00:00:00 2001 From: "Michael J. Chudobiak" Date: Thu, 5 Oct 2017 15:31:45 -0400 Subject: set aux word when setting nominal amplitude, for EA V1 --- device-functions.c | 50 +++++++++++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 21 deletions(-) (limited to 'device-functions.c') diff --git a/device-functions.c b/device-functions.c index 4e21c14..ddeb5bb 100644 --- a/device-functions.c +++ b/device-functions.c @@ -201,7 +201,7 @@ void Main_Rst (void) Set_Trig_Source(i,globals.ChannelState[i].trigger_source); - Set_Amplitude(0,0,0,0,0,0,i,globals.ChannelState[i].amplitude,0); + Set_Amplitude(0,0,0,0,0,0,0,i,globals.ChannelState[i].amplitude,0); Set_Offset(0,0,0,0,i,globals.ChannelState[i].offset); Set_Output_State(i,globals.ChannelState[i].output_state); @@ -247,7 +247,7 @@ static int attenuator_count (int channel) } -int Set_Amplitude(int check_possible_only,int pol_override,int override_on,int word_override,int range_override, +int Set_Amplitude(int check_possible_only,int pol_override,int override_on,int word_override,int range_override,int aux_override, int switch_range_only,int channel,float new_ampl,int called_from_set_pw) { int word_out, word_out_aux; /* what is sent to the DAC */ @@ -320,6 +320,7 @@ int Set_Amplitude(int check_possible_only,int pol_override,int override_on,int w word_out=word_override; relay_range=range_override; actual_pol=pol_override; + word_out_aux=aux_override; } else { /* set the amplitude controls now. */ int status; @@ -636,7 +637,7 @@ int Set_Pw(int check_possible_only,int word_override,int range_override,int chan g_print_debug("pw range %d, word %d\n",relay_range,word_out); if (!called_from_set_ampl) { - Set_Amplitude(0,0,0,0,0,0,channel,globals.ChannelState[channel].amplitude,1); + Set_Amplitude(0,0,0,0,0,0,0,channel,globals.ChannelState[channel].amplitude,1); } return OK; @@ -709,12 +710,12 @@ int Set_Offset(int check_possible_only,int override_on,int word_override,int ran } if ((globals.Flash.ampl_coupled_to_os[channel] || globals.Flash.ampl_os_ranges_related[channel]) && !globals.Changes.update_amp) { - Set_Amplitude(0,0,0,0,0,0,channel,globals.ChannelState[channel].amplitude,0); + Set_Amplitude(0,0,0,0,0,0,0,channel,globals.ChannelState[channel].amplitude,0); } /* change amplitude range if required for calibration */ if (override_on) { - Set_Amplitude(0,0,1,0,relay_range,0,channel,0.0,0); + Set_Amplitude(0,0,1,0,relay_range,0,0,channel,0.0,0); } /* increase PW if required to compensate for series output diode turn-on time */ @@ -1392,7 +1393,7 @@ int Set_zout(int channel,int setting,int really_for_zout) if (really_for_zout) { if (globals.Changes.update_zout) { /* change of Zout may require change in amplitude controls */ - Set_Amplitude(0,0,0,0,0,0,channel,globals.ChannelState[channel].amplitude,0); + Set_Amplitude(0,0,0,0,0,0,0,channel,globals.ChannelState[channel].amplitude,0); } if (update_zout_slowly) { @@ -1432,7 +1433,7 @@ int Set_Load(int channel, float value) if (globals.Changes.update_load) { /* change of load may require change in amplitude controls */ - Set_Amplitude(0,0,0,0,0,0,channel,globals.ChannelState[channel].amplitude,0); + Set_Amplitude(0,0,0,0,0,0,0,channel,globals.ChannelState[channel].amplitude,0); } return OK; @@ -1463,10 +1464,10 @@ int Set_EA(int channel,int mode) /* set to max amplitude range when switching from normal to EA or Ext Amplify */ if ( (globals.ChannelState[channel].amp_mode==amp_mode_normal) && (mode!=amp_mode_normal) ) { if (globals.ChannelState[channel].amplitude<0.0) - Set_Amplitude(0,0,0,0,0,set_DAC_to_zero,channel, + Set_Amplitude(0,0,0,0,0,0,set_DAC_to_zero,channel, globals.ChannelState[channel].amplitude=globals.Flash.min_ampl[channel],0); /* most negative */ else - Set_Amplitude(0,0,0,0,0,set_DAC_to_zero,channel, + Set_Amplitude(0,0,0,0,0,0,set_DAC_to_zero,channel, globals.ChannelState[channel].amplitude=globals.Flash.max_ampl[channel],0); /* most positive */ } @@ -1474,9 +1475,9 @@ int Set_EA(int channel,int mode) /* protect when switching from EA or Ext Amplify back to normal */ if ( (globals.ChannelState[channel].amp_mode!=amp_mode_normal) && (mode==amp_mode_normal) ) { if (globals.ChannelState[channel].amplitude<0.0) { - Set_Amplitude(0,0,0,0,0,0,channel,globals.ChannelState[channel].amplitude=-smallest_allowed_number,0); + Set_Amplitude(0,0,0,0,0,0,0,channel,globals.ChannelState[channel].amplitude=-smallest_allowed_number,0); } else { - Set_Amplitude(0,0,0,0,0,0,channel,globals.ChannelState[channel].amplitude=smallest_allowed_number,0); + Set_Amplitude(0,0,0,0,0,0,0,channel,globals.ChannelState[channel].amplitude=smallest_allowed_number,0); } } @@ -1970,7 +1971,7 @@ int Set_Dly_Shr_Nom(int channel,int calibration_point_number) } else { ampl = globals.Flash.min_ampl[channel]; } - Set_Amplitude(0,0,0,0,0,0,channel,ampl,0); + Set_Amplitude(0,0,0,0,0,0,0,channel,ampl,0); // set to PW to 20 ns, if possible @@ -2041,7 +2042,7 @@ int Set_Dly_Shr_Cal(int channel,int calibration_point_number,float cal_point) int Set_Cal_Nom(int channel,int calibration_point_number,int parameter, float *nom_val) { - int nominal_wordout,polarity,range,entry,status,num_in_range,num_of_ranges; + int nominal_wordout,nominal_wordout_aux,polarity,range,entry,status,num_in_range,num_of_ranges; float nominal_val,other_setting,temp1,temp2; int reset_state; int disable_errors; @@ -2059,7 +2060,14 @@ int Set_Cal_Nom(int channel,int calibration_point_number,int parameter, float *n nominal_val=-nominal_val; } nominal_wordout=globals.Flash.ampl_dacval[channel][range][polarity][entry]; - if (Set_Amplitude(0,0,0,0,0,0,channel,globals.Flash.min_ampl[channel],0) || Set_Amplitude(0,0,0,0,0,0,channel,globals.Flash.max_ampl[channel],0)) { + + if (globals.Flash.distort_enabled[channel]) { + nominal_wordout_aux=globals.Flash.distort_dacval[channel][range][polarity][entry]; + } else { + nominal_wordout_aux=0; + } + + if (Set_Amplitude(0,0,0,0,0,0,0,channel,globals.Flash.min_ampl[channel],0) || Set_Amplitude(0,0,0,0,0,0,0,channel,globals.Flash.max_ampl[channel],0)) { /* confirm that timing settings can support min/max ampl settings */ return CalibrationTimingProblem; } @@ -2138,7 +2146,7 @@ int Set_Cal_Nom(int channel,int calibration_point_number,int parameter, float *n switch (parameter) { case (pwl_ampl_values): - status=Set_Amplitude(0,polarity,1,nominal_wordout,range,0,channel,nominal_val,0); + status=Set_Amplitude(0,polarity,1,nominal_wordout,range,nominal_wordout_aux,0,channel,nominal_val,0); break; case (pwl_os_values): status=Set_Offset(0,1,nominal_wordout,range,channel,nominal_val); @@ -2531,7 +2539,7 @@ int Set_VI_Del_Cal(int parameter,int channel,int calibration_point_number) } } - Set_Amplitude(0,0,0,0,0,0,channel,0.0,0); + Set_Amplitude(0,0,0,0,0,0,0,channel,0.0,0); Main_update_shift_registers(); Set_Offset(0,0,0,0,channel,0.0); @@ -3271,7 +3279,7 @@ int Set_VI_Add_Cal(int parameter,int channel,float cal_point) /* update output */ switch (parameter) { case (pwl_ampl_values): - Set_Amplitude(0,0,0,0,0,0,channel,cal_point,0); + Set_Amplitude(0,0,0,0,0,0,0,channel,cal_point,0); break; case (pwl_os_values): @@ -3436,9 +3444,9 @@ int Check_MinMax_Cal(int channel,int parameter) /* see if new point prevents zero, min, max, or current value from being obtained */ switch (parameter) { case (pwl_ampl_values): - if (status=Set_Amplitude(1,0,0,0,0,0,channel,globals.Flash.min_ampl[channel],0)) return status; - if (status=Set_Amplitude(1,0,0,0,0,0,channel,globals.Flash.max_ampl[channel],0)) return status; - if (status=Set_Amplitude(1,0,0,0,0,0,channel,rst_ampl_value(channel),0)) return status; + if (status=Set_Amplitude(1,0,0,0,0,0,0,channel,globals.Flash.min_ampl[channel],0)) return status; + if (status=Set_Amplitude(1,0,0,0,0,0,0,channel,globals.Flash.max_ampl[channel],0)) return status; + if (status=Set_Amplitude(1,0,0,0,0,0,0,channel,rst_ampl_value(channel),0)) return status; break; case (pwl_os_values): @@ -4365,7 +4373,7 @@ void Set_Rcl(int setting_num) Set_Trig_Source(i,globals.ChannelState[i].trigger_source); - Set_Amplitude(0,0,0,0,0,0,i,globals.ChannelState[i].amplitude,0); + Set_Amplitude(0,0,0,0,0,0,0,i,globals.ChannelState[i].amplitude,0); if (globals.Flash.voltage_offset_enabled[i] || globals.Flash.current_offset_enabled[i]) { Set_Offset(0,0,0,0,i,globals.ChannelState[i].offset); -- cgit