/// <summary>Applies common instrument settings to the analyzer.</summary>
 /// <param name="instrHandle">The open RFmx Instr session to configure.</param>
 /// <param name="instrConfig">The instrument configuration properties to apply.</param>
 public static void ConfigureInstrument(RFmxInstrMX instrHandle, InstrumentConfiguration instrConfig)
 {
     instrHandle.SetFrequencyReferenceSource("", instrConfig.FrequencyReferenceSource);
     instrHandle.GetInstrumentModel("", out string model);
     // Only configure LO settings on supported VSTs
     if (Regex.IsMatch(model, "NI PXIe-58[34].")) // Matches 583x and 584x VST families
     {
         if (instrConfig.LOSharingMode == LocalOscillatorSharingMode.None)
         {
             instrHandle.ConfigureAutomaticSGSASharedLO("", RFmxInstrMXAutomaticSGSASharedLO.Disabled);
         }
         else
         {
             instrHandle.ConfigureAutomaticSGSASharedLO("", RFmxInstrMXAutomaticSGSASharedLO.Enabled);
             // Configure automatic LO offsetting
             instrHandle.SetLOLeakageAvoidanceEnabled("", RFmxInstrMXLOLeakageAvoidanceEnabled.True);
             instrHandle.ResetAttribute("", RFmxInstrMXPropertyId.DownconverterFrequencyOffset);
         }
     }
 }
Exemplo n.º 2
0
        public static void ConfigureCommon(ref RFmxInstrMX sessionHandle, ref RFmxSpecAnMX specAnSignal, CommonConfiguration commonConfig,
                                           AutoLevelConfiguration autoLevelConfig, string selectorString = "")
        {
            sessionHandle.ConfigureFrequencyReference("", commonConfig.FrequencyReferenceSource, 10e6);
            sessionHandle.SetLOSource("", commonConfig.LOSource);
            sessionHandle.SetDownconverterFrequencyOffset("", commonConfig.LOOffset);
            specAnSignal.ConfigureDigitalEdgeTrigger(selectorString, commonConfig.DigitalEdgeSource, commonConfig.DigitalEdgeType, commonConfig.TriggerDelay_s, commonConfig.EnableTrigger);
            specAnSignal.ConfigureFrequency(selectorString, commonConfig.CenterFrequency_Hz);
            specAnSignal.Spectrum.Configuration.ConfigureSpan(selectorString, commonConfig.Span_Hz);
            specAnSignal.ConfigureExternalAttenuation(selectorString, commonConfig.ExternalAttenuation_dB);

            if (autoLevelConfig.AutoLevelReferenceLevel)
            {
                specAnSignal.AutoLevel(selectorString, commonConfig.Span_Hz, autoLevelConfig.AutoLevelMeasureTime_s, out _);
            }
            else
            {
                specAnSignal.ConfigureReferenceLevel(selectorString, commonConfig.ReferenceLevel_dBm);
            }
        }
        void StartGeneration()
        {
            //bool isMeasurementComplete = false;
            Tuple <double[], double[]> measurements;
            decimal amp;
            decimal phase;

            try
            {
                instr        = new RFmxInstrMX(rfsaNameComboBox.SelectedItem.ToString(), "AnalysisOnly=1");
                _rfsgSession = new NIRfsg(rfsgNameComboBox.SelectedItem.ToString(), false, true);

                SimulatedSteppedBeamformer simulatedSteppedBF = new SimulatedSteppedBeamformer(_rfsgSession, (double)frequencyNumeric.Value, (double)powerLevelNumeric.Value);
                simulatedSteppedBF.Connect();

                PAVTMeasurement measurement = new PAVTMeasurement(instr);
                measurement.StartMeasurement(offsets.Count, (double)frequencyNumeric.Value, (double)powerLevelNumeric.Value, (double)measurementOffsetNumeric.Value / 1000000, (double)measurementLengthNumeric.Value / 1000000);
                //measurement will occur after each trigger is sent from Beamformer

                for (int i = 0; i < offsets.Count; i++)
                {
                    simulatedSteppedBF.LoadOffset(offsets[i]); // set phase offset and power level
                    _rfsgSession.Triggers.                     //send a software trigger

                    //ComplexWaveform<ComplexDouble> IQData = simulatedSteppedBF.createWaveform(offsets); //creates complex waveform data
                    //simulatedSteppedBF.writeWaveform(IQData); //generate waveform
                }


                simulatedSteppedBF.Disconnect();
                measurements = measurement.GetMeasurements();
                phase        = Convert.ToDecimal(measurements.Item1);
                amp          = Convert.ToDecimal(measurements.Item2);
                PhaseAmplitudeOffset newValues = new PhaseAmplitudeOffset(phase, amp);
                lsvResults.Items.Add(CreateListViewItem(newValues)); // add results to results listview
            }
            catch (Exception ex)
            {
                ShowError("StartGeneration()", ex);
            }
        }
Exemplo n.º 4
0
        public void TestOfflineAnalysisSingleCarrierTdd()
        {
            RFmxInstrMX instr = new RFmxInstrMX("", "AnalysisOnly=1");
            RFmxLteMX   lte   = instr.GetLteSignalConfiguration();

            ConfigureCommon(lte, CommonConfiguration.GetDefault());
            StandardConfiguration signalConfig = StandardConfiguration.GetDefault();

            signalConfig.DuplexScheme = RFmxLteMXDuplexScheme.Tdd;
            ConfigureStandard(lte, signalConfig);
            ModAccConfiguration modAccConfig = ModAccConfiguration.GetDefault();

            modAccConfig.MeasurementOffset = 4;
            ConfigureModAcc(lte, modAccConfig);

            lte.Commit("");

            instr.GetRecommendedIQPreTriggerTime("", out double pretriggerTime);
            PrecisionTimeSpan timeOffset = new PrecisionTimeSpan(-pretriggerTime);

            Waveform wfm = LoadWaveformFromTDMS(@"Support Files\LTE_TDD_2.0.tdms");

            Buffer <ComplexSingle>         readBuffer  = wfm.Data.GetBuffer(true);
            WritableBuffer <ComplexSingle> writeBuffer = wfm.Data.GetWritableBuffer();

            int sampleOffset = (int)Math.Round(pretriggerTime * wfm.SampleRate);

            for (int i = 0; i < readBuffer.Size; i++)
            {
                writeBuffer[i] = readBuffer[(i - sampleOffset + readBuffer.Size) % readBuffer.Size];
            }
            wfm.Data.PrecisionTiming = PrecisionWaveformTiming.CreateWithRegularInterval(
                wfm.Data.PrecisionTiming.SampleInterval, timeOffset);

            lte.AnalyzeIQ("", "", wfm.Data, true, out _);
            ModAccResults modAccResults = FetchModAcc(lte);

            instr.Close();

            Assert.IsTrue(modAccResults.ComponentCarrierResults[0].MeanRmsCompositeEvm < 0.001);
        }
Exemplo n.º 5
0
        private void CloseSession()
        {
            try
            {
                if (specAn != null)
                {
                    specAn.Dispose();
                    specAn = null;
                }

                if (instrSession != null)
                {
                    instrSession.Close();
                    instrSession = null;
                }
            }
            catch (Exception ex)
            {
                DisplayError(ex);
            }
        }
Exemplo n.º 6
0
        public static void ConfigureCommon(RFmxInstrMX sessionHandle, RFmxWlanMX wlanSignal, CommonConfiguration commonConfig,
                                           AutoLevelConfiguration autoLevelConfig, string selectorString = "")
        {
            string instrModel;

            sessionHandle.ConfigureFrequencyReference("", commonConfig.FrequencyReferenceSource, 10e6);
            sessionHandle.GetInstrumentModel("", out instrModel);

            sessionHandle.SetLOSource("", commonConfig.LOSource);
            sessionHandle.SetDownconverterFrequencyOffset("", commonConfig.LOOffset);

            wlanSignal.ConfigureDigitalEdgeTrigger(selectorString, commonConfig.DigitalEdgeSource, commonConfig.DigitalEdgeType, commonConfig.TriggerDelay_s, commonConfig.EnableTrigger);
            wlanSignal.ConfigureFrequency(selectorString, commonConfig.CenterFrequency_Hz);
            wlanSignal.ConfigureExternalAttenuation(selectorString, commonConfig.ExternalAttenuation_dB);

            if (autoLevelConfig.AutoLevelReferenceLevel)
            {
                wlanSignal.AutoLevel(selectorString, autoLevelConfig.AutoLevelMeasureTime_s);
            }
            else
            {
                wlanSignal.ConfigureReferenceLevel(selectorString, commonConfig.ReferenceLevel_dBm);
            }
        }
        public void Run()
        {
            #region Create Sessions
            NIRfsg       nIRfsg = new NIRfsg(resourceName, false, false);
            RFmxInstrMX  instr  = new RFmxInstrMX(resourceName, "");
            RFmxSpecAnMX specAn = instr.GetSpecAnSignalConfiguration(signalStringSpecan);
            RFmxWlanMX   wlan   = instr.GetWlanSignalConfiguration(signalStringWlan);
            #endregion

            #region Configure Generation
            ConfigureInstrument(nIRfsg, sgInstrConfig);
            Waveform waveform = LoadWaveformFromTDMS(filePath);
            DownloadWaveform(nIRfsg, waveform);
            ConfigureBurstedGeneration(nIRfsg, waveform, paEnableTiming, paenConfig, out double period, out _);

            nIRfsg.Initiate();
            #endregion

            #region Configure Analyzer
            saAutolevelConfig.MeasurementInterval_s = period;
            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.RFmxWLAN.ConfigureCommon(wlan, saCommonConfig);
            SA.RFmxWLAN.ConfigureStandard(wlan, wlanStandardConfig);

            SA.RFmxWLAN.ConfigureOFDMModAcc(wlan, modAccConfig);
            SA.RFmxWLAN.ConfigureSEM(wlan, semConfig);
            #endregion

            #region Measure SpecAn
            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();
            #endregion

            #region WLAN measure and results
            RFmxWlanMXMeasurementTypes[] wlanMeasurements = new RFmxWlanMXMeasurementTypes[1] {
                RFmxWlanMXMeasurementTypes.OfdmModAcc
            };
            SA.RFmxWLAN.SelectAndInitiateMeasurements(wlan, wlanMeasurements, saAutolevelConfig, false, "", resultStringWlan);
            modAccResults = SA.RFmxWLAN.FetchOFDMModAcc(wlan, RFmxWlanMX.BuildResultString(resultStringWlan));
            PrintModAccResults();

            wlanMeasurements[0] = RFmxWlanMXMeasurementTypes.Sem;
            SA.RFmxWLAN.SelectAndInitiateMeasurements(wlan, wlanMeasurements, saAutolevelConfig, false, "", resultStringWlan);
            semResults = SA.RFmxWLAN.FetchSEM(wlan, RFmxWlanMX.BuildResultString(resultStringWlan));
            PrintSemResults();
            #endregion

            AbortGeneration(nIRfsg);
            CloseInstrument(nIRfsg);
            wlan.Dispose();
            wlan = null;
            instr.Close();
            instr = null;
        }
        /// <summary>
        /// This example illustrates how to use the RFmxNR APIs to configure the analyzer to perform a ModAcc measurement.
        /// You can use the Generator Basic example to generate the NR signal before running this example.
        /// </summary>
        static void Main(string[] args)
        {
            Console.WriteLine("\n----------------------- 5GNR 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.RFmxNR.StandardConfiguration StandardConfigNR;
            SA.RFmxNR.ModAccConfiguration   ModaccConfigNR;
            SA.RFmxNR.ModAccResults         ModaccResultsNR = new ModAccResults();

            //Analyzer Configuration
            Console.WriteLine("Configure...\n");
            saInstrConfig  = SA.RFmxInstr.InstrumentConfiguration.GetDefault();
            saCommonConfig = saCommonConfig = SA.CommonConfiguration.GetDefault();
            saCommonConfig.ExternalAttenuation_dB = 0;
            saCommonConfig.CenterFrequency_Hz     = centerFrequency;
            saCommonConfig.ReferenceLevel_dBm     = 0.0;
            saAutolevelConfig         = SA.AutoLevelConfiguration.GetDefault();
            saAutolevelConfig.Enabled = true;
            StandardConfigNR          = SA.RFmxNR.StandardConfiguration.GetDefault();
            StandardConfigNR.ComponentCarrierConfigurations[0].PuschModulationType = RFmxNRMXPuschModulationType.Qpsk;
            ModaccConfigNR = SA.RFmxNR.ModAccConfiguration.GetDefault();

            #region Configure Analyzer
            saAutolevelConfig.MeasurementInterval_s = 0.001;
            RFmxInstrMX instr = new RFmxInstrMX(resourceName, "");
            SA.RFmxInstr.ConfigureInstrument(instr, saInstrConfig);
            RFmxNRMX nr = instr.GetNRSignalConfiguration(signalString);
            SA.RFmxNR.ConfigureCommon(nr, saCommonConfig);
            SA.RFmxNR.ConfigureStandard(nr, StandardConfigNR);
            #endregion

            #region Measure
            Console.WriteLine("Measure...\n");
            ConfigureModacc(nr, ModaccConfigNR);
            RFmxNRMXMeasurementTypes[] nrMeasurements = new RFmxNRMXMeasurementTypes[1] {
                RFmxNRMXMeasurementTypes.ModAcc
            };
            SA.RFmxNR.SelectAndInitiateMeasurements(nr, nrMeasurements, saAutolevelConfig, false, "", resultString);
            ModaccResultsNR = FetchModAcc(nr, RFmxNRMX.BuildResultString(resultString));
            //print Results
            for (int i = 0; i < ModaccResultsNR.ComponentCarrierResults.Length; i++)
            {
                Console.WriteLine("----------------------- EVM Results CC {0} -----------------------\n", i);
                Console.WriteLine("Composite RMS EVM Mean (% or dB)               : {0:0.000}", ModaccResultsNR.ComponentCarrierResults[i].MeanRmsCompositeEvm);
                Console.WriteLine("Composite Peak EVM Maximum (% or dB)           : {0:0.000}", ModaccResultsNR.ComponentCarrierResults[i].MaxPeakCompositeEvm);
                Console.WriteLine("Composite Peak EVM Slot Index                  : {0}", ModaccResultsNR.ComponentCarrierResults[i].PeakCompositeEvmSlotIndex);
                Console.WriteLine("Composite Peak EVM Symbol Index                : {0}", ModaccResultsNR.ComponentCarrierResults[i].PeakCompositeEvmSymbolIndex);
                Console.WriteLine("Composite Peak EVM Subcarrier Index            : {0}", ModaccResultsNR.ComponentCarrierResults[i].PeakCompositeEvmSubcarrierIndex);
                Console.WriteLine("Component Carrier Frequency Error Mean (Hz)    : {0:0.000}", ModaccResultsNR.ComponentCarrierResults[i].MeanFrequencyError_Hz);
            }
            #endregion
            nr.Dispose();
            instr.Close();
            Console.WriteLine("Please press any key to close the application.\n");
            Console.ReadKey();
        }
Exemplo n.º 9
0
 public void InitializeInstr()
 {
     instrSession = new RFmxInstrMX("", "AnalysisOnly=1");  // takes 10ms, move out of here
     //instrSession = new RFmxInstrMX(rfsaResourceName, "");
 }
Exemplo n.º 10
0
 private void FindAndOpenTransceiverSessionsWithAssertion(string model, out NIRfsg rfsg, out RFmxInstrMX instr)
 {
     if (!FindDevice(model, out string resourceName))
     {
         Assert.Inconclusive("No device found.");
     }
     OpenTransceiverSessions(resourceName, out rfsg, out instr);
 }
Exemplo n.º 11
0
 private void CloseTransceiverSessions(NIRfsg rfsg, RFmxInstrMX instr)
 {
     rfsg?.Close();
     instr?.Close();
 }
Exemplo n.º 12
0
        public void Run()
        {
            #region Create Sessions
            NIRfsg       nIRfsg = new NIRfsg(resourceName, false, false);
            RFmxInstrMX  instr  = new RFmxInstrMX(resourceName, "");
            RFmxSpecAnMX specAn = instr.GetSpecAnSignalConfiguration(signalStringSpecan);
            RFmxWlanMX   wlan   = instr.GetWlanSignalConfiguration(signalStringWlan);
            #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);

            var waveformLength_s = waveform.Data.SampleCount / waveform.SampleRate;

            nIRfsg.Initiate();
            #endregion

            #region configure Analyzer
            saAutolevelConfig.MeasurementInterval_s = waveform.BurstLength_s;

            SA.RFmxInstr.ConfigureInstrument(instr, saInstrConfig);
            SA.RFmxSpecAn.ConfigureCommon(specAn, saCommonConfig);
            SA.RFmxWLAN.ConfigureCommon(wlan, saCommonConfig);
            #endregion

            #region Configure SpecAn
            ampmConfigurationSpecAn.ReferenceWaveform        = waveform;
            ampmConfigurationSpecAn.DutAverageInputPower_dBm = sgInstrConfig.DutAverageInputPower_dBm;
            SA.RFmxSpecAn.ConfigureAmpm(specAn, ampmConfigurationSpecAn);
            #endregion

            #region Configure WLAN Measurement
            SA.RFmxWLAN.ConfigureStandard(wlan, wlanStandardConfig);
            SA.RFmxWLAN.ConfigureOFDMModAcc(wlan, modAccConfig);
            SA.RFmxWLAN.ConfigureSEM(wlan, semConfig);
            #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------------------------ Perform DPD ----------------------\n");

                specAn.SelectMeasurements("", RFmxSpecAnMXMeasurementTypes.Dpd, true);
                Methods.RFmxDPD.PerformMemoryPolynomial(specAn, nIRfsg, memoryPolynomialConfiguration, waveform);
                Console.WriteLine("\n------------------------ DPD done --------------------------\n");
            }
            #endregion

            #region Measure SpecAn
            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();
            #endregion

            #region measure and results
            RFmxWlanMXMeasurementTypes[] wlanMeasurements = new RFmxWlanMXMeasurementTypes[1] {
                RFmxWlanMXMeasurementTypes.OfdmModAcc
            };
            SA.RFmxWLAN.SelectAndInitiateMeasurements(wlan, wlanMeasurements, saAutolevelConfig, false, "", resultStringWlan);
            modAccResults = SA.RFmxWLAN.FetchOFDMModAcc(wlan, RFmxWlanMX.BuildResultString(resultStringWlan));
            PrintModAccResults();

            wlanMeasurements[0] = RFmxWlanMXMeasurementTypes.Sem;
            SA.RFmxWLAN.SelectAndInitiateMeasurements(wlan, wlanMeasurements, saAutolevelConfig, false, "", resultStringWlan);
            semResults = SA.RFmxWLAN.FetchSEM(wlan, RFmxWlanMX.BuildResultString(resultStringWlan));
            PrintSemResults();
            #endregion

            AbortGeneration(nIRfsg);
            CloseInstrument(nIRfsg);
            wlan.Dispose();
            wlan = null;
            instr.Close();
            instr = null;
        }
Exemplo n.º 13
0
 private void OpenTransceiverSessions(string resourceName, out NIRfsg rfsg, out RFmxInstrMX instr)
 {
     rfsg  = new NIRfsg(resourceName, false, true);
     instr = new RFmxInstrMX(resourceName, "");
 }
Exemplo n.º 14
0
        public void Run()
        {
            #region Create Sessions
            NIRfsg       nIRfsg = new NIRfsg(resourceName, false, false);
            RFmxInstrMX  instr  = new RFmxInstrMX(resourceName, "");
            RFmxSpecAnMX specAn = instr.GetSpecAnSignalConfiguration(signalStringSpecan);
            #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.RFmxSpecAn.ConfigureTxp(specAn, TxpConfigurationSpecAn);
            SA.RFmxSpecAn.ConfigureAcp(specAn, AcpConfigurationSpecAn, "");

            if (EnableDpd)
            {
                Methods.RFmxDPD.ConfigureCommon(specAn, CommonConfigurationDpd, waveform);
                Methods.RFmxDPD.ConfigureMemoryPolynomial(specAn, MemoryPolynomialConfiguration);
                Methods.RFmxDPD.ConfigureApplyDpdCrestFactorReduction(specAn, applyDpdCrestFactorReductionConfig);
            }
            #endregion

            #region Measure

            Console.WriteLine("\n--------------------- Results --------------------\n");
            if (EnableDpd)
            {
                specAn.SelectMeasurements("", RFmxSpecAnMXMeasurementTypes.Dpd, true);
                Methods.RFmxDPD.PerformMemoryPolynomial(specAn, nIRfsg, MemoryPolynomialConfiguration, waveform);
            }
            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();

            specanMeasurements[0] = RFmxSpecAnMXMeasurementTypes.Txp;
            SA.RFmxSpecAn.SelectAndInitiateMeasurements(specAn, specanMeasurements, saAutolevelConfig, waveform.SignalBandwidth_Hz, false, "", resultStringSpecan);
            TxpResultsSpecAn = SA.RFmxSpecAn.FetchTxp(specAn, RFmxSpecAnMX.BuildResultString(resultStringSpecan));
            PrintTxPResults();

            specanMeasurements[0] = RFmxSpecAnMXMeasurementTypes.Acp;
            SA.RFmxSpecAn.SelectAndInitiateMeasurements(specAn, specanMeasurements, saAutolevelConfig, waveform.SignalBandwidth_Hz, false, "", resultStringSpecan);
            AcpResultsSpecAn = SA.RFmxSpecAn.FetchAcp(specAn, RFmxSpecAnMX.BuildResultString(resultStringSpecan));
            PrintACPResults();
            #endregion

            AbortGeneration(nIRfsg);
            CloseInstrument(nIRfsg);
            specAn.Dispose();
            specAn = null;
            instr.Close();
            instr = null;
        }
Exemplo n.º 15
0
 private void InitializeInstr()
 {
     /* Create a new RFmx Session */
     instrSession = new RFmxInstrMX(resourceName, "");
 }
 /// <summary>
 /// Creates an NR signal configuration by serializing the data in <paramref name="objectToSerialize"/>.
 /// </summary>
 /// <returns></returns>
 public static RFmxNRMX CreateNRSignalConfigurationFromObject(this RFmxInstrMX instr, object objectToSerialize, string baseSelectorString = "")
 {
     return(instr.CreateNRSignalConfigurationFromObject(objectToSerialize, string.Empty, baseSelectorString));
 }
        /// <summary>Saves the RFmx Instr configuration file as is appropriate to the file type.</summary>
        /// <param name="instr">The RFmx Instr configuration to save.</param>
        public void SaveConfiguration(RFmxInstrMX instr)
        {
            string directory = Path.GetDirectoryName(FilePath);

            SaveConfiguration(instr, directory);
        }
 void InitializeInstr()
 {
     instrSession = new RFmxInstrMX(resourceName, "");
 }
        static void Main()
        {
            #region Configure Generation
            string resourceName = "VST2";
            string filePath     = Path.GetFullPath(@"Support Files\80211a_20M_48Mbps.tdms");

            NIRfsg nIRfsg = new NIRfsg(resourceName, false, false);
            InstrumentConfiguration instrConfig = InstrumentConfiguration.GetDefault();
            instrConfig.CarrierFrequency_Hz = 2.412e9;

            ConfigureInstrument(nIRfsg, instrConfig);
            Waveform waveform = LoadWaveformFromTDMS(filePath);

            DownloadWaveform(nIRfsg, waveform);

            WaveformTimingConfiguration timing = new WaveformTimingConfiguration
            {
                DutyCycle_Percent       = 60,
                PreBurstTime_s          = 1e-9,
                PostBurstTime_s         = 1e-9,
                BurstStartTriggerExport = "PXI_Trig0"
            };

            PAENConfiguration paenConfig = new PAENConfiguration
            {
                PAEnableMode = PAENMode.Dynamic,
                PAEnableTriggerExportTerminal = "PFI0",
                PAEnableTriggerMode           = RfsgMarkerEventOutputBehaviour.Toggle
            };

            ConfigureBurstedGeneration(nIRfsg, waveform, timing, paenConfig, out double period, out _);
            nIRfsg.Initiate();
            #endregion

            RFmxInstrMX instr = new RFmxInstrMX("VST2", "");
            RFmxWlanMX  wlan  = instr.GetWlanSignalConfiguration();
            instr.GetWlanSignalConfiguration();


            CommonConfiguration commonConfiguration = CommonConfiguration.GetDefault();
            commonConfiguration.CenterFrequency_Hz = 2.412e9;

            AutoLevelConfiguration autoLevel = new AutoLevelConfiguration
            {
                AutoLevelMeasureTime_s  = period,
                AutoLevelReferenceLevel = true
            };

            SA.RFmxWLAN.ConfigureCommon(instr, wlan, commonConfiguration, autoLevel);

            SignalConfiguration signal = SignalConfiguration.GetDefault();
            signal.AutoDetectSignal    = false;
            signal.ChannelBandwidth_Hz = 20e6;
            signal.Standard            = RFmxWlanMXStandard.Standard802_11ag;

            SA.RFmxWLAN.ConfigureSignal(wlan, signal);

            TxPConfiguration txpConfig = new TxPConfiguration
            {
                AveragingCount = 10,
                MaximumMeasurementInterval_s = waveform.BurstLength_s,
                AveragingEnabled             = RFmxWlanMXTxpAveragingEnabled.True
            };

            SA.RFmxWLAN.ConfigureTxP(wlan, txpConfig);

            OFDMModAccConfiguration modAccConfig = OFDMModAccConfiguration.GetDefault();
            modAccConfig.OptimizeDynamicRangeForEvmEnabled = RFmxWlanMXOfdmModAccOptimizeDynamicRangeForEvmEnabled.False;
            modAccConfig.AveragingEnabled = RFmxWlanMXOfdmModAccAveragingEnabled.True;

            SA.RFmxWLAN.ConfigureOFDMModAcc(wlan, modAccConfig);

            TxPServoConfiguration servoConfig = TxPServoConfiguration.GetDefault();
            servoConfig.TargetTxPPower_dBm = 0.5;

            SA.RFmxWLAN.TxPServoPower(wlan, nIRfsg, servoConfig, autoLevel);

            SEMConfiguration semConfig = SEMConfiguration.GetDefault();
            SA.RFmxWLAN.ConfigureSEM(wlan, semConfig);

            wlan.Initiate("", "");

            TxPResults        txpRes        = SA.RFmxWLAN.FetchTxP(wlan);
            OFDMModAccResults modAccResults = SA.RFmxWLAN.FetchOFDMModAcc(wlan);
            SEMResults        semResults    = SA.RFmxWLAN.FetchSEM(wlan);

            Console.WriteLine("TXP Avg Power: {0:N}", txpRes.AveragePowerMean_dBm);
            Console.WriteLine("Composite RMS EVM (dB): {0:N}", modAccResults.CompositeRMSEVMMean_dB);
            Console.WriteLine("\n----------Lower Offset Measurements----------\n");
            for (int i = 0; i < semResults.LowerOffsetMargin_dB.Length; i++)
            {
                Console.WriteLine("Offset {0}", i);
                Console.WriteLine("Measurement Status              :{0}",
                                  semResults.lowerOffsetMeasurementStatus[i]);
                Console.WriteLine("Margin (dB)                     :{0}", semResults.LowerOffsetMargin_dB[i]);
                Console.WriteLine("Margin Frequency (Hz)           :{0}", semResults.LowerOffsetMarginFrequency_Hz[i]);
                Console.WriteLine("Margin Absolute Power (dBm)     :{0}\n", semResults.LowerOffsetMarginAbsolutePower_dBm[i]);
            }

            Console.WriteLine("\n----------Upper Offset Measurements----------\n");
            for (int i = 0; i < semResults.UpperOffsetMargin_dB.Length; i++)
            {
                Console.WriteLine("Offset {0}", i);
                Console.WriteLine("Measurement Status              :{0}", semResults.upperOffsetMeasurementStatus[i]);
                Console.WriteLine("Margin (dB)                     :{0}", semResults.UpperOffsetMargin_dB[i]);
                Console.WriteLine("Margin Frequency (Hz)           :{0}", semResults.UpperOffsetMarginFrequency_Hz[i]);
                Console.WriteLine("Margin Absolute Power (dBm)     :{0}\n", semResults.UpperOffsetMarginAbsolutePower_dBm[i]);
            }

            Console.WriteLine("\n--------------------\n\nPress any key to exit.");
            Console.ReadKey();

            wlan.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();
                }
            }
        }