Mercurial > hg > fxanalyse
comparison FXAnalyse.c @ 46:6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
author | Daniele Nicolodi <daniele.nicolodi@obspm.fr> |
---|---|
date | Wed, 10 Oct 2012 12:27:29 +0200 |
parents | 2e37910b28bc |
children | 1d3cd8260cbb |
comparison
equal
deleted
inserted
replaced
45:b47b97cfd050 | 46:6503feae1809 |
---|---|
71 }; | 71 }; |
72 | 72 |
73 int settling = 0; | 73 int settling = 0; |
74 | 74 |
75 int Measuring_1 = FALSE; | 75 int Measuring_1 = FALSE; |
76 int Measuring_2 = FALSE, Step1_2 = FALSE, Step2_2 = FALSE, Step3_2 = FALSE; | 76 int Measuring_2 = FALSE; |
77 int Measuring_3 = FALSE; | 77 int Measuring_3 = FALSE; |
78 | 78 |
79 double FrequDDS1=110000000.0, FrequDDS2=15300000.0, FrequDDS3=150400000.0, FrequDDS4=110000000.0; | 79 double FrequDDS1=110000000.0, FrequDDS2=15300000.0, FrequDDS3=150400000.0, FrequDDS4=110000000.0; |
80 double Slope_1=0.0,Slope_2=0.0,Slope_3=0.0,Beatslope_2=0.0; | 80 double Slope_1=0.0,Slope_2=0.0,Slope_3=0.0,Beatslope_2=0.0; |
81 double SlopeTime1=40.0, SlopeTime2=40.0; SlopeTime3=40.0; | 81 double SlopeTime1=40.0, SlopeTime2=40.0; SlopeTime3=40.0; |
91 double Beat_slope_2=0.0 ,Moy_Beatslope_2=0.0,Slope_Beatslope_2=0.0; | 91 double Beat_slope_2=0.0 ,Moy_Beatslope_2=0.0,Slope_Beatslope_2=0.0; |
92 double Ch4_slope=0.0,Moy_Ch4slope_1=0.0,Slope_Ch4slope_1=0.0,Ch4Slope=0.0; | 92 double Ch4_slope=0.0,Moy_Ch4slope_1=0.0,Slope_Ch4slope_1=0.0,Ch4Slope=0.0; |
93 | 93 |
94 double FrequencyDDSBes=0.0,FrequencyDDSBesInit=0.0; | 94 double FrequencyDDSBes=0.0,FrequencyDDSBesInit=0.0; |
95 double FrequencyDDS3=0.0,FrequencyDDS3Init=0.0; | 95 double FrequencyDDS3=0.0,FrequencyDDS3Init=0.0; |
96 double DDSBesChanged1=FALSE,DDSBesChanged2=FALSE; | |
97 | 96 |
98 double DeltaDDS3=0.0,Delta10K_Plus=0.0,Delta10K_Minus=0.0; | 97 double DeltaDDS3=0.0,Delta10K_Plus=0.0,Delta10K_Minus=0.0; |
99 double Nu1=0.0, Nu2= 200000-147000+282143746.557455e6; | 98 double Nu1=0.0, Nu2= 200000-147000+282143746.557455e6; |
100 | 99 |
101 double Step1=800000.0,Step2=800000.0; | 100 double Step1=800000.0,Step2=800000.0; |
102 | 101 |
103 double Ch4Plus=0.0,Ch4Minus=0.0; | 102 double Ch4Plus=0.0,Ch4Minus=0.0; |
104 | |
105 int nDDSChange=0, nstabilization=0; | |
106 | 103 |
107 double Frequencystep1=10000.0, tbegin1=0.0, Frepbefore1=0.0, Frequency1=0.0; | 104 double Frequencystep1=10000.0, tbegin1=0.0, Frepbefore1=0.0, Frequency1=0.0; |
108 double Frequencystep2=10.0, tbegin2=0.0, Frepbefore2=0.0, Ch2before=0.0, Frequency2=0.0; | 105 double Frequencystep2=10.0, tbegin2=0.0, Frepbefore2=0.0, Ch2before=0.0, Frequency2=0.0; |
109 double Frequencystep3=100000.0, tbegin3=0.0, Frepbefore3=0.0, Frequency3=0.0; | 106 double Frequencystep3=100000.0, tbegin3=0.0, Frepbefore3=0.0, Frequency3=0.0; |
110 | 107 |
198 mupDefinePostfixOprt( * pMathParser, "µ", µ, 1); | 195 mupDefinePostfixOprt( * pMathParser, "µ", µ, 1); |
199 mupDefinePostfixOprt( * pMathParser, "n_1", &nano, 1); | 196 mupDefinePostfixOprt( * pMathParser, "n_1", &nano, 1); |
200 mupDefinePostfixOprt( * pMathParser, "p", &pico, 1); | 197 mupDefinePostfixOprt( * pMathParser, "p", &pico, 1); |
201 mupDefinePostfixOprt( * pMathParser, "f", &femto, 1); | 198 mupDefinePostfixOprt( * pMathParser, "f", &femto, 1); |
202 } | 199 } |
200 | |
203 | 201 |
204 int main (int argc, char *argv[]) | 202 int main (int argc, char *argv[]) |
205 { | 203 { |
206 double initfreqDDS ; | 204 double initfreqDDS ; |
207 char * MathString1 = " " ; | 205 char * MathString1 = " " ; |
601 SetCtrlVal(MainPanel, PANEL_FREQ1, Ch1); | 599 SetCtrlVal(MainPanel, PANEL_FREQ1, Ch1); |
602 SetCtrlVal(MainPanel, PANEL_FREQ2, Ch2); | 600 SetCtrlVal(MainPanel, PANEL_FREQ2, Ch2); |
603 SetCtrlVal(MainPanel, PANEL_FREQ3, Ch3); | 601 SetCtrlVal(MainPanel, PANEL_FREQ3, Ch3); |
604 SetCtrlVal(MainPanel, PANEL_FREQ4, Ch4); | 602 SetCtrlVal(MainPanel, PANEL_FREQ4, Ch4); |
605 SetCtrlVal(MainPanel, PANEL_SIGN1, Signe1); | 603 SetCtrlVal(MainPanel, PANEL_SIGN1, Signe1); |
606 SetCtrlVal(MainPanel, PANEL_SIGN2, Signe2); | 604 SetCtrlVal(MainPanel, PANEL_SIGN2, Signe2); |
607 SetCtrlVal(MainPanel, PANEL_SIGN3, Signe3); | 605 SetCtrlVal(MainPanel, PANEL_SIGN3, Signe3); |
608 SetCtrlVal(CalcN2Panel, CALCN2_N, N_2); | 606 SetCtrlVal(MainPanel, PANEL_CENTERFREQUENCY, CenterFrequencyCh2); |
609 SetCtrlVal(CalcN2Panel, CALCN2_SLOPE, Beatslope_2); | 607 SetCtrlVal(MainPanel, PANEL_LED1, SlopeMeasuring); |
610 SetCtrlVal(MainPanel, PANEL_CENTERFREQUENCY, CenterFrequencyCh2); | |
611 SetCtrlVal(MainPanel, PANEL_LED1, SlopeMeasuring); | |
612 SetCtrlVal(MainPanel, PANEL_LED2, OnSlopeCancelling); | 608 SetCtrlVal(MainPanel, PANEL_LED2, OnSlopeCancelling); |
609 | |
613 // Treat data | 610 // Treat data |
614 | 611 |
615 Math1 = mupEval(MathParser1); | 612 Math1 = mupEval(MathParser1); |
616 SetCtrlVal(MainPanel,PANEL_MATH1, Math1); | 613 SetCtrlVal(MainPanel,PANEL_MATH1, Math1); |
617 | 614 |
770 // allow counter to settle | 767 // allow counter to settle |
771 settling = 3; | 768 settling = 3; |
772 | 769 |
773 // next step | 770 // next step |
774 Measuring_1 += 1; | 771 Measuring_1 += 1; |
775 } | 772 } |
776 break; | 773 break; |
777 | 774 |
778 case N_MEASUREMENT_ADJUST_FREQ_PLUS: | 775 case N_MEASUREMENT_ADJUST_FREQ_PLUS: |
779 case N_MEASUREMENT_ADJUST_FREQ_MINUS: | 776 case N_MEASUREMENT_ADJUST_FREQ_MINUS: |
780 // adjust DDS frequency to keep beatnote within the bandpass filter | 777 // adjust DDS frequency to keep beatnote within the bandpass filter |
870 // done | 867 // done |
871 Measuring_1 = N_MEASUREMENT_NONE; | 868 Measuring_1 = N_MEASUREMENT_NONE; |
872 } | 869 } |
873 break; | 870 break; |
874 } | 871 } |
875 | 872 |
876 if (Measuring_2==TRUE) | 873 switch (Measuring_2) { |
877 { | 874 |
878 if (Step1_2==FALSE) { | 875 case N_MEASUREMENT_NONE: |
876 // not measuring | |
877 break; | |
878 | |
879 case N_MEASUREMENT_INIT: | |
880 // initialization step | |
881 | |
882 // set DDS1 to nominal frequency | |
879 SetCtrlVal(MainPanel, PANEL_DDS1, FrequDDS1); | 883 SetCtrlVal(MainPanel, PANEL_DDS1, FrequDDS1); |
880 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, FrequDDS1); | 884 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, FrequDDS1); |
881 | 885 |
882 GetCtrlVal(MainPanel, PANEL_DDS2, &FrequencyDDSBesInit); | 886 GetCtrlVal(MainPanel, PANEL_DDS2, &FrequencyDDSBesInit); |
883 GetCtrlVal(MainPanel, PANEL_DDS3, &FrequencyDDS3Init); | 887 GetCtrlVal(MainPanel, PANEL_DDS3, &FrequencyDDS3Init); |
884 t1_2=utc; | 888 t1_2 = utc; |
885 Frequ_slope_2=Math1; | 889 Frequ_slope_2 = Math1; |
886 Beat_slope_2=Ch2; | 890 Beat_slope_2 = Ch2; |
887 Moy_slope_2= Frequ_slope_2; | 891 Moy_slope_2 = Frequ_slope_2; |
888 Moy_Beatslope_2= Beat_slope_2; | 892 Moy_Beatslope_2 = Beat_slope_2; |
889 N_slope_2=1; | 893 N_slope_2 = 1; |
890 Step1_2=TRUE; | 894 Nu1 = N1 * (250000000 + Math1); |
891 Nu1=(250000000+Math1)*N1; | 895 |
892 } | 896 // next step |
893 else { | 897 Measuring_2 += 1; |
894 if(Step2_2==FALSE){ | 898 break; |
895 N_slope_2=N_slope_2+1; | 899 |
896 Frequ_slope_2=Math1; | 900 case N_MEASUREMENT_SLOPE: |
897 Beat_slope_2=Ch2; | 901 // slope measurement |
898 Moy_slope_2=((N_slope_2-1)*Moy_slope_2 + Frequ_slope_2)/N_slope_2; | 902 |
899 Moy_Beatslope_2=((N_slope_2-1)*Moy_Beatslope_2 + Beat_slope_2)/N_slope_2; | 903 N_slope_2 = N_slope_2 + 1; |
900 Slope_slope_2 = (Slope_slope_2*(N_slope_2-2) + 6*(Frequ_slope_2-Moy_slope_2)/N_slope_2)/(N_slope_2+1); | 904 Frequ_slope_2 = Math1; |
901 Slope_Beatslope_2 = (Slope_Beatslope_2*(N_slope_2-2) + 6*(Beat_slope_2-Moy_Beatslope_2)/N_slope_2)/(N_slope_2+1); | 905 Beat_slope_2 = Ch2; |
902 if (utc-t1_2>SlopeTime2) { | 906 Moy_slope_2 = ((N_slope_2-1)*Moy_slope_2 + Frequ_slope_2)/N_slope_2; |
903 Slope_2 = Slope_slope_2; | 907 Moy_Beatslope_2 = ((N_slope_2-1)*Moy_Beatslope_2 + Beat_slope_2)/N_slope_2; |
904 Beatslope_2 = Slope_Beatslope_2; | 908 Slope_slope_2 = (Slope_slope_2*(N_slope_2-2) + 6*(Frequ_slope_2-Moy_slope_2)/N_slope_2)/(N_slope_2+1); |
905 Step2_2=TRUE; | 909 Slope_Beatslope_2 = (Slope_Beatslope_2*(N_slope_2-2) + 6*(Beat_slope_2-Moy_Beatslope_2)/N_slope_2)/(N_slope_2+1); |
906 N_slope_2=0; | 910 |
907 Frequ_slope_2=0.0; | 911 if ((utc - t1_2) > SlopeTime2) { |
908 Moy_slope_2=0.0; | 912 Slope_2 = Slope_slope_2; |
909 Slope_slope_2 =0.0; | 913 Beatslope_2 = Slope_Beatslope_2; |
910 Moy_Beatslope_2=0.0; | 914 SetCtrlVal(CalcN2Panel, CALCN2_SLOPE, Beatslope_2); |
911 Slope_Beatslope_2 =0.0; | 915 |
912 Beat_slope_2=0.0; | 916 N_slope_2 = 0; |
913 | 917 Frequ_slope_2 = 0.0; |
914 DDS4xAD9912_FrequencyRampe (&DDS4xAD9912,1, FrequDDS1,(FrequDDS1+DeltakHz_2*1000), Step2/Ndiv ); | 918 Moy_slope_2 = 0.0; |
915 SetCtrlVal(MainPanel, PANEL_DDS1, (FrequDDS1+DeltakHz_2*1000)); | 919 Slope_slope_2 = 0.0; |
916 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, (FrequDDS1+DeltakHz_2*1000)); | 920 Moy_Beatslope_2 = 0.0; |
917 Delay(0.1); | 921 Slope_Beatslope_2 = 0.0; |
918 DeltaDDS3 = -DeltakHz_2*1000*(-Signe1/Signe2)*Ndiv*(Nu2)/(Nu1) - Beatslope_2*(utc-t1_2); | 922 Beat_slope_2 = 0.0; |
919 SetCtrlVal(MainPanel, PANEL_DDS3, (FrequencyDDS3Init+DeltaDDS3)); | 923 |
920 DDS4xAD9912_SetFrequency (&DDS4xAD9912,3,(FrequencyDDS3Init+DeltaDDS3)); | 924 // frep positive step |
921 | 925 double fDDS1 = FrequDDS1 + DeltakHz_2 * 1000; |
922 } | 926 DDS4xAD9912_FrequencyRampe(&DDS4xAD9912,1, FrequDDS1, fDDS1, Step2/Ndiv); |
927 SetCtrlVal(MainPanel, PANEL_DDS1, fDDS1); | |
928 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, fDDS1); | |
929 DeltaDDS3 = -DeltakHz_2*1000*(-Signe1/Signe2)*Ndiv*(Nu2)/(Nu1) - Beatslope_2*(utc-t1_2); | |
930 SetCtrlVal(MainPanel, PANEL_DDS3, FrequencyDDS3Init + DeltaDDS3); | |
931 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, FrequencyDDS3Init + DeltaDDS3); | |
932 | |
933 // allow counter to settle | |
934 settling = 3; | |
935 | |
936 // next step | |
937 Measuring_2 += 1; | |
923 } | 938 } |
924 else { | 939 break; |
925 if (DDSBesChanged1==FALSE){ | 940 |
926 | 941 case N_MEASUREMENT_ADJUST_FREQ_PLUS: |
927 if (nDDSChange<3) | 942 case N_MEASUREMENT_ADJUST_FREQ_MINUS: |
928 { nDDSChange=nDDSChange+1;} | 943 // adjust DDS frequency to keep beatnote within the bandpass filter |
929 | 944 |
930 else | 945 if (settling > 0) { |
931 { | 946 settling--; |
932 nDDSChange=0; | 947 break; |
933 | |
934 double DeltaFrep275 = 275000-Ch4; | |
935 double DeltaFrep10 = 10000-Ch2; | |
936 DeltaDDS3 = DeltaDDS3 + DeltaFrep10; | |
937 FrequencyDDSBes = FrequencyDDSBesInit + DeltaFrep275; | |
938 FrequencyDDS3 = FrequencyDDS3Init + DeltaDDS3; | |
939 | |
940 SetCtrlVal(MainPanel, PANEL_DDS2, FrequencyDDSBes); | |
941 DDS4xAD9912_SetFrequency(&DDS4xAD9912,2,FrequencyDDSBes); | |
942 | |
943 Delay(0.1); | |
944 SetCtrlVal(MainPanel, PANEL_DDS3, FrequencyDDS3); | |
945 DDS4xAD9912_SetFrequency(&DDS4xAD9912,3,FrequencyDDS3); | |
946 | |
947 DDSBesChanged1=TRUE; | |
948 t2_2=utc; | |
949 | |
950 } | |
951 | |
952 } | |
953 else{ | |
954 | |
955 if(Step3_2==FALSE){ | |
956 if (nstabilization<3) | |
957 {nstabilization= nstabilization+1;} | |
958 else | |
959 { | |
960 if (utc-t2_2<DeltaT_2) { | |
961 Frepplus_2=Frepplus_2 +Math1+250000000-Slope_2*(utc-t2_2); | |
962 Delta10K_Plus= Delta10K_Plus + 10000 - (Ch2 -Beatslope_2*(utc-t2_2)); | |
963 n_2=n_2+1; | |
964 } | |
965 else | |
966 { | |
967 Frepplus_2=Frepplus_2/n_2; | |
968 Delta10K_Plus=Delta10K_Plus/n_2; | |
969 n_2=0; | |
970 Step3_2=TRUE; | |
971 nstabilization=0; | |
972 DDS4xAD9912_FrequencyRampe ( &DDS4xAD9912,1, (FrequDDS1+DeltakHz_2*1000),(FrequDDS1-DeltakHz_2*1000), Step2/Ndiv ); | |
973 SetCtrlVal(MainPanel, PANEL_DDS1, (FrequDDS1-DeltakHz_2*1000)); | |
974 DDS4xAD9912_SetFrequency (&DDS4xAD9912,1, (FrequDDS1-DeltakHz_2*1000) ); | |
975 | |
976 Delay(0.1); | |
977 DeltaDDS3 = (FrequencyDDS3Init+DeltakHz_2*1000*(-Signe1/Signe2)*Ndiv*(Nu2)/(Nu1)) - FrequencyDDS3; | |
978 SetCtrlVal(MainPanel, PANEL_DDS3, FrequencyDDS3+DeltaDDS3); | |
979 DDS4xAD9912_SetFrequency (&DDS4xAD9912,3, FrequencyDDS3+DeltaDDS3 ); | |
980 | |
981 } | |
982 } | |
983 } | |
984 | |
985 else { | |
986 if (DDSBesChanged2==FALSE){ | |
987 | |
988 if (nDDSChange<3) { | |
989 nDDSChange=nDDSChange+1; | |
990 } | |
991 else | |
992 { | |
993 nDDSChange=0; | |
994 | |
995 double DeltaFrep275=275000-Ch4; | |
996 double DeltaFrep10=10000-Ch2; | |
997 DeltaDDS3 = DeltaDDS3+(DeltaFrep10); | |
998 FrequencyDDSBes=FrequencyDDSBes+(DeltaFrep275); | |
999 FrequencyDDS3=FrequencyDDS3+DeltaDDS3; | |
1000 DDS4xAD9912_SetFrequency(&DDS4xAD9912,2,FrequencyDDSBes); | |
1001 SetCtrlVal(MainPanel, PANEL_DDS2, FrequencyDDSBes); | |
1002 | |
1003 Delay(0.1); | |
1004 SetCtrlVal(MainPanel, PANEL_DDS3, FrequencyDDS3); | |
1005 DDS4xAD9912_SetFrequency(&DDS4xAD9912,3,FrequencyDDS3); | |
1006 | |
1007 DDSBesChanged2=TRUE; | |
1008 t3_2=utc; | |
1009 } | |
1010 } | |
1011 else | |
1012 { | |
1013 if (nstabilization<3) { | |
1014 nstabilization=nstabilization+1; | |
1015 } | |
1016 else | |
1017 { | |
1018 if (utc-t3_2<DeltaT_2) { | |
1019 Frepminus_2=Frepminus_2 +Math1+250000000-Slope_2*(utc-t3_2); | |
1020 Delta10K_Minus= Delta10K_Minus +10000 - ( Ch2 -Beatslope_2*(utc-t3_2)); | |
1021 n_2=n_2+1; | |
1022 } | |
1023 else | |
1024 { | |
1025 Frepminus_2=Frepminus_2/(n_2); | |
1026 Delta10K_Minus= Delta10K_Minus/n_2; | |
1027 N_2 = (Signe2)*(-DeltaDDS3+Delta10K_Plus-Delta10K_Minus-Beatslope_2*(t3_2-t2_2) )/(Frepminus_2-Frepplus_2-Slope_2*(t3_2-t2_2)); | |
1028 n_2=0; | |
1029 Frepminus_2=0.0; | |
1030 Frepplus_2=0.0; | |
1031 Delta10K_Minus=0.0; | |
1032 Delta10K_Plus=0.0; | |
1033 DDS4xAD9912_FrequencyRampe (&DDS4xAD9912, 1, FrequDDS1-DeltakHz_2*1000,FrequDDS1, Step2/Ndiv ); | |
1034 SetCtrlVal(MainPanel, PANEL_DDS1, FrequDDS1); | |
1035 DDS4xAD9912_SetFrequency(&DDS4xAD9912,1,FrequDDS1); | |
1036 | |
1037 Delay(0.1); | |
1038 | |
1039 SetCtrlVal(MainPanel, PANEL_DDS2, FrequencyDDSBesInit); | |
1040 DDS4xAD9912_SetFrequency (&DDS4xAD9912, 2, FrequencyDDSBesInit ); | |
1041 | |
1042 Delay(0.1); | |
1043 | |
1044 SetCtrlVal(MainPanel, PANEL_DDS3, FrequencyDDS3Init-Beatslope_2*(utc-t1_2)); | |
1045 DDS4xAD9912_SetFrequency (&DDS4xAD9912, 3, FrequencyDDS3Init-Beatslope_2*(utc-t1_2) ); | |
1046 | |
1047 Measuring_2=FALSE; | |
1048 Step1_2=FALSE; | |
1049 Step2_2=FALSE; | |
1050 Step3_2=FALSE; | |
1051 t1_2=0.0; | |
1052 t2_2=0.0; | |
1053 t3_2=0.0; | |
1054 DDSBesChanged1=FALSE; | |
1055 DDSBesChanged2=FALSE; | |
1056 FrequencyDDSBes=0.0; | |
1057 nstabilization=0; | |
1058 | |
1059 } | |
1060 } | |
1061 } | |
1062 } | |
1063 } | |
1064 } | 948 } |
1065 } | 949 |
950 double DeltaFrep275 = 275000 - Ch4; | |
951 double DeltaFrep10 = 10000 - Ch2; | |
952 | |
953 DeltaDDS3 = DeltaDDS3 + DeltaFrep10; | |
954 FrequencyDDSBes = FrequencyDDSBes + DeltaFrep275; | |
955 FrequencyDDS3 = FrequencyDDS3 + DeltaDDS3; | |
956 SetCtrlVal(MainPanel, PANEL_DDS2, FrequencyDDSBes); | |
957 DDS4xAD9912_SetFrequency(&DDS4xAD9912,2,FrequencyDDSBes); | |
958 SetCtrlVal(MainPanel, PANEL_DDS3, FrequencyDDS3); | |
959 DDS4xAD9912_SetFrequency(&DDS4xAD9912,3,FrequencyDDS3); | |
960 | |
961 // allow counter to settle | |
962 settling = 3; | |
963 | |
964 // next step | |
965 Measuring_2 += 1; | |
966 break; | |
967 | |
968 case N_MEASUREMENT_FREP_PLUS: | |
969 // frep positive step | |
970 | |
971 if (settling > 0) { | |
972 settling--; | |
973 break; | |
974 } | |
975 | |
976 if (t2_1 == 0.0) | |
977 t2_1 = utc; | |
978 | |
979 Frepplus_2 = Frepplus_2 + Math1 + 250000000 - Slope_2 * (utc - t2_2); | |
980 Delta10K_Plus = Delta10K_Plus + 10000 - (Ch2 - Beatslope_2 * (utc - t2_2)); | |
981 n_2 += 1; | |
982 | |
983 if ((utc - t2_2) > DeltaT_2) { | |
984 Frepplus_2 = Frepplus_2 / n_2; | |
985 Delta10K_Plus = Delta10K_Plus / n_2; | |
986 n_2 = 0; | |
987 | |
988 // negative frequency step | |
989 DDS4xAD9912_FrequencyRampe(&DDS4xAD9912,1, (FrequDDS1+DeltakHz_2*1000),(FrequDDS1-DeltakHz_2*1000), Step2/Ndiv); | |
990 SetCtrlVal(MainPanel, PANEL_DDS1, (FrequDDS1-DeltakHz_2*1000)); | |
991 DDS4xAD9912_SetFrequency(&DDS4xAD9912,1, (FrequDDS1-DeltakHz_2*1000)); | |
992 DeltaDDS3 = (FrequencyDDS3Init+DeltakHz_2*1000*(-Signe1/Signe2)*Ndiv*(Nu2)/(Nu1)) - FrequencyDDS3; | |
993 SetCtrlVal(MainPanel, PANEL_DDS3, FrequencyDDS3+DeltaDDS3); | |
994 DDS4xAD9912_SetFrequency(&DDS4xAD9912,3, FrequencyDDS3+DeltaDDS3); | |
995 | |
996 // allow counter to settle | |
997 settling = 3; | |
998 | |
999 // next step | |
1000 Measuring_2 += 1; | |
1001 } | |
1002 break; | |
1003 | |
1004 case N_MEASUREMENT_FREP_MINUS: | |
1005 // frep negative step | |
1006 | |
1007 if (settling > 0) { | |
1008 settling--; | |
1009 break; | |
1010 } | |
1011 | |
1012 if (t3_1 == 0.0) | |
1013 t3_1 = utc; | |
1014 | |
1015 Frepminus_2 = Frepminus_2 + Math1 + 250000000 - Slope_2 * (utc - t3_2); | |
1016 Delta10K_Minus= Delta10K_Minus + 10000 - (Ch2 - Beatslope_2 * (utc - t3_2)); | |
1017 n_2 += 1; | |
1018 | |
1019 if ((utc -t3_2) > DeltaT_2) { | |
1020 Frepminus_2 = Frepminus_2 / n_2; | |
1021 Delta10K_Minus = Delta10K_Minus / n_2; | |
1022 n_2 = 0; | |
1023 | |
1024 // compute N2 | |
1025 N_2 = (Signe2)*(-DeltaDDS3+Delta10K_Plus-Delta10K_Minus-Beatslope_2*(t3_2-t2_2) )/(Frepminus_2-Frepplus_2-Slope_2*(t3_2-t2_2)); | |
1026 SetCtrlVal(CalcN2Panel, CALCN2_N, N_2); | |
1027 | |
1028 // back to nominal frequency | |
1029 DDS4xAD9912_FrequencyRampe (&DDS4xAD9912, 1, FrequDDS1-DeltakHz_2*1000,FrequDDS1, Step2/Ndiv ); | |
1030 SetCtrlVal(MainPanel, PANEL_DDS1, FrequDDS1); | |
1031 DDS4xAD9912_SetFrequency(&DDS4xAD9912,1,FrequDDS1); | |
1032 Delay(0.1); | |
1033 SetCtrlVal(MainPanel, PANEL_DDS2, FrequencyDDSBesInit); | |
1034 DDS4xAD9912_SetFrequency (&DDS4xAD9912, 2, FrequencyDDSBesInit ); | |
1035 Delay(0.1); | |
1036 SetCtrlVal(MainPanel, PANEL_DDS3, FrequencyDDS3Init-Beatslope_2*(utc-t1_2)); | |
1037 DDS4xAD9912_SetFrequency (&DDS4xAD9912, 3, FrequencyDDS3Init-Beatslope_2*(utc-t1_2) ); | |
1038 | |
1039 t1_2 = 0.0; | |
1040 t2_2 = 0.0; | |
1041 t3_2 = 0.0; | |
1042 Frepminus_2 = 0.0; | |
1043 Frepplus_2 = 0.0; | |
1044 Delta10K_Minus = 0.0; | |
1045 Delta10K_Plus = 0.0; | |
1046 FrequencyDDSBes = 0.0; | |
1047 | |
1048 // done | |
1049 Measuring_2 = N_MEASUREMENT_NONE; | |
1050 } | |
1051 break; | |
1066 } | 1052 } |
1067 | 1053 |
1068 switch (Measuring_3) { | 1054 switch (Measuring_3) { |
1069 | 1055 |
1070 case N_MEASUREMENT_STEP_0: | 1056 case N_MEASUREMENT_STEP_0: |
2041 Moy_slope_1=0.0; | 2027 Moy_slope_1=0.0; |
2042 Slope_slope_1 =0.0; | 2028 Slope_slope_1 =0.0; |
2043 Ch4_slope=0.0; | 2029 Ch4_slope=0.0; |
2044 Moy_Ch4slope_1=0.0; | 2030 Moy_Ch4slope_1=0.0; |
2045 Slope_Ch4slope_1=0.0; | 2031 Slope_Ch4slope_1=0.0; |
2046 DDSBesChanged1=FALSE; | |
2047 DDSBesChanged2=FALSE; | |
2048 nDDSChange=0.0; | |
2049 | 2032 |
2050 SetCtrlVal(MainPanel, PANEL_DDS1, FrequDDS1) ; | 2033 SetCtrlVal(MainPanel, PANEL_DDS1, FrequDDS1) ; |
2051 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, FrequDDS1); | 2034 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, FrequDDS1); |
2052 SetCtrlVal(MainPanel, PANEL_DDS2, FrequencyDDSBesInit) ; | 2035 SetCtrlVal(MainPanel, PANEL_DDS2, FrequencyDDSBesInit) ; |
2053 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 2, FrequencyDDSBesInit); | 2036 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 2, FrequencyDDSBesInit); |
2054 nstabilization=0; | |
2055 } | 2037 } |
2056 if (panel == CalcN2Panel) { | 2038 if (panel == CalcN2Panel) { |
2057 GetPanelAttribute (CalcN2Panel, ATTR_VISIBLE, &PanelIsVisible); | 2039 GetPanelAttribute (CalcN2Panel, ATTR_VISIBLE, &PanelIsVisible); |
2058 if (PanelIsVisible) | 2040 if (PanelIsVisible) |
2059 HidePanel(CalcN2Panel); | 2041 HidePanel(CalcN2Panel); |
2060 | 2042 |
2061 Measuring_2=FALSE; | 2043 Measuring_2=FALSE; |
2062 Step1_2=FALSE ; | |
2063 Step2_2=FALSE ; | |
2064 Step3_2=FALSE ; | |
2065 Frepminus_2=0.0; | 2044 Frepminus_2=0.0; |
2066 Delta10K_Minus=0.0; | 2045 Delta10K_Minus=0.0; |
2067 Frepplus_2=0.0; | 2046 Frepplus_2=0.0; |
2068 Delta10K_Plus=0.0; | 2047 Delta10K_Plus=0.0; |
2069 DeltaDDS3=0.0; | 2048 DeltaDDS3=0.0; |
2075 Moy_slope_2=0.0; | 2054 Moy_slope_2=0.0; |
2076 Beat_slope_2=0.0; | 2055 Beat_slope_2=0.0; |
2077 Moy_Beatslope_2=0.0; | 2056 Moy_Beatslope_2=0.0; |
2078 Slope_Beatslope_2 =0.0; | 2057 Slope_Beatslope_2 =0.0; |
2079 Slope_slope_2 =0.0; | 2058 Slope_slope_2 =0.0; |
2080 DDSBesChanged1=FALSE; | |
2081 DDSBesChanged2=FALSE; | |
2082 nDDSChange=0.0; | |
2083 | 2059 |
2084 SetCtrlVal(MainPanel, PANEL_DDS1, FrequDDS1) ; | 2060 SetCtrlVal(MainPanel, PANEL_DDS1, FrequDDS1) ; |
2085 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, FrequDDS1); | 2061 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, FrequDDS1); |
2086 SetCtrlVal(MainPanel, PANEL_DDS2, FrequencyDDSBesInit) ; | 2062 SetCtrlVal(MainPanel, PANEL_DDS2, FrequencyDDSBesInit) ; |
2087 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 2, FrequencyDDSBesInit); | 2063 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 2, FrequencyDDSBesInit); |
2088 SetCtrlVal(MainPanel, PANEL_DDS3, FrequencyDDS3Init) ; | 2064 SetCtrlVal(MainPanel, PANEL_DDS3, FrequencyDDS3Init) ; |
2089 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, FrequencyDDS3Init); | 2065 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, FrequencyDDS3Init); |
2090 nstabilization=0; | |
2091 } | 2066 } |
2092 if (panel == CalcN3Panel) { | 2067 if (panel == CalcN3Panel) { |
2093 GetPanelAttribute (CalcN3Panel, ATTR_VISIBLE, &PanelIsVisible); | 2068 GetPanelAttribute (CalcN3Panel, ATTR_VISIBLE, &PanelIsVisible); |
2094 if (PanelIsVisible) | 2069 if (PanelIsVisible) |
2095 HidePanel(CalcN3Panel); | 2070 HidePanel(CalcN3Panel); |