# HG changeset patch # User Daniele Nicolodi # Date 1349196948 -7200 # Node ID 585c60175bd5eff8f6b3e880ef228076ee8e2ddc # Parent 1e4ecf64b48525d5e003395a7094545d6fd4533e Cleanup AD9956 DDS parameters setting code diff -r 1e4ecf64b485 -r 585c60175bd5 FXAnalyse.c --- a/FXAnalyse.c Tue Oct 02 17:51:27 2012 +0200 +++ b/FXAnalyse.c Tue Oct 02 18:55:48 2012 +0200 @@ -15,12 +15,10 @@ #include "DDS_Fox.h" #include "muParserDLL.h" - #define FXLINELENGTH 123 #define LOGFILEPATH "C:\\Femto\\Software\\FXQE80" -#define DDSBESCLOCK (200.e6) // 200MHz de clock pour la DDS de Besancon... -#define FACTORDDSBES 36*(8/770000) +#define DEDRIFT_DDS_FREQUENCY 70000000 //============================================================================== // Static global variables @@ -57,7 +55,10 @@ Plot_Data PlotCh1, PlotCh2, PlotCh3, PlotCh4, PlotMath1, PlotMath2, PlotMath3, PlotMath4, PlotMath5 ; Allan_Data AllanCh1, AllanCh2, AllanCh3, AllanCh4, AllanMath1, AllanMath2, AllanMath3, AllanMath4, AllanMath5 ; -DDS4xAD9912_Data DDS4xAD9912 ; +// 1xAD9956 DDS box +DDSParameter DDS1xAD9956; +// 4xAD9912 DDS box +DDS4xAD9912_Data DDS4xAD9912; muParserHandle_t MathParser1, MathParser2, MathParser3, MathParser4, MathParser5 ; @@ -145,16 +146,6 @@ double TimetoSlope=60.0; double SlopeMeasuringTimeBegin=0.0; -char DDSFoxName[255] = "DDS Fox Control" ; -double DDSFoxClock=200000000; -int DDSFoxSweepSign=0; -double DDSFoxFrequency=70000000.0; -char DDSFoxip[255]="145.238.205.58"; -int DDSFoxPort=6665 ; -unsigned int DDSFoxProfil=7; -double DDSFoxSweeprate=0.0;// numéro de profil de la DDS : single freq=0, sweep=7 ; -double DDSFoxDeltaT=0.01; - double Slope_Math2slope=0.0,Math2_slope=0.0,Moy_Math2slope=0.0; int N_Math2slope=0.0,nstabilisationSlopeMeasuring=0; @@ -188,15 +179,17 @@ double CenteringTimeBegin10K=0.0; +int DDSFox_Set(DDSParameter *DDS, double Frequency, double Sweeprate) +{ + DDS->Frequency = Frequency; + DDS->SweepRate = Sweeprate; + + DDSFox_SetFreq(DDS); + DDSFox_SetDf(DDS); + + return 0; +} -//============================================================================== -// Functions - int LaunchDDSFOX (char *Name,char *ip,int Port,unsigned int Profil,double Clock,double DeltaT,double Frequency,double Sweeprate,int mode) ; - double ReadDDSFOX (char *Name,char *ip,int Port,unsigned int Profil,double Clock,double DeltaT,double Frequency,double Sweeprate) ; - - - - void initMathParser(muParserHandle_t * pMathParser) { @@ -262,8 +255,7 @@ DisplayPanel (MainPanel); - // Initialize the quadruple AD9959 DDS (Fox board interface) - + // initialize 4x AD9959 DDS box DDS4xAD9912_Reset(&DDS4xAD9912) ; GetCtrlVal(MainPanel, PANEL_DDS1, &initfreqDDS) ; DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, initfreqDDS) ; @@ -275,8 +267,15 @@ DDS4xAD9912_SetFrequency(&DDS4xAD9912, 4, initfreqDDS) ; - // Initialyze the DDSFOX Output - LaunchDDSFOX (DDSFoxName,DDSFoxip,DDSFoxPort,DDSFoxProfil,DDSFoxClock,DDSFoxDeltaT,DDSFoxFrequency,DDSFoxSweeprate,1); + // initialyze 1x AD9956 DDS box + strcpy(DDS1xAD9956.ip, "145.238.205.58"); + DDS1xAD9956.Port = 6665; + DDS1xAD9956.Profil = 7; // configuration profile: single freq=0, sweep=7 + DDS1xAD9956.Clock = 200000000; + DDS1xAD9956.Frequency = DEDRIFT_DDS_FREQUENCY; + DDS1xAD9956.Delta_T = 0.01; + DDS1xAD9956.SweepRate = 0.0; + DDS_Initialize(&DDS1xAD9956); // Initialize the 5 (separate) math parsers for frep, Nu_Hg, Nu_Sr, N3 and ExtraMath @@ -1326,8 +1325,8 @@ } OnSlopeCancelling = TRUE; - - FoxFrequ = ReadDDSFOX (DDSFoxName,DDSFoxip,DDSFoxPort,DDSFoxProfil,DDSFoxClock,DDSFoxDeltaT,DDSFoxFrequency,DDSFoxSweeprate); + + FoxFrequ = DDSFox_ReadFreq(&DDS1xAD9956); if (Nratio == ratio) { @@ -1340,7 +1339,7 @@ MoyMath2 = 0.0; } - LaunchDDSFOX (DDSFoxName,DDSFoxip,DDSFoxPort,DDSFoxProfil,DDSFoxClock,DDSFoxDeltaT,FoxFrequ,SlopeMath2,0); + DDSFox_Set(&DDS1xAD9956, FoxFrequ, SlopeMath2); nstabilisationSlopeMeasuring = 0; SlopeMeasuringTimeBegin = utc; @@ -1373,11 +1372,11 @@ if (KeepFrequ == TRUE) { - ActualFrequ = ReadDDSFOX (DDSFoxName,DDSFoxip,DDSFoxPort,DDSFoxProfil,DDSFoxClock,DDSFoxDeltaT,DDSFoxFrequency,DDSFoxSweeprate); + ActualFrequ = DDSFox_ReadFreq(&DDS1xAD9956); } else { - ActualFrequ = DDSFoxFrequency; + ActualFrequ = DEDRIFT_DDS_FREQUENCY; } if (KeepSlope == TRUE) @@ -1386,11 +1385,11 @@ } else { - ActualSlope = DDSFoxSweeprate; + ActualSlope = 0.0; OnSlopeCancelling = FALSE; } - LaunchDDSFOX (DDSFoxName,DDSFoxip,DDSFoxPort,DDSFoxProfil,DDSFoxClock,DDSFoxDeltaT,ActualFrequ,ActualSlope,0); + DDSFox_Set(&DDS1xAD9956, ActualFrequ, ActualSlope); SlopeMeasuring = FALSE; N_Math2slope = 0.0; @@ -2386,9 +2385,9 @@ { SlopeMeasuringTimeBegin=utc; SlopeMeasuring=TRUE; - ActualFrequ=ReadDDSFOX (DDSFoxName,DDSFoxip,DDSFoxPort,DDSFoxProfil,DDSFoxClock,DDSFoxDeltaT,DDSFoxFrequency,DDSFoxSweeprate); + ActualFrequ=DDSFox_ReadFreq(&DDS1xAD9956); ActualSlope= SlopeMath2; - LaunchDDSFOX (DDSFoxName,DDSFoxip,DDSFoxPort,DDSFoxProfil,DDSFoxClock,DDSFoxDeltaT,ActualFrequ,ActualSlope,0); + DDSFox_Set(&DDS1xAD9956, ActualFrequ, ActualSlope); Nratio=-1; CenterFrequencyCh2ToDetermine=TRUE ; CenterFrequencyCh2=0.0; @@ -2396,13 +2395,13 @@ } else { - if (KeepFrequ==TRUE) {ActualFrequ=ReadDDSFOX (DDSFoxName,DDSFoxip,DDSFoxPort,DDSFoxProfil,DDSFoxClock,DDSFoxDeltaT,DDSFoxFrequency,DDSFoxSweeprate);} - else { ActualFrequ= DDSFoxFrequency;} + if (KeepFrequ==TRUE) {ActualFrequ=DDSFox_ReadFreq(&DDS1xAD9956);} + else { ActualFrequ= DEDRIFT_DDS_FREQUENCY;} if (KeepSlope==TRUE) {ActualSlope= SlopeMath2; OnSlopeCancelling =TRUE; } - else { ActualSlope= DDSFoxSweeprate; + else { ActualSlope= 0.0; OnSlopeCancelling =FALSE; } - LaunchDDSFOX (DDSFoxName,DDSFoxip,DDSFoxPort,DDSFoxProfil,DDSFoxClock,DDSFoxDeltaT,ActualFrequ,ActualSlope,0); + DDSFox_Set(&DDS1xAD9956, ActualFrequ, ActualSlope); SlopeMeasuring=FALSE; N_Math2slope=0.0; Math2_slope=0.0; @@ -2435,7 +2434,7 @@ Nratio = -1; CenterFrequencyCh2ToDetermine = TRUE ; OnSlopeCancelling = FALSE; - LaunchDDSFOX (DDSFoxName,DDSFoxip,DDSFoxPort,DDSFoxProfil,DDSFoxClock,DDSFoxDeltaT,DDSFoxFrequency,DDSFoxSweeprate,0); + DDSFox_Set(&DDS1xAD9956, DEDRIFT_DDS_FREQUENCY, 0.0); break; } return 0; @@ -2455,49 +2454,6 @@ } -int LaunchDDSFOX (char *Name,char *ip,int Port,unsigned int Profil,double Clock,double DeltaT,double Frequency,double Sweeprate,int mode) -{ - //mode =0 pour normal - //mode =1 pour reset - - DDSParameter DDSState; - - strcpy(DDSState.Name, Name); - DDSState.Profil = Profil; - strcpy(DDSState.ip, ip); - DDSState.Port = Port; - DDSState.Clock = Clock; - DDSState.Delta_T = DeltaT; - DDSState.Frequency = Frequency; - DDSState.SweepRate = Sweeprate; - - if (mode == 1) { - DDS_Initialize (&DDSState); - } else { - DDS_ReInitialize (&DDSState); - } - - return 0; -} - -double ReadDDSFOX (char *Name,char *ip,int Port,unsigned int Profil,double Clock,double DeltaT,double Frequency,double Sweeprate) -{ - - DDSParameter DDSState; - - strcpy(DDSState.Name, Name); - DDSState.Profil = Profil; - strcpy(DDSState.ip, ip); - DDSState.Port = Port; - DDSState.Clock = Clock; - DDSState.Delta_T = DeltaT; - DDSState.Frequency = Frequency; - DDSState.SweepRate = Sweeprate; - - return DDSFox_ReadFreq(&DDSState); -} - - int CVICALLBACK CB_OnCROX (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { @@ -2536,8 +2492,8 @@ KeepSlope=TRUE ; if (SlopeMeasuring==FALSE && OnSlopeCancelling==FALSE) { - ActualFrequ=ReadDDSFOX (DDSFoxName,DDSFoxip,DDSFoxPort,DDSFoxProfil,DDSFoxClock,DDSFoxDeltaT,DDSFoxFrequency,DDSFoxSweeprate); - LaunchDDSFOX (DDSFoxName,DDSFoxip,DDSFoxPort,DDSFoxProfil,DDSFoxClock,DDSFoxDeltaT,ActualFrequ,SlopeMath2,0); + ActualFrequ = DDSFox_ReadFreq(&DDS1xAD9956); + DDSFox_Set(&DDS1xAD9956, ActualFrequ, SlopeMath2); OnSlopeCancelling=TRUE; @@ -2546,8 +2502,8 @@ else {KeepSlope=FALSE ; if (SlopeMeasuring==FALSE && OnSlopeCancelling==TRUE) { - ActualFrequ=ReadDDSFOX (DDSFoxName,DDSFoxip,DDSFoxPort,DDSFoxProfil,DDSFoxClock,DDSFoxDeltaT,DDSFoxFrequency,DDSFoxSweeprate); - LaunchDDSFOX (DDSFoxName,DDSFoxip,DDSFoxPort,DDSFoxProfil,DDSFoxClock,DDSFoxDeltaT,ActualFrequ,DDSFoxSweeprate,0); + ActualFrequ=DDSFox_ReadFreq(&DDS1xAD9956); + DDSFox_Set(&DDS1xAD9956, ActualFrequ, 0.0); OnSlopeCancelling=FALSE; }