From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

High-Speed Digitizers

cancel
Showing results for 
Search instead for 
Did you mean: 

PCI-5105 FetchForever with 2 or more channels?

Solved!
Go to solution

I'm using the PCI-5105 and MS Visual Studio 2008 to capture a signal.  I based my code off of the FetchForever example and it works great for one channel.  I now need to continously monitor 2 channels.  Can anyone help me acomplish this?  The example only allows one channel.  Maybe there is a better way.  Currently, I'm running some algorithms on the data coming in from one channel.  When there is a signal that triggers in my code, I record ~25ms of data on that channel.  My goal is to now record two channels when the first channel triggers in my code.

 

Thanks,

tom

0 Kudos
Message 1 of 7
(6,867 Views)

Hi Tom,

 

I am assuming that you are using the .Net API for NI-SCOPE.  The FetchForever Example uses the fetch from single channel function.  Try looking at another example such as Configured Acquisition which uses the fetch from multiple channels function: 

 

sampleScopeSingleRecordReader.MemoryOptimizedFetchFromMultipleChannelsAsync(channelsTextBox.Text, 0, Int64.Parse(maximumPointsPerFetchTextBox.Text), PrecisionTimeSpan.FromSeconds(0),waveformCollection, null);

 

You will need to make a few other modifications, but this will be a good starting place.  For example, you will need to remove the error check when >1 channel is in the channel string, change the variable type for multiple waveforms, and modify the plotting.

 

- Jennifer O.

Message Edited by Jennifer O on 10-15-2009 10:12 AM
0 Kudos
Message 2 of 7
(6,845 Views)

Thanks for the advice Jennifer.  I am not using the .Net API, just the c examples for a simple console app.  I looked at the ConfiguredAquisition.c example and based my new code from that.  I can get the two channels recorded, but the data recorded just repeats itself.  Maybe I need to change the trigger, or where in the waveform I should point to get the latest data.

 

Attached is my code.  If you or anyone else could take a look and tell me where I'm missing something, that'll be great.

 

Thanks,

Tom

0 Kudos
Message 3 of 7
(6,811 Views)
Solution
Accepted by topic author tom_madl

Hi Tom,

 

What is your end goal in terms of aquiring data?  I understand you would like to acquire 2 channels worth of data, but it is not clear as to whether you want continuous samples, several records of samples, the latest available samples etc.  There are many possibilities.  Also, do you need to correlate the data back to a trigger? 

 

Assuming you are looking for continous data you will want to stick with the FetchForever example rather than trying the Configured Acquisition Example (I only refer you there to see how 2 channels are fetched).

 

 

FetchForever isn't the most intuitive of the examples.  So here is a quick explanation of how/why it works: Acquiring Data Continuously

 

 

Basically, a reference trigger is a trigger which tells the board when to stop acquiring.  By setting this trigger to software, we are making the digitizer wait for a trigger, and guaranteeing that it will never get one (because we wont send one).  Records are normally formed around the stop trigger, and when you fetch, you get the record including pre and post trigger samples.  In this case the digitizer is continously filling a buffer with samples that could potentially become pre-trigger samples (if a trigger was sent). We just use the read pointer to keep track of which samples we have already read & therefore which samples to read next.

 

   checkErr (niScope_SetAttributeViInt32 (vi, VI_NULL,
                                          NISCOPE_ATTR_FETCH_RELATIVE_TO,
                                          NISCOPE_VAL_READ_POINTER ));

 

The reason why your application is reading the same data is because you are configuring and triggering a single record, then fetching that record over and over again in a loop.  There is no manipulation of the read pointer, and you have sent an immediate reference trigger so the digitizer has stopped acquiring new data.

 

As a side note, to avoid surprises, you may wish to refer to your NI-5105 device specifications for the valid sample rates and voltage ranges.  Based upon an 8V and 8MS/s sample rate, your actual settings will be coerced to 30V and 60M/7 = 8.5714 MS/s.

 

- Jennifer O.

0 Kudos
Message 4 of 7
(6,803 Views)

Hi Jennifer,

 

I will take a look into using the Fetch Relative To attribute.  In the mean time, let me try to explain my end goal.  I am using the 5105 for my development system, the end product will use an FPGA.  So, I do not want to rely on any built in trigger features of the 5105.  Only the fast A/D conversion.

 

For each channel (I will be using 2 channels):

I have a sensor that is collecting analog data at 4k fps.  The analog signal is sent to the 5105 and sampled at 8MS/s, which gives about 2,400 digital data points per frame.  Of these 2,400 data points, only 1,100 are of interest.  There is a synch pulse in the analog signal so I always know which 1,100 points I want to analyze.  I am checking the data and looking for a temporal signature that meets my filters.  The temporal signature can happen on any one or more of the data points and at any time, so I have to be watching all of them all the time.

 

I've done this successfully with one channel using the FetchForever.c example.  Now, it's time to add another channel with another analog sensor and have the two correlate there data.  If I have to, I can lower the sample rate.

 

-Tom

0 Kudos
Message 5 of 7
(6,794 Views)

Tom,

 

I wanted to check in with you and see if you were able to get your program running with acquiring two channels? We want to make sure that you are successful in writing your code for the 5105. Thanks. 

Aaron W.
National Instruments
CLA, CTA and CPI
0 Kudos
Message 6 of 7
(6,732 Views)

Yes, Jennifer was a great help.

 

Thanks,

Tom

0 Kudos
Message 7 of 7
(6,728 Views)