void StopGeneration() { EnableControls(true); updateButton.Enabled = false; try { if (_rfsgSession != null) { // Disable the output. This sets the noise floor as low as possible. _rfsgSession.RF.OutputEnabled = false; // Unsubscribe from warning events _rfsgSession.DriverOperation.Warning -= DriverOperation_Warning; // Close the RFSG NIRfsg session _rfsgSession.Close(); } _rfsgSession = null; } catch (Exception ex) { errorTextBox.Text = "Error in StopGeneration(): " + ex.Message; } }
/// <summary> /// Closes both the SA and the SG. /// </summary> public override void Close() { RfsaHandle.Close(); RfsaHandle = null; RfsgHandle.Close(); RfsgHandle = null; }
/// <summary>Configures common instrument settings for generation.</summary> /// <param name="rfsgHandle">The open RFSG session to configure.</param> /// <param name="instrConfig">The common instrument settings to configure.</param> public static void ConfigureInstrument(NIRfsg rfsgHandle, InstrumentConfiguration instrConfig) { rfsgHandle.SignalPath.SelectedPorts = instrConfig.SelectedPorts; rfsgHandle.RF.ExternalGain = -instrConfig.ExternalAttenuation_dB; rfsgHandle.RF.Configure(instrConfig.CarrierFrequency_Hz, instrConfig.DutAverageInputPower_dBm); rfsgHandle.FrequencyReference.Source = RfsgFrequencyReferenceSource.FromString(instrConfig.ReferenceClockSource); // Only configure LO settings on supported VSTs if (Regex.IsMatch(rfsgHandle.Identity.InstrumentModel, "NI PXIe-58[34].")) // Matches 583x and 584x VST families { IntPtr rfsgPtr = rfsgHandle.GetInstrumentHandle().DangerousGetHandle(); NIRfsgPlayback.RetrieveAutomaticSGSASharedLO(rfsgPtr, "", out RfsgPlaybackAutomaticSGSASharedLO currentMode); if (instrConfig.LOSharingMode == LocalOscillatorSharingMode.None && currentMode != RfsgPlaybackAutomaticSGSASharedLO.Disabled) { //Setting this property resets other settings, which can create issues. Hence, it is only set if the value //is different than the current mode. NIRfsgPlayback.StoreAutomaticSGSASharedLO(rfsgPtr, "", RfsgPlaybackAutomaticSGSASharedLO.Disabled); } else if (instrConfig.LOSharingMode == LocalOscillatorSharingMode.Automatic && currentMode != RfsgPlaybackAutomaticSGSASharedLO.Enabled) { //Setting this property resets other settings, which can create issues. Hence, it is only set if the value //is different than the current mode. NIRfsgPlayback.StoreAutomaticSGSASharedLO(rfsgPtr, "", RfsgPlaybackAutomaticSGSASharedLO.Enabled); } } //Do nothing; any configuration for LOs with standalone VSGs should be configured manually. //Baseband instruments don't have LOs. Unsupported VSTs must be configured manually. }
public static void TogglePFILine(NIRfsg rfsgHandle, RfsgMarkerEventToggleInitialState toggleDirection = RfsgMarkerEventToggleInitialState.DigitalLow) { rfsgHandle.Abort(); //Ensure that the terminal is configured to the proper toggle state rfsgHandle.DeviceEvents.MarkerEvents[1].ExportedOutputTerminal = RfsgMarkerEventExportedOutputTerminal.Pfi0; rfsgHandle.DeviceEvents.MarkerEvents[1].OutputBehaviour = RfsgMarkerEventOutputBehaviour.Toggle; rfsgHandle.DeviceEvents.MarkerEvents[1].ToggleInitialState = toggleDirection; //Create a script that doesn't do anything, but ensures that the requested intitial toggle behavior //is applied to the hardware to toggle the PFI line correctly string cachedScriptName = rfsgHandle.Arb.Scripting.SelectedScriptName; string toggleScript = @"script toggleScript wait 10 end script"; rfsgHandle.Arb.Scripting.WriteScript(toggleScript); rfsgHandle.Arb.Scripting.SelectedScriptName = "ToggleScript"; rfsgHandle.Initiate(); rfsgHandle.Abort(); //Return the active script to the previous rfsgHandle.Arb.Scripting.SelectedScriptName = cachedScriptName; rfsgHandle.Utility.Commit(); }
void StartGeneration() { string resourceName; double frequency, power; try { // Read in all the control values resourceName = resourceNameComboBox.Text; frequency = (double)frequencyNumeric.Value; power = (double)powerLevelNumeric.Value; errorTextBox.Text = "No error."; Application.DoEvents(); // Initialize the NIRfsg session _rfsgSession = new NIRfsg(resourceName, true, false); // Subscribe to Rfsg warnings _rfsgSession.DriverOperation.Warning += new EventHandler <RfsgWarningEventArgs>(DriverOperation_Warning); // Configure the instrument _rfsgSession.RF.Frequency = frequency; // Initiate Generation _rfsgSession.Initiate(); // Disable all controls EnableControls(false); } catch (Exception ex) { ShowError("StartGeneration()", ex); } }
public static void DownloadWaveform(NIRfsg rfsgHandle, Waveform waveform) { IntPtr rfsgPtr = rfsgHandle.GetInstrumentHandle().DangerousGetHandle(); rfsgHandle.Abort(); rfsgHandle.RF.PowerLevelType = RfsgRFPowerLevelType.PeakPower; try { rfsgHandle.Arb.ClearWaveform(waveform.WaveformName); //Clear existing waveform to avoid erros } catch (Ivi.Driver.OutOfRangeException) { //Intentionally ignore this exception; clearing the waveform failed because it doesn't exist } rfsgHandle.Arb.WriteWaveform(waveform.WaveformName, waveform.WaveformData); //Store loaded parameters NIRfsgPlayback.StoreWaveformSignalBandwidth(rfsgPtr, waveform.WaveformName, waveform.SignalBandwidth_Hz); NIRfsgPlayback.StoreWaveformPapr(rfsgPtr, waveform.WaveformName, waveform.PAPR_dB); NIRfsgPlayback.StoreWaveformBurstStartLocations(rfsgPtr, waveform.WaveformName, waveform.BurstStartLocations); NIRfsgPlayback.StoreWaveformBurstStopLocations(rfsgPtr, waveform.WaveformName, waveform.BurstStopLocations); NIRfsgPlayback.StoreWaveformSampleRate(rfsgPtr, waveform.WaveformName, waveform.SampleRate); //Manually configure additional settings NIRfsgPlayback.StoreWaveformLOOffsetMode(rfsgPtr, waveform.WaveformName, NIRfsgPlaybackLOOffsetMode.Disabled); NIRfsgPlayback.StoreWaveformRuntimeScaling(rfsgPtr, waveform.WaveformName, -1.5); NIRfsgPlayback.StoreWaveformRFBlankingEnabled(rfsgPtr, waveform.WaveformName, false); }
private void CommitTestConfiguration(NIRfsg rfsg, RFmxInstrMX instr) { SG.DownloadWaveform(rfsg, lteTdd10Waveform); SG.ConfigureContinuousGeneration(rfsg, lteTdd10Waveform); var lteCommonConfig = CommonConfiguration.GetDefault(); string instrumentModel = rfsg.Identity.InstrumentModel; if (Regex.IsMatch(instrumentModel, "NI PXIe-5830")) { lteCommonConfig.SelectedPorts = "if1"; lteCommonConfig.CenterFrequency_Hz = 6.5e9; } else if (Regex.IsMatch(instrumentModel, "NI PXIe-5831")) { lteCommonConfig.SelectedPorts = "rf1/port0"; lteCommonConfig.CenterFrequency_Hz = 28e9; } var lte = instr.GetLteSignalConfiguration(); RFmxLTE.ConfigureCommon(lte, lteCommonConfig); RFmxLTE.ConfigureStandard(lte, RFmxLTE.StandardConfiguration.GetDefault()); RFmxLTE.ConfigureModAcc(lte, RFmxLTE.ModAccConfiguration.GetDefault()); lte.Commit(""); rfsg.Utility.Commit(); }
void StartGeneration() { string rfsgName = resourceNameComboBox.Text; double freq = (double)frequencyNumeric.Value; double power = (double)powerLevelNumeric.Value; try { rfsgSession = new NIRfsg(rfsgName, true, false); rfsgHandle = rfsgSession.GetInstrumentHandle().DangerousGetHandle(); int i = 0; foreach (string tdmsPath in tdmsFilePaths) { NIRfsgPlayback.ReadAndDownloadWaveformFromFile(rfsgHandle, tdmsPath, tdmsWaveformNames[i]); i++; } //Q: Is it acceptable to utilize mostly private class data and keep prototype empty? I suppose if I don't aniticpate any reuse I can leave it empty... string autoScript = ScriptGen(); NIRfsgPlayback.SetScriptToGenerateSingleRfsg(rfsgHandle, autoScript); rfsgSession.RF.Configure(freq, power); rfsgSession.Initiate(); } catch (Exception uhOh) { ShowError("Start Generation", uhOh); } }
private void ApplyAutomaticLOConfiguration(NIRfsg rfsg, RFmxInstrMX instr) { SG.InstrumentConfiguration sgConfig = SG.InstrumentConfiguration.GetDefault(rfsg); SG.ConfigureInstrument(rfsg, sgConfig); RFmxInstr.InstrumentConfiguration instrConfig = RFmxInstr.InstrumentConfiguration.GetDefault(); RFmxInstr.ConfigureInstrument(instr, instrConfig); }
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); }
/// <summary>Configures common instrument settings for the envelope generator.</summary> /// <param name="envVsg">The open RFSG session to configure.</param> /// <param name="envVsgConfig">The common settings to apply to the envelope generator.</param> /// <param name="trackerConfig">The common settings pertaining to the tracker that is used to modulate the power supply voltage.</param> public static void ConfigureEnvelopeGenerator(NIRfsg envVsg, EnvelopeGeneratorConfiguration envVsgConfig, TrackerConfiguration trackerConfig) { // all function calls assume a differential terminal configuration since that is the only option supported by the PXIe-5820 envVsg.FrequencyReference.Source = RfsgFrequencyReferenceSource.FromString(envVsgConfig.ReferenceClockSource); envVsg.IQOutPort[""].LoadImpedance = trackerConfig.InputImpedance_Ohms == 50.0 ? 100.0 : trackerConfig.InputImpedance_Ohms; envVsg.IQOutPort[""].TerminalConfiguration = RfsgTerminalConfiguration.Differential; envVsg.IQOutPort[""].CommonModeOffset = trackerConfig.CommonModeOffset_V; }
private void ApplyNoLOSharingConfiguration(NIRfsg rfsg, RFmxInstrMX instr) { SG.InstrumentConfiguration sgConfig = SG.InstrumentConfiguration.GetDefault(rfsg); sgConfig.LOSharingMode = LocalOscillatorSharingMode.None; SG.ConfigureInstrument(rfsg, sgConfig); RFmxInstr.InstrumentConfiguration instrConfig = RFmxInstr.InstrumentConfiguration.GetDefault(); instrConfig.LOSharingMode = LocalOscillatorSharingMode.None; RFmxInstr.ConfigureInstrument(instr, instrConfig); }
static void Main() { string resourceName = "VST2"; string filePath = Path.GetFullPath(@"Support Files\80211a_20M_48Mbps.tdms"); GenerationType genType = GenerationType.Continuous; NIRfsg nIRfsg = new NIRfsg(resourceName, false, false); InstrumentConfiguration instrConfig = InstrumentConfiguration.GetDefault(); instrConfig.CarrierFrequency_Hz = 2e9; ConfigureInstrument(nIRfsg, instrConfig); Waveform waveform = LoadWaveformFromTDMS(filePath); DownloadWaveform(nIRfsg, waveform); switch (genType) { // For continous generation, we can simply call this function to begin the generation case GenerationType.Continuous: ConfigureContinuousGeneration(nIRfsg, waveform); break; // For bursted generation, we need to configure the duty cycle and PA control case GenerationType.Bursted: WaveformTimingConfiguration dynamicConfig = new WaveformTimingConfiguration { DutyCycle_Percent = 20, PreBurstTime_s = 500e-9, PostBurstTime_s = 500e-9, BurstStartTriggerExport = "PXI_Trig0" }; PAENConfiguration paenConfig = new PAENConfiguration { PAEnableMode = PAENMode.Dynamic, PAEnableTriggerExportTerminal = "PFI0", PAEnableTriggerMode = RfsgMarkerEventOutputBehaviour.Toggle, CommandEnableTime_s = 0, CommandDisableTime_s = 0, }; ConfigureBurstedGeneration(nIRfsg, waveform, dynamicConfig, paenConfig, out _, out _); break; } nIRfsg.Initiate(); Console.WriteLine("Generation has now begun. Press any key to abort generation and close the example."); Console.ReadKey(); AbortGeneration(nIRfsg); CloseInstrument(nIRfsg); }
public override Task <RfsgServiceSession> Initialize(RfsgServiceResource request, ServerCallContext context) { var rfsg = new NIRfsg(request.Name, request.IdQuery, request.Reset, request.OptionString); var handle = rfsg.GetInstrumentHandle().DangerousGetHandle(); sessionMap.Add(handle, rfsg); return(Task.FromResult(new RfsgServiceSession() { Handle = (long)handle })); }
/// <summary>Synchronizes the RF and envelope signal generators, and initiates generation.</summary> /// <param name="rfVsg">The open RFSG session corresponding to the RF signal generator.</param> /// <param name="envVsg">The open RFSG session corresponding to the envelope signal generator.</param> /// <param name="syncConfig">Specifies common settings used for synchronizing the RF and envelope signal generators.</param> public static void InitiateSynchronousGeneration(NIRfsg rfVsg, NIRfsg envVsg, SynchronizationConfiguration syncConfig) { TClock tclk = new TClock(new ITClockSynchronizableDevice[] { rfVsg, envVsg }); // The PXIe-5840 can only apply positive delays so we have to establish an inital delay of -RFDelayRange/2 for TCLK to handle negative shifts as well tclk.DevicesToSynchronize[0].SampleClockDelay = -syncConfig.RFDelayRange_s / 2.0; rfVsg.Arb.RelativeDelay = syncConfig.RFDelayRange_s / 2.0 + syncConfig.RFDelay_s; tclk.ConfigureForHomogeneousTriggers(); tclk.Synchronize(); tclk.Initiate(); }
public WlanSweep(string resourceName) { rfsgSession = new NIRfsg(resourceName, false, false, "DriverSetup=Bitfile:NI-RFIC.lvbitx"); rfsgHandle = rfsgSession.GetInstrumentHandle().DangerousGetHandle(); instr = new RFmxInstrMX(resourceName, "RFmxSetup=Bitfile:NI-RFIC.lvbitx"); wlan = instr.GetWlanSignalConfiguration(); instr.DangerousGetNIRfsaHandle(out IntPtr rfsaHandle); powerServo = new niPowerServo(rfsaHandle, false); }
public void Run() { #region Create Sessions FocusITunerBroker iTuner = new FocusITunerBroker(); iTuner.Initialize(tunerAddress, false, true); NIRfsg nIRfsg = new NIRfsg(resourceName, false, false); RFmxInstrMX instr = new RFmxInstrMX(resourceName, ""); RFmxSpecAnMX specAn = instr.GetSpecAnSignalConfiguration(signalStringSpecan); #endregion #region Configure Tuner FocusTuner.ConfigureCommon(iTuner, commonConfiguration); #endregion #region Configure Generation ConfigureInstrument(nIRfsg, sgInstrConfig); Waveform waveform = LoadWaveformFromTDMS(filePath); DownloadWaveform(nIRfsg, waveform); ConfigureContinuousGeneration(nIRfsg, waveform); nIRfsg.Initiate(); #endregion #region Configure Analyzer saAutolevelConfig.MeasurementInterval_s = waveform.BurstLength_s; RFmxInstr.ConfigureInstrument(instr, saInstrConfig); RFmxSpecAn.ConfigureCommon(specAn, saCommonConfig); RFmxSpecAn.ConfigureTxp(specAn, txpConfigurationSpecAn); #endregion #region Measure foreach (var gamma in gammaSweep) { Console.WriteLine("\n--------------------- Tuning --------------------\n"); currentGamma = FocusTuner.MoveTunerPerGamma(iTuner, gamma)[0]; PrintTuneResults(); Console.WriteLine("\n--------------------- Results --------------------\n"); RFmxSpecAnMXMeasurementTypes[] specanMeasurements = new RFmxSpecAnMXMeasurementTypes[1] { RFmxSpecAnMXMeasurementTypes.Txp }; RFmxSpecAn.SelectAndInitiateMeasurements(specAn, specanMeasurements, saAutolevelConfig, waveform.SignalBandwidth_Hz, false, "", resultStringSpecan); txpResultsSpecAn = RFmxSpecAn.FetchTxp(specAn, RFmxSpecAnMX.BuildResultString(resultStringSpecan)); PrintTxPResults(); } #endregion AbortGeneration(nIRfsg); CloseInstrument(nIRfsg); FocusTuner.CloseTuner(iTuner); specAn.Dispose(); specAn = null; instr.Close(); instr = null; }
public static TxPServoResults TxPServoPower(RFmxWlanMX wlanSignal, NIRfsg rfsgSession, TxPServoConfiguration servoConfig, AutoLevelConfiguration autoLevelConfig, string selectorString = "") { //Duplicate the existing configuration so that we can select only TxP for the power servo to save time, //but not disrupt all of the other user enabled measurements. wlanSignal.CloneSignalConfiguration("servo_txp", out RFmxWlanMX servoTxpSession); servoTxpSession.SelectMeasurements(selectorString, RFmxWlanMXMeasurementTypes.Txp, false); double[] servoTrace = new double[servoConfig.MaxNumberOfIterations]; double powerLevel = 0, outputPower = 0, margin = 0; bool servoSucess = false; for (int i = 0; i < servoConfig.MaxNumberOfIterations; i++) { if (autoLevelConfig.Enabled) { servoTxpSession.AutoLevel(selectorString, autoLevelConfig.MeasurementInterval_s); } servoTxpSession.Initiate(selectorString, ""); powerLevel = rfsgSession.RF.PowerLevel; servoTxpSession.Txp.Results.FetchMeasurement(selectorString, 10, out outputPower, out _); margin = servoConfig.TargetTxPPower_dBm - outputPower; servoTrace[i] = outputPower; if (Math.Abs(margin) <= servoConfig.Tolerance_dBm) //Servo complete; exit the loop { servoSucess = true; break; } else //Still more room to go { rfsgSession.RF.PowerLevel = powerLevel + margin; rfsgSession.Utility.WaitUntilSettled(1000); } } //If we auto-leveled we need to set the original configuration to the newly calculated ref level servoTxpSession.GetReferenceLevel(selectorString, out double newRefLevel); wlanSignal.ConfigureReferenceLevel(selectorString, newRefLevel); servoTxpSession.Dispose(); TxPServoResults servoResults = new TxPServoResults(); servoResults.FinalInputPower_dBm = powerLevel; servoResults.FinalOutputPower_dBm = outputPower; servoResults.ServoTrace = servoTrace; if (!servoSucess) { throw new System.TimeoutException("WLAN TxP Power Servo exceeded max iterations without success."); } return(servoResults); }
/// <summary>Calls <see cref="NIRfsgPlayback.SetScriptToGenerateSingleRfsg(IntPtr, string)"/>, which will download the script contained in <paramref name="waveform"/> and apply /// all associated parameters.</summary> /// <param name="rfsgHandle">The open RFSG session to configure.</param> /// <param name="waveform">Specifies the waveform and its associated script that is to be used for generation.</param> public static void ApplyWaveformAttributes(NIRfsg rfsgHandle, Waveform waveform) { if (string.IsNullOrEmpty(waveform.Script)) // default to continuous if no script in waveform { ConfigureContinuousGeneration(rfsgHandle, waveform); } else { IntPtr rfsgPtr = rfsgHandle.GetInstrumentHandle().DangerousGetHandle(); NIRfsgPlayback.SetScriptToGenerateSingleRfsg(rfsgPtr, waveform.Script); } }
/// <summary>Scales the envelope waveform data based on the settings in <paramref name="trackerConfig"/>, and downloads the waveform to the envelope generator.</summary> /// <param name="envVsg">The open RFSG session to configure.</param> /// <param name="envelopeWaveform">The envelope waveform created by <see cref="CreateDetroughEnvelopeWaveform(Waveform, DetroughConfiguration)"/> or /// <see cref="CreateLookUpTableEnvelopeWaveform(Waveform, LookUpTableConfiguration)"/> that is to be generated.</param> /// <param name="trackerConfig">The common settings pertaining to the tracker that is used to modulate the power supply voltage.</param> /// <returns>The envelope waveform with data scaled according to the tracker configuration.</returns> public static Waveform ScaleAndDownloadEnvelopeWaveform(NIRfsg envVsg, Waveform envelopeWaveform, TrackerConfiguration trackerConfig) { // grab the raw envelope so we can use linq to get statistics on it ComplexSingle.DecomposeArray(envelopeWaveform.Data.GetRawData(), out float[] envelope, out _); // scale envelope to adjust for tracker gain and offset for (int i = 0; i < envelope.Length; i++) { envelope[i] = (float)((envelope[i] - trackerConfig.OutputOffset_V) / trackerConfig.Gain_VperV); } // clone an envelope waveform to return to the user - want unique waveforms per tracker configuration Waveform scaledEnvelopeWaveform = envelopeWaveform; scaledEnvelopeWaveform.Data = envelopeWaveform.Data.Clone(); WritableBuffer <ComplexSingle> scaledEnvelopeWaveformBuffer = scaledEnvelopeWaveform.Data.GetWritableBuffer(); // populate cloned waveform with scaled waveform data for (int i = 0; i < envelope.Length; i++) { scaledEnvelopeWaveformBuffer[i] = ComplexSingle.FromSingle(envelope[i]); } // get peak of the waveform float absolutePeak = envelope.Max(i => Math.Abs(i)); // applies the absolute value function to each element and returns the max // scale waveform to peak voltage for (int i = 0; i < envelope.Length; i++) { envelope[i] = envelope[i] / (absolutePeak); // brings waveform down to +/- 1 magnitude } // set instrument properties envVsg.IQOutPort[""].Level = 2.0 * absolutePeak; // gain is interpreted as peak-to-peak envVsg.IQOutPort[""].Offset = 0.0; // set offset to 0 since this is done in DSP not in HW on the 5820 and only clips the waveform further // create another waveform that we can use to download the scaled envelope to the instrument Waveform instrEnvelopeWaveform = envelopeWaveform; instrEnvelopeWaveform.Data = envelopeWaveform.Data.Clone(); WritableBuffer <ComplexSingle> instrEnvelopeWaveformBuffer = instrEnvelopeWaveform.Data.GetWritableBuffer(); // populate cloned waveform with scaled waveform data for (int i = 0; i < envelope.Length; i++) { instrEnvelopeWaveformBuffer[i] = ComplexSingle.FromSingle(envelope[i]); } SG.DownloadWaveform(envVsg, instrEnvelopeWaveform); // download optimized waveform return(scaledEnvelopeWaveform); // return the waveform as it will appear coming out of the front end of the envelope generator }
/// <summary> /// Initializes both the SA and the SG. /// </summary> public override void Initialize() { if (RfsaHandle == null) { RfsaHandle = new NIRfsa(IOAddress, true, true); } if (RfsgHandle == null) { RfsgHandle = new NIRfsg(IOAddress, true, true); } RfsaHandle.Configuration.ReferenceClock.Configure(RfsaReferenceClockSource.PxiClock, 10E6); RfsgHandle.FrequencyReference.Configure(RfsgFrequencyReferenceSource.PxiClock, 10E6); RfsaHandle.Utility.Commit(); RfsgHandle.Utility.Commit(); }
public void Run() { NIRfsg nIRfsg = new NIRfsg(resourceName, false, false); ConfigureInstrument(nIRfsg, instrConfig); Waveform waveform = LoadWaveformFromTDMS(filePath); DownloadWaveform(nIRfsg, waveform); ConfigureContinuousGeneration(nIRfsg, waveform, "PXI_Trig0"); ni568x sensor = new ni568x(powerMeterResourceName, true, true); PowerMeter.ConfigureCommon(sensor, commonConfiguration); bool measuredPowerInRange; double measuredPower = 0.0; double maximumDutOutputPower = paOutputPower_dBm + designedAccuracy_dB; double minimumDutOutputPower = paOutputPower_dBm - designedAccuracy_dB; Console.WriteLine("\n------------------------Servo Started ---------------------\n"); for (int currentServoStep = 1; currentServoStep <= maximumSteps; currentServoStep++) { nIRfsg.Initiate(); measuredPower = PowerMeter.ReadMeasurement(sensor, 10000) + Coupling_dB; Console.WriteLine("Servo step: {0}", currentServoStep); Console.WriteLine("Measured power (dBm): {0:0.00}", measuredPower); AbortGeneration(nIRfsg); measuredPowerInRange = (measuredPower >= minimumDutOutputPower) && (measuredPower <= maximumDutOutputPower); if (measuredPowerInRange && (currentServoStep >= minimumSteps)) { servoFailed = false; break; } else { instrConfig.DutAverageInputPower_dBm += ((paOutputPower_dBm - measuredPower) * 0.95); ConfigureInstrument(nIRfsg, instrConfig); } } PrintServoResults(measuredPower); CloseInstrument(nIRfsg); sensor.Dispose(); }
public void Connect() { try { PopulateSequenceList(); waveformNamesLoaded = new List <string>(); session = new NIRfsg(VSGName, false, true); session.RF.Frequency = CenterFrequency; session.Arb.GenerationMode = RfsgWaveformGenerationMode.ArbitraryWaveform; session.Arb.IQRate = IQRate; } catch (Exception ex) { MessageBox.Show("Error in Connect()\n" + ex.Message); } }
public override void Connect() { if (!Environs.Debug) { if (_rfsgSession != null) { _rfsgSession.Close(); _rfsgSession = null; } // Initialize the NIRfsg session _rfsgSession = new NIRfsg(_resourceName, true, false); // Subscribe to Rfsg warnings _rfsgSession.DriverOperation.Warning += new EventHandler <RfsgWarningEventArgs>(DriverOperation_Warning); } }
/// <summary>Returns the struct with default values set based upon the instrument model of <paramref name="rfsg"/>.</summary> /// <param name="rfsg">The open RFSG session to configure.</param> /// <returns>The struct with default values set based upon the instrument model of <paramref name="rfsg"/>.</returns> public static InstrumentConfiguration GetDefault(NIRfsg rfsg) { InstrumentConfiguration instrConfig = GetDefault(); string instrumentModel = rfsg.Identity.InstrumentModel; if (Regex.IsMatch(instrumentModel, "NI PXIe-5830")) { instrConfig.SelectedPorts = "if0"; instrConfig.CarrierFrequency_Hz = 6.5e9; } else if (Regex.IsMatch(instrumentModel, "NI PXIe-5831")) { instrConfig.SelectedPorts = "rf0/port0"; instrConfig.CarrierFrequency_Hz = 28e9; } return(instrConfig); }
public static void ConfigureInstrument(ref NIRfsg rfsgHandle, InstrumentConfiguration instrConfig) { rfsgHandle.Arb.GenerationMode = RfsgWaveformGenerationMode.Script; rfsgHandle.RF.PowerLevelType = RfsgRFPowerLevelType.PeakPower; rfsgHandle.RF.ExternalGain = -instrConfig.ExternalAttenuation_dBm; rfsgHandle.RF.Configure(instrConfig.CarrierFrequency_Hz, instrConfig.AverageInputPower_dBm); rfsgHandle.FrequencyReference.Source = RfsgFrequencyReferenceSource.FromString(instrConfig.ReferenceClockSource); rfsgHandle.DeviceEvents.MarkerEvents[0].ExportedOutputTerminal = RfsgMarkerEventExportedOutputTerminal.FromString(instrConfig.BurstStartTriggerExportTerminal); if (instrConfig.ShareLOSGToSA) { rfsgHandle.RF.LocalOscillator.LOOutEnabled = true; rfsgHandle.RF.LocalOscillator.Source = RfsgLocalOscillatorSource.Onboard; } }
public override void Disconnect() { if (!Environs.Debug) { if (_rfsgSession != null) { // Disable the output. This sets the noise floor as low as possible. _rfsgSession.RF.OutputEnabled = false; // Unsubscribe from warning events _rfsgSession.DriverOperation.Warning -= DriverOperation_Warning; // Close the RFSG NIRfsg session _rfsgSession.Close(); } _rfsgSession = null; } }
/// <summary> /// This example illustrates how to use RFSG drivers to generate a bursted or continuous waveform. /// </summary> static void Main() { string resourceName = "5840"; string filePath = Path.GetFullPath(@"C:\Users\Public\Documents\National Instruments\RFIC Test Software\Waveforms\NR_FR1_UL_1x100MHz_30kHz-SCS_256QAM_OS4_VST2_1ms.tdms"); //string filePath = Path.GetFullPath(@"C:\Users\Public\Documents\National Instruments\RFIC Test Software\Waveforms\LTE_FDD_UL_1x20MHz_256QAM_OS4.tdms"); //string filePath = Path.GetFullPath(@"C:\Users\Public\Documents\National Instruments\RFIC Test Software\Waveforms\80211ax_80M_MCS11.tdms"); GenerationType genType = GenerationType.Continuous; NIRfsg nIRfsg = new NIRfsg(resourceName, false, false); InstrumentConfiguration instrConfig = InstrumentConfiguration.GetDefault(); instrConfig.CarrierFrequency_Hz = 3.5e9; ConfigureInstrument(nIRfsg, instrConfig); Waveform waveform = LoadWaveformFromTDMS(filePath); DownloadWaveform(nIRfsg, waveform); switch (genType) { // For continous generation, we can simply call this function to begin the generation case GenerationType.Continuous: ConfigureContinuousGeneration(nIRfsg, waveform, "PXI_Trig0"); break; // For bursted generation, we need to configure the duty cycle and PA control case GenerationType.Bursted: WaveformTimingConfiguration dynamicConfig = WaveformTimingConfiguration.GetDefault(); PAENConfiguration paenConfig = PAENConfiguration.GetDefault(); ConfigureBurstedGeneration(nIRfsg, waveform, dynamicConfig, paenConfig, out _, out _); break; } nIRfsg.Initiate(); Console.WriteLine("Generation has now begun. Press any key to abort generation and close the example."); Console.ReadKey(); AbortGeneration(nIRfsg); CloseInstrument(nIRfsg); }
public static Waveform GetWaveformParametersByName(NIRfsg rfsgHandle, string waveformName) { IntPtr rfsgPtr = rfsgHandle.GetInstrumentHandle().DangerousGetHandle(); Waveform waveform = new Waveform { WaveformName = waveformName }; NIRfsgPlayback.RetrieveWaveformSignalBandwidth(rfsgPtr, waveformName, out waveform.SignalBandwidth_Hz); NIRfsgPlayback.RetrieveWaveformPapr(rfsgPtr, waveformName, out waveform.PAPR_dB); NIRfsgPlayback.RetrieveWaveformSampleRate(rfsgPtr, waveformName, out waveform.SampleRate); NIRfsgPlayback.RetrieveWaveformBurstStartLocations(rfsgPtr, waveformName, ref waveform.BurstStartLocations); NIRfsgPlayback.RetrieveWaveformBurstStopLocations(rfsgPtr, waveformName, ref waveform.BurstStopLocations); waveform.BurstLength_s = CalculateWaveformDuration(waveform.BurstStartLocations, waveform.BurstStopLocations, waveform.SampleRate); return(waveform); }
void StopGeneration() { try { if (rfsgSession != null) { rfsgSession.Abort(); rfsgSession.RF.OutputEnabled = false; rfsgSession.Close(); rfsgSession = null; } } catch (Exception ohNo) { ShowError("StopGeneration", ohNo); } // Stop the status checking timer EnableControls(true); }
void MakePulses() { ShapedPulse pulse1, pulse2; double[] pulsedata1, pulsedata2; double[] blankData; string resourceName = "Dev2"; int numberOfSamples, numberOfDeadPoints; int waveformQuantum; double frequency = 170000000; double power = 5; double iqRate = 100e6; double actualIQRate; double pulseLength = 1e-6; double bandwidth = 2 / pulseLength; double actualPulseLength; double deadTime = 3e-7; int waveformRepeatCount = 1; try { // Initialise the NIRfsg session _rfsgSession = new NIRfsg(resourceName, true, false); // Subscribe to warnings _rfsgSession.DriverOperation.Warning += new EventHandler<RfsgWarningEventArgs>(DriverOperation_Warning); // Configure instrument _rfsgSession.RF.Configure(frequency, power); _rfsgSession.Arb.GenerationMode = RfsgWaveformGenerationMode.Script; _rfsgSession.Arb.IQRate = iqRate; _rfsgSession.Arb.PreFilterGain = ArbPreFilterGain; _rfsgSession.RF.PowerLevelType = RfsgRFPowerLevelType.PeakPower; // Enable finite generation _rfsgSession.Arb.IsWaveformRepeatCountFinite = true; _rfsgSession.Arb.WaveformRepeatCount = waveformRepeatCount; // Configure bandwidth _rfsgSession.Arb.SignalBandwidth = bandwidth; // Get actual IQ rate actualIQRate = _rfsgSession.Arb.IQRate; Console.WriteLine("Sampling rate: " + actualIQRate); // Calculate waveform quantum based on pulse length waveformQuantum = _rfsgSession.Arb.WaveformCapabilities.WaveformQuantum; numberOfSamples = CoerceToQuantum(actualIQRate * pulseLength, waveformQuantum); Console.WriteLine("No. of samples: " + numberOfSamples); // Get actual pulse length actualPulseLength = numberOfSamples / actualIQRate; Console.WriteLine("Pulse length: " + actualPulseLength + " s"); // Get number of dead points at the end numberOfDeadPoints = Convert.ToInt32(actualIQRate * deadTime); Console.WriteLine("No. of dead points: " + numberOfDeadPoints); // Generate waveforms pulse1 = new ShapedPulse(0, 0.9, 0.1, numberOfSamples, numberOfDeadPoints); pulse2 = new ShapedPulse(1, 0, 0, numberOfSamples, numberOfDeadPoints); pulsedata1 = pulse1.MakePulse(); pulsedata2 = pulse2.MakePulse(); blankData = Enumerable.Repeat(0.0, numberOfSamples).ToArray(); // Write waveforms to device _rfsgSession.Arb.WriteWaveform("Pulse1", pulsedata1, blankData); _rfsgSession.Arb.WriteWaveform("Pulse2", pulsedata2, blankData); _rfsgSession.Arb.WriteWaveform("allZeros", blankData, blankData); } catch (Exception ex) { ShowError("MakePulses()", ex); } }
public void Initialise() { pulses.Add(1, new ShapedPulse()); pulses.Add(2, new ShapedPulse()); RfChoice.Add(1, "pulse1"); RfChoice.Add(2, "pulse2"); topRfChoice = 1; botRfChoice = 1; string resourceName = (String)Environs.Hardware.Boards["rfPulseGenerator"]; double ArbPreFilterGain = -2; int waveformRepeatCount = 1; double frequency = 170e6; double power = 5; double iqRate = 100e6; double pulseLength = 1e-6; double deadTime = 3e-7; // The generated pulses seem to cut off at some point if I use // all the sampling points available, hence the need for some // 'dead time' at the end where the output is all zeros. int numberOfSamples, numberOfDeadPoints; int waveformQuantum; double actualIQRate, actualPulseLength; double bandwidth; try { Console.WriteLine("Initialising.."); // Initialise the NIRfsg session _rfsgSession = new NIRfsg(resourceName, true, false); // Subscribe to warnings _rfsgSession.DriverOperation.Warning += new EventHandler<RfsgWarningEventArgs>(DriverOperation_Warning); // Configure instrument _rfsgSession.RF.Configure(frequency, power); _rfsgSession.Arb.GenerationMode = RfsgWaveformGenerationMode.Script; _rfsgSession.Arb.IQRate = iqRate; _rfsgSession.Arb.PreFilterGain = ArbPreFilterGain; _rfsgSession.RF.PowerLevelType = RfsgRFPowerLevelType.PeakPower; // Enable finite generation _rfsgSession.Arb.IsWaveformRepeatCountFinite = true; _rfsgSession.Arb.WaveformRepeatCount = waveformRepeatCount; // Get actual IQ rate actualIQRate = _rfsgSession.Arb.IQRate; Console.WriteLine("Sampling rate: " + actualIQRate); // Calculate waveform quantum based on pulse length waveformQuantum = _rfsgSession.Arb.WaveformCapabilities.WaveformQuantum; numberOfSamples = CoerceToQuantum(actualIQRate * pulseLength, waveformQuantum); Console.WriteLine("No. of samples: " + numberOfSamples); // Get actual pulse length actualPulseLength = numberOfSamples / actualIQRate; Console.WriteLine("Pulse length: " + actualPulseLength + " s"); // Configure bandwidth bandwidth = 2 / actualPulseLength; _rfsgSession.Arb.SignalBandwidth = bandwidth; // Get number of dead points at the end numberOfDeadPoints = Convert.ToInt32(actualIQRate * deadTime); Console.WriteLine("No. of dead points: " + numberOfDeadPoints); // Initialise waveforms and write waveforms to device double[] initialParams = new double[3] { 1, 0, 0 }; double[] blankData = Enumerable.Repeat(0.0, numberOfSamples).ToArray(); double[] writeData; foreach(int key in pulses.Keys) { writeData = MakePulse(pulses[key], numberOfSamples, numberOfDeadPoints); _rfsgSession.Arb.WriteWaveform(RfChoice[key], writeData, blankData); } _rfsgSession.Arb.WriteWaveform("allZeros", blankData, blankData); } catch (Exception ex) { ShowError("Initialise()", ex); } }
public void StopGeneration() { try { if (_rfsgSession != null) { // Disable the output _rfsgSession.RF.OutputEnabled = false; // Unsubscribe from warning events _rfsgSession.DriverOperation.Warning -= DriverOperation_Warning; // Close the RFSG NIRfsg session _rfsgSession.Close(); } _rfsgSession = null; } catch (Exception ex) { Console.WriteLine("Error in StopGeneration(): " + ex.Message); } }