Mercurial > hg > fxanalyse
comparison FXAnalyse.c @ 47:1d3cd8260cbb
Uniform N3 measurement code to N1 and N2
author | Daniele Nicolodi <daniele.nicolodi@obspm.fr> |
---|---|
date | Wed, 10 Oct 2012 13:12:46 +0200 |
parents | 6503feae1809 |
children | 70980f27e1a4 |
comparison
equal
deleted
inserted
replaced
46:6503feae1809 | 47:1d3cd8260cbb |
---|---|
49 | 49 |
50 int Acquiring = FALSE; | 50 int Acquiring = FALSE; |
51 | 51 |
52 long OldLogFilePtr = 0; | 52 long OldLogFilePtr = 0; |
53 double Ndiv = 8.0; | 53 double Ndiv = 8.0; |
54 | |
55 enum { | |
56 N_MEASUREMENT_STEP_0, | |
57 N_MEASUREMENT_STEP_1, | |
58 N_MEASUREMENT_STEP_2, | |
59 N_MEASUREMENT_STEP_3, | |
60 N_MEASUREMENT_STEP_4, | |
61 }; | |
62 | 54 |
63 enum { | 55 enum { |
64 N_MEASUREMENT_NONE, | 56 N_MEASUREMENT_NONE, |
65 N_MEASUREMENT_INIT, | 57 N_MEASUREMENT_INIT, |
66 N_MEASUREMENT_SLOPE, | 58 N_MEASUREMENT_SLOPE, |
1051 break; | 1043 break; |
1052 } | 1044 } |
1053 | 1045 |
1054 switch (Measuring_3) { | 1046 switch (Measuring_3) { |
1055 | 1047 |
1056 case N_MEASUREMENT_STEP_0: | 1048 case N_MEASUREMENT_NONE: |
1057 // not measuring N3 | 1049 // not measuring N3 |
1058 break; | 1050 break; |
1059 | 1051 |
1060 case N_MEASUREMENT_STEP_1: | 1052 case N_MEASUREMENT_INIT: |
1061 // init | 1053 // init |
1062 | 1054 |
1063 SetCtrlVal(MainPanel, PANEL_DDS4, FrequDDS4); | 1055 SetCtrlVal(MainPanel, PANEL_DDS4, FrequDDS4); |
1064 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 4, FrequDDS4); | 1056 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 4, FrequDDS4); |
1065 settling = 3; | 1057 settling = 3; |
1067 t1_3 = utc; | 1059 t1_3 = utc; |
1068 N_slope_3 = 0; | 1060 N_slope_3 = 0; |
1069 // record current DDS3 frequency | 1061 // record current DDS3 frequency |
1070 GetCtrlVal(MainPanel, PANEL_DDS3, &FrequencyDDS3Init); | 1062 GetCtrlVal(MainPanel, PANEL_DDS3, &FrequencyDDS3Init); |
1071 | 1063 |
1072 // step 1 done | 1064 // next step |
1073 Measuring_3 = N_MEASUREMENT_STEP_2; | 1065 Measuring_3 += 1; |
1074 break; | 1066 break; |
1075 | 1067 |
1076 case N_MEASUREMENT_STEP_2: | 1068 case N_MEASUREMENT_SLOPE: |
1077 // slope measurement | 1069 // slope measurement |
1078 | 1070 |
1079 if (settling > 0) { | 1071 if (settling > 0) { |
1080 settling--; | 1072 settling--; |
1081 break; | 1073 break; |
1093 t2_3 = utc; | 1085 t2_3 = utc; |
1094 N_slope_3 = 0; | 1086 N_slope_3 = 0; |
1095 Frequ_slope_3 = 0.0; | 1087 Frequ_slope_3 = 0.0; |
1096 Moy_slope_3 = 0.0; | 1088 Moy_slope_3 = 0.0; |
1097 Slope_slope_3 = 0.0; | 1089 Slope_slope_3 = 0.0; |
1098 | |
1099 // step 2 done | |
1100 Measuring_3 = N_MEASUREMENT_STEP_3; | |
1101 | 1090 |
1102 // frep positive step | 1091 // frep positive step |
1103 SetCtrlVal(MainPanel, PANEL_DDS4, FrequDDS4 + DeltakHz_3 * 1000); | 1092 SetCtrlVal(MainPanel, PANEL_DDS4, FrequDDS4 + DeltakHz_3 * 1000); |
1104 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 4, FrequDDS4 + DeltakHz_3 * 1000); | 1093 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 4, FrequDDS4 + DeltakHz_3 * 1000); |
1105 // compensate with DDS3 to keep measured beatnote in counter box range | 1094 // compensate with DDS3 to keep measured beatnote in counter box range |
1106 double fDDS3 = FrequencyDDS3Init + N3/N1 * Ndiv * DeltakHz_3 * 1000; | 1095 double fDDS3 = FrequencyDDS3Init + N3/N1 * Ndiv * DeltakHz_3 * 1000; |
1107 SetCtrlVal(MainPanel, PANEL_DDS3, fDDS3); | 1096 SetCtrlVal(MainPanel, PANEL_DDS3, fDDS3); |
1108 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, fDDS3); | 1097 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, fDDS3); |
1098 | |
1109 // allow counter to settle | 1099 // allow counter to settle |
1110 settling = 3; | 1100 settling = 3; |
1101 | |
1102 // next step | |
1103 Measuring_3 += 1; | |
1111 } | 1104 } |
1112 break; | 1105 break; |
1113 | 1106 |
1114 case N_MEASUREMENT_STEP_3: | 1107 case N_MEASUREMENT_ADJUST_FREQ_PLUS: |
1108 case N_MEASUREMENT_ADJUST_FREQ_MINUS: | |
1109 // adjust DDS frequency to keep beatnote within the bandpass filter | |
1110 | |
1111 // next step | |
1112 Measuring_3 += 1; | |
1113 break; | |
1114 | |
1115 case N_MEASUREMENT_FREP_PLUS: | |
1115 // frep positive step | 1116 // frep positive step |
1116 | 1117 |
1117 if (settling > 0) { | 1118 if (settling > 0) { |
1118 settling--; | 1119 settling--; |
1119 break; | 1120 break; |
1126 // positive step measurement | 1127 // positive step measurement |
1127 Frepplus_3 = Frepplus_3 / n_3; | 1128 Frepplus_3 = Frepplus_3 / n_3; |
1128 | 1129 |
1129 n_3 = 0; | 1130 n_3 = 0; |
1130 t3_3 = utc; | 1131 t3_3 = utc; |
1131 | |
1132 // step 3 done | |
1133 Measuring_3 = N_MEASUREMENT_STEP_4; | |
1134 | 1132 |
1135 // frep negative step | 1133 // frep negative step |
1136 SetCtrlVal(MainPanel, PANEL_DDS4, FrequDDS4 - DeltakHz_3 * 1000); | 1134 SetCtrlVal(MainPanel, PANEL_DDS4, FrequDDS4 - DeltakHz_3 * 1000); |
1137 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 4, FrequDDS4 - DeltakHz_3 * 1000); | 1135 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 4, FrequDDS4 - DeltakHz_3 * 1000); |
1138 // compensate with DDS3 to keep measured beatnote in counter box range | 1136 // compensate with DDS3 to keep measured beatnote in counter box range |
1139 double fDDS3 = FrequencyDDS3Init - N3/N1 * Ndiv * DeltakHz_3 * 1000; | 1137 double fDDS3 = FrequencyDDS3Init - N3/N1 * Ndiv * DeltakHz_3 * 1000; |
1140 SetCtrlVal(MainPanel, PANEL_DDS3, fDDS3); | 1138 SetCtrlVal(MainPanel, PANEL_DDS3, fDDS3); |
1141 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, fDDS3); | 1139 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, fDDS3); |
1140 | |
1142 // allow counter to settle | 1141 // allow counter to settle |
1143 settling = 3; | 1142 settling = 3; |
1143 | |
1144 // next step | |
1145 Measuring_3 += 1; | |
1144 } | 1146 } |
1145 break; | 1147 break; |
1146 | 1148 |
1147 | 1149 |
1148 case N_MEASUREMENT_STEP_4: | 1150 case N_MEASUREMENT_FREP_MINUS: |
1149 // frep negative step | 1151 // frep negative step |
1150 | 1152 |
1151 if (settling > 0) { | 1153 if (settling > 0) { |
1152 settling--; | 1154 settling--; |
1153 break; | 1155 break; |
1169 t3_3=0.0; | 1171 t3_3=0.0; |
1170 n_3 = 0; | 1172 n_3 = 0; |
1171 Frepminus_3 = 0.0; | 1173 Frepminus_3 = 0.0; |
1172 Frepplus_3 = 0.0; | 1174 Frepplus_3 = 0.0; |
1173 | 1175 |
1174 // step 4 done | |
1175 Measuring_3 = N_MEASUREMENT_STEP_0; | |
1176 | |
1177 // back to nominal frep | 1176 // back to nominal frep |
1178 SetCtrlVal(MainPanel, PANEL_DDS4, FrequDDS4); | 1177 SetCtrlVal(MainPanel, PANEL_DDS4, FrequDDS4); |
1179 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 4, FrequDDS4); | 1178 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 4, FrequDDS4); |
1180 // back to initial DDS3 frequency | 1179 // back to initial DDS3 frequency |
1181 SetCtrlVal(MainPanel, PANEL_DDS3, FrequencyDDS3Init); | 1180 SetCtrlVal(MainPanel, PANEL_DDS3, FrequencyDDS3Init); |
1182 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, FrequencyDDS3Init); | 1181 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, FrequencyDDS3Init); |
1182 | |
1183 // done | |
1184 Measuring_3 = N_MEASUREMENT_NONE; | |
1183 } | 1185 } |
1184 break; | 1186 break; |
1185 } | 1187 } |
1186 | 1188 |
1187 // Calcul du signe de fb | 1189 // Calcul du signe de fb |