Mercurial > hg > fxanalyse
comparison FXAnalyse.c @ 65:da82b4815c2f
Fix automatic measurement stop on unlock and simplify dedrifting slope setting
author | Daniele Nicolodi <daniele.nicolodi@obspm.fr> |
---|---|
date | Mon, 29 Oct 2012 14:46:33 +0100 |
parents | d6efe6fe6eb3 |
children | aa125ad6e842 |
comparison
equal
deleted
inserted
replaced
64:d6efe6fe6eb3 | 65:da82b4815c2f |
---|---|
106 int StopSlopeCancellingOnUnlocked = TRUE; | 106 int StopSlopeCancellingOnUnlocked = TRUE; |
107 double SlopeMath2 = 0.0; // currently applied frequency dedrifiting slope | 107 double SlopeMath2 = 0.0; // currently applied frequency dedrifiting slope |
108 double TimetoSlope = 60.0; | 108 double TimetoSlope = 60.0; |
109 double SlopeMeasuringTimeBegin = 0.0; | 109 double SlopeMeasuringTimeBegin = 0.0; |
110 | 110 |
111 double Slope_Math2slope=0.0,Math2_slope=0.0,Moy_Math2slope=0.0; | 111 double Slope_Math2slope=0.0,Moy_Math2slope=0.0; |
112 int N_Math2slope=0.0; | 112 int N_Math2slope=0.0; |
113 | 113 |
114 double LimitToDelock=5.0; | 114 double LimitToDelock=5.0; |
115 double limitotakoff=70.0; | 115 double limitotakoff=70.0; |
116 | 116 |
124 enum { | 124 enum { |
125 SLOPE_REFERENCE_MICROWAVE = 0, | 125 SLOPE_REFERENCE_MICROWAVE = 0, |
126 SLOPE_REFERENCE_HG_CAVITY = 1, | 126 SLOPE_REFERENCE_HG_CAVITY = 1, |
127 }; | 127 }; |
128 | 128 |
129 double previousFreq = 0.0; | |
129 int invertSlopeSign = 0; | 130 int invertSlopeSign = 0; |
130 int slopeReference = SLOPE_REFERENCE_MICROWAVE; | 131 int slopeReference = SLOPE_REFERENCE_MICROWAVE; |
131 | 132 |
132 int KeepCentering = FALSE; | 133 int KeepCentering = FALSE; |
133 double Timetorecenter275K = 3600.0 * 10; | 134 double Timetorecenter275K = 3600.0 * 10; |
134 double Timetorecenter10K = 3600.0 * 3; | 135 double Timetorecenter10K = 3600.0 * 3; |
135 double CenteringTimeBegin275K = 0.0; | 136 double CenteringTimeBegin275K = 0.0; |
136 double CenteringTimeBegin10K = 0.0; | 137 double CenteringTimeBegin10K = 0.0; |
137 | 138 |
138 | 139 |
139 int DDSFox_Set(DDSParameter *DDS, double Frequency, double Sweeprate) | 140 int DDSFox_Set(DDSParameter *DDS, double Frequency, double SweepRate) |
140 { | 141 { |
141 DDS->Frequency = Frequency; | 142 DDS->Frequency = Frequency; |
142 DDS->SweepRate = Sweeprate; | 143 DDS->SweepRate = SweepRate; |
143 | 144 |
144 DDSFox_SetFreq(DDS); | 145 DDSFox_SetFreq(DDS); |
145 DDSFox_SetDf(DDS); | 146 DDSFox_SetDf(DDS); |
146 | 147 |
148 return 0; | |
149 } | |
150 | |
151 | |
152 int DDSFox_SetSweepRate(DDSParameter *DDS, double SweepRate) | |
153 { | |
154 DDS->SweepRate = SweepRate; | |
155 DDSFox_SetDf(DDS); | |
147 return 0; | 156 return 0; |
148 } | 157 } |
149 | 158 |
150 | 159 |
151 muParserHandle_t initMathParser() | 160 muParserHandle_t initMathParser() |
1223 currentFreq = Ch2 * 1062.5 / 1542.2; | 1232 currentFreq = Ch2 * 1062.5 / 1542.2; |
1224 break; | 1233 break; |
1225 } | 1234 } |
1226 | 1235 |
1227 // stop slope cancelling if the comb is not locked | 1236 // stop slope cancelling if the comb is not locked |
1228 if (StopSlopeCancellingOnUnlocked & (fabs(currentFreq - Math2_slope) < limitotakoff)) { | 1237 if (StopSlopeCancellingOnUnlocked |
1238 & (previousFreq != 0.0) | |
1239 & (fabs(currentFreq - previousFreq) > limitotakoff)) { | |
1229 | 1240 |
1230 double frequency = DEDRIFT_DDS_FREQUENCY; | 1241 double frequency = DEDRIFT_DDS_FREQUENCY; |
1231 if (KeepFrequ) | 1242 if (KeepFrequ) |
1232 frequency = DDSFox_ReadFreq(&DDS1xAD9956); | 1243 frequency = DDSFox_ReadFreq(&DDS1xAD9956); |
1233 | 1244 |
1242 SetCtrlVal(MainPanel, PANEL_MEASURE_SLOPE, 0); | 1253 SetCtrlVal(MainPanel, PANEL_MEASURE_SLOPE, 0); |
1243 } | 1254 } |
1244 | 1255 |
1245 // update slope measurement | 1256 // update slope measurement |
1246 N_Math2slope = N_Math2slope + 1; | 1257 N_Math2slope = N_Math2slope + 1; |
1247 Math2_slope = currentFreq; | 1258 previousFreq = currentFreq; |
1248 Moy_Math2slope = ((N_Math2slope-1)*Moy_Math2slope + Math2_slope)/N_Math2slope; | 1259 Moy_Math2slope = ((N_Math2slope-1)*Moy_Math2slope + currentFreq)/N_Math2slope; |
1249 Slope_Math2slope = (Slope_Math2slope*(N_Math2slope-2) + 6*(Math2_slope-Moy_Math2slope)/N_Math2slope)/(N_Math2slope+1); | 1260 Slope_Math2slope = (Slope_Math2slope*(N_Math2slope-2) + 6*(currentFreq-Moy_Math2slope)/N_Math2slope)/(N_Math2slope+1); |
1250 // update indicator | 1261 // update indicator |
1251 SetCtrlVal(MainPanel, PANEL_SLOPE_MEASURED, 0); | 1262 SetCtrlVal(MainPanel, PANEL_SLOPE_MEASURED, Slope_Math2slope); |
1252 | 1263 |
1253 // update applied slope | 1264 // update applied slope |
1254 if ((utc - SlopeMeasuringTimeBegin) > TimetoSlope) { | 1265 if ((utc - SlopeMeasuringTimeBegin) > TimetoSlope) { |
1255 | 1266 |
1256 if (invertSlopeSign) | 1267 if (invertSlopeSign) |
1275 Nratio = 0; | 1286 Nratio = 0; |
1276 MoyMath2 = 0.0; | 1287 MoyMath2 = 0.0; |
1277 } | 1288 } |
1278 } | 1289 } |
1279 | 1290 |
1280 double frequency = DDSFox_ReadFreq(&DDS1xAD9956); | |
1281 SetCtrlVal(MainPanel, PANEL_SLOPE_APPLIED, SlopeMath2); | 1291 SetCtrlVal(MainPanel, PANEL_SLOPE_APPLIED, SlopeMath2); |
1282 DDSFox_Set(&DDS1xAD9956, frequency, SlopeMath2); | 1292 DDSFox_SetSweepRate(&DDS1xAD9956, SlopeMath2); |
1283 | 1293 |
1284 N_Math2slope = 0.0; | 1294 N_Math2slope = 0.0; |
1285 Math2_slope = 0.0; | |
1286 Moy_Math2slope = 0.0; | 1295 Moy_Math2slope = 0.0; |
1287 Slope_Math2slope = 0.0; | 1296 Slope_Math2slope = 0.0; |
1288 SlopeMeasuringTimeBegin = utc; | 1297 SlopeMeasuringTimeBegin = utc; |
1289 } | 1298 } |
1290 } | 1299 } |
2215 | 2224 |
2216 if (active) { | 2225 if (active) { |
2217 | 2226 |
2218 SlopeMeasuringTimeBegin = utc; | 2227 SlopeMeasuringTimeBegin = utc; |
2219 SlopeMeasuring = TRUE; | 2228 SlopeMeasuring = TRUE; |
2220 | 2229 previousFreq = 0.0; |
2221 frequency = DDSFox_ReadFreq(&DDS1xAD9956); | |
2222 GetCtrlVal(panel, PANEL_SLOPE_APPLIED, &SlopeMath2); | |
2223 DDSFox_Set(&DDS1xAD9956, frequency, SlopeMath2); | |
2224 | 2230 |
2225 Nratio = -1; | 2231 Nratio = -1; |
2226 CenterFrequencyCh2ToDetermine = TRUE ; | 2232 CenterFrequencyCh2ToDetermine = TRUE ; |
2227 CenterFrequencyCh2 = 0.0; | 2233 CenterFrequencyCh2 = 0.0; |
2228 | 2234 |
2238 SetCtrlVal(panel, PANEL_SLOPE_APPLIED, SlopeMath2); | 2244 SetCtrlVal(panel, PANEL_SLOPE_APPLIED, SlopeMath2); |
2239 DDSFox_Set(&DDS1xAD9956, frequency, SlopeMath2); | 2245 DDSFox_Set(&DDS1xAD9956, frequency, SlopeMath2); |
2240 | 2246 |
2241 SlopeMeasuring = FALSE; | 2247 SlopeMeasuring = FALSE; |
2242 N_Math2slope = 0.0; | 2248 N_Math2slope = 0.0; |
2243 Math2_slope = 0.0; | |
2244 Moy_Math2slope = 0.0; | 2249 Moy_Math2slope = 0.0; |
2245 Slope_Math2slope = 0.0; | 2250 Slope_Math2slope = 0.0; |
2246 MoyMath2 = 0.0; | 2251 MoyMath2 = 0.0; |
2247 Slope_Math2slope = 0.0; | 2252 Slope_Math2slope = 0.0; |
2248 CenterFrequencyCh2 = 0.0; | 2253 CenterFrequencyCh2 = 0.0; |
2450 } | 2455 } |
2451 | 2456 |
2452 int CVICALLBACK CB_SetSlope (int panel, int control, int event, | 2457 int CVICALLBACK CB_SetSlope (int panel, int control, int event, |
2453 void *callbackData, int eventData1, int eventData2) | 2458 void *callbackData, int eventData1, int eventData2) |
2454 { | 2459 { |
2455 double frequency; | |
2456 | |
2457 switch (event) | 2460 switch (event) |
2458 { | 2461 { |
2459 case EVENT_COMMIT: | 2462 case EVENT_COMMIT: |
2460 GetCtrlVal(panel, control, &SlopeMath2); | 2463 GetCtrlVal(panel, control, &SlopeMath2); |
2461 frequency = DDSFox_ReadFreq(&DDS1xAD9956); | 2464 DDSFox_SetSweepRate(&DDS1xAD9956, SlopeMath2); |
2462 DDSFox_Set(&DDS1xAD9956, frequency, SlopeMath2); | |
2463 break; | 2465 break; |
2464 } | 2466 } |
2465 return 0; | 2467 return 0; |
2466 } | 2468 } |
2467 | 2469 |