High-Speed Digitizers

cancel
Showing results for 
Search instead for 
Did you mean: 

StreamToDisk with repeated fetching?

Solved!
Go to solution

Hi there,

 

I am running the C#.NET for VS 2008 example StreamToDisk for my USB 5132.  The example streams one trigger to disk.  I would like to modify the example so that it can stream many triggers to disk instead of just one.  So, I have added a TextBox to the MainForm called nTriggersTextBox, and I am using it like this (MainForm.cs attached):

 

for (int i = 0; i < Int64.Parse(nTriggersTextBox.Text); i++)
   {
   scopeSingleRecordReader.FetchFromMultipleChannelsAsync(channelNameTextBox.Text, 0, sampleScopeSession.Timing.ActualRecordLength, PrecisionTimeSpan.FromSeconds(5), null);
   }

 

The error code that results for nTriggers>1 is "Can not perform a fetch/read operation when the associated ScopeSession object is being changed."

 

Should I put my loop someplace else?  Or is it more complicated than that?

 

Thanks,

Penny

 

 

Download All
0 Kudos
Message 1 of 16
(7,031 Views)

Hi Penny,

 

I think what you are trying to accomplish is a multi-record acquisition.  This is not a feature of the USB-5132 or 5133:  

 

Does the NI USB-5132/5133 Support Multiple Record Acquisition?

 

There have been a couple of other discussions about how you could determine the retriggering rate (using software benchmarks on fetching one record + calculations based on your record size.)  However, the USB-513x currently can only store one record at a time in internal memory.

 

Can you share your higher-level goals for your project, or what signal you are trying to acquire?  If you determine (from single record fetches on the USB-513x) that you absolutely need to store more than one record on the digitizer at a time, I might recommend looking at a PCI version of a digitizer (such as the 5114).

 

-Andrew

National Instruments
0 Kudos
Message 2 of 16
(7,025 Views)

Hi Andrew,

Thanks for the reply.  Actually we do not need multi-record acquisition.  I just want the 5132-USB to re-arm, and then I want to get the next waveform, then re-arm again, then get that waveform, etc.  The NI C# example called StreamToDisk gets one waveform from each of the 2 channels and then quits.  There is another C# example that is called "FetchForever" that would be perfect, but it can only fetch from 1 channel at a time, and we need 2  I am wondering how can I edit the C# StreamToDisk example to keep it fetching my 2 waveforms for a certain number of trigger/re-arms?  I thought that I could just loop over the Fetch step, but this causes the error that I described above.

 

We are measuring RF power from the output of a radiometer in a particle physics experiment.

 

Thanks,

Penny

 

0 Kudos
Message 3 of 16
(7,019 Views)

Hi Penny,

 

Thanks for the additional detail. You can not fetch multiple records in the way you describe; that is essentially a multi-record acquisition.

 

My best suggestion is to perform a psuedo multi-record acquisition in software, which you can do. It requires you to completely close the session to the scope and re-open it. This is an expensive operation time-wise compared to a multi-record acquisition, but if the time between records is long enough, you should be able to get several records of data using this method. I have posted this in more detail here.

 

If this method is not good enough, then we can look into alternatives.

 

Let me know if you have thoughts or questions!

 

Regards,

Aaron

National Instruments
0 Kudos
Message 4 of 16
(6,995 Views)

Hi Aaron,

OK great, thanks.  It is helpful to know that we have to close the session entirely in order to re-arm.  We will get this going asap and then see how things are looking.

Regards,

Penny

 

0 Kudos
Message 5 of 16
(6,983 Views)

You do not need to close and re open the session to re arm the digitizer.  After you start an acquisition and fetch the data you want, you can call Initiate Acquisition to start a new acquistion.  If you haven't changed the configuration of the digitizer doing this will be quicker than closing and re-opening a session since a lot of the configuration won't have to be repeated.

 

Stephen

0 Kudos
Message 6 of 16
(6,976 Views)

Hi Stephen,

Thanks for the additional info.  Will start checking our stuff.

Regards,

Penny

 

0 Kudos
Message 7 of 16
(6,968 Views)

Penny,

 

I wanted to second what Stephen just mentioned. I was under the impression that closing the session was required for the USB digitizers. I tested this and it is not the case. You do not need to close and reopen the session. Sorry for the confusion!

 

Regards,
Aaron 

National Instruments
0 Kudos
Message 8 of 16
(6,964 Views)

Penny,

 

I also wanted to add one more comment regarding your question about using the fetch forever example.

 

I have tested this with the USB-5132, and was able to modify the example to perform an acquisition on two channels simultaneously. To accomplish this, you must change the niScope Fetch to a niScope Multi Fetch, allowing the fetch function to return data for two channels. The data type output for the original example is a 1-dimensional array of I8, and when changed will be a 2-dimensional array of I8. From here, you can do what you wish with the data. 

 

I wanted to make sure you knew this option was on the table!

 

Regards,

Aaron

National Instruments
0 Kudos
Message 9 of 16
(6,959 Views)

Thank you Aaron and Stephen.  I am going start trying these suggestions asap.

Regards,

Penny

 

0 Kudos
Message 10 of 16
(6,943 Views)