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