summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--device-functions.c41
1 files changed, 31 insertions, 10 deletions
diff --git a/device-functions.c b/device-functions.c
index 47a5bcd..ee62cf1 100644
--- a/device-functions.c
+++ b/device-functions.c
@@ -735,7 +735,7 @@ int Set_Delay(int check_possible_only,int word_override,int range_override,int c
{
int word_out; /* what is sent to the DAC */
int cap_range_control; /* what is actually sent to shift register */
- float setting;
+ float adj_setting, setting, min_one_shot_delay;
int point_found,relay_range,UseNegData,entry,actual_pol,dummy;
/* abandon if high channel selected by user but not enabled by firmware */
@@ -754,24 +754,45 @@ int Set_Delay(int check_possible_only,int word_override,int range_override,int c
}
}
- setting=set_delay-globals.Flash.propagation_delay[channel];
+ /* 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.delay_shrink[channel] < min_one_shot_delay) {
+ return HardwareError;
+ }
+
+ /* 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
+
+ ( Flash.delay_shrink - Flash.propagation_delay ) >= min_one_shot_delay
+
+ shrink ~ fixed DDU delay (around 25 ns)
+ prop ~ propagation delay of main PG - prog delay of SYNC
+ This is not normally the case, because Flash.propagation_delay can be large.
+
+ 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.
+ */
+
+
/* tweak depending on polarity */
+ adj_setting = set_delay;
if (globals.ChannelState[channel].amplitude<0.0) {
- setting -= globals.Flash.delay_pol_tweak[channel][1];
+ adj_setting -= globals.Flash.delay_pol_tweak[channel][1];
} else {
- setting -= globals.Flash.delay_pol_tweak[channel][0];
+ adj_setting -= globals.Flash.delay_pol_tweak[channel][0];
}
- if (setting >= 0.0) {
- Set_AdvDel(channel,to_Advance);
- } else {
+ 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);
- setting *= -1;
}
- setting=setting+globals.Flash.delay_shrink[channel];
-
/* protect against impossible settings during first turn-on */
if (setting<zero_equiv_timing) {
return HardwareError;