/// <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. }
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 void InitializeParameters() { //shared Parameters resourceName = "5840"; centerFrequency = 5.18e9; //Hz filePath = @"C:\Users\Public\Documents\National Instruments\RFIC Test Software\Waveforms\80211ax_80M_MCS11.tdms"; signalStringSpecan = "specanSig0"; signalStringWlan = "wlanSig0"; resultStringSpecan = "specanResult0"; resultStringWlan = "wlanResult0"; //Generator Configuration sgInstrConfig = InstrumentConfiguration.GetDefault(); sgInstrConfig.CarrierFrequency_Hz = centerFrequency; sgInstrConfig.DutAverageInputPower_dBm = -10.0; sgInstrConfig.ExternalAttenuation_dB = 0; // Analyzer Configuration 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; ampmConfigurationSpecAn = SA.RFmxSpecAn.AmpmConfiguration.GetDefault(); ampmConfigurationSpecAn.DutAverageInputPower_dBm = sgInstrConfig.DutAverageInputPower_dBm; // WLAN Configuration wlanStandardConfig = SA.RFmxWLAN.StandardConfiguration.GetDefault(); wlanStandardConfig.ChannelBandwidth_Hz = 80e6; // Hz wlanStandardConfig.Standard = RFmxWlanMXStandard.Standard802_11ax; modAccConfig = SA.RFmxWLAN.OFDMModAccConfiguration.GetDefault(); semConfig = SA.RFmxWLAN.SEMConfiguration.GetDefault(); //Methods Configuration commonConfigurationDpd = Methods.RFmxDPD.CommonConfiguration.GetDefault(); commonConfigurationDpd.DutAverageInputPower_dBm = sgInstrConfig.DutAverageInputPower_dBm; memoryPolynomialConfiguration = Methods.RFmxDPD.MemoryPolynomialConfiguration.GetDefault(); memoryPolynomialConfiguration.NumberOfIterations = 1; EnableDpd = true; preDpdCrestFactorReductionConfig = Methods.RFmxDPD.PreDpdCrestFactorReductionConfiguration.GetDefault(); preDpdCrestFactorReductionConfig.Enabled = RFmxSpecAnMXDpdPreDpdCfrEnabled.False; applyDpdCrestFactorReductionConfig = Methods.RFmxDPD.ApplyDpdCrestFactorReductionConfiguration.GetDefault(); applyDpdCrestFactorReductionConfig.Enabled = RFmxSpecAnMXDpdApplyDpdCfrEnabled.False; }
/// <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; } }
/// <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 void ConfigureInstrument(NIRfsg rfsgHandle, InstrumentConfiguration instrConfig) { rfsgHandle.RF.ExternalGain = -instrConfig.ExternalAttenuation_dBm; rfsgHandle.RF.Configure(instrConfig.CarrierFrequency_Hz, instrConfig.DutAverageInputPower_dBm); rfsgHandle.FrequencyReference.Source = RfsgFrequencyReferenceSource.FromString(instrConfig.ReferenceClockSource); if (instrConfig.ShareLOSGToSA) { rfsgHandle.RF.LocalOscillator.LOOutEnabled = true; rfsgHandle.RF.LocalOscillator.Source = RfsgLocalOscillatorSource.Onboard; } else { rfsgHandle.RF.LocalOscillator.LOOutEnabled = false; // Return to the default value, in case in future modifications the above case changes // this to something other than the default rfsgHandle.RF.LocalOscillator.Source = RfsgLocalOscillatorSource.Onboard; } }
/// <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); } } }
public void InitializeParameters() { //shared Parameters resourceName = "5840"; centerFrequency = 5.18e9; //Hz filePath = @"C:\Users\Public\Documents\National Instruments\RFIC Test Software\Waveforms\80211ax_80M_MCS11.tdms"; signalStringSpecan = "specanSig0"; signalStringWlan = "wlanSig0"; resultStringSpecan = "specanResult0"; resultStringWlan = "wlanResult0"; //Generator Configuration sgInstrConfig = InstrumentConfiguration.GetDefault(); sgInstrConfig.CarrierFrequency_Hz = centerFrequency; sgInstrConfig.DutAverageInputPower_dBm = -10.0; sgInstrConfig.ExternalAttenuation_dB = 0; paEnableTiming = WaveformTimingConfiguration.GetDefault(); paenConfig = SG.PAENConfiguration.GetDefault(); // Analyzer Configuration 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; ampmConfigurationSpecAn = SA.RFmxSpecAn.AmpmConfiguration.GetDefault(); ampmConfigurationSpecAn.DutAverageInputPower_dBm = sgInstrConfig.DutAverageInputPower_dBm; // WLAN Configuration wlanStandardConfig = SA.RFmxWLAN.StandardConfiguration.GetDefault(); wlanStandardConfig.ChannelBandwidth_Hz = 80e6; // Hz wlanStandardConfig.Standard = RFmxWlanMXStandard.Standard802_11ax; modAccConfig = SA.RFmxWLAN.OFDMModAccConfiguration.GetDefault(); semConfig = SA.RFmxWLAN.SEMConfiguration.GetDefault(); }
static void Main() { string resourceName = "VST2"; string filePath = Path.GetFullPath(@"Support Files\80211a_20M_48Mbps.tdms"); NIRfsg nIRfsg = new NIRfsg(resourceName, false, false); InstrumentConfiguration instrConfig = new InstrumentConfiguration(); instrConfig.SetDefaults(); instrConfig.CarrierFrequency_Hz = 2e9; ConfigureInstrument(ref nIRfsg, instrConfig); Waveform waveform = LoadWaveformFromTDMS(ref nIRfsg, filePath); DownloadWaveform(ref nIRfsg, ref waveform); WaveformTimingConfiguration dynamicConfig = new WaveformTimingConfiguration { DutyCycle_Percent = 20, PreBurstTime_s = 500e-9, PostBurstTime_s = 500e-9, }; PAENConfiguration paenConfig = new PAENConfiguration { PAEnableMode = PAENMode.Dynamic, PAEnableTriggerExportTerminal = "PFI0", PAEnableTriggerMode = RfsgMarkerEventOutputBehaviour.Toggle, CommandEnableTime_s = 0, CommandDisableTime_s = 0, }; ConfigureWaveformTimingAndPAControl(ref nIRfsg, ref waveform, dynamicConfig, paenConfig, out _, out _); nIRfsg.Initiate(); Console.ReadKey(); AbortDynamicGeneration(ref nIRfsg); CloseInstrument(ref nIRfsg); }
public void InitializeParameters() { resourceName = "5840"; filePath = Path.GetFullPath(@"C:\Users\Public\Documents\National Instruments\RFIC Test Software\Waveforms\80211ax_80M_MCS11.tdms"); centerFrequency = 3.5e9; Coupling_dB = 33; paOutputPower_dBm = 5; designedAccuracy_dB = 0.1; paGain_dB = 0; minimumSteps = 1; maximumSteps = 5; servoFailed = true; instrConfig = InstrumentConfiguration.GetDefault(); instrConfig.CarrierFrequency_Hz = centerFrequency; instrConfig.DutAverageInputPower_dBm = paOutputPower_dBm - paGain_dB; powerMeterResourceName = "COM3"; commonConfiguration = PowerMeter.CommonConfiguration.GetDefault(); commonConfiguration.Frequency = centerFrequency; }
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); }
public void updateRow(SpectrumDataSet.SpectrumTableRow row, MassSpectrum spectrum) { spectrumList[spectrum.Index] = spectrum; Spectrum s = spectrum.Element; //GetElement(false); DataProcessing dp = spectrum.DataProcessing; Scan scan = null; InstrumentConfiguration ic = null; if (s.scanList.scans.Count > 0) { scan = s.scanList.scans[0]; ic = scan.instrumentConfiguration; } if (dp == null) { dp = s.dataProcessing; } CVParam param; param = s.cvParam(CVID.MS_ms_level); row.MsLevel = !param.empty() ? (int)param.value : 0; param = scan != null?scan.cvParam(CVID.MS_scan_start_time) : new CVParam(); row.ScanTime = !param.empty() ? (double)param.value : 0; param = s.cvParam(CVID.MS_base_peak_m_z); row.BasePeakMz = !param.empty() ? (double)param.value : 0; param = s.cvParam(CVID.MS_base_peak_intensity); row.BasePeakIntensity = !param.empty() ? (double)param.value : 0; param = s.cvParam(CVID.MS_total_ion_current); row.TotalIonCurrent = !param.empty() ? (double)param.value : 0; StringBuilder precursorInfo = new StringBuilder(); if (row.MsLevel == 1 || s.precursors.Count == 0) { precursorInfo.Append("n/a"); } else { foreach (Precursor p in s.precursors) { foreach (SelectedIon si in p.selectedIons) { if (precursorInfo.Length > 0) { precursorInfo.Append(","); } precursorInfo.Append((double)si.cvParam(CVID.MS_selected_ion_m_z).value); } } } if (precursorInfo.Length == 0) { precursorInfo.Append("unknown"); } row.PrecursorInfo = precursorInfo.ToString(); StringBuilder scanInfo = new StringBuilder(); foreach (Scan scan2 in s.scanList.scans) { if (scan2.scanWindows.Count > 0) { foreach (ScanWindow sw in scan2.scanWindows) { if (scanInfo.Length > 0) { scanInfo.Append(","); } scanInfo.AppendFormat("[{0}-{1}]", (double)sw.cvParam(CVID.MS_scan_window_lower_limit).value, (double)sw.cvParam(CVID.MS_scan_window_upper_limit).value); } } } if (scanInfo.Length == 0) { scanInfo.Append("unknown"); } row.ScanInfo = scanInfo.ToString(); row.SpotId = s.spotID; row.SpectrumType = s.cvParamChild(CVID.MS_spectrum_type).name; row.DataPoints = s.defaultArrayLength; row.IcId = (ic == null || ic.id.Length == 0 ? "unknown" : ic.id); row.DpId = (dp == null || dp.id.Length == 0 ? "unknown" : dp.id); }
static void Main(string[] args) { #region Station Configuration string sgName = "VST2"; string digitalName = "PXIe-6570"; DigitalMode desiredMode = DigitalMode.Digital_Enable; //To calculate this delay, use the TDR feature of the Digital Pattern Editor (DPE) //In the DPE, navigate to Instruments ยป TDR... double PFI0CableDelay_s = 11.4e-9; #endregion #region SG Configuration NIRfsg rfsgSession = new NIRfsg(sgName, false, false); InstrumentConfiguration instrConfig = new InstrumentConfiguration { ReferenceClockSource = RfsgFrequencyReferenceSource.PxiClock, CarrierFrequency_Hz = 2.402e9, DutAverageInputPower_dBm = 0, ShareLOSGToSA = false, }; ConfigureInstrument(rfsgSession, instrConfig); string waveformPath = Path.GetFullPath(@"TDMS Files\11AC_MCS8_40M.tdms"); Waveform wave = LoadWaveformFromTDMS(waveformPath, "wave"); DownloadWaveform(rfsgSession, wave); WaveformTimingConfiguration waveTiming = new WaveformTimingConfiguration { DutyCycle_Percent = 20, PreBurstTime_s = 2000e-9, PostBurstTime_s = 500e-9, BurstStartTriggerExport = "PXI_Trig0" }; PAENConfiguration paenConfig = new PAENConfiguration { PAEnableMode = PAENMode.Dynamic, PAEnableTriggerExportTerminal = "PFI0", PAEnableTriggerMode = RfsgMarkerEventOutputBehaviour.Toggle, }; switch (desiredMode) { case DigitalMode.RFFE_MIPI: //Calculate the command length by multiplying the number of vector cycles (18 for Reg0Write) //by the clock rate (currently 52 MHz) paenConfig.CommandEnableTime_s = 18 * (1 / 52e6); paenConfig.CommandDisableTime_s = 18 * (1 / 52e6); break; case DigitalMode.Digital_Enable: //For the digital enable case, the command time can be considered to be 0 since the digital //line is simply being toggled high/low paenConfig.CommandDisableTime_s = 0; paenConfig.CommandEnableTime_s = 0; break; } //Until NI-DIGITAL 19.0 is released, the triggering mechanism used is to trigger using the PFI line //and detecting the change with a match opcode. There are a total of 830 cycles of the instrument required //before the command is sent from the pattern. Hence, an 830ns delay is added to the command time to account //for this. paenConfig.CommandEnableTime_s += 830e-9; paenConfig.CommandDisableTime_s += 830e-9; ConfigureBurstedGeneration(rfsgSession, wave, waveTiming, paenConfig, out _, out _); #endregion #region NI Digital Config NIDigital digital = new NIDigital(digitalName, false, false); ProjectFiles projectFiles = Digital.Utilities.SearchForProjectFiles(Path.GetFullPath(@"Dynamic Digital Control Project"), true); LoadProjectFiles(digital, projectFiles); ApplyPinTDROffset(digital, "PFI0", PFI0CableDelay_s); //Select the appropriate pattern based on the desired control mechanism switch (desiredMode) { case DigitalMode.Digital_Enable: digital.PatternControl.BurstPattern("", "Dynamic_Digital_Enable", true, false, TimeSpan.FromSeconds(10)); break; case DigitalMode.RFFE_MIPI: digital.PatternControl.BurstPattern("", "Dynamic_RFFE_Control", true, false, TimeSpan.FromSeconds(10)); break; } #endregion rfsgSession.Initiate(); Console.WriteLine("Generation on the signal generator and digital pattern instrument has begun. Press any key to abort generation and exit the program."); Console.ReadKey(); AbortGeneration(rfsgSession); digital.PatternControl.Abort(); DisconnectAndClose(digital); rfsgSession.Close(); }
private static void GetInstrumentConfig(InstrumentConfiguration ic, out string ionSource, out string analyzer, out string detector) { // ReSharper disable CollectionNeverQueried.Local (why does ReSharper warn on this?) SortedDictionary<int, string> ionSources = new SortedDictionary<int, string>(); SortedDictionary<int, string> analyzers = new SortedDictionary<int, string>(); SortedDictionary<int, string> detectors = new SortedDictionary<int, string>(); // ReSharper restore CollectionNeverQueried.Local foreach (Component c in ic.componentList) { CVParam term; switch (c.type) { case ComponentType.ComponentType_Source: term = c.cvParamChild(CVID.MS_ionization_type); if (!term.empty()) ionSources.Add(c.order, term.name); else { // If we did not find the ion source in a CVParam it may be in a UserParam UserParam uParam = c.userParam("msIonisation"); // Not L10N if (HasInfo(uParam)) { ionSources.Add(c.order, uParam.value); } } break; case ComponentType.ComponentType_Analyzer: term = c.cvParamChild(CVID.MS_mass_analyzer_type); if (!term.empty()) analyzers.Add(c.order, term.name); else { // If we did not find the analyzer in a CVParam it may be in a UserParam UserParam uParam = c.userParam("msMassAnalyzer"); // Not L10N if (HasInfo(uParam)) { analyzers.Add(c.order, uParam.value); } } break; case ComponentType.ComponentType_Detector: term = c.cvParamChild(CVID.MS_detector_type); if (!term.empty()) detectors.Add(c.order, term.name); else { // If we did not find the detector in a CVParam it may be in a UserParam UserParam uParam = c.userParam("msDetector"); // Not L10N if (HasInfo(uParam)) { detectors.Add(c.order, uParam.value); } } break; } } ionSource = String.Join("/", new List<string>(ionSources.Values).ToArray()); // Not L10N analyzer = String.Join("/", new List<string>(analyzers.Values).ToArray()); // Not L10N detector = String.Join("/", new List<string>(detectors.Values).ToArray()); // Not L10N }
public void updateRow(SpectrumDataSet.SpectrumTableRow row, MassSpectrum spectrum) { spectrumList[spectrum.Index] = spectrum; Spectrum s = spectrum.Element; //GetElement(false); DataProcessing dp = spectrum.DataProcessing; Scan scan = null; InstrumentConfiguration ic = null; if (s.scanList.scans.Count > 0) { scan = s.scanList.scans[0]; ic = scan.instrumentConfiguration; } if (dp == null) { dp = s.dataProcessing; } CVParam param; param = s.cvParam(CVID.MS_ms_level); row.MsLevel = !param.empty() ? (int)param.value : 0; param = scan != null?scan.cvParam(CVID.MS_scan_start_time) : new CVParam(); row.ScanTime = !param.empty() ? (double)param.value : 0; param = s.cvParam(CVID.MS_base_peak_m_z); row.BasePeakMz = !param.empty() ? (double)param.value : 0; param = s.cvParam(CVID.MS_base_peak_intensity); row.BasePeakIntensity = !param.empty() ? (double)param.value : 0; param = s.cvParam(CVID.MS_total_ion_current); row.TotalIonCurrent = !param.empty() ? (double)param.value : 0; var precursorInfo = new StringBuilder(); var isolationWindows = new StringBuilder(); if (row.MsLevel == 1 || s.precursors.Count == 0) { precursorInfo.Append("n/a"); isolationWindows.Append("n/a"); } else { foreach (Precursor p in s.precursors) { foreach (SelectedIon si in p.selectedIons) { if (precursorInfo.Length > 0) { precursorInfo.Append(","); } precursorInfo.AppendFormat("{0:G8}", (double)si.cvParam(CVID.MS_selected_ion_m_z).value); } var iw = p.isolationWindow; CVParam isolationTarget = iw.cvParam(CVID.MS_isolation_window_target_m_z); if (!isolationTarget.empty()) { double iwMz = (double)isolationTarget.value; if (isolationWindows.Length > 0) { isolationWindows.Append(","); } CVParam lowerOffset = iw.cvParam(CVID.MS_isolation_window_lower_offset); CVParam upperOffset = iw.cvParam(CVID.MS_isolation_window_upper_offset); if (lowerOffset.empty() || upperOffset.empty()) { isolationWindows.AppendFormat("{0:G8}", iwMz); } else { isolationWindows.AppendFormat("[{0:G8}-{1:G8}]", iwMz - (double)lowerOffset.value, iwMz + (double)upperOffset.value); } } } } if (precursorInfo.Length == 0) { precursorInfo.Append("unknown"); } row.PrecursorInfo = precursorInfo.ToString(); if (isolationWindows.Length == 0) { isolationWindows.Append("unknown"); } row.IsolationWindows = isolationWindows.ToString(); StringBuilder scanInfo = new StringBuilder(); foreach (Scan scan2 in s.scanList.scans) { if (scan2.scanWindows.Count > 0) { foreach (ScanWindow sw in scan2.scanWindows) { if (scanInfo.Length > 0) { scanInfo.Append(","); } scanInfo.AppendFormat("[{0:G8}-{1:G8}]", (double)sw.cvParam(CVID.MS_scan_window_lower_limit).value, (double)sw.cvParam(CVID.MS_scan_window_upper_limit).value); } } } if (scanInfo.Length == 0) { scanInfo.Append("unknown"); } row.ScanInfo = scanInfo.ToString(); row.IonMobility = scan != null ? (double)scan.cvParam(CVID.MS_ion_mobility_drift_time).value : 0; if (row.IonMobility == 0 && scan != null) { row.IonMobility = (double)scan.cvParam(CVID.MS_inverse_reduced_ion_mobility).value; if (row.IonMobility == 0) { // Early version of drift time info, before official CV params var userparam = scan.userParam("drift time"); if (!userparam.empty()) { row.IonMobility = userparam.timeInSeconds() * 1000.0; } } } row.SpotId = s.spotID; row.SpectrumType = s.cvParamChild(CVID.MS_spectrum_type).name; row.DataPoints = s.defaultArrayLength; row.IcId = (ic == null || ic.id.Length == 0 ? "unknown" : ic.id); row.DpId = (dp == null || dp.id.Length == 0 ? "unknown" : dp.id); }
public static void ConfigureRF(ref NIRfsg rfsgHandle, InstrumentConfiguration instrConfig) { rfsgHandle.RF.ExternalGain = -instrConfig.ExternalAttenuation_dBm; rfsgHandle.RF.Configure(instrConfig.CarrierFrequency_Hz, instrConfig.AverageInputPower_dBm); }
private void gridView_ShowCellToolTip(DataGridViewCell cell) { MassSpectrum spectrum = cell.OwningRow.Tag as MassSpectrum; Spectrum s = spectrum.Element; TreeViewForm treeViewForm = new TreeViewForm(spectrum); TreeView tv = treeViewForm.TreeView; if (gridView.Columns[cell.ColumnIndex].Name == "PrecursorInfo") { treeViewForm.Text = "Precursor Details"; if (s.precursors.Count == 0) { tv.Nodes.Add("No precursor information available."); } else { foreach (Precursor p in s.precursors) { string pNodeText = "Precursor scan"; if (p.sourceFile != null && p.externalSpectrumID.Length > 0) { pNodeText += String.Format(": {0}:{1}", p.sourceFile.name, p.externalSpectrumID); } else if (p.spectrumID.Length > 0) { pNodeText += String.Format(": {0}", p.spectrumID); } TreeNode pNode = tv.Nodes.Add(pNodeText); addParamsToTreeNode(p as ParamContainer, pNode); if (p.selectedIons.Count == 0) { pNode.Nodes.Add("No selected ion list available."); } else { foreach (SelectedIon si in p.selectedIons) { TreeNode siNode = pNode.Nodes.Add("Selected ion"); //siNode.ToolTipText = new CVTermInfo(CVID.MS_selected_ion); // not yet in CV addParamsToTreeNode(si as ParamContainer, siNode); } } if (p.activation.empty()) { pNode.Nodes.Add("No activation details available."); } else { TreeNode actNode = pNode.Nodes.Add("Activation"); addParamsToTreeNode(p.activation as ParamContainer, actNode); } if (p.isolationWindow.empty()) { pNode.Nodes.Add("No isolation window details available."); } else { TreeNode iwNode = pNode.Nodes.Add("Isolation Window"); addParamsToTreeNode(p.isolationWindow as ParamContainer, iwNode); } } } } else if (gridView.Columns[cell.ColumnIndex].Name == "ScanInfo") { treeViewForm.Text = "Scan Configuration Details"; if (s.scanList.empty()) { tv.Nodes.Add("No scan details available."); } else { TreeNode slNode = tv.Nodes.Add("Scan List"); addParamsToTreeNode(s.scanList as ParamContainer, slNode); foreach (Scan scan in s.scanList.scans) { TreeNode scanNode = slNode.Nodes.Add("Acquisition"); addParamsToTreeNode(scan as ParamContainer, scanNode); foreach (ScanWindow sw in scan.scanWindows) { TreeNode swNode = scanNode.Nodes.Add("Scan Window"); addParamsToTreeNode(sw as ParamContainer, swNode); } } } } else if (gridView.Columns[cell.ColumnIndex].Name == "InstrumentConfigurationID") { treeViewForm.Text = "Instrument Configuration Details"; InstrumentConfiguration ic = s.scanList.scans[0].instrumentConfiguration; if (ic == null || ic.empty()) { tv.Nodes.Add("No instrument configuration details available."); } else { TreeNode icNode = tv.Nodes.Add(String.Format("Instrument Configuration ({0})", ic.id)); addParamsToTreeNode(ic as ParamContainer, icNode); if (ic.componentList.Count == 0) { icNode.Nodes.Add("No component list available."); } else { TreeNode clNode = icNode.Nodes.Add("Component List"); foreach (pwiz.CLI.msdata.Component c in ic.componentList) { string cNodeText; switch (c.type) { case ComponentType.ComponentType_Source: cNodeText = "Source"; break; case ComponentType.ComponentType_Analyzer: cNodeText = "Analyzer"; break; default: case ComponentType.ComponentType_Detector: cNodeText = "Detector"; break; } TreeNode cNode = clNode.Nodes.Add(cNodeText); addParamsToTreeNode(c as ParamContainer, cNode); } } Software sw = ic.software; if (sw == null || sw.empty()) { icNode.Nodes.Add("No software details available."); } else { TreeNode swNode = icNode.Nodes.Add(String.Format("Software ({0})", sw.id)); CVParam softwareParam = sw.cvParamChild(CVID.MS_software); TreeNode swNameNode = swNode.Nodes.Add("Name: " + softwareParam.name); swNameNode.ToolTipText = new CVTermInfo(softwareParam.cvid).def; swNode.Nodes.Add("Version: " + sw.version); } } } else if (gridView.Columns[cell.ColumnIndex].Name == "DataProcessing") { treeViewForm.Text = "Data Processing Details"; DataProcessing dp = s.dataProcessing; if (dp == null || dp.empty()) { tv.Nodes.Add("No data processing details available."); } else { TreeNode dpNode = tv.Nodes.Add(String.Format("Data Processing ({0})", dp.id)); if (dp.processingMethods.Count == 0) { dpNode.Nodes.Add("No component list available."); } else { TreeNode pmNode = dpNode.Nodes.Add("Processing Methods"); foreach (ProcessingMethod pm in dp.processingMethods) { addParamsToTreeNode(pm as ParamContainer, pmNode); } } } } else { return; } tv.ExpandAll(); treeViewForm.StartPosition = FormStartPosition.CenterParent; treeViewForm.AutoSize = true; //treeViewForm.DoAutoSize(); treeViewForm.Show(this.DockPanel); //leaveTimer.Start(); this.Focus(); }
/// <summary> /// This example illustrates how to use RFSG drivers and envelope tracking APIs to configure envelope tracking. /// </summary> static void Main(string[] args) { #region Example Settings // Select mode for use in the example EnvelopeMode mode = EnvelopeMode.Detrough; string waveformPath = @"C:\Users\Public\Documents\National Instruments\RFIC Test Software\Waveforms\LTE_FDD_DL_1x20MHz_TM11_OS4.tdms"; #endregion #region Configure RF Generator // Initialize instrument sessions NIRfsg rfVsg = new NIRfsg("5840", true, false); // Load up waveform Waveform rfWfm = LoadWaveformFromTDMS(waveformPath); // Configure RF generator InstrumentConfiguration rfInstrConfig = InstrumentConfiguration.GetDefault(); ConfigureInstrument(rfVsg, rfInstrConfig); DownloadWaveform(rfVsg, rfWfm); ConfigureContinuousGeneration(rfVsg, rfWfm); #endregion #region Configure Tracker Generator NIRfsg envVsg = new NIRfsg("5820", true, false); // Configure envelope generator EnvelopeGeneratorConfiguration envInstrConfig = EnvelopeGeneratorConfiguration.GetDefault(); TrackerConfiguration trackerConfig = TrackerConfiguration.GetDefault(); ConfigureEnvelopeGenerator(envVsg, envInstrConfig, trackerConfig); Waveform envWfm = new Waveform(); switch (mode) { case EnvelopeMode.Detrough: // Create envelope waveform DetroughConfiguration detroughConfig = DetroughConfiguration.GetDefault(); detroughConfig.MinimumVoltage_V = 1.5; detroughConfig.MaximumVoltage_V = 3.5; detroughConfig.Exponent = 1.2; detroughConfig.Type = DetroughType.Exponential; envWfm = CreateDetroughEnvelopeWaveform(rfWfm, detroughConfig); break; case EnvelopeMode.LUT: LookUpTableConfiguration lutConfig = new LookUpTableConfiguration { DutAverageInputPower_dBm = rfInstrConfig.DutAverageInputPower_dBm }; // Todo - initialize lookup table envWfm = CreateLookUpTableEnvelopeWaveform(rfWfm, lutConfig); break; } ScaleAndDownloadEnvelopeWaveform(envVsg, envWfm, trackerConfig); ConfigureContinuousGeneration(envVsg, envWfm, "PFI0"); #endregion // Start envelope tracking SynchronizationConfiguration syncConfig = SynchronizationConfiguration.GetDefault(); InitiateSynchronousGeneration(rfVsg, envVsg, syncConfig); // Wait until user presses a button to stop Console.WriteLine("Press any key to abort envelope tracking.."); Console.ReadKey(); AbortGeneration(envVsg); AbortGeneration(rfVsg); // Close instruments rfVsg.Close(); envVsg.Close(); }