Hi, I have a problem in a setup using both the start trigger and reference trigger to start and stop the data acquisition using a hardware signal. Basically my setup is working in that my signal is sampled from the start trigger until the reference trigger, however I now only know that because after the reference trigger no more samples are available. I would like to check if the reference trigger has occurred to close my acquisition screen, and I thought I could do that using the IsDone property of the task. However, IsDone is always false.
My source looks like this:
myTask.AIChannels.CreateVoltageChannel(channelName, "", AITerminalConfiguration.Rse, -5, 5, AIVoltageUnits.Volts); myTask.Timing.ConfigureSampleClock("", config.SampleRate, SampleClockActiveEdge.Rising, SampleQuantityMode.FiniteSamples, samplesPerChannel); var srcTriggerLine = $"/{mxDevice.DeviceID}/PFI0"; myTask.Triggers.StartTrigger.ConfigureDigitalEdgeTrigger(srcTriggerLine, DigitalEdgeStartTriggerEdge.Rising); myTask.Triggers.ReferenceTrigger.ConfigureDigitalEdgeTrigger(srcTriggerLine, DigitalEdgeReferenceTriggerEdge.Falling, samplesPerChannel); myTask.Stream.ReadRelativeTo = ReadRelativeTo.CurrentReadPosition; myTask.Stream.ReadOverwriteMode = ReadOverwriteMode.DoNotOverwriteUnreadSamples; _reader = new AnalogUnscaledReader(myTask.Stream); _reader.SynchronizeCallbacks = false; myTask.Start(); while (!(myTask.IsDone && samplesAvailable == 0)) { samplesAvailable = (int)myTask.Stream.AvailableSamplesPerChannel; _data = _reader.ReadInt16(samplesAvailable); }
First I used the asynchronous method for data acquisition and got a time out exception (as expected), but I changed it to this because I thought I would be better able to handle the stop trigger. Using the asynchronous method I also didn't get an IsDone event. The device I am using is the USB-6211.
I could use the time out exception using asynchronous method, or check if availableSamples becomes zero but it I would prefer some way of directly checking if the reference trigger stopped the acquisition since there might be other reasons for samples to be collected (ie an acquisition problem).