/// <summary> /// This example illustrates how to use the RFmxLTE APIs to configure the analyzer to perform a ModAcc measurement. /// You can use the Generator Basic example to generate the LTE signal before running this example. /// </summary> static void Main(string[] args) { Console.WriteLine("\n----------------------- LTE Analyzer Example -----------------------\n"); double centerFrequency = 3.5e9; //Hz string resourceName = "5840"; string signalString = "Signal0"; string resultString = "Result0"; SA.RFmxInstr.InstrumentConfiguration saInstrConfig; SA.CommonConfiguration saCommonConfig; SA.AutoLevelConfiguration saAutolevelConfig; SA.RFmxLTE.StandardConfiguration StandardConfigLte; SA.RFmxLTE.ModAccConfiguration ModaccConfigLte; SA.RFmxLTE.ModAccResults ModaccResultsLte = new ModAccResults(); //Analyzer Configuration Console.WriteLine("Configure...\n"); saInstrConfig = SA.RFmxInstr.InstrumentConfiguration.GetDefault(); saCommonConfig = SA.CommonConfiguration.GetDefault(); saCommonConfig.ExternalAttenuation_dB = 0; saCommonConfig.CenterFrequency_Hz = centerFrequency; saCommonConfig.ReferenceLevel_dBm = 0.0; saAutolevelConfig = SA.AutoLevelConfiguration.GetDefault(); saAutolevelConfig.Enabled = true; StandardConfigLte = SA.RFmxLTE.StandardConfiguration.GetDefault(); StandardConfigLte.AutoDmrsDetectionEnabled = RFmxLteMXAutoDmrsDetectionEnabled.True; StandardConfigLte.ComponentCarrierConfigurations[0].Bandwidth_Hz = 20.0e6; ModaccConfigLte = SA.RFmxLTE.ModAccConfiguration.GetDefault(); #region Configure Analyzer saAutolevelConfig.MeasurementInterval_s = 0.001; RFmxInstrMX instr = new RFmxInstrMX(resourceName, ""); SA.RFmxInstr.ConfigureInstrument(instr, saInstrConfig); RFmxLteMX lte = instr.GetLteSignalConfiguration(signalString); SA.RFmxLTE.ConfigureCommon(lte, saCommonConfig); SA.RFmxLTE.ConfigureStandard(lte, StandardConfigLte); #endregion #region Measure Console.WriteLine("Measure...\n"); ConfigureModAcc(lte, ModaccConfigLte); RFmxLteMXMeasurementTypes[] lteMeasurements = new RFmxLteMXMeasurementTypes[1] { RFmxLteMXMeasurementTypes.ModAcc }; SA.RFmxLTE.SelectAndInitiateMeasurements(lte, lteMeasurements, saAutolevelConfig, false, "", resultString); ModaccResultsLte = FetchModAcc(lte, RFmxLteMX.BuildResultString(resultString)); //print Results for (int i = 0; i < ModaccResultsLte.ComponentCarrierResults.Length; i++) { Console.WriteLine("----------------------- EVM Results CC {0} -----------------------\n", i); Console.WriteLine("Composite RMS EVM Mean (% or dB) : {0:0.000}", ModaccResultsLte.ComponentCarrierResults[i].MeanRmsCompositeEvm); Console.WriteLine("Composite Peak EVM Maximum (% or dB) : {0:0.000}", ModaccResultsLte.ComponentCarrierResults[i].MaxPeakCompositeEvm); Console.WriteLine("Composite Peak EVM Slot Index : {0}", ModaccResultsLte.ComponentCarrierResults[i].PeakCompositeEvmSlotIndex); Console.WriteLine("Composite Peak EVM Symbol Index : {0}", ModaccResultsLte.ComponentCarrierResults[i].PeakCompositeEvmSymbolIndex); Console.WriteLine("Composite Peak EVM Subcarrier Index : {0}", ModaccResultsLte.ComponentCarrierResults[i].PeakCompositeEvmSubcarrierIndex); Console.WriteLine("Component Carrier Frequency Error Mean (Hz) : {0:0.000}", ModaccResultsLte.ComponentCarrierResults[i].MeanFrequencyError_Hz); } #endregion lte.Dispose(); instr.Close(); Console.WriteLine("Please press any key to close the application.\n"); Console.ReadKey(); }
public void Run() { #region Create Sessions NIRfsg nIRfsg = new NIRfsg(resourceName, false, false); RFmxInstrMX instr = new RFmxInstrMX(resourceName, ""); RFmxSpecAnMX specAn = instr.GetSpecAnSignalConfiguration(signalStringSpecan); RFmxLteMX lte = instr.GetLteSignalConfiguration(signalStringLte); #endregion #region Configure Generation ConfigureInstrument(nIRfsg, SgInstrConfig); Waveform waveform = LoadWaveformFromTDMS(filePath); // Apply CRF to the waveform if it is enabled waveform = Methods.RFmxDPD.ConfigurePreDpdCrestFactorReduction(specAn, waveform, preDpdCrestFactorReductionConfig); DownloadWaveform(nIRfsg, waveform); ConfigureContinuousGeneration(nIRfsg, waveform); nIRfsg.Initiate(); #endregion #region Configure Analyzer saAutolevelConfig.MeasurementInterval_s = waveform.BurstLength_s; SA.RFmxInstr.ConfigureInstrument(instr, saInstrConfig); SA.RFmxSpecAn.ConfigureCommon(specAn, saCommonConfig); AmpmConfigurationSpecAn.ReferenceWaveform = waveform; AmpmConfigurationSpecAn.DutAverageInputPower_dBm = SgInstrConfig.DutAverageInputPower_dBm; SA.RFmxSpecAn.ConfigureAmpm(specAn, AmpmConfigurationSpecAn); SA.RFmxLTE.ConfigureCommon(lte, saCommonConfig); SA.RFmxLTE.ConfigureStandard(lte, StandardConfigLte); #endregion #region Configure and Measure DPD if (EnableDpd) { Methods.RFmxDPD.ConfigureCommon(specAn, CommonConfigurationDpd, waveform); Methods.RFmxDPD.ConfigureMemoryPolynomial(specAn, MemoryPolynomialConfiguration); Methods.RFmxDPD.ConfigureApplyDpdCrestFactorReduction(specAn, applyDpdCrestFactorReductionConfig); Console.WriteLine("\n--------------- Measurement Results with DPD --------------\n"); specAn.SelectMeasurements("", RFmxSpecAnMXMeasurementTypes.Dpd, true); Methods.RFmxDPD.PerformMemoryPolynomial(specAn, nIRfsg, MemoryPolynomialConfiguration, waveform); } else { Console.WriteLine("\n------------- Measurement Results without DPD -------------\n"); } #endregion #region Measure RFmxSpecAnMXMeasurementTypes[] specanMeasurements = new RFmxSpecAnMXMeasurementTypes[1] { RFmxSpecAnMXMeasurementTypes.Ampm }; SA.RFmxSpecAn.SelectAndInitiateMeasurements(specAn, specanMeasurements, saAutolevelConfig, waveform.SignalBandwidth_Hz, false, "", resultStringSpecan); AmpmResultsSpecAn = SA.RFmxSpecAn.FetchAmpm(specAn, RFmxSpecAnMX.BuildResultString(resultStringSpecan)); PrintAMPMResults(); ConfigureAcp(lte, AcpConfigLte); RFmxLteMXMeasurementTypes[] lteMeasurements = new RFmxLteMXMeasurementTypes[1] { RFmxLteMXMeasurementTypes.Acp }; SA.RFmxLTE.SelectAndInitiateMeasurements(lte, lteMeasurements, saAutolevelConfig, false, "", resultStringLte); AcpResultsLte = FetchAcp(lte, RFmxLteMX.BuildResultString(resultStringLte)); PrintACPResults(); ConfigureModAcc(lte, ModaccConfigLte); lteMeasurements[0] = RFmxLteMXMeasurementTypes.ModAcc; SA.RFmxLTE.SelectAndInitiateMeasurements(lte, lteMeasurements, saAutolevelConfig, false, "", resultStringLte); ModaccResultsLte = FetchModAcc(lte, RFmxLteMX.BuildResultString(resultStringLte)); PrintModAccResults(); #endregion specAn.Dispose(); specAn = null; lte.Dispose(); instr.Close(); AbortGeneration(nIRfsg); CloseInstrument(nIRfsg); }
static void LoadAndRunMeasurements(string instrName, string inputPath, string outputPath) { inputPath = Path.GetFullPath(inputPath); RFmxInstrMX instr = null; NIRfsa rfsa = null; IntPtr rfsaHandle; try { Console.WriteLine($"Initializing RFmx session with instrument \"{instrName}\"..."); instr = new RFmxInstrMX(instrName, ""); Console.WriteLine($"Loading configuration from \"{Path.GetFileName(inputPath)}\"..."); instr.LoadAllConfigurations(inputPath, true); instr.DangerousGetNIRfsaHandle(out rfsaHandle); rfsa = new NIRfsa(rfsaHandle); string[] signalNames = new string[0]; RFmxInstrMXPersonalities[] personalities = new RFmxInstrMXPersonalities[0]; Console.WriteLine("Configuration loaded successfully."); instr.GetSignalConfigurationNames("", RFmxInstrMXPersonalities.All, ref signalNames, ref personalities); for (int i = 0; i < signalNames.Length; i++) { Console.WriteLine(""); ConsoleKeyInfo info; switch (personalities[i]) { case RFmxInstrMXPersonalities.BT: RFmxBTMX bt = instr.GetBTSignalConfiguration(signalNames[i]); Console.WriteLine($"Enter 'y' to initiate acquisition for RFmx Bluetooth with signal \"{signalNames[i]}\"; any other key to skip."); info = Console.ReadKey(); Console.WriteLine(); if (info.KeyChar == 'y') { bt.Initiate("", ""); bt.WaitForMeasurementComplete("", 10); FetchAndLog(rfsa, personalities[i], signalNames[i], outputPath); } bt.Dispose(); break; case RFmxInstrMXPersonalities.Wlan: RFmxWlanMX wlan = instr.GetWlanSignalConfiguration(signalNames[i]); Console.WriteLine($"Enter 'y' to initiate acquisition for RFmx WLAN with signal \"{signalNames[i]}\"; any other key to skip."); info = Console.ReadKey(); Console.WriteLine(); if (info.KeyChar == 'y') { wlan.Initiate("", ""); wlan.WaitForMeasurementComplete("", 10); FetchAndLog(rfsa, personalities[i], signalNames[i], outputPath); } wlan.Dispose(); break; case RFmxInstrMXPersonalities.SpecAn: RFmxSpecAnMX specAn = instr.GetSpecAnSignalConfiguration(signalNames[i]); Console.WriteLine($"Enter 'y' to initiate acquisition for RFmx SpecAn with signal \"{signalNames[i]}\"; any other key to skip."); info = Console.ReadKey(); Console.WriteLine(); if (info.KeyChar == 'y') { specAn.Initiate("", ""); specAn.WaitForMeasurementComplete("", 10); FetchAndLog(rfsa, personalities[i], signalNames[i], outputPath); } specAn.Dispose(); break; case RFmxInstrMXPersonalities.NR: RFmxNRMX nr = instr.GetNRSignalConfiguration(signalNames[i]); Console.WriteLine($"Enter 'y' to initiate acquisition for RFmx NR with signal \"{signalNames[i]}\"; any other key to skip."); info = Console.ReadKey(); Console.WriteLine(); if (info.KeyChar == 'y') { nr.Initiate("", ""); nr.WaitForMeasurementComplete("", 10); FetchAndLog(rfsa, personalities[i], signalNames[i], outputPath); } nr.Dispose(); break; case RFmxInstrMXPersonalities.Lte: RFmxLteMX lte = instr.GetLteSignalConfiguration(signalNames[i]); Console.WriteLine($"Enter 'y' to initiate acquisition for RFmx LTE with signal \"{signalNames[i]}\"; any other key to skip."); info = Console.ReadKey(); Console.WriteLine(); if (info.KeyChar == 'y') { lte.Initiate("", ""); lte.WaitForMeasurementComplete("", 10); FetchAndLog(rfsa, personalities[i], signalNames[i], outputPath); } lte.Dispose(); break; default: throw new System.NotImplementedException($"The \"{personalities[i].ToString()}\" personality has not been implemented."); } } Console.WriteLine("All measurements complete."); } catch (Exception ex) { Console.WriteLine("Exception occurred: " + ex.Message); Console.WriteLine("Location: " + ex.StackTrace); } finally { if (instr != null) { instr.Dispose(); } } }