comparison FXAnalyse.c @ 115:23f8b7b2b63a

Use DDS1 to change frep in the measurement of N3. Improve some variable names
author Daniele Nicolodi <daniele.nicolodi@obspm.fr>
date Fri, 05 Jul 2013 16:06:26 +0200
parents 77b442322984
children 4f56dbdad85d
comparison
equal deleted inserted replaced
114:77b442322984 115:23f8b7b2b63a
56 DDSParameter DDS1xAD9956; 56 DDSParameter DDS1xAD9956;
57 // 4xAD9912 DDS box 57 // 4xAD9912 DDS box
58 DDS4xAD9912_Data DDS4xAD9912; 58 DDS4xAD9912_Data DDS4xAD9912;
59 59
60 muParserHandle_t MathParser1, MathParser2, MathParser3, MathParser4, MathParser5; 60 muParserHandle_t MathParser1, MathParser2, MathParser3, MathParser4, MathParser5;
61
62
63 61
64 double Ndiv = 8.0; 62 double Ndiv = 8.0;
65 63
66 int settling = 0; 64 int settling = 0;
67 65
86 84
87 int Measuring_1 = N_MEASUREMENT_NONE; 85 int Measuring_1 = N_MEASUREMENT_NONE;
88 int Measuring_2 = N_MEASUREMENT_NONE; 86 int Measuring_2 = N_MEASUREMENT_NONE;
89 int Measuring_3 = N_MEASUREMENT_NONE; 87 int Measuring_3 = N_MEASUREMENT_NONE;
90 88
91 double FrequDDS1=110000000.0, FrequDDS4=110000000.0; 89 double FrequDDS1=110000000.0;
92 double Slope_1=0.0, Slope_2=0.0, Slope_3=0.0, Beatslope_2=0.0; 90 double Slope_1=0.0, Slope_2=0.0, Slope_3=0.0, Beatslope_2=0.0;
93 double SlopeTime1=40.0, SlopeTime2=40.0, SlopeTime3=40.0; 91 double SlopeTime1=40.0, SlopeTime2=40.0, SlopeTime3=40.0;
94 double Ch4Slope = 0.0; 92 double Ch4Slope = 0.0;
95 93
96 double N_1=0.0, N_2=0.0, N_3=0.0; 94 double N_1=0.0, N_2=0.0, N_3=0.0;
97 double DeltaT_1=20.0, DeltakHz_1=500.0, t1_1=0.0, t2_1=0.0, t3_1=0.0, Frepplus_1=0.0, Frepminus_1=0.0; 95 double DeltaT_1=20.0, DeltakHz_1=500.0, t1_1=0.0, t2_1=0.0, t3_1=0.0, Frepplus_1=0.0, Frepminus_1=0.0;
98 double DeltaT_2=20.0, DeltakHz_2=500.0, t1_2=0.0, t2_2=0.0, t3_2=0.0, Frepplus_2=0.0, Frepminus_2=0.0; 96 double DeltaT_2=20.0, DeltakHz_2=500.0, t1_2=0.0, t2_2=0.0, t3_2=0.0, Frepplus_2=0.0, Frepminus_2=0.0;
99 double DeltaT_3=20.0, DeltakHz_3=500.0, t1_3=0.0, t2_3=0.0, t3_3=0.0, Frepplus_3=0.0, Frepminus_3=0.0; 97 double DeltaT_3=20.0, DeltakHz_3=500.0, t1_3=0.0, t2_3=0.0, t3_3=0.0;
100 98
101 int n_1=0, n_2=0, n_3=0; 99 int n_1=0, n_2=0, n_3=0;
102 100
103 double FrequencyDDSBesInit = 0.0; 101 double FrequencyDDSBesInit = 0.0;
104 double FrequencyDDS3Init = 0.0; 102 double FrequencyDDS3Init = 0.0;
105 103
106 double DeltaDDS3=0.0,Delta10K_Plus=0.0,Delta10K_Minus=0.0; 104 double DeltaDDS3=0.0,Delta10K_Plus=0.0,Delta10K_Minus=0.0;
107 double Nu1=0.0, Nu2= 200000-147000+282143746.557455e6; 105 double Nu1=0.0, Nu2= 200000-147000+282143746.557455e6;
108 106
107 double f_rep_plus, f_rep_minus;
109 double f_beat_Sr_plus, f_beat_Sr_minus; 108 double f_beat_Sr_plus, f_beat_Sr_minus;
110 109
111 double Step1=800000.0,Step2=800000.0; 110 double Step1=800000.0,Step2=800000.0;
112 111
113 double Ch4Plus=0.0,Ch4Minus=0.0; 112 double Ch4Plus=0.0,Ch4Minus=0.0;
742 Slope_1 = stat_math1.slope; 741 Slope_1 = stat_math1.slope;
743 Ch4Slope = stat_ch4.slope; 742 Ch4Slope = stat_ch4.slope;
744 SetCtrlVal(CalcNPanel, CALCN_SLOPE, Slope_1); 743 SetCtrlVal(CalcNPanel, CALCN_SLOPE, Slope_1);
745 744
746 // frep positive step 745 // frep positive step
747 DDS4xAD9912_RampFrequency(&DDS4xAD9912,1, FrequDDS1, FrequDDS1 + DeltakHz_1 * 1000.0, FREP_STEP_SIZE); 746 DDS4xAD9912_RampFrequency(&DDS4xAD9912, 1, FrequDDS1, FrequDDS1 + DeltakHz_1 * 1000.0, FREP_STEP_SIZE);
748 SetCtrlVal(MainPanel, PANEL_DDS1, FrequDDS1 + DeltakHz_1 * 1000.0); 747 SetCtrlVal(MainPanel, PANEL_DDS1, FrequDDS1 + DeltakHz_1 * 1000.0);
749 748
750 // allow counter to settle 749 // allow counter to settle
751 settling = 3; 750 settling = 3;
752 751
1029 break; 1028 break;
1030 1029
1031 case N_MEASUREMENT_INIT: 1030 case N_MEASUREMENT_INIT:
1032 // init 1031 // init
1033 1032
1034 SetCtrlVal(MainPanel, PANEL_DDS4, FrequDDS4); 1033 SetCtrlVal(MainPanel, 1, FrequDDS1);
1035 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 4, FrequDDS4); 1034 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, FrequDDS1);
1036 settling = 3; 1035 settling = 3;
1037 1036
1038 t1_3 = utc; 1037 t1_3 = utc;
1039 stat_zero(&stat_ch2); 1038 stat_zero(&stat_ch2);
1040 stat_zero(&stat_ch3); 1039 stat_zero(&stat_ch3);
1041 f_beat_Sr_plus = 0.0; 1040 f_rep_plus = f_rep_minus = 0.0;
1042 f_beat_Sr_minus = 0.0; 1041 f_beat_Sr_plus = f_beat_Sr_minus = 0.0;
1043 1042
1044 // record current DDS3 frequency 1043 // record current DDS3 frequency
1045 GetCtrlVal(MainPanel, PANEL_DDS3, &FrequencyDDS3Init); 1044 GetCtrlVal(MainPanel, PANEL_DDS3, &FrequencyDDS3Init);
1046 1045
1047 // next step 1046 // next step
1066 t2_3 = utc; 1065 t2_3 = utc;
1067 stat_zero(&stat_ch2); 1066 stat_zero(&stat_ch2);
1068 stat_zero(&stat_ch3); 1067 stat_zero(&stat_ch3);
1069 1068
1070 // frep positive step 1069 // frep positive step
1071 SetCtrlVal(MainPanel, PANEL_DDS4, FrequDDS4 + DeltakHz_3 * 1000); 1070 SetCtrlVal(MainPanel, PANEL_DDS1, FrequDDS1 + DeltakHz_3 * 1000);
1072 DDS4xAD9912_RampFrequency(&DDS4xAD9912, 4, FrequDDS4, FrequDDS4 + DeltakHz_3 * 1000, FREP_STEP_SIZE); 1071 DDS4xAD9912_RampFrequency(&DDS4xAD9912, 1, FrequDDS1, FrequDDS1 + DeltakHz_3 * 1000, FREP_STEP_SIZE);
1073 // compensate with DDS3 to keep measured beatnote in counter box range 1072 // compensate with DDS3 to keep measured beatnote in counter box range
1074 double fDDS3 = FrequencyDDS3Init + Signe1 * Signe3 * N3/N1 * Ndiv * DeltakHz_3 * 1000; 1073 double fDDS3 = FrequencyDDS3Init + Signe1 * Signe3 * N3/N1 * Ndiv * DeltakHz_3 * 1000;
1075 SetCtrlVal(MainPanel, PANEL_DDS3, fDDS3); 1074 SetCtrlVal(MainPanel, PANEL_DDS3, fDDS3);
1076 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, fDDS3); 1075 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, fDDS3);
1077 1076
1111 settling--; 1110 settling--;
1112 break; 1111 break;
1113 } 1112 }
1114 1113
1115 n_3++; 1114 n_3++;
1116 Frepplus_3 += Math1 + 250000000 - Slope_3 * (utc - t3_2); 1115 f_rep_plus += Math1 + 250000000 - Slope_3 * (utc - t3_2);
1117 f_beat_Sr_plus += Ch3; 1116 f_beat_Sr_plus += Ch3;
1118 1117
1119 if (utc - t2_3 > DeltaT_3) { 1118 if (utc - t2_3 > DeltaT_3) {
1120 // positive step measurement 1119 // positive step measurement
1121 Frepplus_3 = Frepplus_3 / n_3; 1120 f_rep_plus = f_rep_plus / n_3;
1122 f_beat_Sr_plus = f_beat_Sr_plus / n_3; 1121 f_beat_Sr_plus = f_beat_Sr_plus / n_3;
1123 1122
1124 n_3 = 0; 1123 n_3 = 0;
1125 t3_3 = utc; 1124 t3_3 = utc;
1126 1125
1127 // frep negative step 1126 // frep negative step
1128 SetCtrlVal(MainPanel, PANEL_DDS4, FrequDDS4 - DeltakHz_3 * 1000); 1127 SetCtrlVal(MainPanel, PANEL_DDS1, FrequDDS1 - DeltakHz_3 * 1000);
1129 DDS4xAD9912_RampFrequency(&DDS4xAD9912, 4, FrequDDS4 + DeltakHz_3 * 1000, FrequDDS4 - DeltakHz_3 * 1000, FREP_STEP_SIZE); 1128 DDS4xAD9912_RampFrequency(&DDS4xAD9912, 1, FrequDDS1 + DeltakHz_3 * 1000, FrequDDS1 - DeltakHz_3 * 1000, FREP_STEP_SIZE);
1130 // compensate with DDS3 to keep measured beatnote in counter box range 1129 // compensate with DDS3 to keep measured beatnote in counter box range
1131 double fDDS3 = FrequencyDDS3Init - Signe1 * Signe3 * N3/N1 * Ndiv * DeltakHz_3 * 1000; 1130 double fDDS3 = FrequencyDDS3Init - Signe1 * Signe3 * N3/N1 * Ndiv * DeltakHz_3 * 1000;
1132 SetCtrlVal(MainPanel, PANEL_DDS3, fDDS3); 1131 SetCtrlVal(MainPanel, PANEL_DDS3, fDDS3);
1133 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, fDDS3); 1132 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, fDDS3);
1134 1133
1148 settling--; 1147 settling--;
1149 break; 1148 break;
1150 } 1149 }
1151 1150
1152 n_3++; 1151 n_3++;
1153 Frepminus_3 += Ch2 - Slope_3 * (utc - t3_3); 1152 f_rep_minus += Ch2 - Slope_3 * (utc - t3_3);
1154 f_beat_Sr_minus += Ch3; 1153 f_beat_Sr_minus += Ch3;
1155 1154
1156 if (utc - t3_3 > DeltaT_3) { 1155 if (utc - t3_3 > DeltaT_3) {
1157 // negative step measurement 1156 // negative step measurement
1158 Frepminus_3 = Frepminus_3 / n_3; 1157 f_rep_minus = f_rep_minus / n_3;
1159 f_beat_Sr_minus = f_beat_Sr_plus / n_3; 1158 f_beat_Sr_minus = f_beat_Sr_plus / n_3;
1160 1159
1161 // check delta frep 1160 // check delta frep
1162 double delta_f_rep = Frepplus_3 - Frepplus_3; 1161 double delta_f_rep = f_rep_plus - f_rep_minus;
1163 double expected = N1 / Ndiv * 2.0 * DeltakHz_3 * 1000.0; 1162 double expected = N1 / Ndiv * 2.0 * DeltakHz_3 * 1000.0;
1164 logmsg("delta frep=%g expected=%g", delta_f_rep, expected); 1163 logmsg("delta frep=%g Hz expected=%g Hz", delta_f_rep, expected);
1165 1164
1166 // compute N3 1165 // compute N3
1167 double delta_f_beat_Sr = f_beat_Sr_plus - f_beat_Sr_minus + 2.0 * N3/N1 * Ndiv * DeltakHz_3 * 1000; 1166 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); 1167 logmsg("delta fbeat=%g", delta_f_beat_Sr);
1169 N_3 = delta_f_beat_Sr / delta_f_rep; 1168 N_3 = delta_f_beat_Sr / delta_f_rep;
1171 1170
1172 t1_3=0.0; 1171 t1_3=0.0;
1173 t2_3=0.0; 1172 t2_3=0.0;
1174 t3_3=0.0; 1173 t3_3=0.0;
1175 n_3 = 0; 1174 n_3 = 0;
1176 Frepminus_3 = 0.0;
1177 Frepplus_3 = 0.0;
1178 1175
1179 // back to nominal frep 1176 // back to nominal frep
1180 SetCtrlVal(MainPanel, PANEL_DDS4, FrequDDS4); 1177 SetCtrlVal(MainPanel, PANEL_DDS1, FrequDDS1);
1181 DDS4xAD9912_RampFrequency(&DDS4xAD9912, 4, FrequDDS4 - DeltakHz_3 * 1000, FrequDDS4, FREP_STEP_SIZE); 1178 DDS4xAD9912_RampFrequency(&DDS4xAD9912, 1, FrequDDS1 - DeltakHz_3 * 1000, FrequDDS1, FREP_STEP_SIZE);
1182 // back to initial DDS3 frequency 1179 // back to initial DDS3 frequency
1183 SetCtrlVal(MainPanel, PANEL_DDS3, FrequencyDDS3Init); 1180 SetCtrlVal(MainPanel, PANEL_DDS3, FrequencyDDS3Init);
1184 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, FrequencyDDS3Init); 1181 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, FrequencyDDS3Init);
1185 // adjust DDS frequency to keep 55 MHz tracker oscillator locked 1182 // adjust DDS frequency to keep 55 MHz tracker oscillator locked
1186 double fDDS2 = DDS4xAD9912.Frequency2 + 275000 - Ch4; 1183 double fDDS2 = DDS4xAD9912.Frequency2 + 275000 - Ch4;