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