10-11-2019 11:48 AM
I'm trying to get a super simple analog edge trigger example to work. I've set up the DAQmx task the same as shipping examples and lots of posts I've seen. I'm supplying a nice clean DC voltage to a 9205 card using a high quality HP variable power supply. Using NI-MAX, I've verified that my 9174 chassis & 9205 are working properly.
THE PROBLEM - When I run it, the vi just sails right through to the end, with no error, and an empty data array out. No matter WHAT crazy voltage I give the "DAQmx Trigger.vi" (set up for Start Analog Edge), it never waits for the trigger to be satisfied, just breezes on through as if it weren't there. If I set the Sample Clock for "Finite Samples", the DAQmx Read fails with timeout - makes sense, since the trigger wasn't satisfied. What could I possibly be doing wrong with such a simple task???????
much thanks for any suggestion, paul
Solved! Go to Solution.
10-11-2019 03:36 PM
I don't have hardware to try, but a few questions and thoughts to try. I think it's related to your DAQmx Read function. The default value for Number of Samples to Read is -1 if it's unwired (as it is in your code) From the help:
"If the task acquires samples continuously and you set this input to -1, this VI reads all the samples currently available in the buffer. "
This means the function is non-blocking. Since presumably there aren't any samples in the buffer, you'll just read an empty buffer and move on, getting the issue you're seeing. Try changing the "Number of samples to read" to any value other than -1 and see if that works. If not, here are a few random thoughts:
-Does it work in RSE mode instead of Differential?
-Does it work with Finite samples instead of Continuous?
-You said it flies right through- does it wait on the Timeout (5 seconds) or does the whole thing execute instantly?
-Any error shown in the Error indicator?
-Throw some probes on the Error lines after each function. Are there any errors/warnings that are getting "eaten" and not shown by the end of execution?
-Does it work with the 9205 in different slots in the chassis?
10-11-2019 07:15 PM
I did probe the errors from the DAQmxTrigger and the DAQmx Start Task - no errors. The execution just blows thru the DAQmxTrigger and the DAQmx Start Task as if they weren't there. I fiddled with the Finite versus Continous on the DAQmx Timing setup - if I used Continous, the Read would complete with no error, but output an empty 2D array. For Finite (20 samples), the DAQmx Read throws a -200284 error, timeout.
I haven't tried single-ended measurement, but I did use NI-MAX Test Panels to verify that I was reading the inputs accurately. I could try single-ended Tuesday (but I think the differential is working fine.
I assumed that the DAQmxTrigger would block until the trigger conditions are met. Anybody know otherwise?
10-12-2019 10:14 AM
@PaulOfElora wrote:
...The execution just blows thru the DAQmxTrigger and the DAQmx Start Task as if they weren't there...
I assumed that the DAQmxTrigger would block until the trigger conditions are met. Anybody know otherwise?
It is entirely normal and expected to "blow thru" DAQmx Trigger and DAQmx Start Task. DAQmx Read is the call that might block if you request samples that aren't yet available because the trigger conditions haven't been met yet. (Or not enough time has passed since the trigger condition to acquire all the requested samples.)
@PaulOfElora wrote:
I fiddled with the Finite versus Continous on the DAQmx Timing setup - if I used Continous, the Read would complete with no error, but output an empty 2D array. For Finite (20 samples), the DAQmx Read throws a -200284 error, timeout.
Also entirely normal and expected when you haven't wired a value to the input 'number of samples per channel'. This was already pointed out in the response from @BertMcMahan in msg #2:
@BertMcMahan wrote:
...I think it's related to your DAQmx Read function. The default value for Number of Samples to Read is -1 if it's unwired (as it is in your code) From the help: "If the task acquires samples continuously and you set this input to -1, this VI reads all the samples currently available in the buffer." This means the function is non-blocking. Since presumably there aren't any samples in the buffer, you'll just read an empty buffer and move on, getting the issue you're seeing. Try changing the "Number of samples to read" to any value other than -1 and see if that works.
Note that when you configure for Finite Sampling mode, the behavior is different. The default value of -1 *then* means "give me *all* the samples the task was configured to collect at DAQmx Timing, blocking and waiting if necessary."
It's a better habit to always wire a specific value to the # samples input terminal of DAQmx Read, even in the cases where you want to wire in the default value of -1. I've grown used to the drastic difference in default behavior between Finite and Continuous sampling, but it isn't at all inherently obvious. Making a habit of always wiring helps make you think about making an explicit decision, which over time will help reinforce your knowledge of the different behaviors.
-Kevin P
10-12-2019 11:24 AM
Can you describe the conditions under which you want to start sampling? I notice that you've wired the signal being sampled as both "the signal being sampled" and "the signal serving as the trigger". When I've used triggering, I've always used a digital trigger (like a PFI line) -- I'd never thought about using an analog signal as its own trigger, not sure I quite understand how that would work (and I don't have a USB-600x handy to try it out).
Bob Schor