Mercurial > hg > fxanalyse
comparison FXAnalyse.c @ 270:a451d4618dbf
Simplify code moving the update of the DDS frequency display to the wrappers
author | Daniele Nicolodi <daniele.nicolodi@obspm.fr> |
---|---|
date | Fri, 10 Jul 2015 15:21:15 +0200 |
parents | 3f395eab72eb |
children | 4a2fa10b8421 |
comparison
equal
deleted
inserted
replaced
269:3f395eab72eb | 270:a451d4618dbf |
---|---|
194 | 194 |
195 | 195 |
196 struct ad9956 ad9956; | 196 struct ad9956 ad9956; |
197 struct ad9912 ad9912; | 197 struct ad9912 ad9912; |
198 | 198 |
199 static const int PANEL_DDS[4] = { PANEL_DDS1, PANEL_DDS2, PANEL_DDS3, PANEL_DDS4 }; | |
199 | 200 |
200 static inline int ad9912_set_frequency_w(struct ad9912 *d, unsigned c, double f) | 201 static inline int ad9912_set_frequency_w(struct ad9912 *d, unsigned c, double f) |
201 { | 202 { |
202 int r = ad9912_set_frequency(d, c, f); | 203 int r = ad9912_set_frequency(d, c, f); |
203 if (r) | 204 if (r) { |
204 logmessage(ERROR, "ad9912 set frequency channel=%d error=%d", c, -r); | 205 logmessage(ERROR, "ad9912 set frequency channel=%d error=%d", c, -r); |
205 return r; | 206 return r; |
207 } | |
208 | |
209 // update DDS frequency display | |
210 SetCtrlVal(MainPanel, PANEL_DDS[c], d->frequency[i]); | |
211 return 0; | |
206 } | 212 } |
207 | 213 |
208 | 214 |
209 static inline int ad9912_ramp_frequency_w(struct ad9912 *d, unsigned c, double f, double s) | 215 static inline int ad9912_ramp_frequency_w(struct ad9912 *d, unsigned c, double f, double s) |
210 { | 216 { |
211 int r = ad9912_ramp_frequency(d, c, f, s); | 217 int r = ad9912_ramp_frequency(d, c, f, s); |
212 if (r) | 218 if (r) { |
213 logmessage(ERROR, "ad9912 ramp frequency channel=%d error=%d", c, -r); | 219 logmessage(ERROR, "ad9912 ramp frequency channel=%d error=%d", c, -r); |
214 return r; | 220 return r; |
221 } | |
222 | |
223 // update DDS frequency display | |
224 SetCtrlVal(MainPanel, PANEL_DDS[c], d->frequency[i]); | |
225 return 0; | |
215 } | 226 } |
216 | 227 |
217 | 228 |
218 static inline int ad9956_set_sweep_rate_w(struct ad9956 *d, double s) | 229 static inline int ad9956_set_sweep_rate_w(struct ad9956 *d, double s) |
219 { | 230 { |
545 if (fabs(adj) > recenter.threshold[LO]) { | 556 if (fabs(adj) > recenter.threshold[LO]) { |
546 logmessage(WARNING, "not recenter ch4 to 275 kHz: DDS2 adjustment=%+3e exceeds threshold", adj); | 557 logmessage(WARNING, "not recenter ch4 to 275 kHz: DDS2 adjustment=%+3e exceeds threshold", adj); |
547 } else { | 558 } else { |
548 freq = freq + adj; | 559 freq = freq + adj; |
549 ad9912_set_frequency_w(&ad9912, 1, freq); | 560 ad9912_set_frequency_w(&ad9912, 1, freq); |
550 SetCtrlVal(MainPanel, PANEL_DDS2, ad9912.frequency[1]); | |
551 logmsg("recenter ch4 to 275 kHz: DDS2 adjustment=%+3e", adj); | 561 logmsg("recenter ch4 to 275 kHz: DDS2 adjustment=%+3e", adj); |
552 } | 562 } |
553 } | 563 } |
554 | 564 |
555 if (recenter.enabled[HG]) { | 565 if (recenter.enabled[HG]) { |
559 if (fabs(adj) > recenter.threshold[HG]) { | 569 if (fabs(adj) > recenter.threshold[HG]) { |
560 logmessage(WARNING, "not recenter Hg beatnote (ch2) to 10 kHz: DDS3 adjustment=%+3e exceeds threshold", adj); | 570 logmessage(WARNING, "not recenter Hg beatnote (ch2) to 10 kHz: DDS3 adjustment=%+3e exceeds threshold", adj); |
561 } else { | 571 } else { |
562 freq = freq + adj; | 572 freq = freq + adj; |
563 ad9912_set_frequency_w(&ad9912, 2, freq); | 573 ad9912_set_frequency_w(&ad9912, 2, freq); |
564 SetCtrlVal(MainPanel, PANEL_DDS3, ad9912.frequency[2]); | |
565 logmsg("recenter Hg beatnote (ch2) to 10 kHz: DDS3 adjustment=%+3e", adj); | 574 logmsg("recenter Hg beatnote (ch2) to 10 kHz: DDS3 adjustment=%+3e", adj); |
566 } | 575 } |
567 } | 576 } |
568 | 577 |
569 if (recenter.enabled[SR]) { | 578 if (recenter.enabled[SR]) { |
573 if (fabs(adj) > recenter.threshold[SR]) { | 582 if (fabs(adj) > recenter.threshold[SR]) { |
574 logmessage(WARNING, "not recenter Sr beatnote (ch3) to 10 kHz: DDS4 adjustment=%+3e exceeds threshold", adj); | 583 logmessage(WARNING, "not recenter Sr beatnote (ch3) to 10 kHz: DDS4 adjustment=%+3e exceeds threshold", adj); |
575 } else { | 584 } else { |
576 freq = freq + adj; | 585 freq = freq + adj; |
577 ad9912_set_frequency_w(&ad9912, 3, freq); | 586 ad9912_set_frequency_w(&ad9912, 3, freq); |
578 SetCtrlVal(MainPanel, PANEL_DDS4, ad9912.frequency[3]); | |
579 logmsg("recenter Sr beatnote (ch3) to 10 kHz: DDS4 adjustment=%+3e", adj); | 587 logmsg("recenter Sr beatnote (ch3) to 10 kHz: DDS4 adjustment=%+3e", adj); |
580 } | 588 } |
581 } | 589 } |
582 | 590 |
583 recenter.t0 = utc; | 591 recenter.t0 = utc; |
719 { | 727 { |
720 int i, rv, nchan; | 728 int i, rv, nchan; |
721 double frequency, clock; | 729 double frequency, clock; |
722 char expr[1024]; | 730 char expr[1024]; |
723 char host[256]; | 731 char host[256]; |
724 int PANEL_DDS[4] = { PANEL_DDS1, PANEL_DDS2, PANEL_DDS3, PANEL_DDS4 }; | |
725 | 732 |
726 if ((MainPanel = LoadPanel (0, "FXAnalyse.uir", PANEL)) < 0) | 733 if ((MainPanel = LoadPanel (0, "FXAnalyse.uir", PANEL)) < 0) |
727 return -1; | 734 return -1; |
728 if ((CalcNPanel = LoadPanel (MainPanel, "FXAnalyse.uir", CALCN)) < 0) | 735 if ((CalcNPanel = LoadPanel (MainPanel, "FXAnalyse.uir", CALCN)) < 0) |
729 return -1; | 736 return -1; |
784 logmessage(ERROR, "ad9912 init erorr=%d", -rv); | 791 logmessage(ERROR, "ad9912 init erorr=%d", -rv); |
785 | 792 |
786 // try to read back current frequency from DDS | 793 // try to read back current frequency from DDS |
787 for (i = 0; i < 4; i++) { | 794 for (i = 0; i < 4; i++) { |
788 rv = ad9912_get_frequency(&ad9912, i, &frequency); | 795 rv = ad9912_get_frequency(&ad9912, i, &frequency); |
789 if ((rv) || (frequency == 0.0)) { | 796 if ((rv != 0) || (frequency == 0.0)) { |
790 logmessage(WARNING, "reset DDS%d frequency to default value", i + 1); | 797 logmessage(WARNING, "reset DDS%d frequency to default value", i + 1); |
791 GetCtrlVal(MainPanel, PANEL_DDS[i], &frequency); | 798 GetCtrlVal(MainPanel, PANEL_DDS[i], &frequency); |
792 ad9912_set_frequency_w(&ad9912, i, frequency); | 799 ad9912_set_frequency_w(&ad9912, i, frequency); |
793 } | 800 } |
794 SetCtrlVal(MainPanel, PANEL_DDS[i], frequency); | |
795 } | 801 } |
796 | 802 |
797 // setup ZMQ pub socket | 803 // setup ZMQ pub socket |
798 char *socket; | 804 char *socket; |
799 rv = Ini_GetStringCopy(configuration, "ZMQ", "socket", &socket); | 805 rv = Ini_GetStringCopy(configuration, "ZMQ", "socket", &socket); |
1044 case N_MEASUREMENT_INIT: | 1050 case N_MEASUREMENT_INIT: |
1045 // initialization step | 1051 // initialization step |
1046 | 1052 |
1047 // set DDS1 to nominal frequency | 1053 // set DDS1 to nominal frequency |
1048 ad9912_set_frequency_w(&ad9912, 0, f0_DDS[0]); | 1054 ad9912_set_frequency_w(&ad9912, 0, f0_DDS[0]); |
1049 SetCtrlVal(MainPanel, PANEL_DDS1, ad9912.frequency[0]); | |
1050 | 1055 |
1051 // record current DDS frequencies | 1056 // record current DDS frequencies |
1052 f0_DDS[1] = ad9912.frequency[1]; | 1057 f0_DDS[1] = ad9912.frequency[1]; |
1053 | 1058 |
1054 t1 = utc; | 1059 t1 = utc; |
1069 if ((utc - t1) > slope_time[LO]) { | 1074 if ((utc - t1) > slope_time[LO]) { |
1070 f_rep_slope = stat_math1.slope; | 1075 f_rep_slope = stat_math1.slope; |
1071 | 1076 |
1072 // frep positive step | 1077 // frep positive step |
1073 ad9912_ramp_frequency_w(&ad9912, 0, f0_DDS[0] + delta_f_lock[LO], FREP_STEP_SIZE); | 1078 ad9912_ramp_frequency_w(&ad9912, 0, f0_DDS[0] + delta_f_lock[LO], FREP_STEP_SIZE); |
1074 SetCtrlVal(MainPanel, PANEL_DDS1, ad9912.frequency[0]); | |
1075 | 1079 |
1076 // allow counter to settle | 1080 // allow counter to settle |
1077 settling = 3; | 1081 settling = 3; |
1078 | 1082 |
1079 // next step | 1083 // next step |
1088 if (settling-- > 0) | 1092 if (settling-- > 0) |
1089 break; | 1093 break; |
1090 | 1094 |
1091 double fDDS2 = ad9912.frequency[1]; | 1095 double fDDS2 = ad9912.frequency[1]; |
1092 ad9912_set_frequency_w(&ad9912, 1, fDDS2 + 275000 - Ch4); | 1096 ad9912_set_frequency_w(&ad9912, 1, fDDS2 + 275000 - Ch4); |
1093 SetCtrlVal(MainPanel, PANEL_DDS2, ad9912.frequency[1]); | |
1094 | 1097 |
1095 // allow counter to settle | 1098 // allow counter to settle |
1096 settling = 3; | 1099 settling = 3; |
1097 | 1100 |
1098 // next step | 1101 // next step |
1115 f_rep_plus = f_rep_plus / nobs; | 1118 f_rep_plus = f_rep_plus / nobs; |
1116 nobs = 0; | 1119 nobs = 0; |
1117 | 1120 |
1118 // frep negative step | 1121 // frep negative step |
1119 ad9912_ramp_frequency_w(&ad9912, 0, f0_DDS[0] - delta_f_lock[LO], FREP_STEP_SIZE); | 1122 ad9912_ramp_frequency_w(&ad9912, 0, f0_DDS[0] - delta_f_lock[LO], FREP_STEP_SIZE); |
1120 SetCtrlVal(MainPanel, PANEL_DDS1, ad9912.frequency[0]); | |
1121 | 1123 |
1122 // allow counter to settle | 1124 // allow counter to settle |
1123 settling = 3; | 1125 settling = 3; |
1124 | 1126 |
1125 // next step | 1127 // next step |
1149 SetCtrlVal(CalcNPanel, CALCN_N, measured); | 1151 SetCtrlVal(CalcNPanel, CALCN_N, measured); |
1150 | 1152 |
1151 // back to nominal frep | 1153 // back to nominal frep |
1152 ad9912_ramp_frequency_w(&ad9912, 0, f0_DDS[0], FREP_STEP_SIZE); | 1154 ad9912_ramp_frequency_w(&ad9912, 0, f0_DDS[0], FREP_STEP_SIZE); |
1153 ad9912_set_frequency_w(&ad9912, 1, f0_DDS[1]); | 1155 ad9912_set_frequency_w(&ad9912, 1, f0_DDS[1]); |
1154 SetCtrlVal(MainPanel, PANEL_DDS1, ad9912.frequency[0]); | |
1155 SetCtrlVal(MainPanel, PANEL_DDS2, ad9912.frequency[1]); | |
1156 | 1156 |
1157 // done | 1157 // done |
1158 n_measurement[LO] = N_MEASUREMENT_NONE; | 1158 n_measurement[LO] = N_MEASUREMENT_NONE; |
1159 } | 1159 } |
1160 break; | 1160 break; |
1169 case N_MEASUREMENT_INIT: | 1169 case N_MEASUREMENT_INIT: |
1170 // initialization step | 1170 // initialization step |
1171 | 1171 |
1172 // set DDS1 to nominal frequency | 1172 // set DDS1 to nominal frequency |
1173 ad9912_set_frequency_w(&ad9912, 0, f0_DDS[0]); | 1173 ad9912_set_frequency_w(&ad9912, 0, f0_DDS[0]); |
1174 SetCtrlVal(MainPanel, PANEL_DDS1, ad9912.frequency[0]); | |
1175 | 1174 |
1176 // record current DDS frequencies | 1175 // record current DDS frequencies |
1177 f0_DDS[1] = ad9912.frequency[1]; | 1176 f0_DDS[1] = ad9912.frequency[1]; |
1178 f0_DDS[2] = ad9912.frequency[2]; | 1177 f0_DDS[2] = ad9912.frequency[2]; |
1179 | 1178 |
1200 f_beat_slope = stat_ch2.slope; | 1199 f_beat_slope = stat_ch2.slope; |
1201 | 1200 |
1202 // frep positive step | 1201 // frep positive step |
1203 double fDDS1 = f0_DDS[0] + delta_f_lock[HG]; | 1202 double fDDS1 = f0_DDS[0] + delta_f_lock[HG]; |
1204 ad9912_ramp_frequency_w(&ad9912, 0, fDDS1, FREP_STEP_SIZE); | 1203 ad9912_ramp_frequency_w(&ad9912, 0, fDDS1, FREP_STEP_SIZE); |
1205 SetCtrlVal(MainPanel, PANEL_DDS1, ad9912.frequency[0]); | |
1206 | 1204 |
1207 // adjust DDS3 to keep beatnote within the bandpass filter. prediction | 1205 // adjust DDS3 to keep beatnote within the bandpass filter. prediction |
1208 double fDDS3 = f0_DDS[2] + Sign1 * Sign2 * N2/N1 * Ndiv * delta_f_lock[HG]; | 1206 double fDDS3 = f0_DDS[2] + Sign1 * Sign2 * N2/N1 * Ndiv * delta_f_lock[HG]; |
1209 df_DDS3 = fDDS3 - ad9912.frequency[2]; | 1207 df_DDS3 = fDDS3 - ad9912.frequency[2]; |
1210 ad9912_set_frequency_w(&ad9912, 2, fDDS3); | 1208 ad9912_set_frequency_w(&ad9912, 2, fDDS3); |
1211 SetCtrlVal(MainPanel, PANEL_DDS3, ad9912.frequency[2]); | |
1212 | 1209 |
1213 // allow counter to settle | 1210 // allow counter to settle |
1214 settling = 3; | 1211 settling = 3; |
1215 | 1212 |
1216 // next step | 1213 // next step |
1225 if (settling-- > 0) | 1222 if (settling-- > 0) |
1226 break; | 1223 break; |
1227 | 1224 |
1228 double fDDS2 = ad9912.frequency[1] + 275000 - Ch4; | 1225 double fDDS2 = ad9912.frequency[1] + 275000 - Ch4; |
1229 ad9912_set_frequency_w(&ad9912, 1, fDDS2); | 1226 ad9912_set_frequency_w(&ad9912, 1, fDDS2); |
1230 SetCtrlVal(MainPanel, PANEL_DDS2, ad9912.frequency[1]); | |
1231 | 1227 |
1232 double fDDS3 = ad9912.frequency[2] + 10000 - Ch2; | 1228 double fDDS3 = ad9912.frequency[2] + 10000 - Ch2; |
1233 df_DDS3 = df_DDS3 + 10000 - Ch2; | 1229 df_DDS3 = df_DDS3 + 10000 - Ch2; |
1234 ad9912_set_frequency_w(&ad9912, 2, fDDS3); | 1230 ad9912_set_frequency_w(&ad9912, 2, fDDS3); |
1235 SetCtrlVal(MainPanel, PANEL_DDS3, ad9912.frequency[2]); | |
1236 | 1231 |
1237 // allow counter to settle | 1232 // allow counter to settle |
1238 settling = 3; | 1233 settling = 3; |
1239 | 1234 |
1240 // next step | 1235 // next step |
1260 nobs = 0; | 1255 nobs = 0; |
1261 | 1256 |
1262 // negative frequency step | 1257 // negative frequency step |
1263 double fDDS1 = f0_DDS[0] - delta_f_lock[HG]; | 1258 double fDDS1 = f0_DDS[0] - delta_f_lock[HG]; |
1264 ad9912_ramp_frequency_w(&ad9912, 0, fDDS1, FREP_STEP_SIZE); | 1259 ad9912_ramp_frequency_w(&ad9912, 0, fDDS1, FREP_STEP_SIZE); |
1265 SetCtrlVal(MainPanel, PANEL_DDS1, ad9912.frequency[0]); | |
1266 | 1260 |
1267 // adjust DDS3 to keep beatnote within the bandpass filter. prediction | 1261 // adjust DDS3 to keep beatnote within the bandpass filter. prediction |
1268 double fDDS3 = f0_DDS[2] - Sign1 * Sign2 * N2/N1 * Ndiv * delta_f_lock[HG]; | 1262 double fDDS3 = f0_DDS[2] - Sign1 * Sign2 * N2/N1 * Ndiv * delta_f_lock[HG]; |
1269 df_DDS3 = fDDS3 - ad9912.frequency[2]; | 1263 df_DDS3 = fDDS3 - ad9912.frequency[2]; |
1270 ad9912_set_frequency_w(&ad9912, 2, fDDS3); | 1264 ad9912_set_frequency_w(&ad9912, 2, fDDS3); |
1271 SetCtrlVal(MainPanel, PANEL_DDS3, ad9912.frequency[2]); | |
1272 | 1265 |
1273 // allow counter to settle | 1266 // allow counter to settle |
1274 settling = 3; | 1267 settling = 3; |
1275 | 1268 |
1276 // next step | 1269 // next step |
1309 | 1302 |
1310 // back to nominal frequency | 1303 // back to nominal frequency |
1311 ad9912_ramp_frequency_w(&ad9912, 0, f0_DDS[0], FREP_STEP_SIZE); | 1304 ad9912_ramp_frequency_w(&ad9912, 0, f0_DDS[0], FREP_STEP_SIZE); |
1312 ad9912_set_frequency_w(&ad9912, 1, f0_DDS[1]); | 1305 ad9912_set_frequency_w(&ad9912, 1, f0_DDS[1]); |
1313 ad9912_set_frequency_w(&ad9912, 2, f0_DDS[2]); | 1306 ad9912_set_frequency_w(&ad9912, 2, f0_DDS[2]); |
1314 SetCtrlVal(MainPanel, PANEL_DDS1, ad9912.frequency[0]); | |
1315 SetCtrlVal(MainPanel, PANEL_DDS2, ad9912.frequency[1]); | |
1316 SetCtrlVal(MainPanel, PANEL_DDS3, ad9912.frequency[2]); | |
1317 | 1307 |
1318 // done | 1308 // done |
1319 n_measurement[HG] = N_MEASUREMENT_NONE; | 1309 n_measurement[HG] = N_MEASUREMENT_NONE; |
1320 } | 1310 } |
1321 break; | 1311 break; |
1330 case N_MEASUREMENT_INIT: | 1320 case N_MEASUREMENT_INIT: |
1331 // init | 1321 // init |
1332 | 1322 |
1333 // set DDS1 to nominal frequency | 1323 // set DDS1 to nominal frequency |
1334 ad9912_set_frequency_w(&ad9912, 0, f0_DDS[0]); | 1324 ad9912_set_frequency_w(&ad9912, 0, f0_DDS[0]); |
1335 SetCtrlVal(MainPanel, PANEL_DDS1, ad9912.frequency[0]); | |
1336 | 1325 |
1337 // record current DDS frequencies | 1326 // record current DDS frequencies |
1338 f0_DDS[1] = ad9912.frequency[1]; | 1327 f0_DDS[1] = ad9912.frequency[1]; |
1339 f0_DDS[3] = ad9912.frequency[3]; | 1328 f0_DDS[3] = ad9912.frequency[3]; |
1340 | 1329 |
1367 logmsg("f_rep_slope=%e Hz/s", f_rep_slope); | 1356 logmsg("f_rep_slope=%e Hz/s", f_rep_slope); |
1368 logmsg("f_beat_slope=%e Hz/s", f_rep_slope); | 1357 logmsg("f_beat_slope=%e Hz/s", f_rep_slope); |
1369 | 1358 |
1370 // frep positive step | 1359 // frep positive step |
1371 ad9912_ramp_frequency_w(&ad9912, 0, f0_DDS[0] + delta_f_lock[SR], FREP_STEP_SIZE); | 1360 ad9912_ramp_frequency_w(&ad9912, 0, f0_DDS[0] + delta_f_lock[SR], FREP_STEP_SIZE); |
1372 SetCtrlVal(MainPanel, PANEL_DDS1, ad9912.frequency[0]); | |
1373 | 1361 |
1374 // adjust DDS3 to keep beatnote within the bandpass filter | 1362 // adjust DDS3 to keep beatnote within the bandpass filter |
1375 double fDDS4 = f0_DDS[3] + Sign1 * Sign3 * N3/N1 * Ndiv * delta_f_lock[SR]; | 1363 double fDDS4 = f0_DDS[3] + Sign1 * Sign3 * N3/N1 * Ndiv * delta_f_lock[SR]; |
1376 ad9912_set_frequency_w(&ad9912, 3, fDDS4); | 1364 ad9912_set_frequency_w(&ad9912, 3, fDDS4); |
1377 SetCtrlVal(MainPanel, PANEL_DDS4, ad9912.frequency[3]); | |
1378 | 1365 |
1379 // allow counter to settle | 1366 // allow counter to settle |
1380 settling = 3; | 1367 settling = 3; |
1381 | 1368 |
1382 // next step | 1369 // next step |
1392 break; | 1379 break; |
1393 | 1380 |
1394 // adjust DDS frequency to keep 55 MHz tracker oscillator locked | 1381 // adjust DDS frequency to keep 55 MHz tracker oscillator locked |
1395 double fDDS2 = ad9912.frequency[1] + 275000 - Ch4; | 1382 double fDDS2 = ad9912.frequency[1] + 275000 - Ch4; |
1396 ad9912_set_frequency_w(&ad9912, 1, fDDS2); | 1383 ad9912_set_frequency_w(&ad9912, 1, fDDS2); |
1397 SetCtrlVal(MainPanel, PANEL_DDS2, ad9912.frequency[1]); | |
1398 | 1384 |
1399 // allow counter to settle | 1385 // allow counter to settle |
1400 settling = 3; | 1386 settling = 3; |
1401 | 1387 |
1402 // next step | 1388 // next step |
1421 f_beat_plus = f_beat_plus / nobs; | 1407 f_beat_plus = f_beat_plus / nobs; |
1422 nobs = 0; | 1408 nobs = 0; |
1423 | 1409 |
1424 // frep negative step | 1410 // frep negative step |
1425 ad9912_ramp_frequency_w(&ad9912, 0, f0_DDS[0] - delta_f_lock[SR], FREP_STEP_SIZE); | 1411 ad9912_ramp_frequency_w(&ad9912, 0, f0_DDS[0] - delta_f_lock[SR], FREP_STEP_SIZE); |
1426 SetCtrlVal(MainPanel, PANEL_DDS1, ad9912.frequency[0]); | |
1427 | 1412 |
1428 // adjust DDS3 to keep beatnote within the bandpass filter | 1413 // adjust DDS3 to keep beatnote within the bandpass filter |
1429 double fDDS4 = f0_DDS[3] - Sign1 * Sign3 * N3/N1 * Ndiv * delta_f_lock[SR]; | 1414 double fDDS4 = f0_DDS[3] - Sign1 * Sign3 * N3/N1 * Ndiv * delta_f_lock[SR]; |
1430 ad9912_set_frequency_w(&ad9912, 3, fDDS4); | 1415 ad9912_set_frequency_w(&ad9912, 3, fDDS4); |
1431 SetCtrlVal(MainPanel, PANEL_DDS4, ad9912.frequency[3]); | |
1432 | 1416 |
1433 // allow counter to settle | 1417 // allow counter to settle |
1434 settling = 3; | 1418 settling = 3; |
1435 | 1419 |
1436 // next step | 1420 // next step |
1478 | 1462 |
1479 // back to nominal frep | 1463 // back to nominal frep |
1480 ad9912_ramp_frequency_w(&ad9912, 0, f0_DDS[0], FREP_STEP_SIZE); | 1464 ad9912_ramp_frequency_w(&ad9912, 0, f0_DDS[0], FREP_STEP_SIZE); |
1481 ad9912_set_frequency_w(&ad9912, 1, f0_DDS[1]); | 1465 ad9912_set_frequency_w(&ad9912, 1, f0_DDS[1]); |
1482 ad9912_set_frequency_w(&ad9912, 3, f0_DDS[3]); | 1466 ad9912_set_frequency_w(&ad9912, 3, f0_DDS[3]); |
1483 SetCtrlVal(MainPanel, PANEL_DDS1, ad9912.frequency[0]); | |
1484 SetCtrlVal(MainPanel, PANEL_DDS2, ad9912.frequency[1]); | |
1485 SetCtrlVal(MainPanel, PANEL_DDS4, ad9912.frequency[3]); | |
1486 | 1467 |
1487 // done | 1468 // done |
1488 n_measurement[SR] = N_MEASUREMENT_NONE; | 1469 n_measurement[SR] = N_MEASUREMENT_NONE; |
1489 } | 1470 } |
1490 break; | 1471 break; |
1516 break; | 1497 break; |
1517 } | 1498 } |
1518 | 1499 |
1519 // back to original repetition rate | 1500 // back to original repetition rate |
1520 ad9912_set_frequency_w(&ad9912, 0, beatsign.f0_DDS); | 1501 ad9912_set_frequency_w(&ad9912, 0, beatsign.f0_DDS); |
1521 SetCtrlVal(MainPanel, PANEL_DDS1, ad9912.frequency[0]); | |
1522 | 1502 |
1523 // measurement done | 1503 // measurement done |
1524 beatsign.measure = NONE; | 1504 beatsign.measure = NONE; |
1525 | 1505 |
1526 // in the case of the optical beatnotes sign measurement | 1506 // in the case of the optical beatnotes sign measurement |
1620 double frequency; | 1600 double frequency; |
1621 GetCtrlVal(MainPanel, control, &frequency); | 1601 GetCtrlVal(MainPanel, control, &frequency); |
1622 switch (control) { | 1602 switch (control) { |
1623 case PANEL_DDS1: | 1603 case PANEL_DDS1: |
1624 ad9912_set_frequency_w(&ad9912, 0, frequency); | 1604 ad9912_set_frequency_w(&ad9912, 0, frequency); |
1625 SetCtrlVal(MainPanel, PANEL_DDS1, ad9912.frequency[0]); | |
1626 break; | 1605 break; |
1627 case PANEL_DDS2: | 1606 case PANEL_DDS2: |
1628 ad9912_set_frequency_w(&ad9912, 1, frequency); | 1607 ad9912_set_frequency_w(&ad9912, 1, frequency); |
1629 SetCtrlVal(MainPanel, PANEL_DDS2, ad9912.frequency[1]); | |
1630 break; | 1608 break; |
1631 case PANEL_DDS3: | 1609 case PANEL_DDS3: |
1632 ad9912_set_frequency_w(&ad9912, 2, frequency); | 1610 ad9912_set_frequency_w(&ad9912, 2, frequency); |
1633 SetCtrlVal(MainPanel, PANEL_DDS3, ad9912.frequency[2]); | |
1634 break; | 1611 break; |
1635 case PANEL_DDS4: | 1612 case PANEL_DDS4: |
1636 ad9912_set_frequency_w(&ad9912, 3, frequency); | 1613 ad9912_set_frequency_w(&ad9912, 3, frequency); |
1637 SetCtrlVal(MainPanel, PANEL_DDS4, ad9912.frequency[3]); | |
1638 break; | 1614 break; |
1639 } | 1615 } |
1640 break; | 1616 break; |
1641 } | 1617 } |
1642 return 0; | 1618 return 0; |
1877 ad9912_set_frequency_w(&ad9912, 1, f0_DDS[1]); | 1853 ad9912_set_frequency_w(&ad9912, 1, f0_DDS[1]); |
1878 ad9912_set_frequency_w(&ad9912, 3, f0_DDS[3]); | 1854 ad9912_set_frequency_w(&ad9912, 3, f0_DDS[3]); |
1879 break; | 1855 break; |
1880 } | 1856 } |
1881 | 1857 |
1882 // update DDS frequencies display | |
1883 SetCtrlVal(MainPanel, PANEL_DDS1, ad9912.frequency[0]); | |
1884 SetCtrlVal(MainPanel, PANEL_DDS2, ad9912.frequency[1]); | |
1885 SetCtrlVal(MainPanel, PANEL_DDS3, ad9912.frequency[2]); | |
1886 SetCtrlVal(MainPanel, PANEL_DDS4, ad9912.frequency[3]); | |
1887 | |
1888 break; | 1858 break; |
1889 } | 1859 } |
1890 return 0; | 1860 return 0; |
1891 } | 1861 } |
1892 | 1862 |
1919 beatsign.f_rep_zero = Math1; | 1889 beatsign.f_rep_zero = Math1; |
1920 | 1890 |
1921 // step the repetition rate | 1891 // step the repetition rate |
1922 beatsign.f0_DDS = ad9912.frequency[0]; | 1892 beatsign.f0_DDS = ad9912.frequency[0]; |
1923 ad9912_set_frequency_w(&ad9912, 0, beatsign.f0_DDS + step); | 1893 ad9912_set_frequency_w(&ad9912, 0, beatsign.f0_DDS + step); |
1924 SetCtrlVal(MainPanel, PANEL_DDS1, ad9912.frequency[0]); | |
1925 | 1894 |
1926 break; | 1895 break; |
1927 } | 1896 } |
1928 return 0; | 1897 return 0; |
1929 } | 1898 } |
1938 switch (control) | 1907 switch (control) |
1939 { | 1908 { |
1940 case PANEL_ADJUST_DDS2: | 1909 case PANEL_ADJUST_DDS2: |
1941 frequency = ad9912.frequency[1] + 275000 - Ch4; | 1910 frequency = ad9912.frequency[1] + 275000 - Ch4; |
1942 ad9912_set_frequency_w(&ad9912, 1, frequency); | 1911 ad9912_set_frequency_w(&ad9912, 1, frequency); |
1943 SetCtrlVal(MainPanel, PANEL_DDS2, ad9912.frequency[1]); | |
1944 break; | 1912 break; |
1945 case PANEL_ADJUST_DDS3: | 1913 case PANEL_ADJUST_DDS3: |
1946 frequency = ad9912.frequency[2] + 10000 - Ch2; | 1914 frequency = ad9912.frequency[2] + 10000 - Ch2; |
1947 ad9912_set_frequency_w(&ad9912, 2, frequency); | 1915 ad9912_set_frequency_w(&ad9912, 2, frequency); |
1948 SetCtrlVal(MainPanel, PANEL_DDS3, ad9912.frequency[2]); | |
1949 break; | 1916 break; |
1950 case PANEL_ADJUST_DDS4: | 1917 case PANEL_ADJUST_DDS4: |
1951 frequency = ad9912.frequency[3] + 10000 - Ch3; | 1918 frequency = ad9912.frequency[3] + 10000 - Ch3; |
1952 ad9912_set_frequency_w(&ad9912, 3, frequency); | 1919 ad9912_set_frequency_w(&ad9912, 3, frequency); |
1953 SetCtrlVal(MainPanel, PANEL_DDS4, ad9912.frequency[3]); | |
1954 break; | 1920 break; |
1955 } | 1921 } |
1956 break; | 1922 break; |
1957 } | 1923 } |
1958 return 0; | 1924 return 0; |
1965 { | 1931 { |
1966 case EVENT_COMMIT: | 1932 case EVENT_COMMIT: |
1967 GetCtrlVal(MainPanel, PANEL_CHANGENDIV, &Ndiv); | 1933 GetCtrlVal(MainPanel, PANEL_CHANGENDIV, &Ndiv); |
1968 f0_DDS[0] = 880000000.0 / Ndiv; | 1934 f0_DDS[0] = 880000000.0 / Ndiv; |
1969 ad9912_set_frequency_w(&ad9912, 0, f0_DDS[0]); | 1935 ad9912_set_frequency_w(&ad9912, 0, f0_DDS[0]); |
1970 SetCtrlVal(MainPanel, PANEL_DDS1, ad9912.frequency[0]); | |
1971 break; | 1936 break; |
1972 } | 1937 } |
1973 return 0; | 1938 return 0; |
1974 } | 1939 } |
1975 | 1940 |