public static void FakeCableTest()
        {
            //Parameter Initialization
            SwpParamStruct param         = new SwpParamStruct(300, 3000, -40, 25);
            int            numIterations = 2;

            double[] data     = new double[param.numSteps];                  //Define data array
            double[] freqAxis = new double[param.numSteps];                  //Define the frequency array
            double[,] xyDouble = new double[param.numSteps, numIterations + 1];

            //FakeCableTest Code Body
            for (int j = 0; j < numIterations; j++)
            {
                for (int i = 0; i < param.numSteps; i++)
                {
                    double test_freq = param.freqMin + i * (param.freqMax - param.freqMin) / param.numSteps;

                    xyDouble[i, 0]     = test_freq;
                    xyDouble[i, j + 1] = Helper.GetRandomNum(-50, -30);
                }
            }

            //Output Charts to a pdf file
            string path = @"..\..\..\TestResults\FakeCableTestOutput";           //Sends output data to the TestOutputs folder
            var    doc1 = new Document();

            iTextSharp.text.Image[] container = new iTextSharp.text.Image[1];

            string[] chartLabels = new string[] { "Random Number Generator",
                                                  "Arbitrary Frequency (MHz)",
                                                  "Amplitude (dBm)",
                                                  "Trace 1",
                                                  "Trace 2" };
            container[0] = Helper.MakeChartObject(xyDouble, chartLabels, path);
            Helper.AddAllChartsToPdf(container, path + ".pdf", chartLabels);

            ////Open Result PDF
            System.Diagnostics.Process.Start(path + ".pdf");
        }
        public static void CableTest()
        {
            //TEST PARAMETER DEFINITIONS
            int[] amplitudes = new int[1] {
                -20
            };                                                                        //Hard coded values for amplitude settings
            SwpParamStruct param = new SwpParamStruct(2000, 4000, amplitudes[0], 12); //Hard coded values, Initialize param structure

            string[] seriesName = new string[amplitudes.Length];
            double[] data       = new double[param.numSteps];
            double[] freqAxis   = new double[param.numSteps];
            double[,] freqAmplitudeData = new double[param.numSteps, amplitudes.Length + 1]; //Always a 2D array


            //MEASUREMENT EQUIPMENT SETUP
            NumberStyles style = NumberStyles.AllowExponent | NumberStyles.Number;
            ///ESG Setup
            SG_AgilentESG esg = new SG_AgilentESG(ESGAddress);

            Console.WriteLine(esg.Identify());

            //PXA Setup
            Console.WriteLine("--PXA TEST STARTED--");
            SA_AgilentPXA pxa = new SA_AgilentPXA(PXAAddress);

            Console.WriteLine("--CABLE TEST STARTED--");


            for (int j = 0; j < amplitudes.Length; j++)
            {
                param.amplitude = amplitudes[j];
                string seriesLabel = "Input Amplitude " + amplitudes[j] + "dBm";
                seriesName[j] = seriesLabel;

                //set init values on ESG
                esg.SetFrequency(param.freqMin);
                esg.SetAmplitude(param.amplitude);
                esg.SetRfOutput(true);

                for (int i = 0; i < param.numSteps; i++)
                {
                    double test_freq = param.freqMin + i * (param.freqMax - param.freqMin) / param.numSteps;
                    esg.SetFrequency(test_freq);
                    pxa.SetCenterSpan(test_freq, 100, 0);               //MHz
                    pxa.SetAtten(10);
                    pxa.SetRefLevel(-10);
                    pxa.SetMarker(1, test_freq);                        //Sets marker to frequency of interest
                    pxa.HoldAverage();
                    System.Threading.Thread.Sleep(500);
                    data[i]     = Double.Parse(pxa.GetMarker(1), style);        //Rewrite this... it's verbose
                    freqAxis[i] = test_freq;

                    freqAmplitudeData[i, 0]     = test_freq;
                    freqAmplitudeData[i, j + 1] = Double.Parse(pxa.GetMarker(1), style);
                }
            }

            // PRINT OUTPUT FILES
            string path = @"..\..\..\TestResults\CableTest";           //Sends output data to the TestOutputs folder
            //Output Data to a text file

            //Output Charts to a pdf file
            var doc1 = new Document();

            string[] chartLabels = new string[] { "Received ESG Amplitude on PXA (Cable Test)",
                                                  "ESG Frequency (MHz)",
                                                  "Amplitude (dBm)",
                                                  "ESG Amplitude (dBm): " + amplitudes[0] };
            string[] headerStrings = new string[] { "Cable Test Output Graph",
                                                    "Mykonos API Regression Testing Development",
                                                    Helper.GetTimestamp() };

            iTextSharp.text.Image[] container = new iTextSharp.text.Image[1];
            container[0] = Helper.MakeChartObject(freqAmplitudeData, chartLabels, path + ".pdf");
            Helper.AddAllChartsToPdf(container, path + ".pdf", headerStrings);
            //Open Result pdf
            System.Diagnostics.Process.Start(path + ".pdf");
        }
Ejemplo n.º 3
0
        public static void QECHarmonicSweep([Values(Mykonos.TXCHANNEL.TX1, Mykonos.TXCHANNEL.TX2)] Mykonos.TXCHANNEL channel)
        {
            InitCalSweepTests obj = new InitCalSweepTests();

            obj.QECTestsInit();
            //Retrieve Profile Information, samplingFreq_Hz,  ProfileBW, LO Frequency Information
            double[] profileInfo = new double[3];
            double   backoff     = -15;
            int      atten       = 0;

            profileInfo[0] = settings.txProfileData.IqRate_kHz;
            profileInfo[1] = settings.txPllLoFreq_Hz;
            profileInfo[2] = settings.txProfileData.PrimarySigBw_Hz;

            double txIqDataRate_kHz     = profileInfo[0];
            double profileBandwidth_MHz = profileInfo[2] / 1000000;

            Console.WriteLine("IQ Data Rate (kHz): " + txIqDataRate_kHz);
            Console.WriteLine("Profile Bandwdith (MHz): " + profileBandwidth_MHz);
            double freqTxLo_MHz = profileInfo[1] / 1000000;

            Console.WriteLine("Tx LO Frequency (MHz): " + freqTxLo_MHz);

            //Define Test Parameters Based on Profile Info & Lo Frequency
            double         SwpMinFreq  = freqTxLo_MHz - (2 * (profileBandwidth_MHz / 2));
            double         SwpMaxFreq  = freqTxLo_MHz + (2 * (profileBandwidth_MHz / 2));
            double         SwpSigAmp   = -40;
            int            SwpNumSteps = 200;
            SwpParamStruct param       = new SwpParamStruct(SwpMinFreq, SwpMaxFreq, SwpSigAmp, SwpNumSteps);
            double         SwpStepSz   = (param.freqMax - param.freqMin) / param.numSteps;

            Console.WriteLine("SwpMinFreq (MHz): " + SwpMinFreq);
            Console.WriteLine("SwpMaxMax (MHz): " + SwpMaxFreq);
            Console.WriteLine("SwpSigAmp (MHz): " + SwpSigAmp);

            //Define Data Array for storing Fundamental Amplitue, LoLeakage and ImageAmplitude
            //double[,] fundAmpXY = new double[param.numSteps, 2];
            double[,] harmonicAmpnoCal = new double[param.numSteps + 1, 4];
            double[,] harmonicAmpCal   = new double[param.numSteps + 1, 4];

            double[,] loLeakageXYcal = new double[param.numSteps + 1, 2];
            double[,] loLeakageXYdif = new double[param.numSteps + 1, 2];

            //double[,] imageAmpXY = new double[param.numSteps, 2];

            //Connect to Signal Generator
            //The span is fixed to 100MHz
            //Set Marker 2 as LO leakage marker
            //Note: this may need to be set depending on profile.
            NumberStyles  style = NumberStyles.AllowExponent | NumberStyles.Number;
            SA_AgilentPXA pxa   = new SA_AgilentPXA(measEquipment.PXAAddress);

            pxa.SetCenterSpan(freqTxLo_MHz, 200, 0);
            pxa.SetAtten(20);
            pxa.SetRefLevel(10);
            pxa.SetMarker(2, freqTxLo_MHz);


            //Config and Enable Mykonos with Test Specific Settings
            AdiCommandServerClient Link = AdiCommandServerClient.Instance;

            Link.hw.Connect(TestSetupConfig.ipAddr, TestSetupConfig.port);
            Link.Mykonos.setTx1Attenuation(0);
            Link.Mykonos.radioOn();
            Link.Disconnect();

#if WR_RES_TO_CONSOLE
            Console.WriteLine(" OffSet Frequency input (MHz):" +
                              "Image Amplitude (dBm)");
#endif
            //Test Sequence
            //Sweep Thru Passband
            for (int i = 0; (i <= param.numSteps); i++)
            {
                //Calculate Test Tone And Generate
                double offsetFreq_Mhz = param.freqMin + (i * SwpStepSz) - (freqTxLo_MHz);
                double testFreq_MHz   = freqTxLo_MHz + offsetFreq_Mhz;
                double harmonicAmp;
                double offsetFreq_Hz = offsetFreq_Mhz * 1000000;

                if (offsetFreq_Hz == 0)
                {
                    harmonicAmpnoCal[i, 0] = offsetFreq_Mhz;
                    harmonicAmpnoCal[i, 1] = harmonicAmpnoCal[i - 1, 1];
                    harmonicAmpnoCal[i, 2] = harmonicAmpnoCal[i - 1, 2];
                    harmonicAmpnoCal[i, 3] = harmonicAmpnoCal[i - 1, 3];

                    continue;
                }
                Helper.GenerateTxTone(Mykonos.TXCHANNEL.TX1_TX2, profileInfo, offsetFreq_Hz, backoff);
                //Take Measurements from PXA

                pxa.SetMarker(1, freqTxLo_MHz + (offsetFreq_Hz / 1000000));
                pxa.SetMarker(2, freqTxLo_MHz + 2 * (offsetFreq_Hz / 1000000));
                pxa.SetMarker(3, freqTxLo_MHz + 3 * (offsetFreq_Hz / 1000000));
                //pxa.HoldAverage();
                System.Threading.Thread.Sleep(500);
                harmonicAmpnoCal[i, 0] = offsetFreq_Mhz;
                harmonicAmp            = Double.Parse(pxa.GetMarker(1), style);
                harmonicAmpnoCal[i, 1] = harmonicAmp;
                harmonicAmp            = Double.Parse(pxa.GetMarker(2), style);
                harmonicAmpnoCal[i, 2] = harmonicAmp;
                harmonicAmp            = Double.Parse(pxa.GetMarker(3), style);
                harmonicAmpnoCal[i, 3] = harmonicAmp;

#if WR_RES_TO_CONSOLE //Optional printout for text based readout in test output window
                Console.WriteLine(offsetFreq_Mhz + ":   " + harmonicAmp + ",   ");
#endif
            }


            Link.hw.Connect(TestSetupConfig.ipAddr, TestSetupConfig.port);
            Link.Mykonos.radioOff();
            Link.Disconnect();


            obj.AllCalsInit();
            Link.hw.Connect(TestSetupConfig.ipAddr, TestSetupConfig.port);
            Link.Mykonos.setTx1Attenuation(0);
            Link.Mykonos.radioOn();
            Link.Disconnect();

            for (int i = 0; (i <= param.numSteps); i++)
            {
                //Calculate Test Tone And Generate
                double offsetFreq_Mhz = param.freqMin + (i * SwpStepSz) - (freqTxLo_MHz);
                double testFreq_MHz   = freqTxLo_MHz + offsetFreq_Mhz;
                double offsetFreq_Hz  = offsetFreq_Mhz * 1000000;
                double harmonicAmp;

                if (offsetFreq_Hz == 0)
                {
                    harmonicAmpCal[i, 0] = offsetFreq_Mhz;
                    harmonicAmpCal[i, 1] = harmonicAmpCal[i - 1, 1];
                    harmonicAmpCal[i, 2] = harmonicAmpCal[i - 1, 2];
                    harmonicAmpCal[i, 3] = harmonicAmpCal[i - 1, 3];
                    //loLeakageXY[i, 3] = loLeakageXY[i, 1] - loLeakageXY[i, 2];

                    continue;
                }
                Helper.GenerateTxTone(Mykonos.TXCHANNEL.TX1_TX2, profileInfo, offsetFreq_Hz, backoff);

                pxa.SetMarker(1, freqTxLo_MHz + (offsetFreq_Hz / 1000000));
                pxa.SetMarker(2, freqTxLo_MHz + 2 * (offsetFreq_Hz / 1000000));
                pxa.SetMarker(3, freqTxLo_MHz + 3 * (offsetFreq_Hz / 1000000));
                //pxa.HoldAverage();
                System.Threading.Thread.Sleep(500);
                harmonicAmpCal[i, 0] = offsetFreq_Mhz;
                harmonicAmp          = Double.Parse(pxa.GetMarker(1), style);
                harmonicAmpCal[i, 1] = harmonicAmp;
                harmonicAmp          = Double.Parse(pxa.GetMarker(2), style);
                harmonicAmpCal[i, 2] = harmonicAmp;
                harmonicAmp          = Double.Parse(pxa.GetMarker(3), style);
                harmonicAmpCal[i, 3] = harmonicAmp;
            }

#if WR_RES_TO_PDF
            //Graph Data and Save in PDF Form
            var       doc1     = new Document();
            string    path     = TxRfTests.ResPath + "QECInitSweep";
            TxRfTests instance = new TxRfTests();
            string[]  pcbInfo;
            iTextSharp.text.Image[] container = new iTextSharp.text.Image[2];
            string[] loLeakageLabels          = new string[] { "Harmonic Amplitude Versus Offset Tone Frequency without Calibrations",
                                                               "Offset Tone Frequency (MHz)",
                                                               "Amplitude (dBm)",
                                                               "1st Harmonic", "2nd Harmonic", "3rd Harmonic" };
            string[] loLeakageLabelscal = new string[] { "Harmonic Amplitude Versus Offset Tone Frequency with Calibrations",
                                                         "Offset Tone Frequency (MHz)",
                                                         "Amplitude (dBm)",
                                                         "1st Harmonic", "2nd Harmonic", "3rd Harmonic" };
            string[] loLeakageLabelsdif = new string[] { "Image Amplitude Versus Offset Tone Frequency Difference",
                                                         "Offset Tone Frequency (MHz)",
                                                         "Amplitude (dBm)",
                                                         "Trace Amplitude" };
            pcbInfo = Helper.PcbInfo((settings.txPllLoFreq_Hz / 1000000000.0).ToString(), (settings.rxPllLoFreq_Hz / 1000000000.0).ToString(), settings.mykSettings.txProfileName, settings.mykSettings.rxProfileName, backoff.ToString(), atten.ToString());
            // pcbInfo = Helper.PcbInfo();
            //container[0] = Helper.MakeChartObject(fundAmpXY, fundAmpLabels, path);
            container[0] = Helper.MakeChartObject(harmonicAmpnoCal, loLeakageLabels, path);
            container[1] = Helper.MakeChartObject(harmonicAmpCal, loLeakageLabelscal, path);
            //container[1] = Helper.MakeChartObject(loLeakageXYcal, loLeakageLabelscal, path);
            //container[2] = Helper.MakeChartObject(loLeakageXYdif, loLeakageLabelsdif, path);

            //container[2] = Helper.MakeChartObject(imageAmpXY, imageAmpLabels, path);
            Helper.AddAllChartsToPdf(container, path + ".pdf", pcbInfo);

            //Open Result PDF
            System.Diagnostics.Process.Start(path + ".pdf");
#endif
#if WR_RES_TO_TXT
            // Write data to txt file
            using (System.IO.StreamWriter file = new System.IO.StreamWriter(path + ".txt"))
            {
                file.WriteLine("Sample,  Frequency MHz, LOL(dBFS) w/o cal, LOL(dBFS) w/ cal");
                for (int i = 0; i <= param.numSteps; i++)
                {
                    file.WriteLine(i + "," + harmonicAmpnoCal[i, 0].ToString() + "," + harmonicAmpnoCal[i, 1].ToString() + "," + harmonicAmpnoCal[i, 2].ToString());
                }
            }
#endif
        }
Ejemplo n.º 4
0
        public static void TxPassbandSweep([Values(Mykonos.TXCHANNEL.TX1, Mykonos.TXCHANNEL.TX2)] Mykonos.TXCHANNEL channel)

        {
            //Retrieve Profile Information, samplingFreq_Hz,  ProfileBW, LO Frequency Information
            double[] profileInfo = new double[3];
            int      atten       = 0;
            int      backoff     = 0;

            profileInfo[0] = settings.txProfileData.IqRate_kHz;
            profileInfo[1] = settings.txPllLoFreq_Hz;
            profileInfo[2] = settings.txProfileData.PrimarySigBw_Hz;

            double txIqDataRate_kHz     = profileInfo[0];
            double profileBandwidth_MHz = profileInfo[2] / 1000000;

            Console.WriteLine("IQ Data Rate (kHz): " + txIqDataRate_kHz);
            Console.WriteLine("Profile Bandwdith (MHz): " + profileBandwidth_MHz);
            double freqTxLo_MHz = profileInfo[1] / 1000000;

            Console.WriteLine("Tx LO Frequency (MHz): " + freqTxLo_MHz);

            //Define Test Parameters Based on Profile Info & Lo Frequency
            double         SwpMinFreq  = freqTxLo_MHz - (1.1 * (profileBandwidth_MHz / 2));
            double         SwpMaxFreq  = freqTxLo_MHz + (1.1 * (profileBandwidth_MHz / 2));
            double         SwpSigAmp   = -40;
            int            SwpNumSteps = 50;
            SwpParamStruct param       = new SwpParamStruct(SwpMinFreq, SwpMaxFreq, SwpSigAmp, SwpNumSteps);
            double         SwpStepSz   = (param.freqMax - param.freqMin) / param.numSteps;

            Console.WriteLine("SwpMinFreq (MHz): " + SwpMinFreq);
            Console.WriteLine("SwpMaxMax (MHz): " + SwpMaxFreq);
            Console.WriteLine("SwpSigAmp (MHz): " + SwpSigAmp);

            //Define Data Array for storing Fundamental Amplitue, LoLeakage and ImageAmplitude
            double[,] fundAmpXY   = new double[param.numSteps + 1, 2];
            double[,] loLeakageXY = new double[param.numSteps + 1, 2];
            double[,] imageAmpXY  = new double[param.numSteps + 1, 2];

            //Connect to Signal Analyser
            //The span is fixed to 100MHz
            //Set Marker 2 as LO leakage marker
            //Note: this may need to be set depending on profile.
            NumberStyles  style = NumberStyles.AllowExponent | NumberStyles.Number;
            SA_AgilentPXA pxa   = new SA_AgilentPXA(measEquipment.PXAAddress);

            pxa.SetCenterSpan(freqTxLo_MHz, 200, 0);
            pxa.SetAtten(20);
            pxa.SetRefLevel(10);
            pxa.SetMarker(2, freqTxLo_MHz);

            //Config and Enable Mykonos with Test Specific Settings
            AdiCommandServerClient Link = AdiCommandServerClient.Instance;

            Link.hw.Connect(TestSetupConfig.ipAddr, TestSetupConfig.port);
            Link.Mykonos.setTx1Attenuation(0);
            Link.Mykonos.radioOn();
            Link.Disconnect();

#if WR_RES_TO_CONSOLE
            Console.WriteLine(" OffSet Frequency input (MHz):" +
                              "Fundamental Amplitude (dBm), " +
                              "LO Leakage (dBm)," +
                              "Image Amplitude (dBm),");
#endif
            //Test Sequence
            //Sweep Thru Passband
            for (int i = 0; (i <= param.numSteps); i++)
            {
                //Calculate Test Tone And Generate
                double offsetFreq_Mhz = param.freqMin + (i * SwpStepSz) - (freqTxLo_MHz);
                double testFreq_MHz = freqTxLo_MHz + offsetFreq_Mhz;
                double fundAmp, loLeakage, imageAmp;
                double offsetFreq_Hz = offsetFreq_Mhz * 1000000;

                if (offsetFreq_Hz == 0)
                {
                    fundAmpXY[i, 0] = offsetFreq_Mhz;
                    fundAmpXY[i, 1] = fundAmpXY[i - 1, 1];

                    loLeakageXY[i, 0] = offsetFreq_Mhz;
                    loLeakageXY[i, 1] = loLeakageXY[i - 1, 1];

                    imageAmpXY[i, 0] = offsetFreq_Mhz;
                    imageAmpXY[i, 1] = imageAmpXY[i - 1, 1];
                    continue;
                }
                Helper.GenerateTxTone(Mykonos.TXCHANNEL.TX1_TX2, profileInfo, offsetFreq_Hz, backoff);
                //Take Measurements from PXA

                pxa.SetMarker(3, freqTxLo_MHz - (offsetFreq_Hz / 1000000)); //Image marker
                pxa.SetMarker(1, testFreq_MHz);                             //Fundamental amplitue marker
                //pxa.HoldAverage();
                System.Threading.Thread.Sleep(500);
                fundAmp   = Double.Parse(pxa.GetMarker(1), style);
                loLeakage = Double.Parse(pxa.GetMarker(2), style);
                imageAmp  = Double.Parse(pxa.GetMarker(3), style);

                fundAmpXY[i, 0] = offsetFreq_Mhz;
                fundAmpXY[i, 1] = fundAmp;

                loLeakageXY[i, 0] = offsetFreq_Mhz;
                loLeakageXY[i, 1] = loLeakage;

                imageAmpXY[i, 0] = offsetFreq_Mhz;
                imageAmpXY[i, 1] = imageAmp;



#if WR_RES_TO_CONSOLE //Optional printout for text based readout in test output window
                Console.WriteLine(offsetFreq_Mhz + ":   " + fundAmp + ",   " + loLeakage + ",   " + imageAmp + ",   " + (fundAmp - imageAmp) + ",   ");
#endif
            }

#if WR_RES_TO_PDF
            //Graph Data and Save in PDF Form
            var       doc1     = new Document();
            string    path     = TxRfTests.ResPath + "TxPassbandSweep";
            TxRfTests instance = new TxRfTests();
            string[]  pcbInfo;
            iTextSharp.text.Image[] container = new iTextSharp.text.Image[3];
            string[] fundAmpLabels            = new string[] { "Fundamental Amplitude Versus Offset Tone Frequency (from LO)",
                                                               "Offset Tone Frequency (MHz)",
                                                               "Amplitude (dBm)",
                                                               "Trace Amplitude" };
            string[] loLeakageLabels = new string[] { "LO Leakage Versus Offset Tone Frequency",
                                                      "Offset Tone Frequency (MHz)",
                                                      "Amplitude (dBm)",
                                                      "Trace Amplitude" };
            string[] imageAmpLabels = new string[] { "Image Amplitude Versus Offset Tone Frequency",
                                                     "Offset Tone Frequency (MHz)",
                                                     "Amplitude (dBm)",
                                                     "Trace Amplitude" };
            pcbInfo = Helper.PcbInfo((settings.txPllLoFreq_Hz / 1000000.0).ToString(), (settings.rxPllLoFreq_Hz / 1000000.0).ToString(), settings.mykSettings.txProfileName, settings.mykSettings.rxProfileName, backoff.ToString(), atten.ToString());

            // pcbInfo = Helper.PcbInfo();
            container[0] = Helper.MakeChartObject(fundAmpXY, fundAmpLabels, path);
            container[1] = Helper.MakeChartObject(loLeakageXY, loLeakageLabels, path);
            container[2] = Helper.MakeChartObject(imageAmpXY, imageAmpLabels, path);
            Helper.AddAllChartsToPdf(container, path + ".pdf", pcbInfo);

            //Open Result PDF
            System.Diagnostics.Process.Start(path + ".pdf");
#endif
#if WR_RES_TO_TXT
            // Write data to txt file
            using (System.IO.StreamWriter file = new System.IO.StreamWriter(path + ".txt"))
            {
                file.WriteLine("Sample,  Frequency MHz, Fundamental Power(dBm),  LOL(dBFS), Image Power(dBFS),");
                for (int i = 0; i < param.numSteps; i++)
                {
                    file.WriteLine(i + "," + fundAmpXY[i, 0].ToString() + "," + fundAmpXY[i, 1].ToString() + "," + loLeakageXY[i, 1].ToString() + "," + imageAmpXY[i, 1].ToString());
                }
            }
#endif

            //Check Min Max Fund Amplitudes are within 0.5db of each other.
            var MinFundAmp = System.Linq.Enumerable.Range(0, param.numSteps).Select(i => fundAmpXY[i, 1]).Min();
            var MaxFundAmp = System.Linq.Enumerable.Range(0, param.numSteps).Select(i => fundAmpXY[i, 1]).Max();
            Console.WriteLine("MinFundAmp: " + MinFundAmp);
            Console.WriteLine("MaxFundAmp: " + MaxFundAmp);
            Console.WriteLine("MaxDiffFundAmp: " + (MaxFundAmp - MinFundAmp));
            NUnit.Framework.Assert.IsTrue((MaxFundAmp - MinFundAmp) < 1.0);
        }
Ejemplo n.º 5
0
        public static void ORxPassbandSweep([Values(Mykonos.OBSRXCHANNEL.OBS_RX1_TXLO, Mykonos.OBSRXCHANNEL.OBS_RX2_TXLO)] Mykonos.OBSRXCHANNEL channel)
        {
            //Retrieve Profile Information, samplingFreq_Hz,  ProfileBW, LO Frequency Information
            double[] profileInfo = new double[3];
            profileInfo[0] = settings.rxProfileData.IqRate_kHz;
            profileInfo[1] = settings.rxPllLoFreq_Hz;
            profileInfo[2] = settings.rxProfileData.PrimarySigBw_Hz;

            double samplingFreq_MHz = profileInfo[0] / 1000;
            double profileBW_MHz    = profileInfo[2] / 1000000;

            Console.WriteLine("Rx Sampling Freq (MHz): " + samplingFreq_MHz);
            Console.WriteLine("Rx Profile Bandwdith (MHz): " + profileBW_MHz);
            double freqLo_MHz = profileInfo[1] / 1000000;

            Console.WriteLine("Rx LO Frequency (MHz): " + freqLo_MHz);



            //Define Test Parameters Based on Profile Info & Lo Frequency
            //Allow for testing 50%  over & under PassBand
            //Hard coded values for amplitude & Frequency Setups settings
            const int      NUM_SAMPLES = 8192;
            double         SwpSigAmp   = -20;
            double         SwpMinFreq  = freqLo_MHz - (profileBW_MHz / 2) * 1.5;
            double         SwpMaxFreq  = freqLo_MHz + (profileBW_MHz / 2) * 1.5;
            int            SwpNumSteps = 150;
            SwpParamStruct param       = new SwpParamStruct(SwpMinFreq, SwpMaxFreq, SwpSigAmp, SwpNumSteps);

            Console.WriteLine("SwpMinFreq (MHz): " + SwpMinFreq);
            Console.WriteLine("SwpMaxMax (MHz): " + SwpMaxFreq);
            Console.WriteLine("SwpSigAmp (MHz): " + SwpSigAmp);


            //Define Data Array for storing Fundamental
            short[] rxDataArray = new short[16384];
            double[,] outputData = new double[param.numSteps, 4];
            string[]            pcbInfo;
            AdiMath.FftAnalysis analysisData = new AdiMath.FftAnalysis();

            //Configure Signal Generator
            SG_AgilentESG sigGen = new SG_AgilentESG(measEquipment.ESGAddress);

            Console.WriteLine(sigGen.Identify());
            sigGen.SetFrequency(param.freqMin);
            sigGen.SetAmplitude(param.amplitude);
            sigGen.SetRfOutput(true);
            //Enable Mykonos Rx Datapath
            AdiCommandServerClient Link = AdiCommandServerClient.Instance;

            Link.hw.Connect(TestSetupConfig.ipAddr, TestSetupConfig.port);
            //Link.Mykonos.setEnsmState(Mykonos.ENSM_STATE.TX_RX);
            //Link.Mykonos.powerUpRxPath(channel);
            Link.Mykonos.radioOn();
            Link.Disconnect();

            //Test Sequence
            //Sweep Thru Rx Passband & Capture Data
            //Capture Received data from FPGA
            //Process Sampled Data to Determine
            //Fundemental Frequency Detected (MHz)
            //Fundamental Power of Signal (dBFS)
            //Image Power(dBFS)
            for (int i = 0; i < param.numSteps; i++)
            {
                double test_freq = param.freqMin + i * (param.freqMax - param.freqMin) / param.numSteps;
                sigGen.SetFrequency(test_freq);
                System.Threading.Thread.Sleep(100);

                rxDataArray = Helper.MykonosOrxCapture(channel, NUM_SAMPLES);

                byte     sampleBitWidth   = 16;
                double[] fftMagnitudeData = AdiMath.complexfftAndScale(rxDataArray, samplingFreq_MHz, sampleBitWidth, true, out analysisData);

                outputData[i, 0] = test_freq;
                //outputData[i, 0] = analysisData.FundamentalFrequency_MHz;
                outputData[i, 1] = analysisData.FundamentalPower_dBFS;
                outputData[i, 2] = analysisData.ImagePower_dBFS;
                outputData[i, 3] = analysisData.DcOffset_dBFS;
            }


            string path = RxRfTests.ResPath + "RxPassbandSweep";

            if (channel == Mykonos.OBSRXCHANNEL.OBS_RX1_TXLO)
            {
                path = path + "RX1";
            }
            else
            {
                path = path + "RX2";
            }
#if  WR_RES_TO_PDF
            var doc1 = new Document();
            iTextSharp.text.Image[] container = new iTextSharp.text.Image[1];
            string[] timeLabels = new string[] { "FFT Statistics versus CW Input Frequency for " + channel.ToString(),
                                                 "CW Input Frequency (MHz)",
                                                 "Amplitude (dBFS)",
                                                 "Fundamental Tone",
                                                 "Image Amplitude",
                                                 "DC Offset Amplitude" };
            pcbInfo      = Helper.PcbInfo((settings.txPllLoFreq_Hz / 1000000.0).ToString(), (settings.rxPllLoFreq_Hz / 1000000.0).ToString(), settings.mykSettings.txProfileName, settings.mykSettings.rxProfileName, "N/A", "N/A");
            container[0] = Helper.MakeChartObject(outputData, timeLabels, path);
            Helper.AddAllChartsToPdf(container, path + ".pdf", pcbInfo);

            //Open Result PDF
            System.Diagnostics.Process.Start(path + ".pdf");
#endif
#if WR_RES_TO_TXT
            // Write data to txt file
            using (System.IO.StreamWriter file = new System.IO.StreamWriter(path + ".txt"))
            {
                file.WriteLine("Sample,  Frequency MHz, Fundamental Power(dBFS), Image Power(dBFS), DC Offset(dBFS)");
                for (int i = 0; i < param.numSteps; i++)
                {
                    file.WriteLine(i + "," + outputData[i, 0].ToString() + "," + outputData[i, 1].ToString() + "," + outputData[i, 2].ToString() + "," + outputData[i, 3].ToString());
                }
            }
#endif
            //Check Min Max Fund Amplitudes are within 0.5db of each other.
            //var MinFundPower_dBFS = System.Linq.Enumerable.Range(50, 100).Select(i => outputData[i, 1]).Min();
            //var MaxFundPower_dBFS = System.Linq.Enumerable.Range(50, 100).Select(i => outputData[i, 1]).Max();
            double MinFundPower_dBFS = outputData[50, 1];
            double MaxFundPower_dBFS = outputData[50, 1];
            for (int i = 50; i < 100; i++)
            {
                if (outputData[i, 1] < MinFundPower_dBFS)
                {
                    MinFundPower_dBFS = outputData[i, 1];
                }
                if (outputData[i, 1] > MaxFundPower_dBFS)
                {
                    MaxFundPower_dBFS = outputData[i, 1];
                }
            }
            Console.WriteLine("MinFundAmp: " + MinFundPower_dBFS);
            Console.WriteLine("MaxFundAmp: " + MaxFundPower_dBFS);
            Console.WriteLine("MaxDiffFundAmp: " + (MaxFundPower_dBFS - MinFundPower_dBFS));
            NUnit.Framework.Assert.IsTrue((MaxFundPower_dBFS - MinFundPower_dBFS) <= 0.5);
        }