Example #1
0
        public FrequencyResponseTest(
            Transceiver transceiver,
            double startFrequency   = 995E6,
            double stopFrequency    = 1.005E9,
            int steps               = 60,
            double sgPowerLevel     = -10,
            double saReferenceLevel = 0,
            double bandwidth        = 1E6, //10E3,
            double dwellTime        = 1E-3,
            double deskew           = 0,
            string triggerLine      = "PXI_Trig0",
            double timeout          = 10)
        {
            this.transceiver      = transceiver;
            this.startFrequency   = startFrequency;
            this.stopFrequency    = stopFrequency;
            this.steps            = steps;
            this.sgPowerLevel     = sgPowerLevel;
            this.saReferenceLevel = saReferenceLevel;
            this.bandwidth        = bandwidth;
            this.dwellTime        = dwellTime;
            this.deskew           = deskew;
            this.triggerLine      = triggerLine;
            this.timeout          = new PrecisionTimeSpan(timeout);

            transceiver.Initialize(); // initializing the hardware ahead of time can dramatically speed up execution of the caller
        }
Example #2
0
        public void Trigger()
        {
            IIviDmmTrigger Trigger = Dmm.Trigger;

            Trigger.Configure("Software", true);
            Assert.AreEqual("Software", Trigger.Source);
            // due to difference between IVI-C and IVI.NET driver, this property will always return false.
            Assert.AreEqual(false, Trigger.DelayAuto);
            PrecisionTimeSpan delay = new PrecisionTimeSpan((decimal)100);

            Trigger.Configure("External", delay);
            Assert.AreEqual("External", Trigger.Source);
            Assert.AreEqual(delay, Trigger.Delay);

            Trigger.Slope = Slope.Positive;
            // Assert.AreEqual(Slope.Positive, Trigger.Slope); // Failed, why?
            Trigger.Slope = Slope.Negative;
            Assert.AreEqual(Slope.Negative, Trigger.Slope);

            Trigger.MeasurementCompleteDestination = "TTL0";
            // Assert.AreEqual("TTL0", Trigger.MeasurementCompleteDestination); // Failed

            Trigger.MeasurementCompleteDestination = "External";
            Assert.AreEqual("External", Trigger.MeasurementCompleteDestination);

            Trigger.MultiPoint.Configure(1, 10, "Software", new PrecisionTimeSpan((decimal)10));
            Assert.AreEqual(1, Trigger.MultiPoint.TriggerCount);
            Assert.AreEqual(10, Trigger.MultiPoint.SampleCount);
            Assert.AreEqual("Software", Trigger.MultiPoint.SampleTrigger);
        }
 public static void ApplyPinTDROffset(NIDigital nIDigital, string pinName, double cableDelay_s)
 {
     //Create a new PrecisionTimeSpan array with the cable delay value
     PrecisionTimeSpan[] offsets = new PrecisionTimeSpan[1] {
         PrecisionTimeSpan.FromSeconds(cableDelay_s)
     };
     nIDigital.PinAndChannelMap.GetPinSet(pinName).ApplyTdrOffsets(offsets);
 }
Example #4
0
        public AnalogWaveformCollection <double> Sample()
        {
            AnalogWaveformCollection <double> waveforms = null;

            ScopeSession.Measurement.Initiate();
            waveforms = ScopeSession.Channels[_channelList].Measurement.FetchDouble(PrecisionTimeSpan.FromSeconds(-1),
                                                                                    _recordLengthMin, waveforms);
            return(waveforms);
        }
        private static void FetchAndLog(NIRfsa rfsa,
                                        RFmxInstrMXPersonalities personality, string signalName, string folderPath)
        {
            RfsaAcquisitionType aqType = rfsa.Configuration.AcquisitionType;

            if (aqType == RfsaAcquisitionType.IQ)
            {
                ComplexDouble[,] data;

                PrecisionTimeSpan timeout = new PrecisionTimeSpan(10.0);
                double            iqRate  = rfsa.Configuration.IQ.IQRate;
                long records = rfsa.Configuration.IQ.NumberOfRecords;
                long samples = rfsa.Configuration.IQ.NumberOfSamples;

                // Fetch IQ data
                data = rfsa.Acquisition.IQ.FetchIQMultiRecordComplex <ComplexDouble>(0, records, samples, timeout);

                // Create file name
                string path     = "";
                string fileName = $"{personality.ToString()}_{signalName}_IQ_{iqRate}.txt";

                // Combine the folder and file path if folder path is not empty; otherwise, just use the filename for path
                if (!string.IsNullOrEmpty(folderPath))
                {
                    path = Path.Combine(folderPath, fileName);
                }
                else
                {
                    path = fileName;
                }

                // Create an absolute path
                path = Path.GetFullPath(path);

                // Make sure the output directory exists if not currently
                Directory.CreateDirectory(Path.GetDirectoryName(path));

                StreamWriter writer = new StreamWriter(path);

                for (int r = 0; r <= data.GetUpperBound(0); r++)     // r = record
                {
                    for (int s = 0; s <= data.GetUpperBound(1); s++) // s = sample
                    {
                        writer.WriteLine(data[r, s].Real);
                        writer.WriteLine(data[r, s].Imaginary);
                    }
                }
                writer.Flush();
                writer.Close();
                Console.WriteLine($"IQ data successfully saved to \"{path}\".");
            }
            else
            {
                Console.WriteLine("This measurement uses a spectral acquisition mode, which is not possible to fetch. This measurement will be skipped.");
            }
        }
        public void writeWaveform(ComplexWaveform <ComplexDouble> IQdata) //input is complex waveform that was created using createWaveform(offsets);
        {
            //rest of code to write offsets
            ComplexWaveform <ComplexDouble> NewIQData = new ComplexWaveform <ComplexDouble>(numSamples);
            //List<PhaseAmplitudeOffset> offsetList = new List<PhaseAmplitudeOffset>();

            PrecisionTimeSpan dt = PrecisionTimeSpan.FromSeconds(1 / actualIQRate);

            IQdata.PrecisionTiming = PrecisionWaveformTiming.CreateWithRegularInterval(dt);
            _rfsgSession.Arb.WriteWaveform("", IQdata);
            _rfsgSession.Initiate();

            //ComplexWaveform<ComplexDouble> IQdata
        }
Example #7
0
        public NoiseFloorTest(
            Transceiver transceiver,
            string band,
            string waveformName,
            ComplexWaveform <ComplexDouble> waveform,
            double txStartFrequency     = 1920E6,
            double txStopFrequency      = 1980E6,
            double rxStartFrequency     = 2110E6,
            double rxStopFrequency      = 2170E6,
            double frequencyStep        = 1E6,
            int numberOfRuns            = 1,
            string referenceTriggerLine = "PXI_Trig0",
            double sgPowerLevel         = -10,
            double saReferenceLevel     = 10,
            double vbw                   = 10000,
            bool preSoakSweep            = false,
            double soakFrequency         = 1955E6,
            double soakTime              = 0,
            double dwellTime             = 1E-3,
            double idleTime              = 300E-6,
            double referenceTriggerDelay = 15E-6,
            double timeout               = 10)
        {
            this.transceiver          = transceiver;
            this.band                 = band;
            this.waveformName         = waveformName;
            this.waveform             = waveform;
            this.txStartFrequency     = txStartFrequency;
            this.txStopFrequency      = txStopFrequency;
            this.rxStartFrequency     = rxStartFrequency;
            this.rxStopFrequency      = rxStopFrequency;
            this.frequencyStep        = frequencyStep;
            this.numberOfRuns         = numberOfRuns;
            this.referenceTriggerLine = referenceTriggerLine;
            this.sgPowerLevel         = sgPowerLevel;
            this.saReferenceLevel     = saReferenceLevel;
            this.vbw                   = vbw;
            this.preSoakSweep          = preSoakSweep;
            this.soakFrequency         = soakFrequency;
            this.soakTime              = soakTime;
            this.dwellTime             = dwellTime;
            this.idleTime              = idleTime;
            this.referenceTriggerDelay = referenceTriggerDelay;
            this.timeout               = new PrecisionTimeSpan(timeout);

            ThreadPool.QueueUserWorkItem(o => LVFilters.Initialize()); // this is launched asynchronously and will never be waited on

            transceiver.Initialize();
        }
Example #8
0
        public void StartAcquisition(string channelName, double sampleRate, double referencePosition,
                                     double range, int numberOfPoints, int numberOfRecords)
        {
            try
            {
                scopeDevices = new ModularInstrumentsSystem("NI-Scope");
                scopeName    = scopeDevices.DeviceCollection[0].Name;
                scopeSession = new NIScope(scopeName, false, true);
                scopeSession.DriverOperation.Warning += new EventHandler <ScopeWarningEventArgs>(DriverOperation_Warning);

                scopeSession.Channels[channelName].InputImpedance = 50;

                double offset = 0.0;
                ScopeVerticalCoupling coupling = ScopeVerticalCoupling.DC;
                double probeAttenuation        = 1.0;
                scopeSession.Channels[channelName].Configure(range, offset, coupling, probeAttenuation, true);

//                scopeSession.Channels[channelName]

                bool enforceRealtime = true;

                scopeSession.Timing.ConfigureTiming
                    (sampleRate, numberOfPoints, referencePosition, numberOfRecords, enforceRealtime);

                double               triggerLevel    = 1.6;
                ScopeTriggerSlope    triggerSlope    = ScopeTriggerSlope.Positive;
                ScopeTriggerCoupling triggerCoupling = ScopeTriggerCoupling.DC;
                PrecisionTimeSpan    triggerHoldoff  = PrecisionTimeSpan.Zero;
                PrecisionTimeSpan    triggerDelay    = PrecisionTimeSpan.Zero;
                ScopeTriggerSource   triggerSource   = ScopeTriggerSource.External;

                scopeSession.Trigger.EdgeTrigger.Configure
                    (triggerSource, triggerLevel, triggerSlope, triggerCoupling, triggerHoldoff, triggerDelay);

                recordLength     = scopeSession.Acquisition.RecordLength;
                sampleRate       = scopeSession.Acquisition.SampleRate;
                this.channelName = channelName;

                scopeSession.Measurement.Initiate();


                timeout = new PrecisionTimeSpan(5.0);
            }
            catch (Exception ex)
            {
                ShowError(ex);
            }
        }
Example #9
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);
        }
Example #10
0
 public IIviDriverLock Lock(PrecisionTimeSpan maxTime)
 {
     throw new NotImplementedException();
 }
Example #11
0
        //读数据
        private void readData(NIScope scopeSession)
        {
            //var channels = ((JArray)_staticConfig.ChannelConfig.ChannelName).ToObject<List<int>>();
            var channels = ChannelNameTranslator.StringToListInt(_staticConfig.ChannelConfig.ChannelName);
            //开新线程等待读数据
            //await Task.Run(() =>
            //{
            int totalReadDataLength   = 0;
            PrecisionTimeSpan timeout = new PrecisionTimeSpan(1000000);  //无timeOut
            AnalogWaveformCollection <double> scopeWaveform = null;

            double[,] readData = new double[_staticConfig.ChannelCount, _staticConfig.ClockConfig.TotalSampleLengthPerChannel];

            //生成 channels
            string channelScope = null;
            //var sChannels = ((JArray)_staticConfig.ChannelConfig.ChannelName).ToObject<List<int>>();
            var sChannels = ChannelNameTranslator.StringToListInt(_staticConfig.ChannelConfig.ChannelName);

            foreach (var s in sChannels)
            {
                channelScope += s + ",";
            }
            channelScope = channelScope.Substring(0, channelScope.Length - 1);

            //一次采完
            //经过测试,发现在默认设置(不设置其它)情况下:
            // 1、如果多次 FetchDouble,则每 2 次的数据不连续(中间断一截)
            // 2、如果设置多个 records,则每 2 个 record 之间的数据不连续(中间断一截)
            //因此暂时只允许一个 record
            scopeWaveform = scopeSession.Channels[channelScope].Measurement.FetchDouble(timeout, _staticConfig.ClockConfig.TotalSampleLengthPerChannel, scopeWaveform);

            //一旦上面这里获取到数据,则表示采集开始
            AIState = Status.Running;

            // i 是读取次数
            // j 是通道计数
            // k 是每一波的每个点
            double[] temp;
            AnalogWaveform <double> waveform;

            for (int i = 0; i < _staticConfig.ClockConfig.TotalSampleLengthPerChannel / _staticConfig.ClockConfig.ReadSamplePerTime; i++)
            {
                //将一个通道的数据拷贝到 data[,] 的一行
                for (int j = 0; j < _staticConfig.ChannelCount; j++)
                {
                    waveform = scopeWaveform[i, j];
                    temp     = waveform.GetRawData();
                    for (int k = 0; k < _staticConfig.ClockConfig.ReadSamplePerTime; k++)
                    {
                        readData[j, i *_staticConfig.ClockConfig.ReadSamplePerTime + k] = temp[k];
                    }
                }

                totalReadDataLength += _staticConfig.ClockConfig.ReadSamplePerTime;
            }
            GC.Collect();
            Thread.Sleep(2000);

            //发布数据到达事件
            OnDataArrival(readData);

            //发布停止任务事件
            OnAITaskStopped();

            //等待,让外部保证获取到 Running 状态
            Thread.Sleep(2000);
            //});
        }
Example #12
0
 public SwitchRelay(string name)
 {
     maxTime = new PrecisionTimeSpan(500);
     _name   = name;
     InitRelay();
 }
 public void ConfigureTrigger(PrecisionTimeSpan scanDelay, string triggerInput, string scannerAdvancedOutput)
 {
     Adapter.ViSessionStatusCheck(IviSwtchInterop.ConfigureScanTrigger(Adapter.Session, scanDelay.TotalSeconds, SwtchTriggerInput.getC_Value(triggerInput), SwtchTriggerInput.getC_Value(scannerAdvancedOutput)));
 }
 public void ConfigureDwell(bool singleStepEnabled, PrecisionTimeSpan dwell)
 {
     Adapter.ViSessionStatusCheck(IviDownconverterInterop.ConfigureFrequencySweepListDwell(Adapter.Session, singleStepEnabled, dwell.TotalSeconds));
 }
Example #15
0
 public IIviDriverLock Lock(PrecisionTimeSpan maxTime)
 {
     throw new NotImplementedException();
 }
 public void WaitForScanComplete(PrecisionTimeSpan maximumTime)
 {
     Adapter.ViSessionStatusCheck(IviSwtchInterop.WaitForScanComplete(Adapter.Session, (int)maximumTime.TotalMilliseconds));
 }
        public static MeasurementResults MeasureChannel(NIScope scope, string channelName = "0")
        {
            MeasurementResults results = new MeasurementResults();

            scope.Measurement.Initiate();
            AnalogWaveformCollection <double> resultWaveform = new AnalogWaveformCollection <double>();

            resultWaveform         = scope.Channels[channelName].Measurement.FetchDouble(PrecisionTimeSpan.FromSeconds(5), -1, null);
            results.ResultsTrace   = resultWaveform[0].GetRawData();
            results.AverageValue_V = scope.Channels[channelName].Measurement.FetchScalarMeasurement(PrecisionTimeSpan.FromSeconds(5),
                                                                                                    ScopeScalarMeasurementType.VoltageAverage)[0];
            scope.Measurement.Abort();

            return(results);
        }
        public void Trigger()
        {
            IIviDmmTrigger Trigger = Dmm.Trigger;
            Trigger.Configure("Software", true);
            Assert.AreEqual("Software", Trigger.Source);
            // due to difference between IVI-C and IVI.NET driver, this property will always return false.
            Assert.AreEqual(false, Trigger.DelayAuto);
            PrecisionTimeSpan delay = new PrecisionTimeSpan((decimal)100);
            Trigger.Configure("External", delay);
            Assert.AreEqual("External", Trigger.Source);
            Assert.AreEqual(delay, Trigger.Delay);

            Trigger.Slope = Slope.Positive;
            // Assert.AreEqual(Slope.Positive, Trigger.Slope); // Failed, why?
            Trigger.Slope = Slope.Negative;
            Assert.AreEqual(Slope.Negative, Trigger.Slope);

            Trigger.MeasurementCompleteDestination = "TTL0";
            // Assert.AreEqual("TTL0", Trigger.MeasurementCompleteDestination); // Failed

            Trigger.MeasurementCompleteDestination = "External";
            Assert.AreEqual("External", Trigger.MeasurementCompleteDestination);

            Trigger.MultiPoint.Configure(1, 10, "Software", new PrecisionTimeSpan((decimal)10));
            Assert.AreEqual(1, Trigger.MultiPoint.TriggerCount);
            Assert.AreEqual(10, Trigger.MultiPoint.SampleCount);
            Assert.AreEqual("Software", Trigger.MultiPoint.SampleTrigger);


        }