10-04-2011 09:25 AM
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
Solved! Go to Solution.
10-04-2011 04:11 PM - edited 10-04-2011 04:11 PM
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
10-04-2011 09:56 PM
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
10-06-2011 05:13 PM
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
10-11-2011 09:21 AM
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
10-11-2011 10:29 AM
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
10-11-2011 10:44 AM
Hi Stephen,
Thanks for the additional info. Will start checking our stuff.
Regards,
Penny
10-11-2011 10:46 AM
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
10-11-2011 01:07 PM
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
10-13-2011 08:29 AM
Thank you Aaron and Stephen. I am going start trying these suggestions asap.
Regards,
Penny