Mercurial > hg > fxanalyse
comparison FXAnalyse.c @ 125:37535873ee83
Rename variables from SigneX to SignX
author | Daniele Nicolodi <daniele.nicolodi@obspm.fr> |
---|---|
date | Fri, 13 Dec 2013 12:32:51 +0100 |
parents | bdfc61a8ebee |
children | 2479ad53982b |
comparison
equal
deleted
inserted
replaced
124:bdfc61a8ebee | 125:37535873ee83 |
---|---|
114 double Frequencystep1=10000.0, tbegin1=0.0, Frepbefore1=0.0, Frequency1=0.0; | 114 double Frequencystep1=10000.0, tbegin1=0.0, Frepbefore1=0.0, Frequency1=0.0; |
115 double Frequencystep2=10.0, tbegin2=0.0, Frepbefore2=0.0, Ch2before=0.0, Frequency2=0.0; | 115 double Frequencystep2=10.0, tbegin2=0.0, Frepbefore2=0.0, Ch2before=0.0, Frequency2=0.0; |
116 double Frequencystep3=100000.0, tbegin3=0.0, Frepbefore3=0.0, Frequency3=0.0; | 116 double Frequencystep3=100000.0, tbegin3=0.0, Frepbefore3=0.0, Frequency3=0.0; |
117 | 117 |
118 volatile bool Getsign1=FALSE,Getsign2=FALSE,Getsign3=FALSE; | 118 volatile bool Getsign1=FALSE,Getsign2=FALSE,Getsign3=FALSE; |
119 double Signe1=1.0,Signe2=1.0,Signe3=0.0; | 119 double Sign1=1.0, Sign2=1.0, Sign3=0.0; |
120 | 120 |
121 // slope cancelling | 121 // slope cancelling |
122 | 122 |
123 double dedrift_DDS_freq = 70e6; | 123 double dedrift_DDS_freq = 70e6; |
124 int SlopeMeasuring = FALSE; | 124 int SlopeMeasuring = FALSE; |
285 mupDefineVar(parser, "N2", &N2); | 285 mupDefineVar(parser, "N2", &N2); |
286 mupDefineVar(parser, "N3", &N3); | 286 mupDefineVar(parser, "N3", &N3); |
287 mupDefineVar(parser, "Nu1", &Nu1); | 287 mupDefineVar(parser, "Nu1", &Nu1); |
288 mupDefineVar(parser, "Nu2", &Nu2); | 288 mupDefineVar(parser, "Nu2", &Nu2); |
289 mupDefineVar(parser, "DeltaDDS3", &DeltaDDS3); | 289 mupDefineVar(parser, "DeltaDDS3", &DeltaDDS3); |
290 mupDefineVar(parser, "Signe1", &Signe1); | 290 mupDefineVar(parser, "Sign1", &Sign1); |
291 mupDefineVar(parser, "Signe2", &Signe2); | 291 mupDefineVar(parser, "Sign2", &Sign2); |
292 mupDefineVar(parser, "Signe3", &Signe3); | 292 mupDefineVar(parser, "Sign3", &Sign3); |
293 mupDefineVar(parser, "Ndiv", &Ndiv); | 293 mupDefineVar(parser, "Ndiv", &Ndiv); |
294 mupDefinePostfixOprt(parser, "P", &Peta, 1); | 294 mupDefinePostfixOprt(parser, "P", &Peta, 1); |
295 mupDefinePostfixOprt(parser, "T", &Tera, 1); | 295 mupDefinePostfixOprt(parser, "T", &Tera, 1); |
296 mupDefinePostfixOprt(parser, "G", &Giga, 1); | 296 mupDefinePostfixOprt(parser, "G", &Giga, 1); |
297 mupDefinePostfixOprt(parser, "M", &Mega, 1); | 297 mupDefinePostfixOprt(parser, "M", &Mega, 1); |
878 Frepminus_1 = Frepminus_1 / n_1; | 878 Frepminus_1 = Frepminus_1 / n_1; |
879 Ch4Minus = Ch4Minus / n_1; | 879 Ch4Minus = Ch4Minus / n_1; |
880 n_1 = 0; | 880 n_1 = 0; |
881 | 881 |
882 // compute N1 | 882 // compute N1 |
883 N_1 = Signe1 * (2*Ndiv * DeltakHz_1 * 1000)/(Frepminus_1 - Frepplus_1 - Slope_1 * (t3_1 - t2_1)); | 883 N_1 = Sign1 * (2*Ndiv * DeltakHz_1 * 1000)/(Frepminus_1 - Frepplus_1 - Slope_1 * (t3_1 - t2_1)); |
884 SetCtrlVal(CalcNPanel, CALCN_N, N_1); | 884 SetCtrlVal(CalcNPanel, CALCN_N, N_1); |
885 | 885 |
886 t1_1 = 0.0; | 886 t1_1 = 0.0; |
887 t2_1 = 0.0; | 887 t2_1 = 0.0; |
888 t3_1 = 0.0; | 888 t3_1 = 0.0; |
944 DDS4xAD9912_RampFrequency(&DDS4xAD9912,1, fDDS1, FREP_STEP_SIZE); | 944 DDS4xAD9912_RampFrequency(&DDS4xAD9912,1, fDDS1, FREP_STEP_SIZE); |
945 SetCtrlVal(MainPanel, PANEL_DDS1, fDDS1); | 945 SetCtrlVal(MainPanel, PANEL_DDS1, fDDS1); |
946 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, fDDS1); | 946 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, fDDS1); |
947 | 947 |
948 // adjust DDS3 to keep beatnote within the bandpass filter. prediction | 948 // adjust DDS3 to keep beatnote within the bandpass filter. prediction |
949 double fDDS3 = FrequencyDDS3Init - DeltakHz_2*1000*(-Signe1/Signe2)*Ndiv*(Nu2)/(Nu1) - Beatslope_2*(utc-t1_2); | 949 double fDDS3 = FrequencyDDS3Init - DeltakHz_2*1000*(-Sign1/Sign2)*Ndiv*(Nu2)/(Nu1) - Beatslope_2*(utc-t1_2); |
950 DeltaDDS3 = fDDS3 - DDS4xAD9912.Frequency3; | 950 DeltaDDS3 = fDDS3 - DDS4xAD9912.Frequency3; |
951 printf("deltaDDS3 = %g\n", DeltaDDS3); | 951 printf("deltaDDS3 = %g\n", DeltaDDS3); |
952 SetCtrlVal(MainPanel, PANEL_DDS3, fDDS3); | 952 SetCtrlVal(MainPanel, PANEL_DDS3, fDDS3); |
953 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, fDDS3); | 953 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, fDDS3); |
954 | 954 |
1010 DDS4xAD9912_RampFrequency(&DDS4xAD9912, 1, fDDS1, FREP_STEP_SIZE); | 1010 DDS4xAD9912_RampFrequency(&DDS4xAD9912, 1, fDDS1, FREP_STEP_SIZE); |
1011 SetCtrlVal(MainPanel, PANEL_DDS1, fDDS1); | 1011 SetCtrlVal(MainPanel, PANEL_DDS1, fDDS1); |
1012 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, fDDS1); | 1012 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, fDDS1); |
1013 | 1013 |
1014 // adjust DDS3 to keep beatnote within the bandpass filter. prediction | 1014 // adjust DDS3 to keep beatnote within the bandpass filter. prediction |
1015 double fDDS3 = FrequencyDDS3Init + DeltakHz_2*1000*(-Signe1/Signe2)*Ndiv*(Nu2)/(Nu1); | 1015 double fDDS3 = FrequencyDDS3Init + DeltakHz_2*1000*(-Sign1/Sign2)*Ndiv*(Nu2)/(Nu1); |
1016 DeltaDDS3 = fDDS3 - DDS4xAD9912.Frequency3; | 1016 DeltaDDS3 = fDDS3 - DDS4xAD9912.Frequency3; |
1017 SetCtrlVal(MainPanel, PANEL_DDS3, fDDS3); | 1017 SetCtrlVal(MainPanel, PANEL_DDS3, fDDS3); |
1018 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, fDDS3); | 1018 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, fDDS3); |
1019 | 1019 |
1020 // allow counter to settle | 1020 // allow counter to settle |
1044 Frepminus_2 = Frepminus_2 / n_2; | 1044 Frepminus_2 = Frepminus_2 / n_2; |
1045 Delta10K_Minus = Delta10K_Minus / n_2; | 1045 Delta10K_Minus = Delta10K_Minus / n_2; |
1046 n_2 = 0; | 1046 n_2 = 0; |
1047 | 1047 |
1048 // compute N2 | 1048 // compute N2 |
1049 N_2 = (Signe2)*(-DeltaDDS3+Delta10K_Plus-Delta10K_Minus-Beatslope_2*(t3_2-t2_2) )/(Frepminus_2-Frepplus_2-Slope_2*(t3_2-t2_2)); | 1049 N_2 = Sign2*(-DeltaDDS3+Delta10K_Plus-Delta10K_Minus-Beatslope_2*(t3_2-t2_2) )/(Frepminus_2-Frepplus_2-Slope_2*(t3_2-t2_2)); |
1050 SetCtrlVal(CalcNPanel, CALCN_N, N_2); | 1050 SetCtrlVal(CalcNPanel, CALCN_N, N_2); |
1051 | 1051 |
1052 // back to nominal frequency | 1052 // back to nominal frequency |
1053 DDS4xAD9912_RampFrequency(&DDS4xAD9912, 1, FrequDDS1, FREP_STEP_SIZE); | 1053 DDS4xAD9912_RampFrequency(&DDS4xAD9912, 1, FrequDDS1, FREP_STEP_SIZE); |
1054 SetCtrlVal(MainPanel, PANEL_DDS1, FrequDDS1); | 1054 SetCtrlVal(MainPanel, PANEL_DDS1, FrequDDS1); |
1116 | 1116 |
1117 // frep positive step | 1117 // frep positive step |
1118 SetCtrlVal(MainPanel, PANEL_DDS1, FrequDDS1 + DeltakHz_3 * 1000); | 1118 SetCtrlVal(MainPanel, PANEL_DDS1, FrequDDS1 + DeltakHz_3 * 1000); |
1119 DDS4xAD9912_RampFrequency(&DDS4xAD9912, 1, FrequDDS1 + DeltakHz_3 * 1000, FREP_STEP_SIZE); | 1119 DDS4xAD9912_RampFrequency(&DDS4xAD9912, 1, FrequDDS1 + DeltakHz_3 * 1000, FREP_STEP_SIZE); |
1120 // compensate with DDS3 to keep measured beatnote in counter box range | 1120 // compensate with DDS3 to keep measured beatnote in counter box range |
1121 double fDDS3 = FrequencyDDS3Init + Signe1 * Signe3 * N3/N1 * Ndiv * DeltakHz_3 * 1000; | 1121 double fDDS3 = FrequencyDDS3Init + Sign1 * Sign3 * N3/N1 * Ndiv * DeltakHz_3 * 1000; |
1122 SetCtrlVal(MainPanel, PANEL_DDS3, fDDS3); | 1122 SetCtrlVal(MainPanel, PANEL_DDS3, fDDS3); |
1123 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, fDDS3); | 1123 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, fDDS3); |
1124 | 1124 |
1125 // allow counter to settle | 1125 // allow counter to settle |
1126 settling = 3; | 1126 settling = 3; |
1173 | 1173 |
1174 // frep negative step | 1174 // frep negative step |
1175 SetCtrlVal(MainPanel, PANEL_DDS1, FrequDDS1 - DeltakHz_3 * 1000); | 1175 SetCtrlVal(MainPanel, PANEL_DDS1, FrequDDS1 - DeltakHz_3 * 1000); |
1176 DDS4xAD9912_RampFrequency(&DDS4xAD9912, 1, FrequDDS1 - DeltakHz_3 * 1000, FREP_STEP_SIZE); | 1176 DDS4xAD9912_RampFrequency(&DDS4xAD9912, 1, FrequDDS1 - DeltakHz_3 * 1000, FREP_STEP_SIZE); |
1177 // compensate with DDS3 to keep measured beatnote in counter box range | 1177 // compensate with DDS3 to keep measured beatnote in counter box range |
1178 double fDDS3 = FrequencyDDS3Init - Signe1 * Signe3 * N3/N1 * Ndiv * DeltakHz_3 * 1000; | 1178 double fDDS3 = FrequencyDDS3Init - Sign1 * Sign3 * N3/N1 * Ndiv * DeltakHz_3 * 1000; |
1179 SetCtrlVal(MainPanel, PANEL_DDS3, fDDS3); | 1179 SetCtrlVal(MainPanel, PANEL_DDS3, fDDS3); |
1180 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, fDDS3); | 1180 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, fDDS3); |
1181 | 1181 |
1182 // allow counter to settle | 1182 // allow counter to settle |
1183 settling = 3; | 1183 settling = 3; |
1212 | 1212 |
1213 logmsg("f_beat_Sr_minus=%.12e", f_beat_Sr_minus); | 1213 logmsg("f_beat_Sr_minus=%.12e", f_beat_Sr_minus); |
1214 logmsg("f_beat_Sr_plus =%.12e", f_beat_Sr_plus); | 1214 logmsg("f_beat_Sr_plus =%.12e", f_beat_Sr_plus); |
1215 | 1215 |
1216 // compute N3 | 1216 // compute N3 |
1217 double delta_f_beat_Sr = f_beat_Sr_plus - f_beat_Sr_minus + 2.0 * Signe1 * Signe3 * N3/N1 * Ndiv * DeltakHz_3 * 1000; | 1217 double delta_f_beat_Sr = f_beat_Sr_plus - f_beat_Sr_minus + 2.0 * Sign1 * Sign3 * N3/N1 * Ndiv * DeltakHz_3 * 1000; |
1218 double delta_f_beat_Sr_expected = delta_f_rep * N3; | 1218 double delta_f_beat_Sr_expected = delta_f_rep * N3; |
1219 logmsg("delta fbeat: measured=%.12e expected=%.12e", delta_f_beat_Sr, delta_f_beat_Sr_expected); | 1219 logmsg("delta fbeat: measured=%.12e expected=%.12e", delta_f_beat_Sr, delta_f_beat_Sr_expected); |
1220 N_3 = delta_f_beat_Sr / delta_f_rep; | 1220 N_3 = delta_f_beat_Sr / delta_f_rep; |
1221 logmsg("measured N3=%.3f", N_3); | 1221 logmsg("measured N3=%.3f", N_3); |
1222 SetCtrlVal(CalcNPanel, CALCN_N, N_3); | 1222 SetCtrlVal(CalcNPanel, CALCN_N, N_3); |
1240 Measuring_3 = N_MEASUREMENT_NONE; | 1240 Measuring_3 = N_MEASUREMENT_NONE; |
1241 } | 1241 } |
1242 break; | 1242 break; |
1243 } | 1243 } |
1244 | 1244 |
1245 // Calcul du signe de fb | 1245 // beatnote sign determination |
1246 | 1246 |
1247 if (Getsign1 == TRUE) { | 1247 if (Getsign1 == TRUE) { |
1248 if (utc > tbegin1+2) { | 1248 if (utc > tbegin1+2) { |
1249 if (Math1 > Frepbefore1) | 1249 if (Math1 > Frepbefore1) |
1250 Signe1 = -1.0; | 1250 Sign1 = -1.0; |
1251 else | 1251 else |
1252 Signe1 = +1.0; | 1252 Sign1 = +1.0; |
1253 SetCtrlVal(MainPanel, PANEL_DDS1, Frequency1); | 1253 SetCtrlVal(MainPanel, PANEL_DDS1, Frequency1); |
1254 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, Frequency1); | 1254 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, Frequency1); |
1255 Getsign1 = FALSE; | 1255 Getsign1 = FALSE; |
1256 SetCtrlVal(MainPanel, PANEL_SIGN1, Signe1); | 1256 SetCtrlVal(MainPanel, PANEL_SIGN1, Sign1); |
1257 } | 1257 } |
1258 } | 1258 } |
1259 if (Getsign2 == TRUE) { | 1259 if (Getsign2 == TRUE) { |
1260 if (utc > tbegin2+2){ | 1260 if (utc > tbegin2+2){ |
1261 if (Math1 > Frepbefore2) { | 1261 if (Math1 > Frepbefore2) { |
1262 if (Ch2 > Ch2before) | 1262 if (Ch2 > Ch2before) |
1263 Signe2 = +1.0; | 1263 Sign2 = +1.0; |
1264 else | 1264 else |
1265 Signe2 = -1.0; | 1265 Sign2 = -1.0; |
1266 } else { | 1266 } else { |
1267 if (Ch2 > Ch2before) | 1267 if (Ch2 > Ch2before) |
1268 Signe2 = -1.0; | 1268 Sign2 = -1.0; |
1269 else | 1269 else |
1270 Signe2 = +1.0; | 1270 Sign2 = +1.0; |
1271 } | 1271 } |
1272 SetCtrlVal(MainPanel, PANEL_DDS1, Frequency2); | 1272 SetCtrlVal(MainPanel, PANEL_DDS1, Frequency2); |
1273 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, Frequency2); | 1273 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, Frequency2); |
1274 Getsign2 = FALSE; | 1274 Getsign2 = FALSE; |
1275 SetCtrlVal(MainPanel, PANEL_SIGN2, Signe2); | 1275 SetCtrlVal(MainPanel, PANEL_SIGN2, Sign2); |
1276 } | 1276 } |
1277 } | 1277 } |
1278 if (Getsign3 == TRUE) { | 1278 if (Getsign3 == TRUE) { |
1279 if (utc > tbegin3+2){ | 1279 if (utc > tbegin3+2){ |
1280 if (Ch3 > Frepbefore3) | 1280 if (Ch3 > Frepbefore3) |
1281 Signe3 = -1.0; | 1281 Sign3 = -1.0; |
1282 else | 1282 else |
1283 Signe3 = +1.0; | 1283 Sign3 = +1.0; |
1284 SetCtrlVal(MainPanel, PANEL_DDS3, Frequency3); | 1284 SetCtrlVal(MainPanel, PANEL_DDS3, Frequency3); |
1285 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 4, Frequency3); | 1285 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 4, Frequency3); |
1286 Getsign3 = FALSE; | 1286 Getsign3 = FALSE; |
1287 SetCtrlVal(MainPanel, PANEL_SIGN3, Signe3); | 1287 SetCtrlVal(MainPanel, PANEL_SIGN3, Sign3); |
1288 } | 1288 } |
1289 } | 1289 } |
1290 | 1290 |
1291 // select reference | 1291 // select reference |
1292 double current = 0.0; | 1292 double current = 0.0; |
2333 void *callbackData, int eventData1, int eventData2) | 2333 void *callbackData, int eventData1, int eventData2) |
2334 { | 2334 { |
2335 switch (event) | 2335 switch (event) |
2336 { | 2336 { |
2337 case EVENT_COMMIT: | 2337 case EVENT_COMMIT: |
2338 GetCtrlVal(panel, control, &Signe3); | 2338 GetCtrlVal(panel, control, &Sign3); |
2339 break; | 2339 break; |
2340 } | 2340 } |
2341 return 0; | 2341 return 0; |
2342 } | 2342 } |
2343 | 2343 |