Example #1
0
        public static void TxTransmitTestTone([Values(20)] double offsetFreq_Mhz)
        {
            //Retrieve Profile Information, samplingFreq_Hz,  ProfileBW, LO Frequency Information
            double[] profileInfo = new double[3];

            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);

            //Calculate Test Tone And Generate
            Console.WriteLine("Tone Offset (Mhz): " + offsetFreq_Mhz);
            double testFreq_MHz  = freqTxLo_MHz + offsetFreq_Mhz;
            double offsetFreq_Hz = offsetFreq_Mhz * 1000000;

            Helper.GenerateTxTone(Mykonos.TXCHANNEL.TX1_TX2, profileInfo, offsetFreq_Hz, -15);

            //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();


            //Connect to Signal Analyser
            //The span is fixed to 50MHz
            NumberStyles  style = NumberStyles.AllowExponent | NumberStyles.Number;
            SA_AgilentPXA pxa   = new SA_AgilentPXA(measEquipment.PXAAddress);

            pxa.SetCenterSpan(freqTxLo_MHz, 50, 0);
            pxa.SetAtten(20);
            pxa.SetRefLevel(10);
            pxa.SetMarker(1, freqTxLo_MHz + offsetFreq_Mhz); //Fundemental Amplitued Marker
            double fundAmp_dB = Double.Parse(pxa.GetMarker(1), style);

            NUnit.Framework.Assert.Greater(fundAmp_dB, 5);
        }
        public static void TestPXA()
        {
            double pkAmp  = 0;
            double pkFreq = 0;

            double[] data = new double[1001];


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


            SA_AgilentPXA pxa = new SA_AgilentPXA(PXAAddress);

            Console.WriteLine(PXAAddress);
            Console.WriteLine(pxa.Identify());

            pxa.SetFreq(2600);
            pxa.SetCenterFreq(10);
            pxa.SetFreqSpan(100);
            pxa.SetRefLevel(10);
            pxa.SetAtten(20);
            pxa.SetRBW_VBW(100, 1);
            pxa.SetCenterSpan(10, 100, 0);

            pxa.MeasPeakPower(ref pkAmp, ref pkFreq);
            Console.WriteLine("Peak Amplitude = " + pkAmp);
            Console.WriteLine("Peak Frequency = " + pkFreq);

            pxa.SetMarker(1, 0);
            Console.WriteLine(pxa.GetMarker(1));

            pxa.SetDetector(SA_AgilentPXA.DetectorTypes.NORM);

            pxa.GetPlotData(out data);

            Console.WriteLine("X    Y");
            Console.WriteLine(" ");

            for (int i = 0; i < data.Length; i++)
            {
                Console.WriteLine("{0}  {1}", i, data[i]);
            }

            pxa.Close();

            Console.WriteLine("--PXA TEST FINISHED--");
        }
        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");
        }
        public static void TxLOLInitCalCheck([Values(Mykonos.TXCHANNEL.TX1, Mykonos.TXCHANNEL.TX2)] Mykonos.TXCHANNEL channel)
        {
            //Setup the calibrations
            settings.calMask = (UInt32)(Mykonos.CALMASK.TX_BB_FILTER) |
                               (UInt32)(Mykonos.CALMASK.ADC_TUNER) |
                               (UInt32)(Mykonos.CALMASK.TIA_3DB_CORNER) |
                               (UInt32)(Mykonos.CALMASK.DC_OFFSET) |
                               (UInt32)(Mykonos.CALMASK.TX_ATTENUATION_DELAY) |
                               (UInt32)(Mykonos.CALMASK.RX_GAIN_DELAY) |
                               (UInt32)(Mykonos.CALMASK.FLASH_CAL) |
                               (UInt32)(Mykonos.CALMASK.PATH_DELAY) |
                               //(UInt32)(Mykonos.CALMASK.TX_LO_LEAKAGE_INTERNAL) |
                               (UInt32)(Mykonos.CALMASK.TX_QEC_INIT) |
                               (UInt32)(Mykonos.CALMASK.LOOPBACK_RX_LO_DELAY) |
                               (UInt32)(Mykonos.CALMASK.LOOPBACK_RX_RX_QEC_INIT) |
                               (UInt32)(Mykonos.CALMASK.RX_LO_DELAY) |
                               (UInt32)(Mykonos.CALMASK.RX_QEC_INIT);
            TestSetup.TestSetupInit(settings);

            //Retrieve Profile Information, samplingFreq_Hz,  ProfileBW, LO Frequency Information
            double[] profileInfo = new double[3];
            int      backoff     = 0;
            string   boardfreq   = settings.testBoard;

            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 variables for storing Fundamental Amplitue, LoLeakage and ImageAmplitude
            double[] fundAmp      = new double[2];
            double[] LoLeakageAmp = new double[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, 100, 0);
            pxa.SetAtten(20);
            pxa.SetRefLevel(10);
            pxa.SetMarker(2, freqTxLo_MHz);

            //Config and Enable Mykonos with Test Specific Settings
            //Use Default Test Constructor
            //Start Calibration

            AdiCommandServerClient Link = AdiCommandServerClient.Instance;

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

            System.Threading.Thread.Sleep(500);
            Link.Mykonos.radioOn();
            Link.Disconnect();

            //Generate Tone and Measure Image
            double offsetFreq_Mhz = 10;
            double testFreq_MHz   = freqTxLo_MHz + offsetFreq_Mhz;
            double offsetFreq_Hz  = offsetFreq_Mhz * 1000000;

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

            //Take Measurements from PXA
            pxa.SetMarker(1, testFreq_MHz);  //Fundamental amplitue marker

            System.Threading.Thread.Sleep(500);
            fundAmp[0]      = Double.Parse(pxa.GetMarker(1), style);
            LoLeakageAmp[0] = Double.Parse(pxa.GetMarker(2), style);
            Console.WriteLine("No Init LO Leakage" + ": FundAmp: " + fundAmp[0] + ", LO Leakage:   " + LoLeakageAmp[0]);


            //Re-Initialise with TX QEC init Cal
            settings.calMask = settings.calMask | (UInt32)(Mykonos.CALMASK.TX_LO_LEAKAGE_INTERNAL);
            TestSetup.TestSetupInit(settings);
            //Turn Radio Off and
            Link = AdiCommandServerClient.Instance;
            Link.hw.Connect(TestSetupConfig.ipAddr, TestSetupConfig.port);
            Link.Mykonos.setTx1Attenuation(0);
            Link.Mykonos.radioOff();
            System.Threading.Thread.Sleep(500);



            System.Threading.Thread.Sleep(500);
            Link.Disconnect();

            //Config and Enable Mykonos with Test Specific Settings
            Link = AdiCommandServerClient.Instance;
            Link.hw.Connect(TestSetupConfig.ipAddr, TestSetupConfig.port);
            Link.Mykonos.setTx1Attenuation(0);
            Link.Mykonos.radioOn();
            Link.Disconnect();

            //Generate Tone and Measure Image
            Helper.GenerateTxTone(Mykonos.TXCHANNEL.TX1_TX2, profileInfo, offsetFreq_Hz, backoff);

            //Take Measurements from PXA
            System.Threading.Thread.Sleep(500);
            fundAmp[1]      = Double.Parse(pxa.GetMarker(1), style);
            LoLeakageAmp[1] = Double.Parse(pxa.GetMarker(2), style);
            Console.WriteLine("Init LO Leakage" + ": FundAmp: " + fundAmp[1] + ", LO Leakage:   " + LoLeakageAmp[1] + ",   " + (fundAmp[1] - LoLeakageAmp[1]) + ",   ");
            Console.WriteLine("Lo Leakage Diff:   " + (LoLeakageAmp[0] - LoLeakageAmp[1]));
            // Check that Image has reduced
            NUnit.Framework.Assert.Less(LoLeakageAmp[1], LoLeakageAmp[0]);
        }
Example #5
0
        public static void TxPassbandSweepTxNCO([Values(Mykonos.TXCHANNEL.TX1, Mykonos.TXCHANNEL.TX2)] Mykonos.TXCHANNEL channel, [Values(2500, 2500)] double deltaF_kHz)
        {
            AdiCommandServerClient Link = AdiCommandServerClient.Instance;

            Link.hw.Connect(TestSetupConfig.ipAddr, TestSetupConfig.port);
            SA_AgilentPXA pxa   = new SA_AgilentPXA(measEquipment.PXAAddress);
            NumberStyles  style = NumberStyles.AllowExponent | NumberStyles.Number;

            double spanMhz;
            int    numSteps = 0;

            double txIqDataRate_MHz     = 0;
            double freqTxLo_MHz         = 0;
            double profileBandwidth_MHz = 0;
            double toneOffsetFreq_Mhz   = 0;
            double offsetFreq_Hz        = 0;
            double testRfFreq_MHz       = 0;


            try
            {
                //Enable the Transmitter Path
                Link.Mykonos.radioOn();
                //Profile Information
                txIqDataRate_MHz     = (double)(settings.txProfileData.IqRate_kHz) / 1000;
                freqTxLo_MHz         = (double)(settings.txPllLoFreq_Hz) / 1000000;
                profileBandwidth_MHz = (double)settings.txProfileData.PrimarySigBw_Hz;

                numSteps = (int)(txIqDataRate_MHz / (deltaF_kHz / 1000.0));
                spanMhz  = txIqDataRate_MHz;
                //Define Data Array for storing Fundamental Amplitue, LoLeakage and ImageAmplitude
                double[,] fundAmpXY   = new double[numSteps, 2];
                double[,] loLeakageXY = new double[numSteps, 2];
                double[,] imageAmpXY  = new double[numSteps, 2];

                pxa.SysPreset();
                pxa.SetRBW_VBW(30, 30);
                pxa.SetCenterSpan(freqTxLo_MHz, 200, 0);
                pxa.SetAtten(20);
                pxa.SetMarker(2, freqTxLo_MHz);  //LO leakage marker

                double peakAmp_dBm  = 0;
                double peakFreq_Mhz = 0;
                double deltaF       = txIqDataRate_MHz / numSteps;

                double fundAmp   = 0;
                double loLeakage = 0;
                double imageAmp  = 0;
                Console.Write(numSteps + 1);
                for (int i = 0; (i < numSteps); i++)
                {
                    toneOffsetFreq_Mhz = (-0.5 * txIqDataRate_MHz) + ((deltaF_kHz / 1000.0) * i);

                    offsetFreq_Hz  = toneOffsetFreq_Mhz * 1000000;
                    testRfFreq_MHz = freqTxLo_MHz + offsetFreq_Hz / 1000000;

                    Link.Mykonos.enableTxNco(1, (int)(toneOffsetFreq_Mhz * 1000), (int)(toneOffsetFreq_Mhz * 1000));

                    System.Threading.Thread.Sleep(500);
                    //pxa.HoldAverage(10);
                    pxa.MeasPeakPower(ref peakAmp_dBm, ref peakFreq_Mhz);

                    //Set PXA Markers
                    /* for this to work, NCO freq set must be rastered to its actual frequency in the chip */
                    //pxa.SetMarker(3, freqTxLo_MHz - (freqTxLo_MHz - peakFreq_Mhz)); //Image marker
                    //pxa.SetMarker(1, testRfFreq_MHz); //Fundamental amplitue marker

                    //fundAmp = Double.Parse(pxa.GetMarker(1), style);
                    //loLeakage = Double.Parse(pxa.GetMarker(2), style);
                    //imageAmp = Double.Parse(pxa.GetMarker(3), style);

                    //TODO: Marker 3 does not always sit on the image, sometimes its off a bin or so and measures incorrectly.
                    pxa.SetMarker(3, (freqTxLo_MHz - ((peakFreq_Mhz / 1000000.0) - freqTxLo_MHz)));  //Image marker

                    fundAmp   = peakAmp_dBm;
                    loLeakage = Double.Parse(pxa.GetMarker(2), style);
                    imageAmp  = Double.Parse(pxa.GetMarker(3), style);

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

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

                    imageAmpXY[i, 0] = toneOffsetFreq_Mhz;
                    imageAmpXY[i, 1] = imageAmp;
                    if ((toneOffsetFreq_Mhz > -1) && (toneOffsetFreq_Mhz < 1))
                    {
                        Console.WriteLine("Bypass:"******"Fundamental Amplitude (dBm)" + i + ": " + toneOffsetFreq_Mhz + ": " + fundAmp);
                    Console.WriteLine("LO Leakage (dBm)" + toneOffsetFreq_Mhz + ": " + loLeakage);
                    Console.WriteLine("Image Amplitude (dBm)" + toneOffsetFreq_Mhz + ": " + imageAmp);
                    Console.WriteLine("Image Amplitude (dBc)" + toneOffsetFreq_Mhz + ": " + (fundAmp - imageAmp));
#endif
                }
                Link.Disconnect();
                //Graph Data and Save in PDF Form
                var      doc1 = new Document();
                string   path = TxRfTests.ResPath + "TxPassbandSweepTxNco";
                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();
                Console.Write(fundAmpXY[48, 0]);
                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");

                //Check Min Max Fund Amplitudes are within +/-0.5db of each other.
                var MinFundAmp = System.Linq.Enumerable.Range(15, 30).Select(i => fundAmpXY[i, 1]).Min();
                var MaxFundAmp = System.Linq.Enumerable.Range(15, 30).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);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
Example #6
0
        public static void TxAttenuationSweep([Values(Mykonos.TXCHANNEL.TX1, Mykonos.TXCHANNEL.TX2)] Mykonos.TXCHANNEL channel)
        {
            int atten   = 0;
            int backoff = 0;

            //Retrieve Profile Information, samplingFreq_Hz,  ProfileBW, LO Frequency Information
            double[] profileInfo = new double[3];
            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);

            //Configure Tone Generator
            //10MHz offset tone generation
            double offsetFreq_Hz = 10000000;

            double[,] fundAmpXY = new double[42, 2];
            Helper.GenerateTxTone(Mykonos.TXCHANNEL.TX1_TX2, profileInfo, offsetFreq_Hz, backoff);

            //Connect to Signal Analyser
            //The span is fixed to 50MHz
            NumberStyles  style = NumberStyles.AllowExponent | NumberStyles.Number;
            SA_AgilentPXA pxa   = new SA_AgilentPXA(measEquipment.PXAAddress);

            pxa.SetCenterSpan(freqTxLo_MHz, 50, 0);
            pxa.SetAtten(20);
            pxa.SetRefLevel(10);
            pxa.SetMarker(1, freqTxLo_MHz + 10);                        //Fundemental Amplitued Marker
            pxa.SetMarker(2, freqTxLo_MHz);                             //LO Leakage Marker
            pxa.SetMarker(3, freqTxLo_MHz - (offsetFreq_Hz / 1000000)); //Image Amplitude marker

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

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

            //Test Sequence
            //Iterate Thru Tx Attenuation Settings
            //Measure Amplitude of the fundamental
            //TODO: 0 to 41950
            int    step          = 0;
            double fundAmp_dB    = 0;
            double minAttnVal_dB = 0;
            double maxAttnVal_dB = 41.95;

            for (double attenVal_dB = minAttnVal_dB; (attenVal_dB < maxAttnVal_dB); attenVal_dB += 1)
            {
                try
                {
                    if (channel == Mykonos.TXCHANNEL.TX1)
                    {
                        Link.Mykonos.setTx1Attenuation(attenVal_dB);
                    }
                    if (channel == Mykonos.TXCHANNEL.TX2)
                    {
                        Link.Mykonos.setTx2Attenuation(attenVal_dB);
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    break;
                }

                pxa.HoldAverage();
                System.Threading.Thread.Sleep(500);

                fundAmp_dB         = Double.Parse(pxa.GetMarker(1), style);
                fundAmpXY[step, 1] = fundAmp_dB;
                fundAmpXY[step, 0] = attenVal_dB;
                step++;
#if WR_RES_TO_CONSOLE
                Console.WriteLine("Fundamental Amplitude, Attenuation Value " + attenVal_dB + ": " + fundAmp_dB);
#endif
            }
            Link.Disconnect();
#if WR_RES_TO_PDF
            //Graph Data and Save in PDF Form
            var      doc1 = new Document();
            string   path = TxRfTests.ResPath + "TxAttenuationSweep";
            string[] pcbInfo;
            iTextSharp.text.Image[] container = new iTextSharp.text.Image[1];
            string[] fundAmpLabels            = new string[] { "Fundamental Amplitude Versus Offset Tone Frequency (from LO)",
                                                               "setTxAtten Argument",
                                                               "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());

            container[0] = Helper.MakeChartObject(fundAmpXY, fundAmpLabels, path);
            TxRfTests instance = new TxRfTests();
            Helper.AddAllChartsToPdf(container, path + ".pdf", pcbInfo);

            //Open Result PDF
            System.Diagnostics.Process.Start(path + ".pdf");
#endif
        }
Example #7
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);
        }
Example #8
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
        }