summaryrefslogtreecommitdiff
path: root/device-functions.c
diff options
context:
space:
mode:
authorMike <mjc@avtechpulse.com>2000-01-01 00:37:29 +0900
committerMike <mjc@avtechpulse.com>2000-01-01 00:37:29 +0900
commit635528d0cb0590f5578cb6ab1d0e0b97b51f0c15 (patch)
treed0d051bf23134d0a8a072e591c1862e0752c6e66 /device-functions.c
parentefca4799e5dbb52fed6963b88d8c73e59b42e123 (diff)
First attempt at handling pwl_distort automatically when adding ampl cal points
Diffstat (limited to 'device-functions.c')
-rw-r--r--device-functions.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/device-functions.c b/device-functions.c
index e8a31ec..6b53063 100644
--- a/device-functions.c
+++ b/device-functions.c
@@ -3094,12 +3094,14 @@ int Set_VI_Add_Cal(int parameter,int channel,float cal_point)
float temp_y_float1[points_in_range+1];
float temp_x_float1[points_in_range+1]; /* float copy of short, for calculations */
int temp_x_short1[points_in_range+1];
+ int temp_x_short2[points_in_range+1];
int index,actual_pol;
float *pointer_y_float1;
short *pointer_x_short1;
+ short *pointer_x_short2;
- int eprom_loc,size_of_y_float1,size_of_x_short1;
+ int eprom_loc,size_of_y_float1,size_of_x_short1,size_of_x_short2;
int true_channel;
@@ -3108,6 +3110,7 @@ int Set_VI_Add_Cal(int parameter,int channel,float cal_point)
range=polarity=0;
max_points=points_in_range;
+ pointer_x_short2=0;
abs_cal_point=cal_point;
@@ -3117,8 +3120,10 @@ int Set_VI_Add_Cal(int parameter,int channel,float cal_point)
max_ranges=ampl_ranges;
pointer_x_short1=&globals.Flash.ampl_dacval[0][0][0][0];
+ pointer_x_short2=&globals.Flash.distort_dacval[0][0][0][0];
pointer_y_float1=&globals.Flash.ampl_pwl[0][0][0][0];
size_of_x_short1=sizeof(globals.Flash.ampl_dacval);
+ size_of_x_short2=sizeof(globals.Flash.distort_dacval);
size_of_y_float1=sizeof(globals.Flash.ampl_pwl);
Set_VI_Control(pwl_ampl_values,channel,globals.ChannelState[channel].amplitude,&point_found,
@@ -3217,6 +3222,7 @@ int Set_VI_Add_Cal(int parameter,int channel,float cal_point)
temp_y_float1[max_points]=0.0; /* Adding a cal point may temporarily result in 11 data points. */
temp_x_float1[max_points]=0.0; /* One is eventually discarded. */
temp_x_short1[max_points]=0;
+ temp_x_short2[max_points]=0;
index=true_channel*max_ranges*max_polarity*max_points
@@ -3228,6 +3234,9 @@ int Set_VI_Add_Cal(int parameter,int channel,float cal_point)
for (i=0; i<max_points; i++) {
temp_y_float1[i]=pointer_y_float1[index+i]; /* work on this data */
temp_x_short1[i]=pointer_x_short1[index+i];
+ if (pointer_x_short2) {
+ temp_x_short2[i]=pointer_x_short2[index+i];
+ }
}
@@ -3262,16 +3271,25 @@ int Set_VI_Add_Cal(int parameter,int channel,float cal_point)
for (i=max_points-1; i>entry; i--) {
temp_y_float1[i+1]=temp_y_float1[i];
temp_x_short1[i+1]=temp_x_short1[i];
+ if (pointer_x_short2) {
+ temp_x_short2[i+1]=temp_x_short2[i];
+ }
}
/* add the new data */
temp_y_float1[entry+1]=abs_cal_point;
temp_x_short1[entry+1]=word_out;
+
for (i=0; i<=max_points; ++i) {
temp_x_float1[i]=(float) temp_x_short1[i];
}
+ if (pointer_x_short2) {
+ // use a simple average of the nearest points for the pw distort dac
+ temp_x_short2[entry+1]= (temp_x_short2[entry] + temp_x_short2[entry+2]) / 2;
+ }
+
/* delete a point, if required */
if (total==max_points) {
@@ -3299,6 +3317,9 @@ int Set_VI_Add_Cal(int parameter,int channel,float cal_point)
temp_y_float1[i]=temp_y_float1[i+1];
temp_x_float1[i]=temp_x_float1[i+1];
temp_x_short1[i]=temp_x_short1[i+1];
+ if (pointer_x_short2) {
+ temp_x_short2[i]=temp_x_short2[i+1];
+ }
}
}
@@ -3307,6 +3328,9 @@ int Set_VI_Add_Cal(int parameter,int channel,float cal_point)
for (i=0; i<max_points; i++) {
*(float *)(&pointer_y_float1[index+i])=temp_y_float1[i];
*(short *)(&pointer_x_short1[index+i])=temp_x_short1[i];
+ if (pointer_x_short2) {
+ *(short *)(&pointer_x_short2[index+i])=temp_x_short2[i];
+ }
}
eprom_loc = (char *) pointer_x_short1 - (char *) &(globals.Flash.flash_start);
@@ -3315,6 +3339,11 @@ int Set_VI_Add_Cal(int parameter,int channel,float cal_point)
eprom_loc = (char *) pointer_y_float1 - (char *) &(globals.Flash.flash_start);
writeUserBlock(&globals.Flash, eprom_loc, size_of_y_float1);
+ if (pointer_x_short2) {
+ eprom_loc = (char *) pointer_x_short2 - (char *) &(globals.Flash.flash_start);
+ writeUserBlock(&globals.Flash, eprom_loc, size_of_x_short2);
+ }
+
globals.Flags.extended_ampl_min_max=NO;
/* update output */