12-28-2012 01:06 PM
Hi,
I am new with this language and I am wondering if it is possible to perform a voltage acquisition with a specific trigger condition using a board NI USB 6251 (for instance the acquisition should begin when voltage reach a certain value).
I couldn't find any example and so I tried the following:
I) I create a Task (AI voltage channel)
II) I create two readers object both on the same task stream (let's say reader1.BeginMemoryOptimizedReadWaveform to read asynchronously and continuously and reader2.ReadWaveform to read just the data after the trigger condition) and two Analogwaveform (let's say data1 and data2).
III) Reader1 stores data in data1 (let's say 2000 samples), the data are analyzed in order to find the trigger condition. After the index satisfying the condition is found I copy the sample values from that index till index+samplesnumber in data2 (let's say samplesnumber=1000 is the data2 size).
IV) I used data2 in Measurements.AutoPowerSpectrum for a spectrum analysis of triggered data.
Unfortunately after the first acquisition data1 size decreases from 2000 till 1000 despite the fact that reader.BeginMemoryOptimizedReadWaveform has 2000 samples per channel.
Does someone can help to understand this point?
12-31-2012 05:27 AM
Hi XUV,
try to see if your code is similar to this one:
http://zone.ni.com/devzone/cda/epd/p/id/5755
Hope it helps,
bye.
FBM
01-02-2013 01:28 PM
Hi FBM,
thanks for the suggestion.
I tried to use the
'myTask.Triggers.ReferenceTrigger.ConfigureAnalogEdgeTrigger' object but it looks like it needs a source signal in a channel different from the analog input channel. For instance in my DaQmx this should be the APFI0 channel. Since I need to use the same input signal as analog trigger I sent the same signal to both channels but the program get blocked.
What I need is to measure the same almost periodic signal several times to extract averaged values. In order to do this
it is important that every measure begin from the same voltage value than the previous one (as I need information on the phase as well) and that's why the trigger should be configured on the same input signal.
I don't think the 'Triggers' object can do what I want but if you have a different opinion every suggestion will be helpful.
XUV
01-08-2013 03:24 AM
Hi XUV,
is there also a terminal condition to avoid consider elements you don't need, or do you consider a certain number of elements after the trigger starts?
I'm asking that 'cause one possibility may be to keep a continuous acquisition and then use a condition let the app understand if the samples must be kept or not.
Let me know,
have a nice day!
FBM
01-18-2013 05:51 AM
Hi FBM,
the only condition is the trigger condition. When the signal satisfies that condition (usually when the signal reaches a given value with a specific slope) the acquisition should start.
I finally solved the problem. It is not probably the more optimized code, but it works.
A certain amount of data are read and then stored in an analogwaveform class. Measured data are analyzed to search for the trigger condition. Once this has been found a subset of data (of a given size) is extracted taking into account the trigger location.
In the previous version I didn't set properly the sample per channel in the
myTask.Timing.ConfigureSampleClock
("", samplingRate, SampleClockActiveEdge.Rising, SampleQuantityMode.FiniteSamples, samplesPerChannel)
considering the subset sample per channel instead of the total sample per channel. The number of data stored thus changed after the first iteration so that was not possible to extract a subset of a given size and the continuous acquisition stopped.
Thanks a lot for suggestions
XUV