comparison FXAnalyse.c @ 217:fefe921a9784

Use DDS4 for shifting Sr beatnote frequency to 10 kHz
author Daniele Nicolodi <daniele.nicolodi@obspm.fr>
date Tue, 15 Apr 2014 13:35:07 +0200
parents 72fafb670eaf
children 28a4ff70fe48
comparison
equal deleted inserted replaced
216:72fafb670eaf 217:fefe921a9784
246 int Measuring_3 = N_MEASUREMENT_NONE; 246 int Measuring_3 = N_MEASUREMENT_NONE;
247 247
248 int nobs = 0; 248 int nobs = 0;
249 int settling = 0; 249 int settling = 0;
250 250
251 double f0_DDS1 = 110000000.0, f0_DDS2, f0_DDS3, df_DDS3; 251 double f0_DDS1 = 110000000.0, f0_DDS2, f0_DDS3, f0_DDS4, df_DDS3;
252 252
253 double SlopeTime1 = 40.0, DeltaT_1 = 40.0, delta_f_lock_1 = 500e3; 253 double SlopeTime1 = 40.0, DeltaT_1 = 40.0, delta_f_lock_1 = 500e3;
254 double SlopeTime2 = 40.0, DeltaT_2 = 40.0, delta_f_lock_2 = 500e3; 254 double SlopeTime2 = 40.0, DeltaT_2 = 40.0, delta_f_lock_2 = 500e3;
255 double SlopeTime3 = 40.0, DeltaT_3 = 40.0, delta_f_lock_3 = 500e3; 255 double SlopeTime3 = 40.0, DeltaT_3 = 40.0, delta_f_lock_3 = 500e3;
256 256
1050 ad9912_set_frequency_w(&ad9912, 0, f0_DDS1); 1050 ad9912_set_frequency_w(&ad9912, 0, f0_DDS1);
1051 SetCtrlVal(MainPanel, PANEL_DDS1, ad9912.frequency[0]); 1051 SetCtrlVal(MainPanel, PANEL_DDS1, ad9912.frequency[0]);
1052 1052
1053 // record current DDS frequencies 1053 // record current DDS frequencies
1054 f0_DDS2 = ad9912.frequency[1]; 1054 f0_DDS2 = ad9912.frequency[1];
1055 f0_DDS3 = ad9912.frequency[2]; 1055 f0_DDS4 = ad9912.frequency[3];
1056 1056
1057 t1 = utc; 1057 t1 = utc;
1058 t2 = t3 = 0.0; 1058 t2 = t3 = 0.0;
1059 nobs = 0; 1059 nobs = 0;
1060 stat_zero(&stat_math1); 1060 stat_zero(&stat_math1);
1086 // frep positive step 1086 // frep positive step
1087 ad9912_ramp_frequency_w(&ad9912, 0, f0_DDS1 + delta_f_lock_3, FREP_STEP_SIZE); 1087 ad9912_ramp_frequency_w(&ad9912, 0, f0_DDS1 + delta_f_lock_3, FREP_STEP_SIZE);
1088 SetCtrlVal(MainPanel, PANEL_DDS1, ad9912.frequency[0]); 1088 SetCtrlVal(MainPanel, PANEL_DDS1, ad9912.frequency[0]);
1089 1089
1090 // adjust DDS3 to keep beatnote within the bandpass filter 1090 // adjust DDS3 to keep beatnote within the bandpass filter
1091 double fDDS3 = f0_DDS3 + Sign1 * Sign3 * N3/N1 * Ndiv * delta_f_lock_3; 1091 double fDDS4 = f0_DDS4 + Sign1 * Sign3 * N3/N1 * Ndiv * delta_f_lock_3;
1092 ad9912_set_frequency_w(&ad9912, 2, fDDS3); 1092 ad9912_set_frequency_w(&ad9912, 3, fDDS4);
1093 SetCtrlVal(MainPanel, PANEL_DDS3, ad9912.frequency[2]); 1093 SetCtrlVal(MainPanel, PANEL_DDS4, ad9912.frequency[3]);
1094 1094
1095 // allow counter to settle 1095 // allow counter to settle
1096 settling = 3; 1096 settling = 3;
1097 1097
1098 // next step 1098 // next step
1140 // frep negative step 1140 // frep negative step
1141 ad9912_ramp_frequency_w(&ad9912, 0, f0_DDS1 - delta_f_lock_3, FREP_STEP_SIZE); 1141 ad9912_ramp_frequency_w(&ad9912, 0, f0_DDS1 - delta_f_lock_3, FREP_STEP_SIZE);
1142 SetCtrlVal(MainPanel, PANEL_DDS1, ad9912.frequency[0]); 1142 SetCtrlVal(MainPanel, PANEL_DDS1, ad9912.frequency[0]);
1143 1143
1144 // adjust DDS3 to keep beatnote within the bandpass filter 1144 // adjust DDS3 to keep beatnote within the bandpass filter
1145 double fDDS3 = f0_DDS3 - Sign1 * Sign3 * N3/N1 * Ndiv * delta_f_lock_3; 1145 double fDDS4 = f0_DDS4 - Sign1 * Sign3 * N3/N1 * Ndiv * delta_f_lock_3;
1146 ad9912_set_frequency_w(&ad9912, 2, fDDS3); 1146 ad9912_set_frequency_w(&ad9912, 3, fDDS4);
1147 SetCtrlVal(MainPanel, PANEL_DDS3, ad9912.frequency[2]); 1147 SetCtrlVal(MainPanel, PANEL_DDS4, ad9912.frequency[3]);
1148 1148
1149 // allow counter to settle 1149 // allow counter to settle
1150 settling = 3; 1150 settling = 3;
1151 1151
1152 // next step 1152 // next step
1193 logmsg("measured N3=%.3f", N_measured); 1193 logmsg("measured N3=%.3f", N_measured);
1194 1194
1195 // back to nominal frep 1195 // back to nominal frep
1196 ad9912_ramp_frequency_w(&ad9912, 0, f0_DDS1, FREP_STEP_SIZE); 1196 ad9912_ramp_frequency_w(&ad9912, 0, f0_DDS1, FREP_STEP_SIZE);
1197 ad9912_set_frequency_w(&ad9912, 1, f0_DDS2); 1197 ad9912_set_frequency_w(&ad9912, 1, f0_DDS2);
1198 ad9912_set_frequency_w(&ad9912, 2, f0_DDS3); 1198 ad9912_set_frequency_w(&ad9912, 3, f0_DDS4);
1199 SetCtrlVal(MainPanel, PANEL_DDS1, ad9912.frequency[0]); 1199 SetCtrlVal(MainPanel, PANEL_DDS1, ad9912.frequency[0]);
1200 SetCtrlVal(MainPanel, PANEL_DDS2, ad9912.frequency[1]); 1200 SetCtrlVal(MainPanel, PANEL_DDS2, ad9912.frequency[1]);
1201 SetCtrlVal(MainPanel, PANEL_DDS3, ad9912.frequency[2]); 1201 SetCtrlVal(MainPanel, PANEL_DDS4, ad9912.frequency[3]);
1202 1202
1203 // done 1203 // done
1204 Measuring_3 = N_MEASUREMENT_NONE; 1204 Measuring_3 = N_MEASUREMENT_NONE;
1205 } 1205 }
1206 break; 1206 break;
1241 if (utc > tbegin3+2){ 1241 if (utc > tbegin3+2){
1242 if (Ch3 > Frepbefore3) 1242 if (Ch3 > Frepbefore3)
1243 Sign3 = -1.0; 1243 Sign3 = -1.0;
1244 else 1244 else
1245 Sign3 = +1.0; 1245 Sign3 = +1.0;
1246 ad9912_set_frequency_w(&ad9912, 3, Frequency3); 1246 ad9912_set_frequency_w(&ad9912, 0, Frequency3);
1247 Getsign3 = FALSE; 1247 Getsign3 = FALSE;
1248 SetCtrlVal(MainPanel, PANEL_SIGN3, Sign3); 1248 SetCtrlVal(MainPanel, PANEL_SIGN3, Sign3);
1249 } 1249 }
1250 } 1250 }
1251 1251
1340 SetCtrlVal(MainPanel, PANEL_DDS3, ad9912.frequency[2]); 1340 SetCtrlVal(MainPanel, PANEL_DDS3, ad9912.frequency[2]);
1341 logmsg("recenter Hg beatnote (ch2) to 10 kHz: DDS3 adjustment=%+3e", adj); 1341 logmsg("recenter Hg beatnote (ch2) to 10 kHz: DDS3 adjustment=%+3e", adj);
1342 } 1342 }
1343 1343
1344 if (recenter.sr) { 1344 if (recenter.sr) {
1345 // adjust DDS3 frequency to keep Ch3 reading at 10 kHz 1345 // adjust DDS4 frequency to keep Ch3 reading at 10 kHz
1346 double freq = ad9912.frequency[2]; 1346 double freq = ad9912.frequency[3];
1347 double adj = 10000 - rollmean_ch3.mean; 1347 double adj = 10000 - rollmean_ch3.mean;
1348 freq = freq + adj; 1348 freq = freq + adj;
1349 ad9912_set_frequency_w(&ad9912, 2, freq); 1349 ad9912_set_frequency_w(&ad9912, 3, freq);
1350 SetCtrlVal(MainPanel, PANEL_DDS3, ad9912.frequency[2]); 1350 SetCtrlVal(MainPanel, PANEL_DDS4, ad9912.frequency[3]);
1351 logmsg("recenter Sr beatnote (ch3) to 10 kHz: DDS3 adjustment=%+3e", adj); 1351 logmsg("recenter Sr beatnote (ch3) to 10 kHz: DDS4 adjustment=%+3e", adj);
1352 } 1352 }
1353 1353
1354 recenter.t0 = utc; 1354 recenter.t0 = utc;
1355 rollmean_zero(&rollmean_ch2); 1355 rollmean_zero(&rollmean_ch2);
1356 rollmean_zero(&rollmean_ch3); 1356 rollmean_zero(&rollmean_ch3);
1673 break; 1673 break;
1674 case SR: 1674 case SR:
1675 Measuring_3 = FALSE; 1675 Measuring_3 = FALSE;
1676 ad9912_ramp_frequency_w(&ad9912, 0, f0_DDS1, FREP_STEP_SIZE); 1676 ad9912_ramp_frequency_w(&ad9912, 0, f0_DDS1, FREP_STEP_SIZE);
1677 ad9912_set_frequency_w(&ad9912, 1, f0_DDS2); 1677 ad9912_set_frequency_w(&ad9912, 1, f0_DDS2);
1678 ad9912_set_frequency_w(&ad9912, 2, f0_DDS3); 1678 ad9912_set_frequency_w(&ad9912, 3, f0_DDS4);
1679 break; 1679 break;
1680 } 1680 }
1681 1681
1682 // update DDS frequencies display 1682 // update DDS frequencies display
1683 SetCtrlVal(MainPanel, PANEL_DDS1, ad9912.frequency[0]); 1683 SetCtrlVal(MainPanel, PANEL_DDS1, ad9912.frequency[0]);
1727 break; 1727 break;
1728 } 1728 }
1729 return 0; 1729 return 0;
1730 } 1730 }
1731 1731
1732 int CVICALLBACK CB_OnFind275K (int panel, int control, int event, 1732 int CVICALLBACK CB_AdjustDDSFreq (int panel, int control, int event,
1733 void *callbackData, int eventData1, int eventData2) 1733 void *callbackData, int eventData1, int eventData2)
1734 { 1734 {
1735 double frequency; 1735 double frequency;
1736 switch (event) 1736 switch (event)
1737 { 1737 {
1738 case EVENT_COMMIT: 1738 case EVENT_COMMIT:
1739 switch (control) 1739 switch (control)
1740 { 1740 {
1741 case PANEL_FIND275K2: 1741 case PANEL_ADJUST_DDS2:
1742 frequency = ad9912.frequency[1] + 275000 - Ch4; 1742 frequency = ad9912.frequency[1] + 275000 - Ch4;
1743 ad9912_set_frequency_w(&ad9912, 1, frequency); 1743 ad9912_set_frequency_w(&ad9912, 1, frequency);
1744 SetCtrlVal(MainPanel, PANEL_DDS2, ad9912.frequency[1]); 1744 SetCtrlVal(MainPanel, PANEL_DDS2, ad9912.frequency[1]);
1745 break; 1745 break;
1746 case PANEL_FIND10K3: 1746 case PANEL_ADJUST_DDS3:
1747 frequency = ad9912.frequency[2] + 10000 - Ch2; 1747 frequency = ad9912.frequency[2] + 10000 - Ch2;
1748 ad9912_set_frequency_w(&ad9912, 2, frequency); 1748 ad9912_set_frequency_w(&ad9912, 2, frequency);
1749 SetCtrlVal(MainPanel, PANEL_DDS3, ad9912.frequency[2]); 1749 SetCtrlVal(MainPanel, PANEL_DDS3, ad9912.frequency[2]);
1750 break;
1751 case PANEL_ADJUST_DDS4:
1752 frequency = ad9912.frequency[3] + 10000 - Ch3;
1753 ad9912_set_frequency_w(&ad9912, 3, frequency);
1754 SetCtrlVal(MainPanel, PANEL_DDS4, ad9912.frequency[3]);
1750 break; 1755 break;
1751 } 1756 }
1752 break; 1757 break;
1753 } 1758 }
1754 return 0; 1759 return 0;
2156 GetCtrlVal(panel, control, &datalogger.enabled); 2161 GetCtrlVal(panel, control, &datalogger.enabled);
2157 break; 2162 break;
2158 } 2163 }
2159 return 0; 2164 return 0;
2160 } 2165 }
2166
2161 int CVICALLBACK CB_DedriftDDSFreq (int panel, int control, int event, 2167 int CVICALLBACK CB_DedriftDDSFreq (int panel, int control, int event,
2162 void *callbackData, int eventData1, int eventData2) 2168 void *callbackData, int eventData1, int eventData2)
2163 { 2169 {
2164 switch (event) 2170 switch (event)
2165 { 2171 {