# HG changeset patch # User Daniele Nicolodi # Date 1349867566 -7200 # Node ID 1d3cd8260cbbad2de84f2c6e4855a06302ed275f # Parent 6503feae180949b055ae0538808e26af9c487c5a Uniform N3 measurement code to N1 and N2 diff -r 6503feae1809 -r 1d3cd8260cbb FXAnalyse.c --- a/FXAnalyse.c Wed Oct 10 12:27:29 2012 +0200 +++ b/FXAnalyse.c Wed Oct 10 13:12:46 2012 +0200 @@ -53,14 +53,6 @@ double Ndiv = 8.0; enum { - N_MEASUREMENT_STEP_0, - N_MEASUREMENT_STEP_1, - N_MEASUREMENT_STEP_2, - N_MEASUREMENT_STEP_3, - N_MEASUREMENT_STEP_4, -}; - -enum { N_MEASUREMENT_NONE, N_MEASUREMENT_INIT, N_MEASUREMENT_SLOPE, @@ -1053,11 +1045,11 @@ switch (Measuring_3) { - case N_MEASUREMENT_STEP_0: + case N_MEASUREMENT_NONE: // not measuring N3 break; - case N_MEASUREMENT_STEP_1: + case N_MEASUREMENT_INIT: // init SetCtrlVal(MainPanel, PANEL_DDS4, FrequDDS4); @@ -1069,11 +1061,11 @@ // record current DDS3 frequency GetCtrlVal(MainPanel, PANEL_DDS3, &FrequencyDDS3Init); - // step 1 done - Measuring_3 = N_MEASUREMENT_STEP_2; + // next step + Measuring_3 += 1; break; - case N_MEASUREMENT_STEP_2: + case N_MEASUREMENT_SLOPE: // slope measurement if (settling > 0) { @@ -1096,9 +1088,6 @@ Moy_slope_3 = 0.0; Slope_slope_3 = 0.0; - // step 2 done - Measuring_3 = N_MEASUREMENT_STEP_3; - // frep positive step SetCtrlVal(MainPanel, PANEL_DDS4, FrequDDS4 + DeltakHz_3 * 1000); DDS4xAD9912_SetFrequency(&DDS4xAD9912, 4, FrequDDS4 + DeltakHz_3 * 1000); @@ -1106,12 +1095,24 @@ double fDDS3 = FrequencyDDS3Init + N3/N1 * Ndiv * DeltakHz_3 * 1000; SetCtrlVal(MainPanel, PANEL_DDS3, fDDS3); DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, fDDS3); + // allow counter to settle settling = 3; + + // next step + Measuring_3 += 1; } break; + + case N_MEASUREMENT_ADJUST_FREQ_PLUS: + case N_MEASUREMENT_ADJUST_FREQ_MINUS: + // adjust DDS frequency to keep beatnote within the bandpass filter + + // next step + Measuring_3 += 1; + break; - case N_MEASUREMENT_STEP_3: + case N_MEASUREMENT_FREP_PLUS: // frep positive step if (settling > 0) { @@ -1129,9 +1130,6 @@ n_3 = 0; t3_3 = utc; - // step 3 done - Measuring_3 = N_MEASUREMENT_STEP_4; - // frep negative step SetCtrlVal(MainPanel, PANEL_DDS4, FrequDDS4 - DeltakHz_3 * 1000); DDS4xAD9912_SetFrequency(&DDS4xAD9912, 4, FrequDDS4 - DeltakHz_3 * 1000); @@ -1139,13 +1137,17 @@ double fDDS3 = FrequencyDDS3Init - N3/N1 * Ndiv * DeltakHz_3 * 1000; SetCtrlVal(MainPanel, PANEL_DDS3, fDDS3); DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, fDDS3); + // allow counter to settle settling = 3; + + // next step + Measuring_3 += 1; } break; - case N_MEASUREMENT_STEP_4: + case N_MEASUREMENT_FREP_MINUS: // frep negative step if (settling > 0) { @@ -1171,15 +1173,15 @@ Frepminus_3 = 0.0; Frepplus_3 = 0.0; - // step 4 done - Measuring_3 = N_MEASUREMENT_STEP_0; - // back to nominal frep SetCtrlVal(MainPanel, PANEL_DDS4, FrequDDS4); DDS4xAD9912_SetFrequency(&DDS4xAD9912, 4, FrequDDS4); // back to initial DDS3 frequency SetCtrlVal(MainPanel, PANEL_DDS3, FrequencyDDS3Init); DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, FrequencyDDS3Init); + + // done + Measuring_3 = N_MEASUREMENT_NONE; } break; }