mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-23 15:00:02 +02:00
rate corr atble changes
This commit is contained in:
parent
d28d737fb9
commit
dd2a0c50e0
@ -1800,7 +1800,6 @@ int Feb_Control_SetRateCorrectionTau(int64_t tau_in_Nsec){
|
|||||||
double b0[1024];
|
double b0[1024];
|
||||||
double m[1024];
|
double m[1024];
|
||||||
|
|
||||||
|
|
||||||
if(tau_in_sec<0||sub_expure_time_in_sec<0){
|
if(tau_in_sec<0||sub_expure_time_in_sec<0){
|
||||||
printf("Error tau %f and sub_expure_time %f must be greater than 0.\n", tau_in_sec, sub_expure_time_in_sec);
|
printf("Error tau %f and sub_expure_time %f must be greater than 0.\n", tau_in_sec, sub_expure_time_in_sec);
|
||||||
return 0;
|
return 0;
|
||||||
@ -1828,17 +1827,24 @@ int Feb_Control_SetRateCorrectionTau(int64_t tau_in_Nsec){
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
int next_i=0;
|
int next_i=0;
|
||||||
|
|
||||||
b0[0] = 0;
|
b0[0] = 0;
|
||||||
m[0] = 1;
|
m[0] = 1;
|
||||||
int b;
|
|
||||||
|
for(i=0; i<1024; i++)
|
||||||
|
Feb_Control_rate_correction_table[i] = 65535;
|
||||||
|
|
||||||
|
Feb_Control_rate_correction_table[0] = (((int)(m[0]+0.5)&0xf)<<14) | ((int)(b0[0]+0.5)&0x3fff);
|
||||||
|
|
||||||
|
int b=0;
|
||||||
for(b=1;b<1024;b++){
|
for(b=1;b<1024;b++){
|
||||||
if(m[b-1]<14.5){
|
if(m[b-1]<15){
|
||||||
double s=0,sx=0,sy=0,sxx=0,sxy=0;
|
double s=0,sx=0,sy=0,sxx=0,sxy=0;
|
||||||
for(;;next_i++){
|
for(;;next_i++){
|
||||||
if(next_i>=np){
|
if(next_i>=np){
|
||||||
cprintf(RED,"Error: (tau/subexptime) must be < 0.0015 \n");
|
b=1024;
|
||||||
return -1;
|
b0[b] = 16383;
|
||||||
|
m[b] = 15;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
double x = Feb_Control_rate_meas[next_i] - b*4;
|
double x = Feb_Control_rate_meas[next_i] - b*4;
|
||||||
@ -1862,16 +1868,17 @@ int Feb_Control_SetRateCorrectionTau(int64_t tau_in_Nsec){
|
|||||||
b0[b] = (sxx*sy - sx*sxy)/delta;
|
b0[b] = (sxx*sy - sx*sxy)/delta;
|
||||||
m[b] = (s*sxy - sx*sy) /delta;
|
m[b] = (s*sxy - sx*sy) /delta;
|
||||||
|
|
||||||
if(m[b]<0||m[b]>15)
|
if(m[b]<0||m[b]>15){
|
||||||
m[b]=15;
|
m[b]=15;
|
||||||
|
b0[b]=16383;
|
||||||
|
}
|
||||||
/*printf("After Loop s: %f,\t sx: %f,\t sy: %f,\t sxx: %f,\t sxy: %f,\t "
|
/*printf("After Loop s: %f,\t sx: %f,\t sy: %f,\t sxx: %f,\t sxy: %f,\t "
|
||||||
"next_i: %d,\t b: %d,\t Feb_Control_rate_meas[next_i]: %f\n",
|
"next_i: %d,\t b: %d,\t Feb_Control_rate_meas[next_i]: %f\n",
|
||||||
s, sx, sy, sxx, sxy, next_i, b, Feb_Control_rate_meas[next_i]);*/
|
s, sx, sy, sxx, sxy, next_i, b, Feb_Control_rate_meas[next_i]);*/
|
||||||
// cout<<s<<" "<<sx<<" "<<sy<<" "<<sxx<<" "<<" "<<sxy<<" "<<delta<<" "<<m[b]<<" "<<b0[b]<<endl;
|
// cout<<s<<" "<<sx<<" "<<sy<<" "<<sxx<<" "<<" "<<sxy<<" "<<delta<<" "<<m[b]<<" "<<b0[b]<<endl;
|
||||||
}else{
|
}else{
|
||||||
b0[b] = b0[b-1] + 4*m[b-1];
|
b0[b] = 16383;
|
||||||
m[b] = m[b-1];
|
m[b] = 15;
|
||||||
/*printf("else\n");*/
|
|
||||||
}
|
}
|
||||||
Feb_Control_rate_correction_table[b] = (((int)(m[b]+0.5)&0xf)<<14) | ((int)(b0[b]+0.5)&0x3fff);
|
Feb_Control_rate_correction_table[b] = (((int)(m[b]+0.5)&0xf)<<14) | ((int)(b0[b]+0.5)&0x3fff);
|
||||||
/*printf("After Loop 4*b: %d\tbase:%d\tslope:%d\n",4*b, (int)(b0[b]+0.5), (int)(m[b]+0.5) );*/
|
/*printf("After Loop 4*b: %d\tbase:%d\tslope:%d\n",4*b, (int)(b0[b]+0.5), (int)(m[b]+0.5) );*/
|
||||||
@ -1953,6 +1960,8 @@ int Feb_Control_PrintCorrectedValues(){
|
|||||||
slope = ((Feb_Control_rate_correction_table[i>>2] & 0x3c000) >> 14);
|
slope = ((Feb_Control_rate_correction_table[i>>2] & 0x3c000) >> 14);
|
||||||
delta = slope*lsb;
|
delta = slope*lsb;
|
||||||
corr = delta+base;
|
corr = delta+base;
|
||||||
|
if(base==16383 && slope==15) corr=4095;
|
||||||
|
|
||||||
printf("Readout Input: %d,\tBase:%d,\tSlope:%d,\tLSB:%d,\tDelta:%d\tResult:%d\tReal:%f\n",
|
printf("Readout Input: %d,\tBase:%d,\tSlope:%d,\tLSB:%d,\tDelta:%d\tResult:%d\tReal:%f\n",
|
||||||
i, base, slope, lsb, delta, corr, Feb_Control_rate_meas[i]);
|
i, base, slope, lsb, delta, corr, Feb_Control_rate_meas[i]);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user