Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Error 200281: Read relative to the reference trigger

I am trying to set up a DAQMx task that, when commanded to start, reads data continously, until it reads a stop trigger (hardware, rising). At that point I want to get back n number of total samples with p samples before the trigger (conceptutally n total, p before trigger, n-p after trigger)
 
I believe that I want to use a "reference trigger" to do this. So I have setup my task thusly:
 

// Create the channel

m_DAQmxTask.AIChannels.CreateVoltageChannel(m_Device.AIPhysicalChannels[channelIndex], channelName,

AITerminalConfiguration.Differential, m_ScalingFactor * -1.0, m_ScalingFactor, "BinaryCodes");

m_DAQmxTask.Timing.ConfigureSampleClock(

string.Empty, m_ClockFrequency, SampleClockActiveEdge.Rising, SampleQuantityMode.FiniteSamples, m_NScans);

m_DAQmxTask.Triggers.ReferenceTrigger.ConfigureDigitalEdgeTrigger(

"PFI0", DigitalEdgeReferenceTriggerEdge.Rising, m_PreTriggersScans);

m_DAQmxTask.Stream.ReadAllAvailableSamples =

true;

m_SingleChannelReader =

new AnalogSingleChannelReader(m_DAQmxTask.Stream);

m_SingleChannelReader.BeginReadMultiSample(m_NScans,

new AsyncCallback(singleChannelRead), null);

then, in singleChannelRead, the line:

double

[] dataArray = m_SingleChannelReader.EndReadMultiSample(iasResult);

Gives me a DAQmx error 200281 read relative blah blah blah.

/////
I added the "m_DAQmxTask.Stream.ReadAllAvailableSamples = true;" as a shot-in-the-dark fix though it didn't work.
////
 
Am I setting this task up correctly for what I want to do? If so, what I am doing wrong? If not, what is the proper way to set up this task?
0 Kudos
Message 1 of 2
(4,086 Views)
Hello Tyzack,

This error is probably occurring, because you have set up a reference trigger (which is designed to acquire pretrigger samples prior to being triggered), but the trigger is occurring before enough pretrigger samples have been acquired.  You can refer to this article on our website for more information about this error:
DAQmx_Read_RelativeTo property in ANSI C returns error -200281

If you are new to data acquisition in Measurement Studio, I would recommend you check out the program structure of some of our examples, such as AcqVoltageSamples_IntClkDigRef, located in the National Instruments directory on your machine:

\National Instruments\NI-DAQ\Examples\DotNET2.0\Analog In\Measure Voltage\AcqVoltageSamples_IntClkDigRef\cs

This is a very helpful example that demonstrates the overall structure of data acquisition in Measurement Studio.  I hope that helps.
Regards,


Marty H.
National Instruments
0 Kudos
Message 2 of 2
(4,042 Views)