Mercurial > hg > fxanalyse
comparison FXAnalyse.c @ 109:2a9f8a811d87
Fix N3 measurement
author | Daniele Nicolodi <daniele.nicolodi@obspm.fr> |
---|---|
date | Fri, 28 Jun 2013 14:45:29 +0200 |
parents | 29b1aa89a34c |
children | 8bdd7e38715f |
comparison
equal
deleted
inserted
replaced
108:54e7b129ecc2 | 109:2a9f8a811d87 |
---|---|
14 #include "DDS_Fox.h" | 14 #include "DDS_Fox.h" |
15 #include "muParserDLL.h" | 15 #include "muParserDLL.h" |
16 | 16 |
17 #define DATAFOLDER "Z:\\Measures-2013" | 17 #define DATAFOLDER "Z:\\Measures-2013" |
18 | 18 |
19 #define DEDRIFT_DDS_FREQUENCY 70000000 | 19 #define DEDRIFT_DDS_FREQUENCY 70000000.0 |
20 #define FREP_STEP_SIZE 50000.0 | |
20 | 21 |
21 // number of channels read | 22 // number of channels read |
22 #define NCHAN 4 | 23 #define NCHAN 4 |
23 | 24 |
24 // data acquisition event | 25 // data acquisition event |
233 mupDefineVar(parser, "N3", &N3); | 234 mupDefineVar(parser, "N3", &N3); |
234 mupDefineVar(parser, "Nu1", &Nu1); | 235 mupDefineVar(parser, "Nu1", &Nu1); |
235 mupDefineVar(parser, "Nu2", &Nu2); | 236 mupDefineVar(parser, "Nu2", &Nu2); |
236 mupDefineVar(parser, "DeltaDDS3", &DeltaDDS3); | 237 mupDefineVar(parser, "DeltaDDS3", &DeltaDDS3); |
237 mupDefineVar(parser, "Signe1", &Signe1); | 238 mupDefineVar(parser, "Signe1", &Signe1); |
238 mupDefineVar(parser, "Signe2", &Signe2); | 239 mupDefineVar(parser, "Signe2", &Signe2); |
239 mupDefineVar(parser, "Ndiv", &Ndiv); | 240 mupDefineVar(parser, "Signe3", &Signe3); |
241 mupDefineVar(parser, "Ndiv", &Ndiv); | |
240 mupDefinePostfixOprt(parser, "P", &Peta, 1); | 242 mupDefinePostfixOprt(parser, "P", &Peta, 1); |
241 mupDefinePostfixOprt(parser, "T", &Tera, 1); | 243 mupDefinePostfixOprt(parser, "T", &Tera, 1); |
242 mupDefinePostfixOprt(parser, "G", &Giga, 1); | 244 mupDefinePostfixOprt(parser, "G", &Giga, 1); |
243 mupDefinePostfixOprt(parser, "M", &Mega, 1); | 245 mupDefinePostfixOprt(parser, "M", &Mega, 1); |
244 mupDefinePostfixOprt(parser, "k", &kilo, 1); | 246 mupDefinePostfixOprt(parser, "k", &kilo, 1); |
738 Slope_1 = stat_math1.slope; | 740 Slope_1 = stat_math1.slope; |
739 Ch4Slope = stat_ch4.slope; | 741 Ch4Slope = stat_ch4.slope; |
740 SetCtrlVal(CalcNPanel, CALCN_SLOPE, Slope_1); | 742 SetCtrlVal(CalcNPanel, CALCN_SLOPE, Slope_1); |
741 | 743 |
742 // frep positive step | 744 // frep positive step |
743 DDS4xAD9912_FrequencyRampe(&DDS4xAD9912,1, FrequDDS1,(FrequDDS1+DeltakHz_1*1000), Step1/Ndiv); | 745 DDS4xAD9912_RampFrequency(&DDS4xAD9912,1, FrequDDS1, FrequDDS1 + DeltakHz_1 * 1000.0, FREP_STEP_SIZE); |
744 SetCtrlVal(MainPanel, PANEL_DDS1, (FrequDDS1+DeltakHz_1*1000)); | 746 SetCtrlVal(MainPanel, PANEL_DDS1, FrequDDS1 + DeltakHz_1 * 1000.0); |
745 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, (FrequDDS1+DeltakHz_1*1000)); | |
746 | 747 |
747 // allow counter to settle | 748 // allow counter to settle |
748 settling = 3; | 749 settling = 3; |
749 | 750 |
750 // next step | 751 // next step |
793 Frepplus_1 = Frepplus_1 / n_1; | 794 Frepplus_1 = Frepplus_1 / n_1; |
794 Ch4Plus = Ch4Plus / n_1; | 795 Ch4Plus = Ch4Plus / n_1; |
795 n_1 = 0; | 796 n_1 = 0; |
796 | 797 |
797 // frep negative step | 798 // frep negative step |
798 DDS4xAD9912_FrequencyRampe(&DDS4xAD9912,1, (FrequDDS1+DeltakHz_1*1000),(FrequDDS1-DeltakHz_1*1000), Step1/Ndiv); | 799 DDS4xAD9912_RampFrequency(&DDS4xAD9912, 1, FrequDDS1 + DeltakHz_1 * 1000.0, FrequDDS1 - DeltakHz_1 * 1000.0, FREP_STEP_SIZE); |
799 SetCtrlVal(MainPanel, PANEL_DDS1, (FrequDDS1-DeltakHz_1*1000)); | 800 SetCtrlVal(MainPanel, PANEL_DDS1, FrequDDS1 - DeltakHz_1 * 1000.0); |
800 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, (FrequDDS1-DeltakHz_1*1000)); | |
801 | 801 |
802 // allow counter to settle | 802 // allow counter to settle |
803 settling = 3; | 803 settling = 3; |
804 | 804 |
805 // next step | 805 // next step |
836 t3_1 = 0.0; | 836 t3_1 = 0.0; |
837 Frepminus_1 = 0.0; | 837 Frepminus_1 = 0.0; |
838 Frepplus_1 = 0.0; | 838 Frepplus_1 = 0.0; |
839 | 839 |
840 // back to nominal frep | 840 // back to nominal frep |
841 DDS4xAD9912_FrequencyRampe(&DDS4xAD9912, 1, FrequDDS1-DeltakHz_1*1000,FrequDDS1, Step1/Ndiv ); | 841 DDS4xAD9912_RampFrequency(&DDS4xAD9912, 1, FrequDDS1 - DeltakHz_1 * 1000.0, FrequDDS1, FREP_STEP_SIZE); |
842 SetCtrlVal(MainPanel, PANEL_DDS1, FrequDDS1); | 842 SetCtrlVal(MainPanel, PANEL_DDS1, FrequDDS1); |
843 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, FrequDDS1); | |
844 SetCtrlVal(MainPanel, PANEL_DDS2, FrequencyDDSBesInit); | 843 SetCtrlVal(MainPanel, PANEL_DDS2, FrequencyDDSBesInit); |
845 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 2, FrequencyDDSBesInit); | 844 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 2, FrequencyDDSBesInit); |
846 | 845 |
847 // done | 846 // done |
848 Measuring_1 = N_MEASUREMENT_NONE; | 847 Measuring_1 = N_MEASUREMENT_NONE; |
888 SetCtrlVal(CalcNPanel, CALCN_SLOPE, Beatslope_2); | 887 SetCtrlVal(CalcNPanel, CALCN_SLOPE, Beatslope_2); |
889 | 888 |
890 // frep positive step | 889 // frep positive step |
891 double fDDS1 = FrequDDS1 + DeltakHz_2 * 1000; | 890 double fDDS1 = FrequDDS1 + DeltakHz_2 * 1000; |
892 printf("fDDS1 = %g\n", fDDS1); | 891 printf("fDDS1 = %g\n", fDDS1); |
893 DDS4xAD9912_FrequencyRampe(&DDS4xAD9912,1, FrequDDS1, fDDS1, Step2/Ndiv); | 892 DDS4xAD9912_RampFrequency(&DDS4xAD9912,1, FrequDDS1, fDDS1, FREP_STEP_SIZE); |
894 SetCtrlVal(MainPanel, PANEL_DDS1, fDDS1); | 893 SetCtrlVal(MainPanel, PANEL_DDS1, fDDS1); |
895 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, fDDS1); | 894 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, fDDS1); |
896 | 895 |
897 // adjust DDS3 to keep beatnote within the bandpass filter. prediction | 896 // adjust DDS3 to keep beatnote within the bandpass filter. prediction |
898 double fDDS3 = FrequencyDDS3Init - DeltakHz_2*1000*(-Signe1/Signe2)*Ndiv*(Nu2)/(Nu1) - Beatslope_2*(utc-t1_2); | 897 double fDDS3 = FrequencyDDS3Init - DeltakHz_2*1000*(-Signe1/Signe2)*Ndiv*(Nu2)/(Nu1) - Beatslope_2*(utc-t1_2); |
954 Delta10K_Plus = Delta10K_Plus / n_2; | 953 Delta10K_Plus = Delta10K_Plus / n_2; |
955 n_2 = 0; | 954 n_2 = 0; |
956 | 955 |
957 // negative frequency step | 956 // negative frequency step |
958 double fDDS1 = FrequDDS1 - DeltakHz_2 * 1000; | 957 double fDDS1 = FrequDDS1 - DeltakHz_2 * 1000; |
959 DDS4xAD9912_FrequencyRampe(&DDS4xAD9912, 1, DDS4xAD9912.Frequency1, fDDS1, Step2/Ndiv); | 958 DDS4xAD9912_RampFrequency(&DDS4xAD9912, 1, DDS4xAD9912.Frequency1, fDDS1, FREP_STEP_SIZE); |
960 SetCtrlVal(MainPanel, PANEL_DDS1, fDDS1); | 959 SetCtrlVal(MainPanel, PANEL_DDS1, fDDS1); |
961 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, fDDS1); | 960 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, fDDS1); |
962 | 961 |
963 // adjust DDS3 to keep beatnote within the bandpass filter. prediction | 962 // adjust DDS3 to keep beatnote within the bandpass filter. prediction |
964 double fDDS3 = FrequencyDDS3Init + DeltakHz_2*1000*(-Signe1/Signe2)*Ndiv*(Nu2)/(Nu1); | 963 double fDDS3 = FrequencyDDS3Init + DeltakHz_2*1000*(-Signe1/Signe2)*Ndiv*(Nu2)/(Nu1); |
997 // compute N2 | 996 // compute N2 |
998 N_2 = (Signe2)*(-DeltaDDS3+Delta10K_Plus-Delta10K_Minus-Beatslope_2*(t3_2-t2_2) )/(Frepminus_2-Frepplus_2-Slope_2*(t3_2-t2_2)); | 997 N_2 = (Signe2)*(-DeltaDDS3+Delta10K_Plus-Delta10K_Minus-Beatslope_2*(t3_2-t2_2) )/(Frepminus_2-Frepplus_2-Slope_2*(t3_2-t2_2)); |
999 SetCtrlVal(CalcNPanel, CALCN_N, N_2); | 998 SetCtrlVal(CalcNPanel, CALCN_N, N_2); |
1000 | 999 |
1001 // back to nominal frequency | 1000 // back to nominal frequency |
1002 DDS4xAD9912_FrequencyRampe (&DDS4xAD9912, 1, FrequDDS1-DeltakHz_2*1000,FrequDDS1, Step2/Ndiv ); | 1001 DDS4xAD9912_RampFrequency(&DDS4xAD9912, 1, FrequDDS1-DeltakHz_2*1000,FrequDDS1, FREP_STEP_SIZE); |
1003 SetCtrlVal(MainPanel, PANEL_DDS1, FrequDDS1); | 1002 SetCtrlVal(MainPanel, PANEL_DDS1, FrequDDS1); |
1004 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, FrequDDS1); | 1003 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, FrequDDS1); |
1005 SetCtrlVal(MainPanel, PANEL_DDS2, FrequencyDDSBesInit); | 1004 SetCtrlVal(MainPanel, PANEL_DDS2, FrequencyDDSBesInit); |
1006 DDS4xAD9912_SetFrequency (&DDS4xAD9912, 2, FrequencyDDSBesInit ); | 1005 DDS4xAD9912_SetFrequency (&DDS4xAD9912, 2, FrequencyDDSBesInit ); |
1007 SetCtrlVal(MainPanel, PANEL_DDS3, FrequencyDDS3Init-Beatslope_2*(utc-t1_2)); | 1006 SetCtrlVal(MainPanel, PANEL_DDS3, FrequencyDDS3Init-Beatslope_2*(utc-t1_2)); |
1061 t2_3 = utc; | 1060 t2_3 = utc; |
1062 stat_zero(&stat_ch2); | 1061 stat_zero(&stat_ch2); |
1063 | 1062 |
1064 // frep positive step | 1063 // frep positive step |
1065 SetCtrlVal(MainPanel, PANEL_DDS4, FrequDDS4 + DeltakHz_3 * 1000); | 1064 SetCtrlVal(MainPanel, PANEL_DDS4, FrequDDS4 + DeltakHz_3 * 1000); |
1066 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 4, FrequDDS4 + DeltakHz_3 * 1000); | 1065 DDS4xAD9912_RampFrequency(&DDS4xAD9912, 4, FrequDDS4, FrequDDS4 + DeltakHz_3 * 1000, FREP_STEP_SIZE); |
1067 // compensate with DDS3 to keep measured beatnote in counter box range | 1066 // compensate with DDS3 to keep measured beatnote in counter box range |
1068 double fDDS3 = FrequencyDDS3Init + N3/N1 * Ndiv * DeltakHz_3 * 1000; | 1067 double fDDS3 = FrequencyDDS3Init + Signe1 * Signe3 * N3/N1 * Ndiv * DeltakHz_3 * 1000; |
1069 SetCtrlVal(MainPanel, PANEL_DDS3, fDDS3); | 1068 SetCtrlVal(MainPanel, PANEL_DDS3, fDDS3); |
1070 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, fDDS3); | 1069 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, fDDS3); |
1071 | 1070 |
1072 // allow counter to settle | 1071 // allow counter to settle |
1073 settling = 3; | 1072 settling = 3; |
1079 | 1078 |
1080 case N_MEASUREMENT_ADJUST_FREQ_PLUS: | 1079 case N_MEASUREMENT_ADJUST_FREQ_PLUS: |
1081 case N_MEASUREMENT_ADJUST_FREQ_MINUS: | 1080 case N_MEASUREMENT_ADJUST_FREQ_MINUS: |
1082 // adjust DDS frequency to keep beatnote within the bandpass filter | 1081 // adjust DDS frequency to keep beatnote within the bandpass filter |
1083 | 1082 |
1084 // next step | |
1085 Measuring_3 += 1; | |
1086 break; | |
1087 | |
1088 case N_MEASUREMENT_FREP_PLUS: | |
1089 // frep positive step | |
1090 | |
1091 if (settling > 0) { | 1083 if (settling > 0) { |
1092 settling--; | 1084 settling--; |
1093 break; | 1085 break; |
1094 } | 1086 } |
1095 | 1087 |
1088 // adjust DDS frequency to keep 55 MHz tracker oscillator locked | |
1089 double fDDS2 = DDS4xAD9912.Frequency2 + 275000 - Ch4; | |
1090 SetCtrlVal(MainPanel, PANEL_DDS2, fDDS2); | |
1091 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 2, fDDS2); | |
1092 | |
1093 // allow counter to settle | |
1094 settling = 3; | |
1095 | |
1096 // next step | |
1097 Measuring_3 += 1; | |
1098 break; | |
1099 | |
1100 case N_MEASUREMENT_FREP_PLUS: | |
1101 // frep positive step | |
1102 | |
1103 if (settling > 0) { | |
1104 settling--; | |
1105 break; | |
1106 } | |
1107 | |
1096 n_3++; | 1108 n_3++; |
1097 Frepplus_3 += Ch2 - Slope_3 * (utc - t2_3); | 1109 Frepplus_3 += Ch2 - Slope_3 * (utc - t2_3); |
1098 | 1110 |
1099 if (utc - t2_3 > DeltaT_3) { | 1111 if (utc - t2_3 > DeltaT_3) { |
1100 // positive step measurement | 1112 // positive step measurement |
1103 n_3 = 0; | 1115 n_3 = 0; |
1104 t3_3 = utc; | 1116 t3_3 = utc; |
1105 | 1117 |
1106 // frep negative step | 1118 // frep negative step |
1107 SetCtrlVal(MainPanel, PANEL_DDS4, FrequDDS4 - DeltakHz_3 * 1000); | 1119 SetCtrlVal(MainPanel, PANEL_DDS4, FrequDDS4 - DeltakHz_3 * 1000); |
1108 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 4, FrequDDS4 - DeltakHz_3 * 1000); | 1120 DDS4xAD9912_RampFrequency(&DDS4xAD9912, 4, FrequDDS4 + DeltakHz_3 * 1000, FrequDDS4 - DeltakHz_3 * 1000, FREP_STEP_SIZE); |
1109 // compensate with DDS3 to keep measured beatnote in counter box range | 1121 // compensate with DDS3 to keep measured beatnote in counter box range |
1110 double fDDS3 = FrequencyDDS3Init - N3/N1 * Ndiv * DeltakHz_3 * 1000; | 1122 double fDDS3 = FrequencyDDS3Init - Signe1 * Signe3 * N3/N1 * Ndiv * DeltakHz_3 * 1000; |
1111 SetCtrlVal(MainPanel, PANEL_DDS3, fDDS3); | 1123 SetCtrlVal(MainPanel, PANEL_DDS3, fDDS3); |
1112 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, fDDS3); | 1124 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, fDDS3); |
1113 | 1125 |
1114 // allow counter to settle | 1126 // allow counter to settle |
1115 settling = 3; | 1127 settling = 3; |
1146 Frepminus_3 = 0.0; | 1158 Frepminus_3 = 0.0; |
1147 Frepplus_3 = 0.0; | 1159 Frepplus_3 = 0.0; |
1148 | 1160 |
1149 // back to nominal frep | 1161 // back to nominal frep |
1150 SetCtrlVal(MainPanel, PANEL_DDS4, FrequDDS4); | 1162 SetCtrlVal(MainPanel, PANEL_DDS4, FrequDDS4); |
1151 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 4, FrequDDS4); | 1163 DDS4xAD9912_RampFrequency(&DDS4xAD9912, 4, FrequDDS4 - DeltakHz_3 * 1000, FrequDDS4, FREP_STEP_SIZE); |
1152 // back to initial DDS3 frequency | 1164 // back to initial DDS3 frequency |
1153 SetCtrlVal(MainPanel, PANEL_DDS3, FrequencyDDS3Init); | 1165 SetCtrlVal(MainPanel, PANEL_DDS3, FrequencyDDS3Init); |
1154 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, FrequencyDDS3Init); | 1166 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, FrequencyDDS3Init); |
1155 | 1167 |
1156 // done | 1168 // done |
1330 GetCtrlVal(MainPanel, PANEL_SAVE_RAW_DATA, &save); | 1342 GetCtrlVal(MainPanel, PANEL_SAVE_RAW_DATA, &save); |
1331 if (save) { | 1343 if (save) { |
1332 writeData4(DATAFOLDER, "Raw", id, timestr, utc, Ch1, Ch2, Ch3, Ch4); | 1344 writeData4(DATAFOLDER, "Raw", id, timestr, utc, Ch1, Ch2, Ch3, Ch4); |
1333 } | 1345 } |
1334 | 1346 |
1335 // write LO frequency (Math2) to disk | 1347 // write Lo frequency (Math2) to disk |
1336 GetCtrlVal(MainPanel, PANEL_CHECKBOX_MATH2SAVE, &save); | 1348 GetCtrlVal(MainPanel, PANEL_CHECKBOX_MATH2SAVE, &save); |
1337 if (save) { | 1349 if (save) { |
1338 writeData(DATAFOLDER, "Lo", id, timestr, utc, Math2); | 1350 writeData(DATAFOLDER, "Lo", id, timestr, utc, Math2); |
1339 writeData("C:\\Femto\\Results", "Lo", id, timestr, utc, Math2); | 1351 writeData("C:\\Femto\\Results", "Lo", id, timestr, utc, Math2); |
1340 } | 1352 } |
2216 SetPanelAttribute(LoggingPanel, ATTR_VISIBLE, 0); | 2228 SetPanelAttribute(LoggingPanel, ATTR_VISIBLE, 0); |
2217 break; | 2229 break; |
2218 } | 2230 } |
2219 return 0; | 2231 return 0; |
2220 } | 2232 } |
2233 | |
2234 int CVICALLBACK CB_Sign3 (int panel, int control, int event, | |
2235 void *callbackData, int eventData1, int eventData2) | |
2236 { | |
2237 switch (event) | |
2238 { | |
2239 case EVENT_COMMIT: | |
2240 GetCtrlVal(panel, control, &Signe3); | |
2241 break; | |
2242 } | |
2243 return 0; | |
2244 } |