summaryrefslogtreecommitdiff
path: root/device-functions.c
diff options
context:
space:
mode:
authorMike <mjc@avtechpulse.com>2000-01-01 00:04:44 +0900
committerMike <mjc@avtechpulse.com>2000-01-01 00:04:44 +0900
commit71cb44945d394883e26b084faca3c45969b92770 (patch)
tree47ac7447daa588875f2aa5f3a04f54c2c930ce2d /device-functions.c
parent5825c1d8982bb7ac65c0c43f34d1de07fda0aa38 (diff)
implement ampl-dependent arbitrary voltage output - for AVR-E5-B S/N 13618
Diffstat (limited to 'device-functions.c')
-rw-r--r--device-functions.c62
1 files changed, 35 insertions, 27 deletions
diff --git a/device-functions.c b/device-functions.c
index 1cc4322..4e21c14 100644
--- a/device-functions.c
+++ b/device-functions.c
@@ -250,7 +250,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 switch_range_only,int channel,float new_ampl,int called_from_set_pw)
{
- int word_out; /* what is sent to the DAC */
+ int word_out, word_out_aux; /* what is sent to the DAC */
int relay_range,atten_range,old_range,old_actual_pol; /* selects relay range */
int UseNegData; /* if polarity is negative and separate piece-wise linear data is available for neg */
int point_found;
@@ -307,7 +307,7 @@ int Set_Amplitude(int check_possible_only,int pol_override,int override_on,int w
/* determine the previous relay range */
Set_VI_Control(pwl_ampl_values,channel,globals.ChannelState[channel].amplitude,&point_found,
- &old_range,&atten_range,&UseNegData,&entry,&word_out,&old_actual_pol);
+ &old_range,&atten_range,&UseNegData,&entry,&word_out,&old_actual_pol,NULL);
}
word_out = -1;
@@ -324,7 +324,7 @@ int Set_Amplitude(int check_possible_only,int pol_override,int override_on,int w
/* set the amplitude controls now. */
int status;
if ((status=Set_VI_Control(pwl_ampl_values,channel,new_ampl,&point_found,
- &relay_range,&atten_range,&UseNegData,&entry,&word_out,&actual_pol))) {
+ &relay_range,&atten_range,&UseNegData,&entry,&word_out,&actual_pol,&word_out_aux))) {
return status;
}
}
@@ -349,10 +349,13 @@ int Set_Amplitude(int check_possible_only,int pol_override,int override_on,int w
globals.Timers.Relay_Switching_Delay_in_Milliseconds=(long) (1000L * globals.Flash.extended_relay_delay_in_sec);
}
+ if (globals.Flash.distort_enabled[channel]) {
+ printf ("distort %d\n",word_out_aux);
+ set_dac(globals.Flash.distort_dac[channel],word_out_aux);
+ }
set_dac(globals.Flash.ampl_DAC[channel],word_out);
-
if (!channel) {
if (!globals.Flash.ampl_ranges_for_ch2_only) {
if ((globals.Flash.ChanKey_amplitude?globals.Flash.channels:1)<=1) {
@@ -509,7 +512,7 @@ int Set_Pw(int check_possible_only,int word_override,int range_override,int chan
} else {
/* set the pw controls now. */
if ((status=Set_VI_Control(pwl_pw_values,channel,set_pw,&point_found,
- &relay_range,&dummy,&UseNegData,&entry,&word_out,&actual_pol))) {
+ &relay_range,&dummy,&UseNegData,&entry,&word_out,&actual_pol,NULL))) {
return status;
}
}
@@ -621,7 +624,7 @@ int Set_Pw(int check_possible_only,int word_override,int range_override,int chan
/* use CH2 calibration to do this */
if (globals.Flash.is_monocycle[0] && channel==0) {
if ((status=Set_VI_Control(pwl_pw_values,1,set_pw,&point_found,
- &relay_range,&dummy,&UseNegData,&entry,&word_out,&actual_pol))) {
+ &relay_range,&dummy,&UseNegData,&entry,&word_out,&actual_pol,NULL))) {
return status;
}
set_dac(globals.Flash.monocycle_dac[0],word_out);
@@ -672,7 +675,7 @@ int Set_Offset(int check_possible_only,int override_on,int word_override,int ran
/* determine the previous relay range */
Set_VI_Control(pwl_os_values,channel,globals.ChannelState[channel].offset,&point_found,
- &old_range,&dummy0,&dummy1,&dummy2,&word_out,&dummy3);
+ &old_range,&dummy0,&dummy1,&dummy2,&word_out,&dummy3,NULL);
}
if (override_on) {
@@ -681,7 +684,7 @@ int Set_Offset(int check_possible_only,int override_on,int word_override,int ran
} else {
int status;
if ((status=Set_VI_Control(pwl_os_values,channel,new_offset,&point_found,
- &relay_range,&dummy0,&dummy2,&entry,&word_out,&actual_pol))) {
+ &relay_range,&dummy0,&dummy2,&entry,&word_out,&actual_pol,NULL))) {
return status;
}
}
@@ -757,7 +760,7 @@ int Set_frequency(int check_possible_only,int word_override,int range_override,i
/* added Feb 23/05 */
/* determine the previous relay range */
Set_VI_Control(pwl_period_values,channel,1.0/globals.ChannelState[channel].frequency,&point_found,
- &old_range,&dummy,&UseNegData,&entry,&word_out,&actual_pol);
+ &old_range,&dummy,&UseNegData,&entry,&word_out,&actual_pol,NULL);
}
/* find appropriate range/fine settings from piece-wise linear data in flash memory */
@@ -768,7 +771,7 @@ int Set_frequency(int check_possible_only,int word_override,int range_override,i
/* set the amplitude controls now. */
int status;
if ((status=Set_VI_Control(pwl_period_values,channel,1.0/set_freq,&point_found,
- &relay_range,&dummy,&UseNegData,&entry,&word_out,&actual_pol))) {
+ &relay_range,&dummy,&UseNegData,&entry,&word_out,&actual_pol,NULL))) {
return status;
}
}
@@ -911,7 +914,7 @@ int Set_Delay(int check_possible_only,int word_override,int range_override,int c
/* 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))) {
+ &relay_range,&dummy,&UseNegData,&entry,&word_out,&actual_pol,NULL))) {
g_print_debug("delay set status: %d",status);
return status;
}
@@ -1678,7 +1681,7 @@ int Set_Amp_Calib(int channel,float meas_ampl)
/* get current range and polarity settings */
Set_VI_Control(pwl_ampl_values,channel,globals.ChannelState[channel].amplitude,&point_found,
- &relay_range,&atten_range,&UseNegData,&entry,&word_out,&actual_pol);
+ &relay_range,&atten_range,&UseNegData,&entry,&word_out,&actual_pol,NULL);
if (fabs(globals.ChannelState[channel].amplitude)<globals.Flash.ampl_zero_equiv[channel]) {
return NeedNonZeroAmpl;
@@ -1721,7 +1724,7 @@ int Set_Mon_Calib(int channel,float meas_ampl)
/* get current range and polarity settings */
Set_VI_Control(pwl_ampl_values,channel,globals.ChannelState[channel].amplitude,&point_found,
- &relay_range,&atten_range,&UseNegData,&entry,&word_out,&actual_pol);
+ &relay_range,&atten_range,&UseNegData,&entry,&word_out,&actual_pol,NULL);
if (fabs(globals.ChannelState[channel].Curr_Mon_value)< (5.0 * globals.Flash.monitor_step[channel])) {
return NeedNonZeroAmpl;
@@ -2548,7 +2551,7 @@ int Set_VI_Del_Cal(int parameter,int channel,int calibration_point_number)
static int linear_interpolation (int x1, int x2, float y1, float y2, float y_need)
{
- if ((y2 == y1) || (x2 == x1)) {
+ if (y2 == y1) {
return -1;
}
@@ -2577,7 +2580,7 @@ static int inverse_interpolation (int x1, int x2, float y1, float y2, float y_ne
int Set_VI_Control(int parameter,int channel,float new_ampl,int *point_found,int *relay_range,int *atten_range,
- int *UseNegData,int *entry,int *word_out,int *actual_pol)
+ int *UseNegData,int *entry,int *word_out,int *actual_pol,int *word_out_aux)
{
float use_ampl,tweaked_use_ampl;
int i;
@@ -2587,6 +2590,8 @@ int Set_VI_Control(int parameter,int channel,float new_ampl,int *point_found,int
int max_points,max_polarity,max_ranges;
float *pwl;
short *pwl_dacval;
+ short *pwl_dacval_aux; /* a second coupled set of dac values, for distort output */
+
int index,use_range;
int range_i,entry_i;
int pw_polarity;
@@ -2612,7 +2617,6 @@ int Set_VI_Control(int parameter,int channel,float new_ampl,int *point_found,int
min_os_in_range=max_os_in_range=0.0;
min_ampl_in_range=max_ampl_in_range=0.0;
-
switch (parameter) {
case pwl_ampl_values:
@@ -2623,6 +2627,7 @@ int Set_VI_Control(int parameter,int channel,float new_ampl,int *point_found,int
max_polarity=ampl_polarities;
max_ranges=ampl_ranges;
pwl_dacval=&globals.Flash.ampl_dacval[0][0][0][0];
+ pwl_dacval_aux=&globals.Flash.distort_dacval[0][0][0][0];
pwl=&globals.Flash.ampl_pwl[0][0][0][0];
if (new_ampl<0.0) {
*actual_pol=1;
@@ -2953,6 +2958,9 @@ int Set_VI_Control(int parameter,int channel,float new_ampl,int *point_found,int
*word_out = inverse_interpolation (pwl_dacval[index], pwl_dacval[index+1], pwlamp1, pwlamp2, tweaked_use_ampl);
} else {
*word_out = linear_interpolation (pwl_dacval[index], pwl_dacval[index+1], pwlamp1, pwlamp2, tweaked_use_ampl);
+ if (pwl_dacval_aux && word_out_aux) {
+ *word_out_aux = linear_interpolation (pwl_dacval_aux[index], pwl_dacval_aux[index+1], pwlamp1, pwlamp2, tweaked_use_ampl);
+ }
}
}
}
@@ -3065,7 +3073,7 @@ int Set_VI_Add_Cal(int parameter,int channel,float cal_point)
size_of_y_float=sizeof(globals.Flash.ampl_pwl);
Set_VI_Control(pwl_ampl_values,channel,globals.ChannelState[channel].amplitude,&point_found,
- &range,&atten_range,&polarity,&entry,&word_out,&actual_pol);
+ &range,&atten_range,&polarity,&entry,&word_out,&actual_pol,NULL);
old_val=globals.ChannelState[channel].amplitude;
abs_cal_point=fabs(cal_point); /* ampl data is positive always */
@@ -3086,7 +3094,7 @@ int Set_VI_Add_Cal(int parameter,int channel,float cal_point)
old_val=globals.ChannelState[channel].offset;
Set_VI_Control(pwl_os_values,channel,old_val,&point_found,
- &range,&atten_range,&polarity,&entry,&word_out,&actual_pol);
+ &range,&atten_range,&polarity,&entry,&word_out,&actual_pol,NULL);
break;
case pwl_pw_values:
max_polarity=timing_polarities;
@@ -3097,7 +3105,7 @@ int Set_VI_Add_Cal(int parameter,int channel,float cal_point)
size_of_y_float=sizeof(globals.Flash.pw_pwl);
old_val=globals.ChannelState[channel].pw;
Set_VI_Control(pwl_pw_values,channel,old_val,&point_found,
- &range,&atten_range,&polarity,&entry,&word_out,&actual_pol);
+ &range,&atten_range,&polarity,&entry,&word_out,&actual_pol,NULL);
break;
case pwl_delay_values:
max_polarity=timing_polarities;
@@ -3108,7 +3116,7 @@ int Set_VI_Add_Cal(int parameter,int channel,float cal_point)
size_of_y_float=sizeof(globals.Flash.delay_pwl);
old_val=globals.ChannelState[channel].delay;
Set_VI_Control(pwl_delay_values,channel,old_val,&point_found,
- &range,&atten_range,&polarity,&entry,&word_out,&actual_pol);
+ &range,&atten_range,&polarity,&entry,&word_out,&actual_pol,NULL);
break;
case pwl_period_values:
max_polarity=timing_polarities;
@@ -3119,7 +3127,7 @@ int Set_VI_Add_Cal(int parameter,int channel,float cal_point)
size_of_y_float=sizeof(globals.Flash.period_pwl);
old_val=1.0/globals.ChannelState[channel].frequency;
Set_VI_Control(pwl_period_values,channel,old_val,&point_found,
- &range,&atten_range,&polarity,&entry,&word_out,&actual_pol);
+ &range,&atten_range,&polarity,&entry,&word_out,&actual_pol,NULL);
break;
case pwl_burst_values:
max_polarity=timing_polarities;
@@ -3130,7 +3138,7 @@ int Set_VI_Add_Cal(int parameter,int channel,float cal_point)
size_of_y_float=sizeof(globals.Flash.burst_pwl);
old_val=globals.ChannelState[channel].burst_time;
Set_VI_Control(pwl_burst_values,channel,old_val,&point_found,
- &range,&atten_range,&polarity,&entry,&word_out,&actual_pol);
+ &range,&atten_range,&polarity,&entry,&word_out,&actual_pol,NULL);
break;
case pwl_rise_time_values:
max_polarity=ampl_polarities;
@@ -3141,7 +3149,7 @@ int Set_VI_Add_Cal(int parameter,int channel,float cal_point)
size_of_y_float=sizeof(globals.Flash.rise_time_pwl);
old_val=globals.ChannelState[channel].rise_time;
Set_VI_Control(pwl_rise_time_values,channel,old_val,&point_found,
- &range,&atten_range,&polarity,&entry,&word_out,&actual_pol);
+ &range,&atten_range,&polarity,&entry,&word_out,&actual_pol,NULL);
break;
case pwl_slew_values:
max_polarity=timing_polarities;
@@ -3152,7 +3160,7 @@ int Set_VI_Add_Cal(int parameter,int channel,float cal_point)
size_of_y_float=sizeof(globals.Flash.slew_pwl);
old_val=globals.ChannelState[channel].slew;
Set_VI_Control(pwl_slew_values,channel,old_val,&point_found,
- &range,&atten_range,&polarity,&entry,&word_out,&actual_pol);
+ &range,&atten_range,&polarity,&entry,&word_out,&actual_pol,NULL);
break;
}
@@ -3593,7 +3601,7 @@ int Set_Burst_Time(int check_possible_only,int word_override,int range_override,
} else {
int status;
if ((status=Set_VI_Control(pwl_burst_values,channel,new_burst_time,&point_found,
- &relay_range,&dummy,&UseNegData,&entry,&word_out,&actual_pol))) {
+ &relay_range,&dummy,&UseNegData,&entry,&word_out,&actual_pol,NULL))) {
return status;
}
}
@@ -3700,7 +3708,7 @@ int Set_rise_time(int check_possible_only,int word_override,int range_override,i
} 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))) {
+ &relay_range,&dummy,&UseNegData,&entry,&word_out,&actual_pol,NULL))) {
return status;
}
}
@@ -3876,7 +3884,7 @@ int Set_slew(int check_possible_only,int word_override,int range_override,int ch
relay_range=range_override;
} else {
if ((status=Set_VI_Control(pwl_slew_values,channel,new_slew,&point_found,
- &relay_range,&dummy,&UseNegData,&entry,&word_out,&actual_pol))) {
+ &relay_range,&dummy,&UseNegData,&entry,&word_out,&actual_pol,NULL))) {
return status;
}
}