diff options
Diffstat (limited to 'device-functions.c')
-rw-r--r-- | device-functions.c | 74 |
1 files changed, 64 insertions, 10 deletions
diff --git a/device-functions.c b/device-functions.c index 6b53063..5c2ed2c 100644 --- a/device-functions.c +++ b/device-functions.c @@ -2129,8 +2129,12 @@ int Set_Cal_Nom(int channel,int calibration_point_number,int parameter, float *n nominal_val=globals.Flash.slew_pwl[channel][range][polarity][entry]; nominal_wordout=globals.Flash.slew_dacval[channel][range][polarity][entry]; break; + default: + return SyntaxError; + break; } + /* just get nominal value, don't activate */ if (nom_val) { *nom_val = nominal_val; @@ -2293,15 +2297,20 @@ int Set_VI_Cal_Pnt(int parameter,int channel,int calibration_point_number,float { int polarity,range,entry,status,num_in_range,num_of_ranges,eprom_loc; float nom_ampl; + int nom_distort; int index; int max_points,max_polarity,max_ranges; - float *pwl; + float *pwl; // most cases + short *pwl_distort; // special case int true_channel; true_channel=channel; Get_VI_Rng_Info(parameter,channel,calibration_point_number,&range,&polarity,&entry,&num_in_range,&num_of_ranges); + pwl = 0; + pwl_distort = 0; + max_points=points_in_range; switch (parameter) { case (pwl_ampl_values): @@ -2309,6 +2318,11 @@ int Set_VI_Cal_Pnt(int parameter,int channel,int calibration_point_number,float max_ranges=ampl_ranges; pwl=&globals.Flash.ampl_pwl[0][0][0][0]; break; + case (pwl_distort_values): + max_polarity=ampl_polarities; + max_ranges=ampl_ranges; + pwl_distort=&globals.Flash.distort_dacval[0][0][0][0]; + break; case (pwl_os_values): max_polarity=os_polarities; max_ranges=os_ranges; @@ -2350,7 +2364,13 @@ int Set_VI_Cal_Pnt(int parameter,int channel,int calibration_point_number,float +polarity*max_points +entry; - nom_ampl=pwl[index]; + if (pwl) { + nom_ampl=pwl[index]; + } + + if (pwl_distort) { + nom_distort = pwl_distort[index]; + } switch (parameter) { case (pwl_ampl_values): @@ -2403,6 +2423,11 @@ int Set_VI_Cal_Pnt(int parameter,int channel,int calibration_point_number,float } break; + case pwl_distort_values: + if ((cal_point < 0.0) || (cal_point > 10.0)) { + return Between_0_and_10_Volts; + } + break; } @@ -2414,14 +2439,28 @@ int Set_VI_Cal_Pnt(int parameter,int channel,int calibration_point_number,float cal_point=fabs(cal_point); } - *(float *)(&pwl[index])=cal_point; + if (pwl) { + *(float *)(&pwl[index])=cal_point; + } - /* see if new point prevents min/max from being obtained */ - status=Check_MinMax_Cal(channel,parameter); + if (pwl_distort) { + /* supplied as a voltage between 0 and 10.0 Volts */ + *(short *)(&pwl_distort[index])=(cal_point/10.0) * dac_max; + } - if (status) { - /* revert to original value if required */ - *(float *)(&pwl[index])=nom_ampl; + if (pwl) { + /* see if new point prevents min/max from being obtained */ + status=Check_MinMax_Cal(channel,parameter); + + if (status) { + /* revert to original value if required */ + *(float *)(&pwl[index])=nom_ampl; + } + } + + if (pwl_distort) { + // update amplitude now + parameter = pwl_ampl_values; } Set_Cal_Nom(channel,calibration_point_number,parameter,NULL); @@ -2429,8 +2468,15 @@ int Set_VI_Cal_Pnt(int parameter,int channel,int calibration_point_number,float Main_update_shift_registers(); Show_Main_Menu(); - eprom_loc = (char *) (&pwl[index]) - (char *) &(globals.Flash.flash_start); - writeUserBlock(&globals.Flash, eprom_loc, sizeof(nom_ampl)); + if (pwl) { + eprom_loc = (char *) (&pwl[index]) - (char *) &(globals.Flash.flash_start); + writeUserBlock(&globals.Flash, eprom_loc, sizeof(nom_ampl)); + } + + if (pwl_distort) { + eprom_loc = (char *) (&pwl_distort[index]) - (char *) &(globals.Flash.flash_start); + writeUserBlock(&globals.Flash, eprom_loc, sizeof(nom_distort)); + } globals.Flags.extended_ampl_min_max=NO; return status; @@ -2523,6 +2569,10 @@ int Set_VI_Del_Cal(int parameter,int channel,int calibration_point_number) size_of_short1=sizeof(globals.Flash.slew_dacval); size_of_float1=sizeof(globals.Flash.slew_pwl); break; + + default: + return SyntaxError; + break; } Get_VI_Rng_Info(parameter,channel,calibration_point_number,&range,&polarity,&entry,&num_in_range,&num_of_ranges); @@ -3217,6 +3267,9 @@ int Set_VI_Add_Cal(int parameter,int channel,float cal_point) &range,&atten_range,&polarity,&entry,&word_out,&actual_pol,NULL); break; + default: + return SyntaxError; + break; } temp_y_float1[max_points]=0.0; /* Adding a cal point may temporarily result in 11 data points. */ @@ -3416,6 +3469,7 @@ int Get_VI_Rng_Info(int parameter, int channel, int calibration_point_number, in switch (parameter) { case pwl_ampl_values: + case pwl_distort_values: max_polarity=ampl_polarities; max_ranges=ampl_ranges; pwl=&globals.Flash.ampl_pwl[0][0][0][0]; |