comparison FXAnalyse.c @ 162:1517a56163de

Cleanup
author Daniele Nicolodi <daniele.nicolodi@obspm.fr>
date Mon, 10 Feb 2014 14:44:41 +0100
parents 6ee23cb3d6bb
children 211ea3950310
comparison
equal deleted inserted replaced
161:6ee23cb3d6bb 162:1517a56163de
184 double Ndiv = 8.0; 184 double Ndiv = 8.0;
185 185
186 int nobs = 0; 186 int nobs = 0;
187 int settling = 0; 187 int settling = 0;
188 188
189 double f0_DDS1 = 110000000.0, f0_DDS2, f0_DDS3; 189 double f0_DDS1 = 110000000.0, f0_DDS2, f0_DDS3, df_DDS3;
190 190
191 double N_1=0.0, N_2=0.0, N_3=0.0;
192 double SlopeTime1=40.0, DeltaT_1=20.0, delta_f_lock_1=500.0; 191 double SlopeTime1=40.0, DeltaT_1=20.0, delta_f_lock_1=500.0;
193 double SlopeTime2=40.0, DeltaT_2=20.0, delta_f_lock_2=500.0; 192 double SlopeTime2=40.0, DeltaT_2=20.0, delta_f_lock_2=500.0;
194 double SlopeTime3=40.0, DeltaT_3=20.0, delta_f_lock_3=500.0; 193 double SlopeTime3=40.0, DeltaT_3=20.0, delta_f_lock_3=500.0;
195
196 double DeltaDDS3=0.0;
197 194
198 double t1, t2, t3; 195 double t1, t2, t3;
199 double f_rep_slope, f_beat_slope; 196 double f_rep_slope, f_beat_slope;
200 double f_rep_plus, f_rep_minus; 197 double f_rep_plus, f_rep_minus;
201 double f_beat_plus, f_beat_minus; 198 double f_beat_plus, f_beat_minus;
199 double N_measured;
202 200
203 double Frequencystep1=10000.0, tbegin1=0.0, Frepbefore1=0.0, Frequency1=0.0; 201 double Frequencystep1=10000.0, tbegin1=0.0, Frepbefore1=0.0, Frequency1=0.0;
204 double Frequencystep2=10.0, tbegin2=0.0, Frepbefore2=0.0, Ch2before=0.0, Frequency2=0.0; 202 double Frequencystep2=10.0, tbegin2=0.0, Frepbefore2=0.0, Ch2before=0.0, Frequency2=0.0;
205 double Frequencystep3=100000.0, tbegin3=0.0, Frepbefore3=0.0, Frequency3=0.0; 203 double Frequencystep3=100000.0, tbegin3=0.0, Frepbefore3=0.0, Frequency3=0.0;
206 204
789 f_rep_minus = f_rep_minus / nobs; 787 f_rep_minus = f_rep_minus / nobs;
790 nobs = 0; 788 nobs = 0;
791 789
792 // compute N1 790 // compute N1
793 double delta_f_rep = f_rep_minus - f_rep_plus; 791 double delta_f_rep = f_rep_minus - f_rep_plus;
794 N_1 = Sign1 * 2 * Ndiv * delta_f_lock_1 / delta_f_rep; 792 N_measured = Sign1 * 2 * Ndiv * delta_f_lock_1 / delta_f_rep;
795 SetCtrlVal(CalcNPanel, CALCN_N, N_1); 793 SetCtrlVal(CalcNPanel, CALCN_N, N_measured);
796 794
797 // back to nominal frep 795 // back to nominal frep
798 DDS4xAD9912_RampFrequency(&DDS4xAD9912, 1, f0_DDS1, FREP_STEP_SIZE); 796 DDS4xAD9912_RampFrequency(&DDS4xAD9912, 1, f0_DDS1, FREP_STEP_SIZE);
799 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 2, f0_DDS2); 797 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 2, f0_DDS2);
800 798
846 double fDDS1 = f0_DDS1 + delta_f_lock_2; 844 double fDDS1 = f0_DDS1 + delta_f_lock_2;
847 DDS4xAD9912_RampFrequency(&DDS4xAD9912,1, fDDS1, FREP_STEP_SIZE); 845 DDS4xAD9912_RampFrequency(&DDS4xAD9912,1, fDDS1, FREP_STEP_SIZE);
848 846
849 // adjust DDS3 to keep beatnote within the bandpass filter. prediction 847 // adjust DDS3 to keep beatnote within the bandpass filter. prediction
850 double fDDS3 = f0_DDS3 + Sign1 * Sign2 * N2/N1 * Ndiv * delta_f_lock_2; 848 double fDDS3 = f0_DDS3 + Sign1 * Sign2 * N2/N1 * Ndiv * delta_f_lock_2;
851 DeltaDDS3 = fDDS3 - DDS4xAD9912_GetFrequency(&DDS4xAD9912, 3); 849 df_DDS3 = fDDS3 - DDS4xAD9912_GetFrequency(&DDS4xAD9912, 3);
852 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, fDDS3); 850 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, fDDS3);
853 851
854 // allow counter to settle 852 // allow counter to settle
855 settling = 3; 853 settling = 3;
856 854
868 866
869 double fDDS2 = DDS4xAD9912_GetFrequency(&DDS4xAD9912, 2) + 275000 - Ch4; 867 double fDDS2 = DDS4xAD9912_GetFrequency(&DDS4xAD9912, 2) + 275000 - Ch4;
870 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 2, fDDS2); 868 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 2, fDDS2);
871 869
872 double fDDS3 = DDS4xAD9912_GetFrequency(&DDS4xAD9912, 3) + 10000 - Ch2; 870 double fDDS3 = DDS4xAD9912_GetFrequency(&DDS4xAD9912, 3) + 10000 - Ch2;
873 DeltaDDS3 = DeltaDDS3 + 10000 - Ch2; 871 df_DDS3 = df_DDS3 + 10000 - Ch2;
874 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, fDDS3); 872 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, fDDS3);
875 873
876 // allow counter to settle 874 // allow counter to settle
877 settling = 3; 875 settling = 3;
878 876
902 double fDDS1 = f0_DDS1 - delta_f_lock_2; 900 double fDDS1 = f0_DDS1 - delta_f_lock_2;
903 DDS4xAD9912_RampFrequency(&DDS4xAD9912, 1, fDDS1, FREP_STEP_SIZE); 901 DDS4xAD9912_RampFrequency(&DDS4xAD9912, 1, fDDS1, FREP_STEP_SIZE);
904 902
905 // adjust DDS3 to keep beatnote within the bandpass filter. prediction 903 // adjust DDS3 to keep beatnote within the bandpass filter. prediction
906 double fDDS3 = f0_DDS3 - Sign1 * Sign2 * N2/N1 * Ndiv * delta_f_lock_2; 904 double fDDS3 = f0_DDS3 - Sign1 * Sign2 * N2/N1 * Ndiv * delta_f_lock_2;
907 DeltaDDS3 = fDDS3 - DDS4xAD9912_GetFrequency(&DDS4xAD9912, 3); 905 df_DDS3 = fDDS3 - DDS4xAD9912_GetFrequency(&DDS4xAD9912, 3);
908 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, fDDS3); 906 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, fDDS3);
909 907
910 // allow counter to settle 908 // allow counter to settle
911 settling = 3; 909 settling = 3;
912 910
938 double delta_f_rep = Sign1 * Ndiv * 2.0 * delta_f_lock_3 / N1; 936 double delta_f_rep = Sign1 * Ndiv * 2.0 * delta_f_lock_3 / N1;
939 937
940 logmsg("delta frep: measured=%e expected=%e difference=%e", 938 logmsg("delta frep: measured=%e expected=%e difference=%e",
941 delta_f_rep_m, delta_f_rep, delta_f_rep_m - delta_f_rep); 939 delta_f_rep_m, delta_f_rep, delta_f_rep_m - delta_f_rep);
942 940
943 N_2 = -Sign2 * (DeltaDDS3 + f_beat_minus - f_beat_plus) / delta_f_rep; 941 N_measured = -Sign2 * (df_DDS3 + f_beat_minus - f_beat_plus) / delta_f_rep;
944 SetCtrlVal(CalcNPanel, CALCN_N, N_2); 942 SetCtrlVal(CalcNPanel, CALCN_N, N_measured);
945 943
946 // back to nominal frequency 944 // back to nominal frequency
947 DDS4xAD9912_RampFrequency(&DDS4xAD9912, 1, f0_DDS1, FREP_STEP_SIZE); 945 DDS4xAD9912_RampFrequency(&DDS4xAD9912, 1, f0_DDS1, FREP_STEP_SIZE);
948 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 2, f0_DDS2); 946 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 2, f0_DDS2);
949 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, f0_DDS3); 947 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, f0_DDS3);
1098 double delta_f_beat_expected = delta_f_rep * N3; 1096 double delta_f_beat_expected = delta_f_rep * N3;
1099 1097
1100 logmsg("delta fbeat: measured=%e expected=%e difference=%e", 1098 logmsg("delta fbeat: measured=%e expected=%e difference=%e",
1101 delta_f_beat, delta_f_beat_expected, delta_f_beat - delta_f_beat_expected); 1099 delta_f_beat, delta_f_beat_expected, delta_f_beat - delta_f_beat_expected);
1102 1100
1103 N_3 = delta_f_beat / delta_f_rep; 1101 N_measured = delta_f_beat / delta_f_rep;
1104 SetCtrlVal(CalcNPanel, CALCN_N, N_3); 1102 SetCtrlVal(CalcNPanel, CALCN_N, N_measured);
1105 1103
1106 logmsg("measured N3=%.3f", N_3); 1104 logmsg("measured N3=%.3f", N_measured);
1107 1105
1108 // back to nominal frep 1106 // back to nominal frep
1109 DDS4xAD9912_RampFrequency(&DDS4xAD9912, 1, f0_DDS1, FREP_STEP_SIZE); 1107 DDS4xAD9912_RampFrequency(&DDS4xAD9912, 1, f0_DDS1, FREP_STEP_SIZE);
1110 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 2, f0_DDS2); 1108 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 2, f0_DDS2);
1111 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, f0_DDS3); 1109 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, f0_DDS3);
1534 switch (event) { 1532 switch (event) {
1535 case EVENT_COMMIT: 1533 case EVENT_COMMIT:
1536 GetPanelAttribute(panel, ATTR_CALLBACK_DATA, &measure); 1534 GetPanelAttribute(panel, ATTR_CALLBACK_DATA, &measure);
1537 switch (measure) { 1535 switch (measure) {
1538 case LO: 1536 case LO:
1539 N1 = round(N_1); 1537 N1 = round(N_measured);
1540 SetCtrlVal(MainPanel, PANEL_N1CHOICE, N1); 1538 SetCtrlVal(MainPanel, PANEL_N1CHOICE, N1);
1541 break; 1539 break;
1542 case HG: 1540 case HG:
1543 N2 = round(N_2); 1541 N2 = round(N_measured);
1544 SetCtrlVal(MainPanel, PANEL_N2CHOICE, N2); 1542 SetCtrlVal(MainPanel, PANEL_N2CHOICE, N2);
1545 break; 1543 break;
1546 case SR: 1544 case SR:
1547 N3 = round(N_3); 1545 N3 = round(N_measured);
1548 SetCtrlVal(MainPanel, PANEL_N3CHOICE, N3); 1546 SetCtrlVal(MainPanel, PANEL_N3CHOICE, N3);
1549 break; 1547 break;
1550 } 1548 }
1551 break; 1549 break;
1552 } 1550 }