diff FXAnalyse.c @ 109:2a9f8a811d87

Fix N3 measurement
author Daniele Nicolodi <daniele.nicolodi@obspm.fr>
date Fri, 28 Jun 2013 14:45:29 +0200
parents 29b1aa89a34c
children 8bdd7e38715f
line wrap: on
line diff
--- a/FXAnalyse.c	Fri Jun 28 14:45:12 2013 +0200
+++ b/FXAnalyse.c	Fri Jun 28 14:45:29 2013 +0200
@@ -16,7 +16,8 @@
 
 #define DATAFOLDER "Z:\\Measures-2013"
 
-#define DEDRIFT_DDS_FREQUENCY 70000000
+#define DEDRIFT_DDS_FREQUENCY 70000000.0
+#define FREP_STEP_SIZE 50000.0
 
 // number of channels read
 #define NCHAN 4
@@ -235,8 +236,9 @@
 	mupDefineVar(parser, "Nu2", &Nu2);
 	mupDefineVar(parser, "DeltaDDS3", &DeltaDDS3);
 	mupDefineVar(parser, "Signe1", &Signe1);
-	mupDefineVar(parser, "Signe2", &Signe2); 
-	mupDefineVar(parser, "Ndiv", &Ndiv); 
+	mupDefineVar(parser, "Signe2", &Signe2);
+	mupDefineVar(parser, "Signe3", &Signe3);
+	mupDefineVar(parser, "Ndiv", &Ndiv);
 	mupDefinePostfixOprt(parser, "P", &Peta,  1);
 	mupDefinePostfixOprt(parser, "T", &Tera,  1);
 	mupDefinePostfixOprt(parser, "G", &Giga,  1);
@@ -740,9 +742,8 @@
 							SetCtrlVal(CalcNPanel, CALCN_SLOPE, Slope_1);
 							
 							// frep positive step
-							DDS4xAD9912_FrequencyRampe(&DDS4xAD9912,1, FrequDDS1,(FrequDDS1+DeltakHz_1*1000), Step1/Ndiv);
-							SetCtrlVal(MainPanel, PANEL_DDS1, (FrequDDS1+DeltakHz_1*1000));
-							DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, (FrequDDS1+DeltakHz_1*1000));
+							DDS4xAD9912_RampFrequency(&DDS4xAD9912,1, FrequDDS1, FrequDDS1 + DeltakHz_1 * 1000.0, FREP_STEP_SIZE);
+							SetCtrlVal(MainPanel, PANEL_DDS1, FrequDDS1 + DeltakHz_1 * 1000.0);
 							
 							// allow counter to settle
 							settling = 3;
@@ -795,9 +796,8 @@
 							n_1 = 0;
 							
 							// frep negative step
-							DDS4xAD9912_FrequencyRampe(&DDS4xAD9912,1, (FrequDDS1+DeltakHz_1*1000),(FrequDDS1-DeltakHz_1*1000), Step1/Ndiv);
-							SetCtrlVal(MainPanel, PANEL_DDS1, (FrequDDS1-DeltakHz_1*1000));  
-							DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, (FrequDDS1-DeltakHz_1*1000));
+							DDS4xAD9912_RampFrequency(&DDS4xAD9912, 1, FrequDDS1 + DeltakHz_1 * 1000.0, FrequDDS1 - DeltakHz_1 * 1000.0, FREP_STEP_SIZE);
+							SetCtrlVal(MainPanel, PANEL_DDS1, FrequDDS1 - DeltakHz_1 * 1000.0);  
 							
 							// allow counter to settle
 							settling = 3;
@@ -838,9 +838,8 @@
 							Frepplus_1 = 0.0;
 							
 							// back to nominal frep
-							DDS4xAD9912_FrequencyRampe(&DDS4xAD9912, 1, FrequDDS1-DeltakHz_1*1000,FrequDDS1, Step1/Ndiv );
+							DDS4xAD9912_RampFrequency(&DDS4xAD9912, 1, FrequDDS1 - DeltakHz_1 * 1000.0, FrequDDS1, FREP_STEP_SIZE);
 							SetCtrlVal(MainPanel, PANEL_DDS1, FrequDDS1);
-							DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, FrequDDS1);
 							SetCtrlVal(MainPanel, PANEL_DDS2, FrequencyDDSBesInit);
 							DDS4xAD9912_SetFrequency(&DDS4xAD9912, 2, FrequencyDDSBesInit);
 							
@@ -890,7 +889,7 @@
 							// frep positive step
 							double fDDS1 = FrequDDS1 + DeltakHz_2 * 1000;
 							printf("fDDS1 = %g\n", fDDS1);
-							DDS4xAD9912_FrequencyRampe(&DDS4xAD9912,1, FrequDDS1, fDDS1, Step2/Ndiv);
+							DDS4xAD9912_RampFrequency(&DDS4xAD9912,1, FrequDDS1, fDDS1, FREP_STEP_SIZE);
 							SetCtrlVal(MainPanel, PANEL_DDS1, fDDS1);
 							DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, fDDS1);
 							
@@ -956,7 +955,7 @@
 
 							// negative frequency step
 							double fDDS1 = FrequDDS1 - DeltakHz_2 * 1000;
-							DDS4xAD9912_FrequencyRampe(&DDS4xAD9912, 1, DDS4xAD9912.Frequency1, fDDS1, Step2/Ndiv);
+							DDS4xAD9912_RampFrequency(&DDS4xAD9912, 1, DDS4xAD9912.Frequency1, fDDS1, FREP_STEP_SIZE);
 							SetCtrlVal(MainPanel, PANEL_DDS1, fDDS1);
 							DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, fDDS1);
 							
@@ -999,7 +998,7 @@
 							SetCtrlVal(CalcNPanel, CALCN_N, N_2);
 							
 							// back to nominal frequency
-							DDS4xAD9912_FrequencyRampe (&DDS4xAD9912, 1, FrequDDS1-DeltakHz_2*1000,FrequDDS1, Step2/Ndiv );
+							DDS4xAD9912_RampFrequency(&DDS4xAD9912, 1, FrequDDS1-DeltakHz_2*1000,FrequDDS1, FREP_STEP_SIZE);
 							SetCtrlVal(MainPanel, PANEL_DDS1, FrequDDS1);
 							DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, FrequDDS1);
 							SetCtrlVal(MainPanel, PANEL_DDS2, FrequencyDDSBesInit);  
@@ -1063,9 +1062,9 @@
 							
 							// frep positive step
 							SetCtrlVal(MainPanel, PANEL_DDS4, FrequDDS4 + DeltakHz_3 * 1000);
-							DDS4xAD9912_SetFrequency(&DDS4xAD9912, 4, FrequDDS4 + DeltakHz_3 * 1000);
+							DDS4xAD9912_RampFrequency(&DDS4xAD9912, 4, FrequDDS4, FrequDDS4 + DeltakHz_3 * 1000, FREP_STEP_SIZE);
 							// compensate with DDS3 to keep measured beatnote in counter box range
-							double fDDS3 = FrequencyDDS3Init + N3/N1 * Ndiv * DeltakHz_3 * 1000;
+							double fDDS3 = FrequencyDDS3Init + Signe1 * Signe3 * N3/N1 * Ndiv * DeltakHz_3 * 1000;
 							SetCtrlVal(MainPanel, PANEL_DDS3, fDDS3);
 							DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, fDDS3);
 							
@@ -1081,6 +1080,19 @@
 					case N_MEASUREMENT_ADJUST_FREQ_MINUS:
 						// adjust DDS frequency to keep beatnote within the bandpass filter
 
+						if (settling > 0) {
+							settling--;
+							break;
+						}
+						
+						// adjust DDS frequency to keep 55 MHz tracker oscillator locked
+						double fDDS2 = DDS4xAD9912.Frequency2 + 275000 - Ch4;
+						SetCtrlVal(MainPanel, PANEL_DDS2, fDDS2);
+						DDS4xAD9912_SetFrequency(&DDS4xAD9912, 2, fDDS2);
+						
+						// allow counter to settle
+						settling = 3;
+						
 						// next step
 						Measuring_3 += 1;
 						break;						
@@ -1105,9 +1117,9 @@
 							
 							// frep negative step
 							SetCtrlVal(MainPanel, PANEL_DDS4, FrequDDS4 - DeltakHz_3 * 1000);
-							DDS4xAD9912_SetFrequency(&DDS4xAD9912, 4, FrequDDS4 - DeltakHz_3 * 1000);
+							DDS4xAD9912_RampFrequency(&DDS4xAD9912, 4, FrequDDS4 + DeltakHz_3 * 1000, FrequDDS4 - DeltakHz_3 * 1000, FREP_STEP_SIZE);
 							// compensate with DDS3 to keep measured beatnote in counter box range
-							double fDDS3 = FrequencyDDS3Init - N3/N1 * Ndiv * DeltakHz_3 * 1000;
+							double fDDS3 = FrequencyDDS3Init - Signe1 * Signe3 * N3/N1 * Ndiv * DeltakHz_3 * 1000;
 							SetCtrlVal(MainPanel, PANEL_DDS3, fDDS3);
 							DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, fDDS3);
 							
@@ -1148,7 +1160,7 @@
 							
 							// back to nominal frep
 							SetCtrlVal(MainPanel, PANEL_DDS4, FrequDDS4);
-							DDS4xAD9912_SetFrequency(&DDS4xAD9912, 4, FrequDDS4);
+							DDS4xAD9912_RampFrequency(&DDS4xAD9912, 4, FrequDDS4 - DeltakHz_3 * 1000, FrequDDS4, FREP_STEP_SIZE);
 							// back to initial DDS3 frequency
 							SetCtrlVal(MainPanel, PANEL_DDS3, FrequencyDDS3Init);
 							DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, FrequencyDDS3Init);
@@ -1332,7 +1344,7 @@
 					writeData4(DATAFOLDER, "Raw", id, timestr, utc, Ch1, Ch2, Ch3, Ch4);
 				}
 				
-				// write LO frequency (Math2) to disk
+				// write Lo frequency (Math2) to disk
 				GetCtrlVal(MainPanel, PANEL_CHECKBOX_MATH2SAVE, &save);
 				if (save) {
 					writeData(DATAFOLDER, "Lo", id, timestr, utc, Math2);
@@ -2218,3 +2230,15 @@
 	}
 	return 0;
 }
+
+int CVICALLBACK CB_Sign3 (int panel, int control, int event,
+		void *callbackData, int eventData1, int eventData2)
+{
+	switch (event)
+	{
+		case EVENT_COMMIT:
+			GetCtrlVal(panel, control, &Signe3);
+			break;
+	}
+	return 0;
+}