Mercurial > hg > fxanalyse
comparison FXAnalyse.c @ 73:1dfaf5ef0352
Refactor mean and slope measurement
author | Daniele Nicolodi <daniele.nicolodi@obspm.fr> |
---|---|
date | Thu, 08 Nov 2012 13:05:55 +0100 |
parents | a945f2b7bef6 |
children | 6aae1ebf397f |
comparison
equal
deleted
inserted
replaced
72:8e6a2ec85169 | 73:1dfaf5ef0352 |
---|---|
67 int Measuring_1 = FALSE; | 67 int Measuring_1 = FALSE; |
68 int Measuring_2 = FALSE; | 68 int Measuring_2 = FALSE; |
69 int Measuring_3 = FALSE; | 69 int Measuring_3 = FALSE; |
70 | 70 |
71 double FrequDDS1=110000000.0, FrequDDS4=110000000.0; | 71 double FrequDDS1=110000000.0, FrequDDS4=110000000.0; |
72 double Slope_1=0.0,Slope_2=0.0,Slope_3=0.0,Beatslope_2=0.0; | 72 double Slope_1=0.0,Slope_2=0.0,Slope_3=0.0,Beatslope_2=0.0; |
73 double SlopeTime1=40.0, SlopeTime2=40.0; SlopeTime3=40.0; | 73 double SlopeTime1=40.0, SlopeTime2=40.0; SlopeTime3=40.0; |
74 double Ch4Slope = 0.0; | |
74 | 75 |
75 double N_1=0.0, N_2=0.0, N_3=0.0; | 76 double N_1=0.0, N_2=0.0, N_3=0.0; |
76 double DeltaT_1=20.0, DeltakHz_1=500.0, t1_1=0.0, t2_1=0.0, t3_1=0.0, Frepplus_1=0.0, Frepminus_1=0.0; | 77 double DeltaT_1=20.0, DeltakHz_1=500.0, t1_1=0.0, t2_1=0.0, t3_1=0.0, Frepplus_1=0.0, Frepminus_1=0.0; |
77 double DeltaT_2=20.0, DeltakHz_2=500.0, t1_2=0.0, t2_2=0.0, t3_2=0.0, Frepplus_2=0.0, Frepminus_2=0.0; | 78 double DeltaT_2=20.0, DeltakHz_2=500.0, t1_2=0.0, t2_2=0.0, t3_2=0.0, Frepplus_2=0.0, Frepminus_2=0.0; |
78 double DeltaT_3=20.0, DeltakHz_3=500.0, t1_3=0.0, t2_3=0.0, t3_3=0.0, Frepplus_3=0.0, Frepminus_3=0.0; | 79 double DeltaT_3=20.0, DeltakHz_3=500.0, t1_3=0.0, t2_3=0.0, t3_3=0.0, Frepplus_3=0.0, Frepminus_3=0.0; |
79 | 80 |
80 int n_1=0, n_2=0, n_3=0; | 81 int n_1=0, n_2=0, n_3=0; |
81 double Frequ_slope_1=0.0,Moy_slope_1=0.0,Slope_slope_1=0.0,Frequ_slope_2=0.0,Moy_slope_2=0.0,Slope_slope_2=0.0,Frequ_slope_3=0.0,Moy_slope_3=0.0,Slope_slope_3=0.0; | |
82 int N_slope_1=0,N_slope_2=0,N_slope_3=0; | |
83 double Beat_slope_2=0.0 ,Moy_Beatslope_2=0.0,Slope_Beatslope_2=0.0; | |
84 double Ch4_slope=0.0,Moy_Ch4slope_1=0.0,Slope_Ch4slope_1=0.0,Ch4Slope=0.0; | |
85 | 82 |
86 double FrequencyDDSBesInit = 0.0; | 83 double FrequencyDDSBesInit = 0.0; |
87 double FrequencyDDS3Init = 0.0; | 84 double FrequencyDDS3Init = 0.0; |
88 | 85 |
89 double DeltaDDS3=0.0,Delta10K_Plus=0.0,Delta10K_Minus=0.0; | 86 double DeltaDDS3=0.0,Delta10K_Plus=0.0,Delta10K_Minus=0.0; |
104 | 101 |
105 int SlopeMeasuring = FALSE; | 102 int SlopeMeasuring = FALSE; |
106 int StopSlopeCancellingOnUnlocked = TRUE; | 103 int StopSlopeCancellingOnUnlocked = TRUE; |
107 double TimetoSlope = 60.0; | 104 double TimetoSlope = 60.0; |
108 double SlopeMeasuringTimeBegin = 0.0; | 105 double SlopeMeasuringTimeBegin = 0.0; |
109 | 106 double appliedSlope = 0.0; // currently applied frequency dedrifiting slope |
110 int Nsamples = 0; // number of samples in current measurement | 107 |
111 double previousFreq = 0.0; // previous frequency value | |
112 double meanFreq = 0.0; // mean value | |
113 double measuredSlope = 0.0; // measured slope | |
114 double appliedSlope = 0.0; // currently applied frequency dedrifiting slope | |
115 | |
116 double LimitToDelock=5.0; | |
117 double limitotakoff=70.0; | 108 double limitotakoff=70.0; |
118 | 109 |
119 int ratio=10; //Recentre la frequence tous les ratios | 110 int ratio=10; //Recentre la frequence tous les ratios |
120 | 111 |
121 int FrequCorrec = FALSE, KeepFrequ = TRUE, KeepSlope = TRUE; | 112 int FrequCorrec = FALSE, KeepFrequ = TRUE, KeepSlope = TRUE; |
134 int KeepCentering = FALSE; | 125 int KeepCentering = FALSE; |
135 double Timetorecenter275K = 3600.0 * 10; | 126 double Timetorecenter275K = 3600.0 * 10; |
136 double Timetorecenter10K = 3600.0 * 3; | 127 double Timetorecenter10K = 3600.0 * 3; |
137 double CenteringTimeBegin275K = 0.0; | 128 double CenteringTimeBegin275K = 0.0; |
138 double CenteringTimeBegin10K = 0.0; | 129 double CenteringTimeBegin10K = 0.0; |
130 | |
131 | |
132 struct stat { | |
133 int samples; | |
134 double mean; | |
135 double slope; | |
136 double previous; | |
137 }; | |
138 | |
139 void stat_zero(struct stat *s) | |
140 { | |
141 s->samples = 0; | |
142 s->mean = 0.0; | |
143 s->slope = 0.0; | |
144 s->previous = 0.0; | |
145 } | |
146 | |
147 void stat_accumulate(struct stat *s, double value) | |
148 { | |
149 s->samples += 1; | |
150 | |
151 if (s->samples > 1) | |
152 s->slope = (s->slope * (s->samples - 2) + 6 * (value - s->mean) / s->samples) / (s->samples + 1); | |
153 | |
154 s->mean = ((s->samples - 1) * s->mean + value) / s->samples; | |
155 | |
156 s->previous = value; | |
157 } | |
158 | |
159 struct stat stat_math1, stat_ch2, stat_ch4, freq; | |
139 | 160 |
140 | 161 |
141 muParserHandle_t initMathParser() | 162 muParserHandle_t initMathParser() |
142 { | 163 { |
143 muParserHandle_t parser = mupCreate(); | 164 muParserHandle_t parser = mupCreate(); |
671 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, FrequDDS1); | 692 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, FrequDDS1); |
672 | 693 |
673 GetCtrlVal(MainPanel, PANEL_DDS2, &FrequencyDDSBesInit); | 694 GetCtrlVal(MainPanel, PANEL_DDS2, &FrequencyDDSBesInit); |
674 t2_1 = t3_1 = 0.0; | 695 t2_1 = t3_1 = 0.0; |
675 t1_1 = utc; | 696 t1_1 = utc; |
676 Frequ_slope_1 = Math1; | 697 |
677 Moy_slope_1 = Frequ_slope_1; | 698 stat_zero(&stat_math1); |
678 Ch4_slope = Ch4; | 699 stat_zero(&stat_ch4); |
679 Moy_Ch4slope_1 = Ch4_slope; | |
680 N_slope_1 = 1; | |
681 | 700 |
682 // next step | 701 // next step |
683 Measuring_1 += 1; | 702 Measuring_1 += 1; |
684 break; | 703 break; |
685 | 704 |
686 case N_MEASUREMENT_SLOPE: | 705 case N_MEASUREMENT_SLOPE: |
687 // slope measurement | 706 // slope measurement |
688 | 707 |
689 N_slope_1 = N_slope_1 + 1; | 708 stat_accumulate(&stat_math1, Math1); |
690 Frequ_slope_1 = Math1; | 709 stat_accumulate(&stat_ch4, Ch4); |
691 Ch4_slope = Ch4; | |
692 Moy_slope_1 = ((N_slope_1-1)*Moy_slope_1 + Frequ_slope_1)/N_slope_1; | |
693 Moy_Ch4slope_1 = ((N_slope_1-1)*Moy_Ch4slope_1 + Ch4_slope)/N_slope_1; | |
694 Slope_slope_1 = (Slope_slope_1*(N_slope_1-2) + 6*(Frequ_slope_1-Moy_slope_1)/N_slope_1)/(N_slope_1+1); | |
695 Slope_Ch4slope_1 = (Slope_Ch4slope_1*(N_slope_1-2) + 6*(Ch4_slope-Moy_Ch4slope_1)/N_slope_1)/(N_slope_1+1); | |
696 | 710 |
697 if ((utc - t1_1) > SlopeTime1) { | 711 if ((utc - t1_1) > SlopeTime1) { |
698 Slope_1 = Slope_slope_1; | 712 Slope_1 = stat_math1.slope; |
699 Ch4Slope = Slope_Ch4slope_1; | 713 Ch4Slope = stat_ch4.slope; |
700 SetCtrlVal(CalcN1Panel, CALCN1_SLOPE, Slope_1); | 714 SetCtrlVal(CalcN1Panel, CALCN1_SLOPE, Slope_1); |
701 | |
702 N_slope_1 = 0; | |
703 Frequ_slope_1 = 0.0; | |
704 Moy_slope_1 = 0.0; | |
705 Slope_slope_1 = 0.0; | |
706 Ch4_slope = 0.0; | |
707 Moy_Ch4slope_1 = 0.0; | |
708 Slope_Ch4slope_1 = 0.0; | |
709 | 715 |
710 // frep positive step | 716 // frep positive step |
711 DDS4xAD9912_FrequencyRampe(&DDS4xAD9912,1, FrequDDS1,(FrequDDS1+DeltakHz_1*1000), Step1/Ndiv); | 717 DDS4xAD9912_FrequencyRampe(&DDS4xAD9912,1, FrequDDS1,(FrequDDS1+DeltakHz_1*1000), Step1/Ndiv); |
712 SetCtrlVal(MainPanel, PANEL_DDS1, (FrequDDS1+DeltakHz_1*1000)); | 718 SetCtrlVal(MainPanel, PANEL_DDS1, (FrequDDS1+DeltakHz_1*1000)); |
713 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, (FrequDDS1+DeltakHz_1*1000)); | 719 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, (FrequDDS1+DeltakHz_1*1000)); |
832 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, FrequDDS1); | 838 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, FrequDDS1); |
833 | 839 |
834 GetCtrlVal(MainPanel, PANEL_DDS2, &FrequencyDDSBesInit); | 840 GetCtrlVal(MainPanel, PANEL_DDS2, &FrequencyDDSBesInit); |
835 GetCtrlVal(MainPanel, PANEL_DDS3, &FrequencyDDS3Init); | 841 GetCtrlVal(MainPanel, PANEL_DDS3, &FrequencyDDS3Init); |
836 t1_2 = utc; | 842 t1_2 = utc; |
837 Frequ_slope_2 = Math1; | 843 |
838 Beat_slope_2 = Ch2; | 844 stat_zero(&stat_math1); |
839 Moy_slope_2 = Frequ_slope_2; | 845 stat_zero(&stat_ch2); |
840 Moy_Beatslope_2 = Beat_slope_2; | 846 |
841 N_slope_2 = 1; | |
842 Nu1 = N1 * (250000000 + Math1); | 847 Nu1 = N1 * (250000000 + Math1); |
843 | 848 |
844 // next step | 849 // next step |
845 Measuring_2 += 1; | 850 Measuring_2 += 1; |
846 break; | 851 break; |
847 | 852 |
848 case N_MEASUREMENT_SLOPE: | 853 case N_MEASUREMENT_SLOPE: |
849 // slope measurement | 854 // slope measurement |
850 | 855 |
851 N_slope_2 = N_slope_2 + 1; | 856 stat_accumulate(&stat_math1, Math1); |
852 Frequ_slope_2 = Math1; | 857 stat_accumulate(&stat_ch2, Ch2); |
853 Beat_slope_2 = Ch2; | |
854 Moy_slope_2 = ((N_slope_2-1)*Moy_slope_2 + Frequ_slope_2)/N_slope_2; | |
855 Moy_Beatslope_2 = ((N_slope_2-1)*Moy_Beatslope_2 + Beat_slope_2)/N_slope_2; | |
856 Slope_slope_2 = (Slope_slope_2*(N_slope_2-2) + 6*(Frequ_slope_2-Moy_slope_2)/N_slope_2)/(N_slope_2+1); | |
857 Slope_Beatslope_2 = (Slope_Beatslope_2*(N_slope_2-2) + 6*(Beat_slope_2-Moy_Beatslope_2)/N_slope_2)/(N_slope_2+1); | |
858 | 858 |
859 if ((utc - t1_2) > SlopeTime2) { | 859 if ((utc - t1_2) > SlopeTime2) { |
860 Slope_2 = Slope_slope_2; | 860 Slope_2 = stat_math1.slope; |
861 Beatslope_2 = Slope_Beatslope_2; | 861 Beatslope_2 = stat_ch2.slope; |
862 SetCtrlVal(CalcN2Panel, CALCN2_SLOPE, Beatslope_2); | 862 SetCtrlVal(CalcN2Panel, CALCN2_SLOPE, Beatslope_2); |
863 | |
864 N_slope_2 = 0; | |
865 Frequ_slope_2 = 0.0; | |
866 Moy_slope_2 = 0.0; | |
867 Slope_slope_2 = 0.0; | |
868 Moy_Beatslope_2 = 0.0; | |
869 Slope_Beatslope_2 = 0.0; | |
870 Beat_slope_2 = 0.0; | |
871 | 863 |
872 // frep positive step | 864 // frep positive step |
873 double fDDS1 = FrequDDS1 + DeltakHz_2 * 1000; | 865 double fDDS1 = FrequDDS1 + DeltakHz_2 * 1000; |
874 printf("fDDS1 = %g\n", fDDS1); | 866 printf("fDDS1 = %g\n", fDDS1); |
875 DDS4xAD9912_FrequencyRampe(&DDS4xAD9912,1, FrequDDS1, fDDS1, Step2/Ndiv); | 867 DDS4xAD9912_FrequencyRampe(&DDS4xAD9912,1, FrequDDS1, fDDS1, Step2/Ndiv); |
1015 SetCtrlVal(MainPanel, PANEL_DDS4, FrequDDS4); | 1007 SetCtrlVal(MainPanel, PANEL_DDS4, FrequDDS4); |
1016 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 4, FrequDDS4); | 1008 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 4, FrequDDS4); |
1017 settling = 3; | 1009 settling = 3; |
1018 | 1010 |
1019 t1_3 = utc; | 1011 t1_3 = utc; |
1020 N_slope_3 = 0; | 1012 stat_zero(&stat_ch2); |
1013 | |
1021 // record current DDS3 frequency | 1014 // record current DDS3 frequency |
1022 GetCtrlVal(MainPanel, PANEL_DDS3, &FrequencyDDS3Init); | 1015 GetCtrlVal(MainPanel, PANEL_DDS3, &FrequencyDDS3Init); |
1023 | 1016 |
1024 // next step | 1017 // next step |
1025 Measuring_3 += 1; | 1018 Measuring_3 += 1; |
1031 if (settling > 0) { | 1024 if (settling > 0) { |
1032 settling--; | 1025 settling--; |
1033 break; | 1026 break; |
1034 } | 1027 } |
1035 | 1028 |
1036 N_slope_3++; | 1029 stat_accumulate(&stat_ch2, Ch2); |
1037 Frequ_slope_3 = Ch2; | |
1038 Moy_slope_3 = ((N_slope_3-1)*Moy_slope_3 + Frequ_slope_3)/N_slope_3; | |
1039 Slope_slope_3 = (Slope_slope_3*(N_slope_3-2) + 6*(Frequ_slope_3-Moy_slope_3)/N_slope_3)/(N_slope_3+1); | |
1040 | 1030 |
1041 if (utc - t1_3 > SlopeTime3) { | 1031 if (utc - t1_3 > SlopeTime3) { |
1042 // slope measurement | 1032 // slope measurement |
1043 Slope_3 = Slope_slope_3; | 1033 Slope_3 = stat_ch2.slope; |
1044 | 1034 |
1045 t2_3 = utc; | 1035 t2_3 = utc; |
1046 N_slope_3 = 0; | 1036 stat_zero(&stat_ch2); |
1047 Frequ_slope_3 = 0.0; | |
1048 Moy_slope_3 = 0.0; | |
1049 Slope_slope_3 = 0.0; | |
1050 | 1037 |
1051 // frep positive step | 1038 // frep positive step |
1052 SetCtrlVal(MainPanel, PANEL_DDS4, FrequDDS4 + DeltakHz_3 * 1000); | 1039 SetCtrlVal(MainPanel, PANEL_DDS4, FrequDDS4 + DeltakHz_3 * 1000); |
1053 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 4, FrequDDS4 + DeltakHz_3 * 1000); | 1040 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 4, FrequDDS4 + DeltakHz_3 * 1000); |
1054 // compensate with DDS3 to keep measured beatnote in counter box range | 1041 // compensate with DDS3 to keep measured beatnote in counter box range |
1191 SetCtrlVal(MainPanel, PANEL_SIGN3, Signe3); | 1178 SetCtrlVal(MainPanel, PANEL_SIGN3, Signe3); |
1192 } | 1179 } |
1193 } | 1180 } |
1194 | 1181 |
1195 // select reference | 1182 // select reference |
1196 double currentFreq = 0.0; | 1183 double current = 0.0; |
1197 switch (slopeReference) { | 1184 switch (slopeReference) { |
1198 case SLOPE_REFERENCE_MICROWAVE: | 1185 case SLOPE_REFERENCE_MICROWAVE: |
1199 currentFreq = Math2; | 1186 current = Math2; |
1200 break; | 1187 break; |
1201 case SLOPE_REFERENCE_HG_CAVITY: | 1188 case SLOPE_REFERENCE_HG_CAVITY: |
1202 currentFreq = Ch2 * 1062.5 / 1542.2; | 1189 current = Ch2 * 1062.5 / 1542.2; |
1203 break; | 1190 break; |
1204 } | 1191 } |
1205 | 1192 |
1206 // stop slope cancelling if the comb is not locked | 1193 // stop slope cancelling if the comb is not locked |
1207 if (SlopeMeasuring & StopSlopeCancellingOnUnlocked | 1194 if (SlopeMeasuring & StopSlopeCancellingOnUnlocked |
1208 & (previousFreq != 0.0) | 1195 & (freq.previous != 0.0) |
1209 & (fabs(currentFreq - previousFreq) > limitotakoff)) { | 1196 & (fabs(current - freq.previous) > limitotakoff)) { |
1210 | 1197 |
1211 if (! KeepSlope) { | 1198 if (! KeepSlope) { |
1212 appliedSlope = 0.0; | 1199 appliedSlope = 0.0; |
1213 DDSFox_SetSweepRate(&DDS1xAD9956, appliedSlope); | 1200 DDSFox_SetSweepRate(&DDS1xAD9956, appliedSlope); |
1214 SetCtrlVal(MainPanel, PANEL_SLOPE_APPLIED, appliedSlope); | 1201 SetCtrlVal(MainPanel, PANEL_SLOPE_APPLIED, appliedSlope); |
1215 } | 1202 } |
1216 if (! KeepFrequ) { | 1203 if (! KeepFrequ) { |
1217 DDSFox_Set(&DDS1xAD9956, DEDRIFT_DDS_FREQUENCY, appliedSlope); | 1204 DDSFox_Set(&DDS1xAD9956, DEDRIFT_DDS_FREQUENCY, appliedSlope); |
1218 } | 1205 } |
1219 measuredSlope = 0.0; | 1206 |
1220 SetCtrlVal(MainPanel, PANEL_SLOPE_MEASURED, measuredSlope); | 1207 stat_zero(&freq); |
1208 SetCtrlVal(MainPanel, PANEL_SLOPE_MEASURED, freq.slope); | |
1221 SlopeMeasuring = FALSE; | 1209 SlopeMeasuring = FALSE; |
1222 SetCtrlVal(MainPanel, PANEL_MEASURE_SLOPE, 0); | 1210 SetCtrlVal(MainPanel, PANEL_MEASURE_SLOPE, 0); |
1223 } | 1211 } |
1224 | 1212 |
1225 // slope measurement | 1213 // slope measurement |
1226 if (SlopeMeasuring) | 1214 if (SlopeMeasuring) |
1227 { | 1215 { |
1228 // update slope measurement | 1216 // update slope measurement |
1229 Nsamples = Nsamples + 1; | 1217 stat_accumulate(&freq, current); |
1230 if (Nsamples > 1) | 1218 |
1231 measuredSlope = (measuredSlope * (Nsamples - 2) + 6 * (currentFreq - meanFreq) / Nsamples) / (Nsamples + 1); | |
1232 else | |
1233 measuredSlope = 0.0; | |
1234 meanFreq = ((Nsamples - 1) * meanFreq + currentFreq) / Nsamples; | |
1235 previousFreq = currentFreq; | |
1236 // update indicator | 1219 // update indicator |
1237 SetCtrlVal(MainPanel, PANEL_SLOPE_MEASURED, measuredSlope); | 1220 SetCtrlVal(MainPanel, PANEL_SLOPE_MEASURED, freq.slope); |
1238 | 1221 |
1239 // update applied slope | 1222 // update applied slope |
1240 if ((utc - SlopeMeasuringTimeBegin) > TimetoSlope) { | 1223 if ((utc - SlopeMeasuringTimeBegin) > TimetoSlope) { |
1241 | 1224 |
1242 if (invertSlopeSign) | 1225 if (invertSlopeSign) |
1243 appliedSlope = appliedSlope - measuredSlope; | 1226 appliedSlope = appliedSlope - freq.slope; |
1244 else | 1227 else |
1245 appliedSlope = appliedSlope + measuredSlope; | 1228 appliedSlope = appliedSlope + freq.slope; |
1246 | 1229 |
1247 if (FrequCorrec) { | 1230 if (FrequCorrec) { |
1248 // proportional correction | 1231 // proportional correction |
1249 | 1232 |
1250 Nratio += 1; | 1233 Nratio += 1; |
1251 if (Nratio >= 1) { | 1234 if (Nratio >= 1) { |
1252 MoyMath2 = MoyMath2 + meanFreq; | 1235 MoyMath2 = MoyMath2 + freq.mean; |
1253 } | 1236 } |
1254 if (Nratio == 1 && CenterFrequencyCh2ToDetermine == TRUE) { | 1237 if (Nratio == 1 && CenterFrequencyCh2ToDetermine == TRUE) { |
1255 CenterFrequencyCh2 = MoyMath2; | 1238 CenterFrequencyCh2 = MoyMath2; |
1256 CenterFrequencyCh2ToDetermine = FALSE; | 1239 CenterFrequencyCh2ToDetermine = FALSE; |
1257 } | 1240 } |
1264 } | 1247 } |
1265 | 1248 |
1266 SetCtrlVal(MainPanel, PANEL_SLOPE_APPLIED, appliedSlope); | 1249 SetCtrlVal(MainPanel, PANEL_SLOPE_APPLIED, appliedSlope); |
1267 DDSFox_SetSweepRate(&DDS1xAD9956, appliedSlope); | 1250 DDSFox_SetSweepRate(&DDS1xAD9956, appliedSlope); |
1268 | 1251 |
1269 Nsamples = 0; | 1252 stat_zero(&freq); |
1270 meanFreq = 0.0; | |
1271 measuredSlope = 0.0; | |
1272 SlopeMeasuringTimeBegin = utc; | 1253 SlopeMeasuringTimeBegin = utc; |
1273 } | 1254 } |
1274 } | 1255 } |
1275 | 1256 |
1276 // re-centering | 1257 // re-centering |
1940 GetPanelAttribute (CalcN1Panel, ATTR_VISIBLE, &PanelIsVisible); | 1921 GetPanelAttribute (CalcN1Panel, ATTR_VISIBLE, &PanelIsVisible); |
1941 if (PanelIsVisible) | 1922 if (PanelIsVisible) |
1942 HidePanel(CalcN1Panel); | 1923 HidePanel(CalcN1Panel); |
1943 | 1924 |
1944 Measuring_1 = FALSE; | 1925 Measuring_1 = FALSE; |
1945 Frepminus_1=0.0; | |
1946 Frepplus_1=0.0; | |
1947 t1_1=0.0; | |
1948 t2_1=0.0; | |
1949 t3_1=0.0; | |
1950 N_slope_1=0; | |
1951 Frequ_slope_1=0.0; | |
1952 Moy_slope_1=0.0; | |
1953 Slope_slope_1 =0.0; | |
1954 Ch4_slope=0.0; | |
1955 Moy_Ch4slope_1=0.0; | |
1956 Slope_Ch4slope_1=0.0; | |
1957 | 1926 |
1958 SetCtrlVal(MainPanel, PANEL_DDS1, FrequDDS1) ; | 1927 SetCtrlVal(MainPanel, PANEL_DDS1, FrequDDS1) ; |
1959 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, FrequDDS1); | 1928 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, FrequDDS1); |
1960 SetCtrlVal(MainPanel, PANEL_DDS2, FrequencyDDSBesInit) ; | 1929 SetCtrlVal(MainPanel, PANEL_DDS2, FrequencyDDSBesInit) ; |
1961 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 2, FrequencyDDSBesInit); | 1930 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 2, FrequencyDDSBesInit); |
1963 if (panel == CalcN2Panel) { | 1932 if (panel == CalcN2Panel) { |
1964 GetPanelAttribute (CalcN2Panel, ATTR_VISIBLE, &PanelIsVisible); | 1933 GetPanelAttribute (CalcN2Panel, ATTR_VISIBLE, &PanelIsVisible); |
1965 if (PanelIsVisible) | 1934 if (PanelIsVisible) |
1966 HidePanel(CalcN2Panel); | 1935 HidePanel(CalcN2Panel); |
1967 | 1936 |
1968 Measuring_2=FALSE; | 1937 Measuring_2 = FALSE; |
1969 Frepminus_2=0.0; | |
1970 Delta10K_Minus=0.0; | |
1971 Frepplus_2=0.0; | |
1972 Delta10K_Plus=0.0; | |
1973 DeltaDDS3=0.0; | |
1974 t1_2=0.0; | |
1975 t2_2=0.0; | |
1976 t3_2=0.0; | |
1977 N_slope_2=0; | |
1978 Frequ_slope_2=0.0; | |
1979 Moy_slope_2=0.0; | |
1980 Beat_slope_2=0.0; | |
1981 Moy_Beatslope_2=0.0; | |
1982 Slope_Beatslope_2 =0.0; | |
1983 Slope_slope_2 =0.0; | |
1984 | 1938 |
1985 SetCtrlVal(MainPanel, PANEL_DDS1, FrequDDS1) ; | 1939 SetCtrlVal(MainPanel, PANEL_DDS1, FrequDDS1) ; |
1986 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, FrequDDS1); | 1940 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, FrequDDS1); |
1987 SetCtrlVal(MainPanel, PANEL_DDS2, FrequencyDDSBesInit) ; | 1941 SetCtrlVal(MainPanel, PANEL_DDS2, FrequencyDDSBesInit) ; |
1988 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 2, FrequencyDDSBesInit); | 1942 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 2, FrequencyDDSBesInit); |
1993 GetPanelAttribute (CalcN3Panel, ATTR_VISIBLE, &PanelIsVisible); | 1947 GetPanelAttribute (CalcN3Panel, ATTR_VISIBLE, &PanelIsVisible); |
1994 if (PanelIsVisible) | 1948 if (PanelIsVisible) |
1995 HidePanel(CalcN3Panel); | 1949 HidePanel(CalcN3Panel); |
1996 | 1950 |
1997 Measuring_3 = FALSE; | 1951 Measuring_3 = FALSE; |
1998 Frepminus_3 = 0.0; | |
1999 Frepplus_3 = 0.0; | |
2000 t1_3 = 0.0; | |
2001 t2_3 = 0.0; | |
2002 t3_3 = 0.0; | |
2003 N_slope_3 = 0; | |
2004 Frequ_slope_3 = 0.0; | |
2005 Moy_slope_3 = 0.0; | |
2006 Slope_slope_3 = 0.0; | |
2007 } | 1952 } |
2008 break; | 1953 break; |
2009 } | 1954 } |
2010 return 0; | 1955 return 0; |
2011 } | 1956 } |
2194 GetCtrlVal(panel, control, &SlopeMeasuring); | 2139 GetCtrlVal(panel, control, &SlopeMeasuring); |
2195 if (SlopeMeasuring) { | 2140 if (SlopeMeasuring) { |
2196 | 2141 |
2197 SlopeMeasuringTimeBegin = utc; | 2142 SlopeMeasuringTimeBegin = utc; |
2198 | 2143 |
2199 Nsamples = 0; | 2144 stat_zero(&freq); |
2200 previousFreq = 0.0; | |
2201 meanFreq = 0.0; | |
2202 measuredSlope = 0.0; | |
2203 | 2145 |
2204 Nratio = -1; | 2146 Nratio = -1; |
2205 MoyMath2 = 0.0; | 2147 MoyMath2 = 0.0; |
2206 CenterFrequencyCh2ToDetermine = TRUE ; | 2148 CenterFrequencyCh2ToDetermine = TRUE ; |
2207 CenterFrequencyCh2 = 0.0; | 2149 CenterFrequencyCh2 = 0.0; |
2213 SetCtrlVal(MainPanel, PANEL_SLOPE_APPLIED, appliedSlope); | 2155 SetCtrlVal(MainPanel, PANEL_SLOPE_APPLIED, appliedSlope); |
2214 } | 2156 } |
2215 if (! KeepFrequ) { | 2157 if (! KeepFrequ) { |
2216 DDSFox_Set(&DDS1xAD9956, DEDRIFT_DDS_FREQUENCY, appliedSlope); | 2158 DDSFox_Set(&DDS1xAD9956, DEDRIFT_DDS_FREQUENCY, appliedSlope); |
2217 } | 2159 } |
2218 measuredSlope = 0.0; | 2160 stat_zero(&freq); |
2219 SetCtrlVal(panel, PANEL_SLOPE_MEASURED, measuredSlope); | 2161 SetCtrlVal(panel, PANEL_SLOPE_MEASURED, freq.slope); |
2220 } | 2162 } |
2221 break; | 2163 break; |
2222 } | 2164 } |
2223 return 0; | 2165 return 0; |
2224 } | 2166 } |