diff options
author | Mike <mjc@avtechpulse.com> | 2000-01-01 01:08:52 +0900 |
---|---|---|
committer | Mike <mjc@avtechpulse.com> | 2000-01-01 01:08:52 +0900 |
commit | 6d781d5c7126b7c4b68f13081ee41518aa18bc76 (patch) | |
tree | f801cded0ee4e687ce4bc36d90573851ae552dc1 | |
parent | 5acd4ee44c4557d1a58ecea08d6a0e0c57fc9219 (diff) |
Do not apply polarity-based PW shift in bot range if bot range is voltage controlled
-rw-r--r-- | device-functions.c | 68 |
1 files changed, 39 insertions, 29 deletions
diff --git a/device-functions.c b/device-functions.c index df5cf40..86cffec 100644 --- a/device-functions.c +++ b/device-functions.c @@ -2892,10 +2892,8 @@ int Set_VI_Control(int parameter,int channel,float new_ampl) /* tweak depending on polarity */ if (globals.ChannelState[channel].amplitude<0.0) { pw_polarity = 1; - use_ampl=use_ampl+globals.Flash.pulse_width_pol_tweak[channel][pw_polarity]; } else { pw_polarity = 0; - use_ampl=use_ampl+globals.Flash.pulse_width_pol_tweak[channel][pw_polarity]; } /* tweak depending on amplitude range (steps, not gradual like distort params */ @@ -2966,17 +2964,33 @@ int Set_VI_Control(int parameter,int channel,float new_ampl) new_entry=0; new_word_out=-1; + float max1 = fabs(globals.Flash.min_ampl[channel]); + float max2 = fabs(globals.Flash.max_ampl[channel]); + if (max2 > max1) { + max1 = max2; + } + + // PW tweaking per PW range as function of amplitude + float dist_frac = 1.0; // use same tweaking for all amplitudes by default + if (fabs(globals.Flash.distort_fully_below_ampl[channel]) > 0.0) { + // if distort_fully_below_ampl is specified (typically for AVR-E, AVIR, etc), + // distort zero at max ampl, and fully below specified ampl + dist_frac = (max1 - fabs(globals.ChannelState[channel].amplitude)) / + (max1 - fabs(globals.Flash.distort_fully_below_ampl[channel])); + if (dist_frac > 1.0) { + dist_frac = 1.0; + } + if (dist_frac < 0.0) { + dist_frac = 0.0; + } + } + float use_atten = 1.0; for (new_atten_range = max_attens; (new_atten_range >= -1) && !new_point_found; ) { new_atten_range--; - float max1 = fabs(globals.Flash.min_ampl[channel]); - float max2 = fabs(globals.Flash.max_ampl[channel]); - if (max2 > max1) { - max1 = max2; - } if (new_atten_range == -1) { // no valid attenuators @@ -3005,36 +3019,27 @@ int Set_VI_Control(int parameter,int channel,float new_ampl) } for (range_i=starting_range; (range_i<max_ranges) && (!new_point_found || top_range_only); ++range_i) { /* use non-all-zero ranges */ + + // most cases + tweaked_use_ampl = use_ampl; + /* apply pw ampl/pol tweaks */ if (parameter == pwl_pw_values) { - // tweak pw shifts - float dist_frac = 1.0; // use same tweaking for all amplitudes by default - - if (fabs(globals.Flash.distort_fully_below_ampl[channel]) > 0.0) { - // if distort_fully_below_ampl is specified (typically for AVR-E, AVIR, etc), - // distort zero at max ampl, and fully below specified ampl - dist_frac = (max1 - fabs(globals.ChannelState[channel].amplitude)) / - (max1 - fabs(globals.Flash.distort_fully_below_ampl[channel])); - if (dist_frac > 1.0) { - dist_frac = 1.0; - } + // tweak pw shifts, two varieties - if (dist_frac < 0.0) { - dist_frac = 0.0; - } - } + tweaked_use_ampl += dist_frac * globals.Flash.pw_range_pol_tweaks[channel][range_i][pw_polarity]; - float correction = dist_frac * globals.Flash.pw_range_pol_tweaks[channel][range_i][pw_polarity]; - tweaked_use_ampl = use_ampl + correction; + if ((range_i > 0) || (!globals.Flash.volt_ctrl_pw[channel]) ) { + // not used in bot range if bot range is voltage controlled + tweaked_use_ampl += globals.Flash.pulse_width_pol_tweak[channel][pw_polarity]; + } } else if (parameter == pwl_ampl_values) { // compensate for attenuators - tweaked_use_ampl = use_ampl * use_atten; - } else { - // no tweaks - tweaked_use_ampl = use_ampl; + tweaked_use_ampl *= use_atten; } + for (entry_i=0; (entry_i<max_points-1) && (!new_point_found || top_range_only); ++entry_i) { index=true_channel*max_ranges*max_polarity*max_points +(range_i)*max_polarity*max_points @@ -3133,7 +3138,12 @@ int Set_VI_Control(int parameter,int channel,float new_ampl) /* identify highest range that starts with a cal point less than the setting */ for (range_i=0; range_i<max_ranges; ++range_i) { /* use non-all-zero ranges */ if (parameter == pwl_pw_values) { - tweaked_use_ampl = use_ampl + globals.Flash.pw_range_pol_tweaks[channel][range_i][pw_polarity]; + tweaked_use_ampl += dist_frac * globals.Flash.pw_range_pol_tweaks[channel][range_i][pw_polarity]; + + if ((range_i > 0) || (!globals.Flash.volt_ctrl_pw[channel]) ) { + // not used in bot range if bot range is voltage controlled + tweaked_use_ampl += globals.Flash.pulse_width_pol_tweak[channel][pw_polarity]; + } } index=true_channel*max_ranges*max_polarity*max_points |