comparison FXAnalyse.c @ 111:8bdd7e38715f

Fix N3 measurement
author Daniele Nicolodi <daniele.nicolodi@obspm.fr>
date Tue, 02 Jul 2013 12:58:01 +0200
parents 2a9f8a811d87
children 6691728a0c58
comparison
equal deleted inserted replaced
110:ce9ecc761bc5 111:8bdd7e38715f
104 double FrequencyDDS3Init = 0.0; 104 double FrequencyDDS3Init = 0.0;
105 105
106 double DeltaDDS3=0.0,Delta10K_Plus=0.0,Delta10K_Minus=0.0; 106 double DeltaDDS3=0.0,Delta10K_Plus=0.0,Delta10K_Minus=0.0;
107 double Nu1=0.0, Nu2= 200000-147000+282143746.557455e6; 107 double Nu1=0.0, Nu2= 200000-147000+282143746.557455e6;
108 108
109 double f_beat_Sr_plus, f_beat_Sr_minus;
110
109 double Step1=800000.0,Step2=800000.0; 111 double Step1=800000.0,Step2=800000.0;
110 112
111 double Ch4Plus=0.0,Ch4Minus=0.0; 113 double Ch4Plus=0.0,Ch4Minus=0.0;
112 114
113 double Frequencystep1=10000.0, tbegin1=0.0, Frepbefore1=0.0, Frequency1=0.0; 115 double Frequencystep1=10000.0, tbegin1=0.0, Frepbefore1=0.0, Frequency1=0.0;
181 s->mean = ((s->samples - 1) * s->mean + value) / s->samples; 183 s->mean = ((s->samples - 1) * s->mean + value) / s->samples;
182 184
183 s->previous = value; 185 s->previous = value;
184 } 186 }
185 187
186 struct stat stat_math1, stat_ch2, stat_ch4, freq; 188 struct stat stat_math1, stat_ch2, stat_ch4, stat_ch3, freq;
187 189
188 #define MIN(x, y) (x) < (y) ? (x) : (y) 190 #define MIN(x, y) (x) < (y) ? (x) : (y)
189 191
190 void logmsg(const char *frmt, ...) 192 void logmsg(const char *frmt, ...)
191 { 193 {
1033 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 4, FrequDDS4); 1035 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 4, FrequDDS4);
1034 settling = 3; 1036 settling = 3;
1035 1037
1036 t1_3 = utc; 1038 t1_3 = utc;
1037 stat_zero(&stat_ch2); 1039 stat_zero(&stat_ch2);
1040 stat_zero(&stat_ch3);
1041 f_beat_Sr_plus = 0.0;
1042 f_beat_Sr_minus = 0.0;
1038 1043
1039 // record current DDS3 frequency 1044 // record current DDS3 frequency
1040 GetCtrlVal(MainPanel, PANEL_DDS3, &FrequencyDDS3Init); 1045 GetCtrlVal(MainPanel, PANEL_DDS3, &FrequencyDDS3Init);
1041 1046
1042 // next step 1047 // next step
1050 settling--; 1055 settling--;
1051 break; 1056 break;
1052 } 1057 }
1053 1058
1054 stat_accumulate(&stat_ch2, Ch2); 1059 stat_accumulate(&stat_ch2, Ch2);
1060 stat_accumulate(&stat_ch3, Ch3);
1055 1061
1056 if (utc - t1_3 > SlopeTime3) { 1062 if (utc - t1_3 > SlopeTime3) {
1057 // slope measurement 1063 // slope measurement
1058 Slope_3 = stat_ch2.slope; 1064 Slope_3 = stat_ch2.slope;
1059 1065
1060 t2_3 = utc; 1066 t2_3 = utc;
1061 stat_zero(&stat_ch2); 1067 stat_zero(&stat_ch2);
1068 stat_zero(&stat_ch3);
1062 1069
1063 // frep positive step 1070 // frep positive step
1064 SetCtrlVal(MainPanel, PANEL_DDS4, FrequDDS4 + DeltakHz_3 * 1000); 1071 SetCtrlVal(MainPanel, PANEL_DDS4, FrequDDS4 + DeltakHz_3 * 1000);
1065 DDS4xAD9912_RampFrequency(&DDS4xAD9912, 4, FrequDDS4, FrequDDS4 + DeltakHz_3 * 1000, FREP_STEP_SIZE); 1072 DDS4xAD9912_RampFrequency(&DDS4xAD9912, 4, FrequDDS4, FrequDDS4 + DeltakHz_3 * 1000, FREP_STEP_SIZE);
1066 // compensate with DDS3 to keep measured beatnote in counter box range 1073 // compensate with DDS3 to keep measured beatnote in counter box range
1104 settling--; 1111 settling--;
1105 break; 1112 break;
1106 } 1113 }
1107 1114
1108 n_3++; 1115 n_3++;
1109 Frepplus_3 += Ch2 - Slope_3 * (utc - t2_3); 1116 Frepplus_3 += Math1 + 250000000 - Slope_3 * (utc - t3_2);
1117 f_beat_Sr_plus += Ch3;
1110 1118
1111 if (utc - t2_3 > DeltaT_3) { 1119 if (utc - t2_3 > DeltaT_3) {
1112 // positive step measurement 1120 // positive step measurement
1113 Frepplus_3 = Frepplus_3 / n_3; 1121 Frepplus_3 = Frepplus_3 / n_3;
1122 f_beat_Sr_plus = f_beat_Sr_plus / n_3;
1114 1123
1115 n_3 = 0; 1124 n_3 = 0;
1116 t3_3 = utc; 1125 t3_3 = utc;
1117 1126
1118 // frep negative step 1127 // frep negative step
1140 break; 1149 break;
1141 } 1150 }
1142 1151
1143 n_3++; 1152 n_3++;
1144 Frepminus_3 += Ch2 - Slope_3 * (utc - t3_3); 1153 Frepminus_3 += Ch2 - Slope_3 * (utc - t3_3);
1154 f_beat_Sr_minus += Ch3;
1145 1155
1146 if (utc - t3_3 > DeltaT_3) { 1156 if (utc - t3_3 > DeltaT_3) {
1147 // positive step measurement 1157 // negative step measurement
1148 Frepminus_3 = Frepminus_3 / n_3; 1158 Frepminus_3 = Frepminus_3 / n_3;
1159 f_beat_Sr_minus = f_beat_Sr_plus / n_3;
1160
1161 // check delta frep
1162 double delta_f_rep = Frepplus_3 - Frepplus_3;
1163 double expected = N1 / Ndiv * 2.0 * DeltakHz_3 * 1000.0;
1164 logmsg("delta frep=%g expected=%g", delta_f_rep, expected);
1149 1165
1150 // compute N3 1166 // compute N3
1151 N_3 = 1000.0 * DeltakHz_3 / (Frepplus_3 - Frepminus_3 + (2 * N3/N1 * Ndiv * DeltakHz_3 * 1000)); 1167 double delta_f_beat_Sr = f_beat_Sr_plus - f_beat_Sr_minus + 2.0 * N3/N1 * Ndiv * DeltakHz_3 * 1000;
1168 logmsg("delta fbeat=%g", delta_f_beat_Sr);
1169 N_3 = delta_f_beat_Sr / delta_f_rep;
1152 SetCtrlVal(CalcNPanel, CALCN_N, N_3); 1170 SetCtrlVal(CalcNPanel, CALCN_N, N_3);
1153 1171
1154 t1_3=0.0; 1172 t1_3=0.0;
1155 t2_3=0.0; 1173 t2_3=0.0;
1156 t3_3=0.0; 1174 t3_3=0.0;
1162 SetCtrlVal(MainPanel, PANEL_DDS4, FrequDDS4); 1180 SetCtrlVal(MainPanel, PANEL_DDS4, FrequDDS4);
1163 DDS4xAD9912_RampFrequency(&DDS4xAD9912, 4, FrequDDS4 - DeltakHz_3 * 1000, FrequDDS4, FREP_STEP_SIZE); 1181 DDS4xAD9912_RampFrequency(&DDS4xAD9912, 4, FrequDDS4 - DeltakHz_3 * 1000, FrequDDS4, FREP_STEP_SIZE);
1164 // back to initial DDS3 frequency 1182 // back to initial DDS3 frequency
1165 SetCtrlVal(MainPanel, PANEL_DDS3, FrequencyDDS3Init); 1183 SetCtrlVal(MainPanel, PANEL_DDS3, FrequencyDDS3Init);
1166 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, FrequencyDDS3Init); 1184 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, FrequencyDDS3Init);
1185 // adjust DDS frequency to keep 55 MHz tracker oscillator locked
1186 double fDDS2 = DDS4xAD9912.Frequency2 + 275000 - Ch4;
1187 SetCtrlVal(MainPanel, PANEL_DDS2, fDDS2);
1188 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 2, fDDS2);
1167 1189
1168 // done 1190 // done
1169 Measuring_3 = N_MEASUREMENT_NONE; 1191 Measuring_3 = N_MEASUREMENT_NONE;
1170 } 1192 }
1171 break; 1193 break;