diff options
-rw-r--r-- | device-functions.c | 100 |
1 files changed, 52 insertions, 48 deletions
diff --git a/device-functions.c b/device-functions.c index c185e6b..28224ab 100644 --- a/device-functions.c +++ b/device-functions.c @@ -843,71 +843,75 @@ int Set_Delay(int check_possible_only,int word_override,int range_override,int c } } - /* won't work for all values if apparent fixed delay is less than minimum variable delay */ - min_one_shot_delay = globals.Flash.delay_pwl_time[channel][0][0][0]; - if ( !globals.Flash.volt_ctrl_delay[channel] && - (globals.Flash.delay_shrink[channel] > 0.0) && - (globals.Flash.delay_shrink[channel] < min_one_shot_delay)) { - return DelayRangeError; - } + /* 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 { - /* If we need the advance mode for all positive values of delay (for the external trigger - mode to work as expected), then we must have + /* won't work for all values if apparent fixed delay is less than minimum variable delay */ + min_one_shot_delay = globals.Flash.delay_pwl_time[channel][0][0][0]; + if ( !globals.Flash.volt_ctrl_delay[channel] && + (globals.Flash.delay_shrink[channel] > 0.0) && + (globals.Flash.delay_shrink[channel] < min_one_shot_delay)) { + return DelayRangeError; + } - ( Flash.delay_shrink - Flash.propagation_delay ) >= min_one_shot_delay + /* If we need the advance mode for all positive values of delay (for the external trigger + mode to work as expected), then we must have - shrink ~ fixed DDU delay (around 25 ns) - prop ~ propagation delay of main PG - prog delay of SYNC + ( Flash.delay_shrink - Flash.propagation_delay ) >= min_one_shot_delay - This is not normally the case, because Flash.propagation_delay can be large. + shrink ~ fixed DDU delay (around 25 ns) + prop ~ propagation delay of main PG - prog delay of SYNC - If necessary, delay_shrink can be increased by using a larger DDU, or the - propagation_delay difference can be reduced by increasing the delay of the - SYNC pulse. - */ + This is not normally the case, because Flash.propagation_delay can be large. - if ( globals.Flash.force_monotonic_ext_trig_delay[channel] && // specials mostly - (globals.Flash.delay_shrink[channel] > 0.0) && // ignore if delay shrink cal not set - (globals.Flash.propagation_delay[channel] > 0.0) && - ((globals.Flash.delay_shrink[channel] - globals.Flash.propagation_delay[channel]) < min_one_shot_delay)) { - return ExternalModeDelayError; - } - - setting = set_delay; + If necessary, delay_shrink can be increased by using a larger DDU, or the + propagation_delay difference can be reduced by increasing the delay of the + SYNC pulse. + */ - if (!globals.Flash.volt_ctrl_delay[channel]) { - /* tweak depending on polarity */ - adj_setting = set_delay; - if (globals.ChannelState[channel].amplitude<0.0) { - adj_setting -= globals.Flash.delay_pol_tweak[channel][1]; - } else { - adj_setting -= globals.Flash.delay_pol_tweak[channel][0]; + if ( globals.Flash.force_monotonic_ext_trig_delay[channel] && // specials mostly + (globals.Flash.delay_shrink[channel] > 0.0) && // ignore if delay shrink cal not set + (globals.Flash.propagation_delay[channel] > 0.0) && + ((globals.Flash.delay_shrink[channel] - globals.Flash.propagation_delay[channel]) < min_one_shot_delay)) { + return ExternalModeDelayError; } - setting = adj_setting + globals.Flash.delay_shrink[channel] - globals.Flash.propagation_delay[channel]; + setting = set_delay; + + if (!globals.Flash.volt_ctrl_delay[channel]) { + /* tweak depending on polarity */ + adj_setting = set_delay; + if (globals.ChannelState[channel].amplitude<0.0) { + adj_setting -= globals.Flash.delay_pol_tweak[channel][1]; + } else { + adj_setting -= globals.Flash.delay_pol_tweak[channel][0]; + } + + setting = adj_setting + globals.Flash.delay_shrink[channel] - globals.Flash.propagation_delay[channel]; - if (setting >= min_one_shot_delay) { - Set_AdvDel(channel,to_Advance); - } else { - setting = globals.Flash.delay_shrink[channel] + globals.Flash.propagation_delay[channel] - adj_setting; - Set_AdvDel(channel,to_Delay); + if (setting >= min_one_shot_delay) { + Set_AdvDel(channel,to_Advance); + } else { + setting = globals.Flash.delay_shrink[channel] + globals.Flash.propagation_delay[channel] - adj_setting; + Set_AdvDel(channel,to_Delay); + } } - } - /* protect against impossible settings during first turn-on */ - if ((setting<zero_equiv_timing) && (globals.Flash.min_delay[channel] >= 0.0) ) { - return HardwareError; - } + /* protect against impossible settings during first turn-on */ + if ((setting<zero_equiv_timing) && (globals.Flash.min_delay[channel] >= 0.0) ) { + return HardwareError; + } + + g_print_debug("set delay %e, actual %e\n",set_delay,setting); - /* 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 { /* set the amplitude controls now. */ int status; if ((status=Set_VI_Control(pwl_delay_values,channel,setting,&point_found, &relay_range,&dummy,&UseNegData,&entry,&word_out,&actual_pol))) { + g_print_debug("delay set status: %d",status); return status; } } |