Mercurial > hg > fxanalyse
changeset 268:ec4462c7f8b7
Extensive cleanup of beatnote specific variables
Reorganize the beatnote specific variables in arrays indexed by the
beatnote enum constants LO, HG, SR. Also reorganize DDS frequency
related variables in arrays indexed by the DDS channel number.
author | Daniele Nicolodi <daniele.nicolodi@obspm.fr> |
---|---|
date | Thu, 09 Jul 2015 23:11:00 +0200 |
parents | 1de805d2d37a |
children | 3f395eab72eb |
files | FXAnalyse.c |
diffstat | 1 files changed, 125 insertions(+), 124 deletions(-) [+] |
line wrap: on
line diff
--- a/FXAnalyse.c Thu Jul 09 23:08:22 2015 +0200 +++ b/FXAnalyse.c Thu Jul 09 23:11:00 2015 +0200 @@ -262,9 +262,10 @@ MICROWAVE = LO, HG, SR, - _N_BEATS, + NBEATNOTES, }; + enum { N_MEASUREMENT_NONE, N_MEASUREMENT_INIT, @@ -275,23 +276,21 @@ N_MEASUREMENT_FREP_MINUS, }; -int n_measurement_1 = N_MEASUREMENT_NONE; -int n_measurement_2 = N_MEASUREMENT_NONE; -int n_measurement_3 = N_MEASUREMENT_NONE; - -int nobs = 0; -int settling = 0; - -double f0_DDS1 = 110000000.0, f0_DDS2, f0_DDS3, f0_DDS4, df_DDS3; - -double slope_time_1 = 40.0, integration_time_1 = 40.0, delta_f_lock_1 = 500e3; -double slope_time_2 = 40.0, integration_time_2 = 40.0, delta_f_lock_2 = 500e3; -double slope_time_3 = 40.0, integration_time_3 = 40.0, delta_f_lock_3 = 500e3; +int n_measurement[NBEATNOTES] = { N_MEASUREMENT_NONE, }; +double slop_time[NBEATNOTES] = { 40.0, }; +double integration_time[NBEATNOTES] = { 40.0, }; +double delta_f_lock[NBEATNOTES] = { 500e3, }; double t1, t2, t3; double f_rep_slope, f_beat_slope; double f_rep_plus, f_rep_minus; double f_beat_plus, f_beat_minus; + +double f0_DDS[4] = { 110000000.0, 0.0, 0.0, 0.0 }; +double df_DDS3 = 0.0; + +int nobs = 0; +int settling = 0; // Beatnote sign determination is done stepping the repetition rate by @@ -324,13 +323,15 @@ // this need to do not exceed the beatnote filters bandwidth. Given // those contraints the following f_lock steps are chosen: -double f_lock_step_1 = 10000.0; -double f_lock_step_2 = 10.0; -double f_lock_step_3 = 10.0; +double f_lock_step[NBEATNOTES] = { + [LO] = 10000.0, + [HG] = 10.0, + [SR] = 10.0 +}; struct beatsign { int measure; // which beatnote sign is being measured - double f0_DDS1; // DDS1 frequency before stepping + double f0_DDS; // DDS frequency before stepping double t0; // measurement start time double f_rep_zero; // repetition rate before stepping double f_beat_zero; // beatnote frequwncy before stepping @@ -497,11 +498,11 @@ // recenter struct recenter { - int active; // recenter enabled - int enabled[_N_BEATS]; // which beatnotes to recenter - double threshold[_N_BEATS]; // maximum frequency correction - double interval; // interval - double t0; // beginning of current interval + int active; // recenter enabled + int enabled[NBEATNOTES]; // which beatnotes to recenter + double threshold[NBEATNOTES]; // maximum frequency correction + double interval; // interval + double t0; // beginning of current interval }; struct recenter recenter = { @@ -518,7 +519,7 @@ if (! recenter.active) return FALSE; - for (int i = 0; i < _N_BEATS; i++) + for (int i = 0; i < NBEATNOTES; i++) if (recenter.enabled[i]) return TRUE; @@ -1034,7 +1035,7 @@ // N measurement - switch (n_measurement_1) { + switch (n_measurement[LO]) { case N_MEASUREMENT_NONE: // not measuring @@ -1044,11 +1045,11 @@ // initialization step // set DDS1 to nominal frequency - ad9912_set_frequency_w(&ad9912, 0, f0_DDS1); + ad9912_set_frequency_w(&ad9912, 0, f0_DDS[0]); SetCtrlVal(MainPanel, PANEL_DDS1, ad9912.frequency[0]); // record current DDS frequencies - f0_DDS2 = ad9912.frequency[1]; + f0_DDS[1] = ad9912.frequency[1]; t1 = utc; t2 = t3 = 0.0; @@ -1057,7 +1058,7 @@ f_rep_plus = f_rep_minus = 0.0; // next step - n_measurement_1 += 1; + n_measurement[LO] += 1; break; case N_MEASUREMENT_SLOPE: @@ -1065,18 +1066,18 @@ stat_accumulate(&stat_math1, Math1); - if ((utc - t1) > slope_time_1) { + if ((utc - t1) > slope_time[LO]) { f_rep_slope = stat_math1.slope; // frep positive step - ad9912_ramp_frequency_w(&ad9912, 0, f0_DDS1 + delta_f_lock_1, FREP_STEP_SIZE); + ad9912_ramp_frequency_w(&ad9912, 0, f0_DDS[0] + delta_f_lock[LO], FREP_STEP_SIZE); SetCtrlVal(MainPanel, PANEL_DDS1, ad9912.frequency[0]); // allow counter to settle settling = 3; // next step - n_measurement_1 += 1; + n_measurement[LO] += 1; } break; @@ -1095,7 +1096,7 @@ settling = 3; // next step - n_measurement_1 += 1; + n_measurement[LO] += 1; break; case N_MEASUREMENT_FREP_PLUS: @@ -1110,19 +1111,19 @@ f_rep_plus += Math1 - f_rep_slope * (utc - t2); nobs += 1; - if ((utc - t2) > integration_time_1) { + if ((utc - t2) > integration_time[LO]) { f_rep_plus = f_rep_plus / nobs; nobs = 0; // frep negative step - ad9912_ramp_frequency_w(&ad9912, 0, f0_DDS1 - delta_f_lock_1, FREP_STEP_SIZE); + ad9912_ramp_frequency_w(&ad9912, 0, f0_DDS[0] - delta_f_lock[LO], FREP_STEP_SIZE); SetCtrlVal(MainPanel, PANEL_DDS1, ad9912.frequency[0]); // allow counter to settle settling = 3; // next step - n_measurement_1 += 1; + n_measurement[LO] += 1; } break; @@ -1138,28 +1139,28 @@ f_rep_minus += Math1 - f_rep_slope * (utc - t2); nobs += 1; - if ((utc - t3) > integration_time_1) { + if ((utc - t3) > integration_time[LO]) { f_rep_minus = f_rep_minus / nobs; nobs = 0; // compute N1 double delta_f_rep = f_rep_minus - f_rep_plus; - double measured = Sign1 * 2 * Ndiv * delta_f_lock_1 / delta_f_rep; + double measured = Sign1 * 2 * Ndiv * delta_f_lock[LO] / delta_f_rep; SetCtrlVal(CalcNPanel, CALCN_N, measured); // back to nominal frep - ad9912_ramp_frequency_w(&ad9912, 0, f0_DDS1, FREP_STEP_SIZE); - ad9912_set_frequency_w(&ad9912, 1, f0_DDS2); + ad9912_ramp_frequency_w(&ad9912, 0, f0_DDS[0], FREP_STEP_SIZE); + ad9912_set_frequency_w(&ad9912, 1, f0_DDS[1]); SetCtrlVal(MainPanel, PANEL_DDS1, ad9912.frequency[0]); SetCtrlVal(MainPanel, PANEL_DDS2, ad9912.frequency[1]); // done - n_measurement_1 = N_MEASUREMENT_NONE; + n_measurement[LO] = N_MEASUREMENT_NONE; } break; } - switch (n_measurement_2) { + switch (n_measurement[HG]) { case N_MEASUREMENT_NONE: // not measuring @@ -1169,12 +1170,12 @@ // initialization step // set DDS1 to nominal frequency - ad9912_set_frequency_w(&ad9912, 0, f0_DDS1); + ad9912_set_frequency_w(&ad9912, 0, f0_DDS[0]); SetCtrlVal(MainPanel, PANEL_DDS1, ad9912.frequency[0]); // record current DDS frequencies - f0_DDS2 = ad9912.frequency[1]; - f0_DDS3 = ad9912.frequency[2]; + f0_DDS[1] = ad9912.frequency[1]; + f0_DDS[2] = ad9912.frequency[2]; t1 = utc; t2 = t3 = 0.0; @@ -1185,7 +1186,7 @@ f_beat_plus = f_beat_minus = 0.0; // next step - n_measurement_2 += 1; + n_measurement[HG] += 1; break; case N_MEASUREMENT_SLOPE: @@ -1194,17 +1195,17 @@ stat_accumulate(&stat_math1, Math1); stat_accumulate(&stat_ch2, Ch2); - if ((utc - t1) > slope_time_2) { + if ((utc - t1) > slope_time[HG]) { f_rep_slope = stat_math1.slope; f_beat_slope = stat_ch2.slope; // frep positive step - double fDDS1 = f0_DDS1 + delta_f_lock_2; + double fDDS1 = f0_DDS[0] + delta_f_lock[HG]; ad9912_ramp_frequency_w(&ad9912, 0, fDDS1, FREP_STEP_SIZE); SetCtrlVal(MainPanel, PANEL_DDS1, ad9912.frequency[0]); // adjust DDS3 to keep beatnote within the bandpass filter. prediction - double fDDS3 = f0_DDS3 + Sign1 * Sign2 * N2/N1 * Ndiv * delta_f_lock_2; + double fDDS3 = f0_DDS[2] + Sign1 * Sign2 * N2/N1 * Ndiv * delta_f_lock[HG]; df_DDS3 = fDDS3 - ad9912.frequency[2]; ad9912_set_frequency_w(&ad9912, 2, fDDS3); SetCtrlVal(MainPanel, PANEL_DDS3, ad9912.frequency[2]); @@ -1213,7 +1214,7 @@ settling = 3; // next step - n_measurement_2 += 1; + n_measurement[HG] += 1; } break; @@ -1237,7 +1238,7 @@ settling = 3; // next step - n_measurement_2 += 1; + n_measurement[HG] += 1; break; case N_MEASUREMENT_FREP_PLUS: @@ -1253,18 +1254,18 @@ f_beat_plus += Ch2 - f_beat_slope * (utc - t2); nobs += 1; - if ((utc - t2) > integration_time_2) { + if ((utc - t2) > integration_time[HG]) { f_rep_plus = f_rep_plus / nobs; f_beat_plus = f_beat_plus / nobs; nobs = 0; // negative frequency step - double fDDS1 = f0_DDS1 - delta_f_lock_2; + double fDDS1 = f0_DDS[0] - delta_f_lock[HG]; ad9912_ramp_frequency_w(&ad9912, 0, fDDS1, FREP_STEP_SIZE); SetCtrlVal(MainPanel, PANEL_DDS1, ad9912.frequency[0]); // adjust DDS3 to keep beatnote within the bandpass filter. prediction - double fDDS3 = f0_DDS3 - Sign1 * Sign2 * N2/N1 * Ndiv * delta_f_lock_2; + double fDDS3 = f0_DDS[2] - Sign1 * Sign2 * N2/N1 * Ndiv * delta_f_lock[HG]; df_DDS3 = fDDS3 - ad9912.frequency[2]; ad9912_set_frequency_w(&ad9912, 2, fDDS3); SetCtrlVal(MainPanel, PANEL_DDS3, ad9912.frequency[2]); @@ -1273,7 +1274,7 @@ settling = 3; // next step - n_measurement_2 += 1; + n_measurement[HG] += 1; } break; @@ -1290,14 +1291,14 @@ f_beat_minus += Ch2 + f_beat_slope * (utc - t2); nobs += 1; - if ((utc -t3) > integration_time_2) { + if ((utc -t3) > integration_time[HG]) { f_rep_minus = f_rep_minus / nobs; f_beat_minus = f_beat_minus / nobs; nobs = 0; // compute N2 double delta_f_rep_m = f_rep_minus - f_rep_plus; - double delta_f_rep = Sign1 * Ndiv * 2.0 * delta_f_lock_2 / N1; + double delta_f_rep = Sign1 * Ndiv * 2.0 * delta_f_lock[HG] / N1; double delta = delta_f_rep_m - delta_f_rep; logmsg("delta frep: measured=%e expected=%e difference=%e rel=%e", @@ -1307,20 +1308,20 @@ SetCtrlVal(CalcNPanel, CALCN_N, measured); // back to nominal frequency - ad9912_ramp_frequency_w(&ad9912, 0, f0_DDS1, FREP_STEP_SIZE); - ad9912_set_frequency_w(&ad9912, 1, f0_DDS2); - ad9912_set_frequency_w(&ad9912, 2, f0_DDS3); + ad9912_ramp_frequency_w(&ad9912, 0, f0_DDS[0], FREP_STEP_SIZE); + ad9912_set_frequency_w(&ad9912, 1, f0_DDS[1]); + ad9912_set_frequency_w(&ad9912, 2, f0_DDS[2]); SetCtrlVal(MainPanel, PANEL_DDS1, ad9912.frequency[0]); SetCtrlVal(MainPanel, PANEL_DDS2, ad9912.frequency[1]); SetCtrlVal(MainPanel, PANEL_DDS3, ad9912.frequency[2]); // done - n_measurement_2 = N_MEASUREMENT_NONE; + n_measurement[HG] = N_MEASUREMENT_NONE; } break; } - switch (n_measurement_3) { + switch (n_measurement[SR]) { case N_MEASUREMENT_NONE: // not measuring N3 @@ -1330,12 +1331,12 @@ // init // set DDS1 to nominal frequency - ad9912_set_frequency_w(&ad9912, 0, f0_DDS1); + ad9912_set_frequency_w(&ad9912, 0, f0_DDS[0]); SetCtrlVal(MainPanel, PANEL_DDS1, ad9912.frequency[0]); // record current DDS frequencies - f0_DDS2 = ad9912.frequency[1]; - f0_DDS4 = ad9912.frequency[3]; + f0_DDS[1] = ad9912.frequency[1]; + f0_DDS[3] = ad9912.frequency[3]; t1 = utc; t2 = t3 = 0.0; @@ -1346,7 +1347,7 @@ f_beat_plus = f_beat_minus = 0.0; // next step - n_measurement_3 += 1; + n_measurement[SR] += 1; break; case N_MEASUREMENT_SLOPE: @@ -1358,7 +1359,7 @@ stat_accumulate(&stat_math1, Math1); stat_accumulate(&stat_ch3, Ch3); - if (utc - t1 > slope_time_3) { + if (utc - t1 > slope_time[SR]) { // slope measurement f_rep_slope = stat_math1.slope; f_beat_slope = stat_ch3.slope; @@ -1367,11 +1368,11 @@ logmsg("f_beat_slope=%e Hz/s", f_rep_slope); // frep positive step - ad9912_ramp_frequency_w(&ad9912, 0, f0_DDS1 + delta_f_lock_3, FREP_STEP_SIZE); + ad9912_ramp_frequency_w(&ad9912, 0, f0_DDS[0] + delta_f_lock[SR], FREP_STEP_SIZE); SetCtrlVal(MainPanel, PANEL_DDS1, ad9912.frequency[0]); // adjust DDS3 to keep beatnote within the bandpass filter - double fDDS4 = f0_DDS4 + Sign1 * Sign3 * N3/N1 * Ndiv * delta_f_lock_3; + double fDDS4 = f0_DDS[3] + Sign1 * Sign3 * N3/N1 * Ndiv * delta_f_lock[SR]; ad9912_set_frequency_w(&ad9912, 3, fDDS4); SetCtrlVal(MainPanel, PANEL_DDS4, ad9912.frequency[3]); @@ -1379,7 +1380,7 @@ settling = 3; // next step - n_measurement_3 += 1; + n_measurement[SR] += 1; } break; @@ -1399,7 +1400,7 @@ settling = 3; // next step - n_measurement_3 += 1; + n_measurement[SR] += 1; break; case N_MEASUREMENT_FREP_PLUS: @@ -1415,17 +1416,17 @@ f_beat_plus += Ch3 - f_beat_slope * (utc - t2); nobs += 1; - if (utc - t2 > integration_time_3) { + if (utc - t2 > integration_time[SR]) { f_rep_plus = f_rep_plus / nobs; f_beat_plus = f_beat_plus / nobs; nobs = 0; // frep negative step - ad9912_ramp_frequency_w(&ad9912, 0, f0_DDS1 - delta_f_lock_3, FREP_STEP_SIZE); + ad9912_ramp_frequency_w(&ad9912, 0, f0_DDS[0] - delta_f_lock[SR], FREP_STEP_SIZE); SetCtrlVal(MainPanel, PANEL_DDS1, ad9912.frequency[0]); // adjust DDS3 to keep beatnote within the bandpass filter - double fDDS4 = f0_DDS4 - Sign1 * Sign3 * N3/N1 * Ndiv * delta_f_lock_3; + double fDDS4 = f0_DDS[3] - Sign1 * Sign3 * N3/N1 * Ndiv * delta_f_lock[SR]; ad9912_set_frequency_w(&ad9912, 3, fDDS4); SetCtrlVal(MainPanel, PANEL_DDS4, ad9912.frequency[3]); @@ -1433,7 +1434,7 @@ settling = 3; // next step - n_measurement_3 += 1; + n_measurement[SR] += 1; } break; @@ -1450,21 +1451,21 @@ f_beat_minus += Ch3 - f_beat_slope * (utc - t2); nobs += 1; - if (utc - t3 > integration_time_3) { + if (utc - t3 > integration_time[SR]) { f_rep_minus = f_rep_minus / nobs; f_beat_minus = f_beat_minus / nobs; nobs = 0; // check delta frep double delta_f_rep_m = f_rep_minus - f_rep_plus; - double delta_f_rep = Sign1 * Ndiv * 2.0 * delta_f_lock_3 / N1; + double delta_f_rep = Sign1 * Ndiv * 2.0 * delta_f_lock[SR] / N1; double delta = delta_f_rep_m - delta_f_rep; logmsg("delta frep: measured=%e expected=%e difference=%e rel=%e", delta_f_rep_m, delta_f_rep, delta, delta / delta_f_rep); // compute N3 - double delta_f_beat = f_beat_minus - f_beat_plus + 2.0 * Sign1 * Sign3 * N3/N1 * Ndiv * delta_f_lock_3; + double delta_f_beat = f_beat_minus - f_beat_plus + 2.0 * Sign1 * Sign3 * N3/N1 * Ndiv * delta_f_lock[SR]; double delta_f_beat_expected = delta_f_rep * N3; logmsg("delta fbeat: measured=%e expected=%e difference=%e", @@ -1476,15 +1477,15 @@ logmsg("measured N3=%.3f", measured); // back to nominal frep - ad9912_ramp_frequency_w(&ad9912, 0, f0_DDS1, FREP_STEP_SIZE); - ad9912_set_frequency_w(&ad9912, 1, f0_DDS2); - ad9912_set_frequency_w(&ad9912, 3, f0_DDS4); + ad9912_ramp_frequency_w(&ad9912, 0, f0_DDS[0], FREP_STEP_SIZE); + ad9912_set_frequency_w(&ad9912, 1, f0_DDS[1]); + ad9912_set_frequency_w(&ad9912, 3, f0_DDS[3]); SetCtrlVal(MainPanel, PANEL_DDS1, ad9912.frequency[0]); SetCtrlVal(MainPanel, PANEL_DDS2, ad9912.frequency[1]); SetCtrlVal(MainPanel, PANEL_DDS4, ad9912.frequency[3]); // done - n_measurement_3 = N_MEASUREMENT_NONE; + n_measurement[SR] = N_MEASUREMENT_NONE; } break; } @@ -1516,7 +1517,7 @@ } // back to original repetition rate - ad9912_set_frequency_w(&ad9912, 0, beatsign.f0_DDS1); + ad9912_set_frequency_w(&ad9912, 0, beatsign.f0_DDS); SetCtrlVal(MainPanel, PANEL_DDS1, ad9912.frequency[0]); // measurement done @@ -1769,9 +1770,9 @@ if (! visible) { SetPanelAttribute(CalcNPanel, ATTR_CALLBACK_DATA, INT_TO_PTR(LO)); SetPanelAttribute(CalcNPanel, ATTR_TITLE, "Measure N_Lo"); - SetCtrlVal(CalcNPanel, CALCN_INTEGRATIONTIME, integration_time_1); - SetCtrlVal(CalcNPanel, CALCN_SLOPETIME, slope_time_1); - SetCtrlVal(CalcNPanel, CALCN_DELTAFREQ, delta_f_lock_1 / 1000.0); + SetCtrlVal(CalcNPanel, CALCN_INTEGRATIONTIME, integration_time[LO]); + SetCtrlVal(CalcNPanel, CALCN_SLOPETIME, slope_time[LO]); + SetCtrlVal(CalcNPanel, CALCN_DELTAFREQ, delta_f_lock[LO] / 1000.0); SetCtrlVal(CalcNPanel, CALCN_N, 0.0); DisplayPanel(CalcNPanel); } @@ -1781,9 +1782,9 @@ if (! visible) { SetPanelAttribute(CalcNPanel, ATTR_CALLBACK_DATA, INT_TO_PTR(HG)); SetPanelAttribute(CalcNPanel, ATTR_TITLE, "Measure N_Hg"); - SetCtrlVal(CalcNPanel, CALCN_INTEGRATIONTIME, integration_time_2); - SetCtrlVal(CalcNPanel, CALCN_SLOPETIME, slope_time_2); - SetCtrlVal(CalcNPanel, CALCN_DELTAFREQ, delta_f_lock_2 / 1000.0); + SetCtrlVal(CalcNPanel, CALCN_INTEGRATIONTIME, integration_time[HG]); + SetCtrlVal(CalcNPanel, CALCN_SLOPETIME, slope_time[HG]); + SetCtrlVal(CalcNPanel, CALCN_DELTAFREQ, delta_f_lock[HG] / 1000.0); SetCtrlVal(CalcNPanel, CALCN_N, 0.0); DisplayPanel(CalcNPanel); } @@ -1793,9 +1794,9 @@ if (! visible) { SetPanelAttribute(CalcNPanel, ATTR_CALLBACK_DATA, INT_TO_PTR(SR)); SetPanelAttribute(CalcNPanel, ATTR_TITLE, "Measure N_Sr"); - SetCtrlVal(CalcNPanel, CALCN_INTEGRATIONTIME, integration_time_3); - SetCtrlVal(CalcNPanel, CALCN_SLOPETIME, slope_time_3); - SetCtrlVal(CalcNPanel, CALCN_DELTAFREQ, delta_f_lock_3 / 1000.0); + SetCtrlVal(CalcNPanel, CALCN_INTEGRATIONTIME, integration_time[SR]); + SetCtrlVal(CalcNPanel, CALCN_SLOPETIME, slope_time[SR]); + SetCtrlVal(CalcNPanel, CALCN_DELTAFREQ, delta_f_lock[SR] / 1000.0); SetCtrlVal(CalcNPanel, CALCN_N, 0.0); DisplayPanel(CalcNPanel); } @@ -1818,28 +1819,28 @@ measuring = PTR_TO_INT(v); switch (measuring) { case LO: - GetCtrlVal(CalcNPanel, CALCN_INTEGRATIONTIME, &integration_time_1); - GetCtrlVal(CalcNPanel, CALCN_SLOPETIME, &slope_time_1); - GetCtrlVal(CalcNPanel, CALCN_DELTAFREQ, &delta_f_lock_1); + GetCtrlVal(CalcNPanel, CALCN_INTEGRATIONTIME, &integration_time[LO]); + GetCtrlVal(CalcNPanel, CALCN_SLOPETIME, &slope_time[LO]); + GetCtrlVal(CalcNPanel, CALCN_DELTAFREQ, &delta_f_lock[LO]); // convert from kHz to Hz - delta_f_lock_1 = delta_f_lock_1 * 1000.0; - n_measurement_1 = TRUE; + delta_f_lock[LO] = delta_f_lock[LO] * 1000.0; + n_measurement[LO] = TRUE; break; case HG: - GetCtrlVal(CalcNPanel, CALCN_INTEGRATIONTIME, &integration_time_2); - GetCtrlVal(CalcNPanel, CALCN_SLOPETIME, &slope_time_2); - GetCtrlVal(CalcNPanel, CALCN_DELTAFREQ, &delta_f_lock_2); + GetCtrlVal(CalcNPanel, CALCN_INTEGRATIONTIME, &integration_time[HG]); + GetCtrlVal(CalcNPanel, CALCN_SLOPETIME, &slope_time[HG]); + GetCtrlVal(CalcNPanel, CALCN_DELTAFREQ, &delta_f_lock[HG]); // convert from kHz to Hz - delta_f_lock_2 = delta_f_lock_2 * 1000.0; - n_measurement_2 = TRUE; + delta_f_lock[HG] = delta_f_lock[HG] * 1000.0; + n_measurement[HG] = TRUE; break; case SR: - GetCtrlVal(CalcNPanel, CALCN_INTEGRATIONTIME, &integration_time_3); - GetCtrlVal(CalcNPanel, CALCN_SLOPETIME, &slope_time_3); - GetCtrlVal(CalcNPanel, CALCN_DELTAFREQ, &delta_f_lock_3); + GetCtrlVal(CalcNPanel, CALCN_INTEGRATIONTIME, &integration_time[SR]); + GetCtrlVal(CalcNPanel, CALCN_SLOPETIME, &slope_time[SR]); + GetCtrlVal(CalcNPanel, CALCN_DELTAFREQ, &delta_f_lock[SR]); // convert from kHz to Hz - delta_f_lock_3 = delta_f_lock_3 * 1000.0; - n_measurement_3 = TRUE; + delta_f_lock[SR] = delta_f_lock[SR] * 1000.0; + n_measurement[SR] = TRUE; break; } break; @@ -1860,21 +1861,21 @@ measuring = PTR_TO_INT(v); switch (measuring) { case LO: - n_measurement_1 = FALSE; - ad9912_ramp_frequency_w(&ad9912, 0, f0_DDS1, FREP_STEP_SIZE); - ad9912_set_frequency_w(&ad9912, 1, f0_DDS2); + n_measurement[LO] = FALSE; + ad9912_ramp_frequency_w(&ad9912, 0, f0_DDS[0], FREP_STEP_SIZE); + ad9912_set_frequency_w(&ad9912, 1, f0_DDS[1]); break; case HG: - n_measurement_2 = FALSE; - ad9912_ramp_frequency_w(&ad9912, 0, f0_DDS1, FREP_STEP_SIZE); - ad9912_set_frequency_w(&ad9912, 1, f0_DDS2); - ad9912_set_frequency_w(&ad9912, 2, f0_DDS3); + n_measurement[HG] = FALSE; + ad9912_ramp_frequency_w(&ad9912, 0, f0_DDS[0], FREP_STEP_SIZE); + ad9912_set_frequency_w(&ad9912, 1, f0_DDS[1]); + ad9912_set_frequency_w(&ad9912, 2, f0_DDS[2]); break; case SR: - n_measurement_3 = FALSE; - ad9912_ramp_frequency_w(&ad9912, 0, f0_DDS1, FREP_STEP_SIZE); - ad9912_set_frequency_w(&ad9912, 1, f0_DDS2); - ad9912_set_frequency_w(&ad9912, 3, f0_DDS4); + n_measurement[SR] = FALSE; + ad9912_ramp_frequency_w(&ad9912, 0, f0_DDS[0], FREP_STEP_SIZE); + ad9912_set_frequency_w(&ad9912, 1, f0_DDS[1]); + ad9912_set_frequency_w(&ad9912, 3, f0_DDS[3]); break; } @@ -1897,20 +1898,20 @@ { case EVENT_COMMIT: switch (control) { - case PANEL_FINDSIGN1: + case PANEL_FINDSIGN1: beatsign.measure = LO; beatsign.f_beat_zero = 0.0; - step = f_lock_step_1; + step = f_lock_step[LO]; break; case PANEL_FINDSIGN2: beatsign.measure = HG; beatsign.f_beat_zero = Ch2; - step = f_lock_step_2; + step = f_lock_step[HG]; break; case PANEL_FINDSIGN3: beatsign.measure = SR; beatsign.f_beat_zero = Ch3; - step = f_lock_step_3; + step = f_lock_step[SR]; break; } @@ -1918,8 +1919,8 @@ beatsign.f_rep_zero = Math1; // step the repetition rate - beatsign.f0_DDS1 = ad9912.frequency[0]; - ad9912_set_frequency_w(&ad9912, 0, beatsign.f0_DDS1 + step); + beatsign.f0_DDS = ad9912.frequency[0]; + ad9912_set_frequency_w(&ad9912, 0, beatsign.f0_DDS + step); SetCtrlVal(MainPanel, PANEL_DDS1, ad9912.frequency[0]); break; @@ -1964,8 +1965,8 @@ { case EVENT_COMMIT: GetCtrlVal(MainPanel, PANEL_CHANGENDIV, &Ndiv); - f0_DDS1 = 880000000.0 / Ndiv; - ad9912_set_frequency_w(&ad9912, 0, f0_DDS1); + f0_DDS[0] = 880000000.0 / Ndiv; + ad9912_set_frequency_w(&ad9912, 0, f0_DDS[0]); SetCtrlVal(MainPanel, PANEL_DDS1, ad9912.frequency[0]); break; }