comparison FXAnalyse.c @ 139:e04123ab79ef

Fix recenter
author Daniele Nicolodi <daniele.nicolodi@obspm.fr>
date Wed, 22 Jan 2014 14:45:22 +0100
parents 7b9cf3d4346e
children 3f7eef731ccc
comparison
equal deleted inserted replaced
138:02044ad2749a 139:e04123ab79ef
1350 } 1350 }
1351 1351
1352 // recenter 1352 // recenter
1353 if (recenter.enabled) 1353 if (recenter.enabled)
1354 { 1354 {
1355 if (recenter.t0 == 0.0) {
1356
1357 }
1358
1359 rollmean_accumulate(&rollmean_ch2, Ch2); 1355 rollmean_accumulate(&rollmean_ch2, Ch2);
1360 rollmean_accumulate(&rollmean_ch3, Ch3); 1356 rollmean_accumulate(&rollmean_ch3, Ch3);
1361 rollmean_accumulate(&rollmean_ch4, Ch4); 1357 rollmean_accumulate(&rollmean_ch4, Ch4);
1362 1358
1363 if ((utc - recenter.t0) > recenter.interval) { 1359 if ((utc - recenter.t0) > recenter.interval) {
1364 1360
1365 if (recenter.Lo) { 1361 if (recenter.Lo) {
1366 // adjust DDS2 frequency to keep Ch4 reading at 275 kHz 1362 // adjust DDS2 frequency to keep Ch4 reading at 275 kHz
1367 double freq = DDS4xAD9912_GetFrequency(&DDS4xAD9912, 2); 1363 double freq = DDS4xAD9912_GetFrequency(&DDS4xAD9912, 2);
1368 freq = freq + 275000.0 - rollmean_ch4.mean; 1364 double adj = 275000.0 - rollmean_ch4.mean;
1365 freq = freq + adj;
1369 SetCtrlVal(MainPanel, PANEL_DDS2, freq); 1366 SetCtrlVal(MainPanel, PANEL_DDS2, freq);
1370 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 2, freq); 1367 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 2, freq);
1368 logmsg("recenter ch4 to 275 kHz: DDS2 adjustment=%5e", adj);
1371 } 1369 }
1372 1370
1373 if (recenter.Hg) { 1371 if (recenter.Hg) {
1374 // adjust DDS3 frequency to keep Ch2 reading at 10 kHz 1372 // adjust DDS3 frequency to keep Ch2 reading at 10 kHz
1375 double freq = DDS4xAD9912_GetFrequency(&DDS4xAD9912, 3); 1373 double freq = DDS4xAD9912_GetFrequency(&DDS4xAD9912, 3);
1376 freq = freq + 10000 - rollmean_ch2.mean; 1374 double adj = 10000 - rollmean_ch2.mean;
1375 freq = freq + adj;
1377 SetCtrlVal(MainPanel, PANEL_DDS3, freq); 1376 SetCtrlVal(MainPanel, PANEL_DDS3, freq);
1378 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, freq); 1377 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, freq);
1378 logmsg("recenter Hg beatnote (ch2) to 10 kHz: DDS3 adjustment=%5e", adj);
1379 } 1379 }
1380 1380
1381 if (recenter.Sr) { 1381 if (recenter.Sr) {
1382 // adjust DDS3 frequency to keep Ch3 reading at 10 kHz 1382 // adjust DDS3 frequency to keep Ch3 reading at 10 kHz
1383 double freq = DDS4xAD9912_GetFrequency(&DDS4xAD9912, 3); 1383 double freq = DDS4xAD9912_GetFrequency(&DDS4xAD9912, 3);
1384 freq = freq + 10000 - rollmean_ch3.mean; 1384 double adj = 10000 - rollmean_ch3.mean;
1385 freq = freq + adj;
1385 SetCtrlVal(MainPanel, PANEL_DDS3, freq); 1386 SetCtrlVal(MainPanel, PANEL_DDS3, freq);
1386 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, freq); 1387 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, freq);
1388 logmsg("recenter Hg beatnote (ch3) to 10 kHz: DDS3 adjustment=%5e", adj);
1387 } 1389 }
1388 1390
1389 recenter.t0 = utc; 1391 recenter.t0 = utc;
1390 rollmean_zero(&rollmean_ch2, ROLLMEAN_N_OBS); 1392 rollmean_zero(&rollmean_ch2);
1391 rollmean_zero(&rollmean_ch3, ROLLMEAN_N_OBS); 1393 rollmean_zero(&rollmean_ch3);
1392 rollmean_zero(&rollmean_ch4, ROLLMEAN_N_OBS); 1394 rollmean_zero(&rollmean_ch4);
1393 } 1395 }
1394 } 1396 }
1395 1397
1396 // local time 1398 // local time
1397 struct tm *ltime = localtime(&event.time.tv_sec); 1399 struct tm *ltime = localtime(&event.time.tv_sec);
2012 return 0; 2014 return 0;
2013 } 2015 }
2014 2016
2015 2017
2016 2018
2017 int CVICALLBACK CB_OnReCentering (int panel, int control, int event, 2019 int CVICALLBACK CB_RecenterEnable (int panel, int control, int event,
2018 void *callbackData, int eventData1, int eventData2) 2020 void *callbackData, int eventData1, int eventData2)
2019 { 2021 {
2020 switch (event) 2022 switch (event)
2021 { 2023 {
2022 case EVENT_COMMIT: 2024 case EVENT_COMMIT:
2023 GetCtrlVal(panel, control, &recenter.enabled); 2025 GetCtrlVal(panel, control, &recenter.enabled);
2024 recenter.t0 = utc; 2026 recenter.t0 = utc;
2025 rollmean_zero(&rollmean_ch2, ROLLMEAN_N_OBS); 2027 rollmean_zero(&rollmean_ch2);
2026 rollmean_zero(&rollmean_ch3, ROLLMEAN_N_OBS); 2028 rollmean_zero(&rollmean_ch3);
2027 rollmean_zero(&rollmean_ch4, ROLLMEAN_N_OBS); 2029 rollmean_zero(&rollmean_ch4);
2028 break; 2030 break;
2029 } 2031 }
2030 return 0; 2032 return 0;
2031 } 2033 }
2032 2034
2232 break; 2234 break;
2233 } 2235 }
2234 return 0; 2236 return 0;
2235 } 2237 }
2236 2238
2239 int CVICALLBACK CB_RecenterInterval (int panel, int control, int event,
2240 void *callbackData, int eventData1, int eventData2)
2241 {
2242 switch (event)
2243 {
2244 case EVENT_COMMIT:
2245 GetCtrlVal(panel, control, &recenter.interval);
2246 break;
2247 }
2248 return 0;
2249 }
2250
2251 int CVICALLBACK CB_RecenterChannel (int panel, int control, int event,
2252 void *callbackData, int eventData1, int eventData2)
2253 {
2254 switch (event)
2255 {
2256 case EVENT_COMMIT:
2257 switch (control)
2258 {
2259 case PANEL_RECENTER_LO:
2260 GetCtrlVal(panel, control, &recenter.Lo);
2261 break;
2262 case PANEL_RECENTER_HG:
2263 GetCtrlVal(panel, control, &recenter.Hg);
2264 break;
2265 case PANEL_RECENTER_SR:
2266 GetCtrlVal(panel, control, &recenter.Sr);
2267 break;
2268 }
2269 break;
2270 }
2271 return 0;
2272 }
2237 int CVICALLBACK CB_DedriftDDSFreq (int panel, int control, int event, 2273 int CVICALLBACK CB_DedriftDDSFreq (int panel, int control, int event,
2238 void *callbackData, int eventData1, int eventData2) 2274 void *callbackData, int eventData1, int eventData2)
2239 { 2275 {
2240 switch (event) 2276 switch (event)
2241 { 2277 {