diff options
author | Mike <mjc@avtechpulse.com> | 2000-01-01 01:14:34 +0900 |
---|---|---|
committer | Mike <mjc@avtechpulse.com> | 2000-01-01 01:14:34 +0900 |
commit | 9c0934c05cfd93881d2c4cc713d0cf91e874b2c7 (patch) | |
tree | 32853ef683caed0fe83062d511af0f1331088714 | |
parent | 635528d0cb0590f5578cb6ab1d0e0b97b51f0c15 (diff) |
Add commands to add EA distort voltages based on existing ampl cal points
-rw-r--r-- | device-functions.c | 74 | ||||
-rw-r--r-- | error_utils.c | 5 | ||||
-rw-r--r-- | globals.h | 2 | ||||
-rw-r--r-- | parser.c | 16 |
4 files changed, 87 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]; diff --git a/error_utils.c b/error_utils.c index dfd6f93..24bcd86 100644 --- a/error_utils.c +++ b/error_utils.c @@ -73,6 +73,7 @@ void set_gpib_error_flags (int error_num) case NetworkNotFound: case Startup_Not_Finished: case GPIB_missing: + case Between_0_and_10_Volts: GPIB_Set_Device_Dependent_Error(); break; default: @@ -465,6 +466,10 @@ void get_error_text(gchar **response, int error_num) format_error_text(response,-340,"Percent change is too large."); break; + case Between_0_and_10_Volts: + format_error_text(response,-340,"Must be between 0.0 and 10.0."); + break; + case CalibrationPolarityError: format_error_text(response,-340,"Old and new polarities disagree."); break; @@ -107,6 +107,7 @@ #define CalibrationMinMaxError_slew 93 #define Dead_Time_Error 94 #define Cant_Do_Burst_and_Double 95 +#define Between_0_and_10_Volts 96 #define YES 1 #define NO 0 @@ -140,6 +141,7 @@ #define pwl_burst_values 6 #define pwl_rise_time_values 7 #define pwl_slew_values 9 +#define pwl_distort_values 10 #define dac_max 8191 @@ -353,6 +353,8 @@ static int Parser_id_word(char *id_me, int *channel, int *with_id_code) id_code = 108; } else if (!strcmp(id_me,"attenuator") || !strcmp(id_me,"att")) { id_code = 109; + } else if (!strcmp(id_me,"distort")) { + id_code = 110; } else { id_code = 9999; } @@ -479,6 +481,7 @@ static int Parser_find_commands(int commands[], int command_depth) {88,37}, /* calibration:frequency - 101 */ {23,57,108}, /* diag:eprom:reset - 102 */ {23,109,16|optional}, /* diag:attenuator:state - 103 */ + {23,32,110,88,93}, /* diag:ampl:distort:calib:point - 104 */ }; @@ -1047,6 +1050,10 @@ void Parser_main (char *raw_in, int interactive_terminal, void(*cbfunc)(gpointer case 103: error_num=Go_atten_103(&response,channel,parameter,units,command_type); break; + case 104: + error_num=Go_amp_pnt_83(&response,channel,parameter,units,command_type,pwl_distort_values); + break; + case 9999: // was only whitespace, ignore break; @@ -3451,6 +3458,15 @@ static int Go_amp_pnt_83(gchar** response, int channel, char *parameter,char *un return Unrecognized; } break; + case pwl_distort_values: + if (status = check_channel_ok (channel, globals.Flash.channels, globals.Flash.ChanKey_amplitude)) { + return status; + } + if (!globals.Flash.distort_enabled[channel]) { + return Unrecognized; + } + break; + case pwl_rise_time_values: if (status = check_channel_ok (channel, globals.Flash.channels, globals.Flash.ChanKey_rise_time)) { return status; |