High-Speed Digitizers

cancel
Showing results for 
Search instead for 
Did you mean: 

Multi Record Channel Example

Hello,

 

i have a NI PXIE 5122 with two Channels.

And i used help to synchronized the two channels in one measurment.

 

 

My test Code:

 

scopeSession = new NIScope("PXI1Slot3", false, false);
          
scopeSession.DriverOperation.Warning += new EventHandler<ScopeWarningEventArgs>(DriverOperation_Warning);
 
scopeSession.Channels["1"].Enabled = true;
scopeSession.Channels["1"].Range = 5;
scopeSession.Channels["0"].Enabled = true;
scopeSession.Channels["0"].Range = 5;
 
scopeSession.Acquisition.SampleRateMin = frequenz;
scopeSession.Acquisition.NumberOfPointsMin = blockLenght ;
           
scopeSession.Timing.EnforceRealtime = true;
scopeSession.Timing.NumberOfRecordsToAcquire = 1;
 
scopeSession.Channels["0"].Measurement.OtherChannel = "1";
scopeSession.Trigger.ConfigureTriggerImmediate();
scopeSession.Measurement.Initiate();
 
AnalogWaveformCollection<double> waveformsLine0 = new AnalogWaveformCollection<double>();
 
waveformsLine0 =scopeSession.Channels["0"].Measurement.FetchArrayMeasurement(timeout,
ScopeArrayMeasurementType.MultipleAcquisitionVoltageHistogram, waveformsLine0);
 
The test code work, but the give only data from Channel 0.
 
 
And i like to have, in waveformsLine0, the data from two channels.
In the Form
waveformsLine0[0].GetScaledData(); --> Data Channel 0
waveformsLine0[1].GetScaledData(); --> Data Channel 1
 
Please help me, and thanks
Robert
0 Kudos
Message 1 of 5
(5,598 Views)

Hi Robert,

 

What are you trying to accomplish?  Just a simple 2 channel acquisition, where the waveforms returned is the channel data?  Also, how familiar are you with the NI-SCOPE driver and NI Digitizers?   By design, both channels on the same digitizer/oscilloscope will be synchronized, because they share the same ADC sample clock (and timebase settings).  

 

Your test code is a little strange because you are fetching measurements, but it sounds like you want to fetch acquisiton data.  With NI-SCOPE you can fetch the waveform acquisition data, and additionally you can fetch measurement data.  A measurement fetch performs a normal waveform data fetch, but then applies some extra processing before it is returned to you.  For example, the ScopeArrayMeasurementType.AddChannels is an array measurement function.  This function (as documented here: http://zone.ni.com/reference/en-XX/help/370592N-01/digitizers/add_channels/), will fetch data from both channels and perform the "Add" operation on the channels, and return the waveform array of the added channels.  This extra processing is done in the driver, after the data is fetched from the device.  For examples on the differences, see the C# examples "ConfiguredAcquisition", which shows acquisition fetching, and "AdvancedMeasurementLibrary" which show fetching processed measurements.  For a list of all the measurements you can perform see: http://zone.ni.com/reference/en-XX/help/370592N-01/TOC140.htm

 

So in summary, the code you wrote is fetching processed acquisition data called measurements, and from the sound of your acquisition, you will want to fetch acquired data.  To understand the calls you are performing, you need to understand the NI-SCOPE driver programming flow.

 

http://zone.ni.com/reference/en-XX/help/370592N-01/digitizers/programming_flow/

http://zone.ni.com/reference/en-XX/help/370592N-01/digitizers/acquisition_functions/

http://zone.ni.com/reference/en-XX/help/370592N-01/TOC131.htm

 

For reference, the above links are from the help file, and contrast with the Waveform Measurement functions here:

http://zone.ni.com/reference/en-XX/help/370592N-01/TOC134.htm

 

In summary, I think the code you need is this:

 

...

AnalogWaveformCollection<double> waveformsLine0 = null;
scopeSession.Measurement.Initiate();
waveformsLine0 =scopeSession.Channels["0,1"].Measurement.FetchDouble(timeout, -1, waveformsLine0); 

...

 

Instead of fetching waveform measurements, we are fetching the acquired data, directly from the digitizer without post-processing.  

 

 


 

So in your code, you are doing a Voltage Histogram measurement, and if this is what you want to do, then this line of code is the one you need to change.  This line states fetch a measurement from channel "0". 

 

waveformsLine0 =scopeSession.Channels["0"].Measurement.FetchArrayMeasurement(timeout,
ScopeArrayMeasurementType.MultipleAcquisitionVoltageHistogram, waveformsLine0);
 
So if you want to fetch data from channel "0" and "1", then the channels string should be "0,1":
 
waveformsLine0 =scopeSession.Channels["0,1"].Measurement.FetchArrayMeasurement(timeout,
ScopeArrayMeasurementType.MultipleAcquisitionVoltageHistogram, waveformsLine0);
 
 
 
I hope this helps, if you have further questions on how the driver works, I highly reccomend the help file as the first place to look.
 
Regards,
Nathan
Systems Engineer
SISU
0 Kudos
Message 2 of 5
(5,577 Views)

Hello Nathan-P,

 

Thank you very mutch. 🙂

 

This was the code I need to finish my question:

waveformsLine0 = scopeSession.Channels["0,1"].Measurement.FetchDouble(timeout, -1, waveformsLine0);

And now I get synchrony my data.

 

This help was very good.

 

And maybe you can help me again.

The scope card I have is a PXIE 5122.

The have two input channels and one trigger channel.

 

And I like to configure the trigger channel to the StartTrigger?

How I program this?

 

The trigger input signal is zero on start the acquisition.

I started the program in form of this code:

waveformsLine0 = scopeSession.Channels["0,1"].Measurement.FetchDouble(timeout, -1, waveformsLine0);

And 20 seconds later the trigger input signal goes on 5V.

Then started the acquisition and the get 40 ms because my

scopeSession.Acquisition.NumberOfPointsMin is long enough.

And after the buffer is fill then I get the data.

 

I know:

I have the start trigger on this form

scopeSession.Trigger.StartTrigger

But how I can configure on input line trigger?

 

Please help me, and thanks

Robert

 

 

 

 

 

 

0 Kudos
Message 3 of 5
(5,560 Views)

Hi Robert,

I am unsure of exactly what you are attempting to do.  There is a difference between Start Triggers and Reference Triggers.  The TRIG BNC connector can only be used for Reference Triggers.  Start Triggers can also only come from digital events, so externally on the PXI_Trig lines or the PFI 0 or PFI 1 lines.  

 

The TRIG input channel is an analog channel, and how the firmware of NI Digitizers/oscilloscopes works is that the Start trigger prevents the ADCs from sampling until after this event occurs.  Since the Start trigger gates the acquisition of analog data, analog triggers cannot be used for the Start Trigger, only digital signals.  For more information see:  http://zone.ni.com/reference/en-XX/help/370592Y-01/digitizers/5122_state_model/

 

 

 

 

 

For an example of how to configure reference triggering I reccomend you look at the c# example "ConfiguredAcquisition", as this shows how to implement both digital triggers and analog triggers.  

 

I hope this helps!

Nathan P.

Systems Engineer
SISU
0 Kudos
Message 4 of 5
(5,555 Views)

Hello Nathan-P,

 

sorry for not answer, but we hat not a test system.

 

And now i can test but it work not. 🙂

We have a digital signal on PFI0.

They are "0" when we not to record data and "1" when we need data.

To start  the acquisition we want to used the "Start (Acquisition Arm) Trigger" to see in your state modell.

And later the "Reference Stop Trigger" to stop the acquisition.

 

To test i have build two Threads.

One thread to make ready the system and make the measurment:

{

            scopeSession.Timing.ConfigureTiming(10000, 10000, 0, 1, true);
            PrecisionTimeSpan triggerHoldoff = PrecisionTimeSpan.FromSeconds(20.0);
            PrecisionTimeSpan triggerDelay = PrecisionTimeSpan.Zero;

            scopeSession.Trigger.ConfigureTriggerSoftware(triggerHoldoff, triggerDelay);
            scopeSession.Measurement.Initiate();

            PrecisionTimeSpan timeout = new PrecisionTimeSpan(5.0);
            AnalogWaveformCollection<double> test = new AnalogWaveformCollection<double>();
            test = scopeSession.Channels["0,1"].Measurement.FetchDouble(timeout,6, test);

}

 

Second thread to test the start trigger with:

scopeSession.Trigger.StartTrigger.SendSoftwareEdgeTrigger();

 

End

I did work not.

And the measurment thread run and wait nothing.

 

The "StartTrigger" Thread make nothing.

In the NI-SCOPE .NET Class Library 2.0 i did found not a example for StartTrigger.

Can you please send me a example for a test with a Starttrigger.

 

 

 

0 Kudos
Message 5 of 5
(5,215 Views)