05-19-2021 06:12 PM
Apologies for a novice question. I've read several forum posts, and still not sure I follow the best approach for my application.
I am using some 6614 boards. I've configured nine counters for two-edge separation.
The "start" edge is the same for all nine counters, and I've wired the input pulse to the default "Aux" signal for each of the nine counters.
The "stop" edge is different for all nine, but I've again wired the respective pulses to the nine different "Gate" inputs.
I'm doing rising edge to rising edge time measurement. This is one-shot--I set up all the counters, wait for the pulses, and then read the time values.
I initially thought that doing DAQmx Start would arm the counters so they would wait for their start pulses, and then I could read the counters later when I knew the pulses had been delivered. That doesn't seem to be how it behaves, though.
If I Start and then Read with a long timeout, all of the reads measure the two-edge time difference as expected. So I guess it is the DAQmx Read that arms the counters.
Is there a way I can have Start start the counters, so that I don't have to use a long timeout on Read?
I'm not using the Trigger VI at all. I've read some about Arm Start Trigger, but I'm not convinced that's the right thing to use.
Thanks for any help.
Solved! Go to Solution.
05-19-2021 09:35 PM
So a Start followed by a Read with a long timeout works. That makes sense, supposing all the edges come in before the timeout expires.
It isn't clear to me what you observed when you simply Start and then wait around a while until you know the edges would have come in, and *then* do the Read. That should work too. The counters should arm when you call Start. The measurement should get "recorded" when the edges arrive. And they should be available and given to you when you call Read. So what exactly *actually* happens?
-Kevin P
05-19-2021 10:05 PM
Thanks, Kevin. That’s a good question I should have already answered.
If I arm, wait for the pulses, and then read, the reads will timeout and return zero.
I have a loop around the Start calls, but I have to have nine reads in parallel to get values. In an earlier attempt, I looped through nine reads, but the first read saw its pulse, and all subsequent reads timed out.
Brian
05-20-2021 09:42 AM
Hmmmmmm. Curious, I did some really brief tinkering and experiments and think I'm seeing the same thing as you. Very unexpected.
FWIW, I did this on my only up-to-date PC -- LV 2020 SP1 64-bit, DAQmx 20.1 -- and haven't tried anything elsewhere yet.
I basically just slightly tweaked shipping examples. 2 to manually generate a pulse on demand, 1 to do 2-edge separation measurement of the other 2 counters' outputs. No triggering. No calls to DAQmx Timing, which I've long understood to mean that the task should be a one-shot. Here's what happened instead:
This behavior seems wrong to me but admittedly I really don't do much with one-shot counter measurements -- I mainly deal with continuous sampling buffered tasks on the equipment I support.
I know that DAQmx Read has an implied "auto-start" behavior. That could explain what I saw in the 2nd iteration and thereafter. Well, except that if the task needed to be auto-restarted, the corresponding Task Done? queries should have been True rather than False. And it also doesn't explain the 1st iteration, where Start was already called and shouldn't have needed a further boost.
-Kevin P
05-20-2021 12:06 PM
Thanks for confirming that you're seeing similar results as me, and that the results differ from our expectations of how it should behave.
I've submitted a service request to NI to see if there's a way to do an arm before the Read.
If I can't, I'll need to do a couple of things...
05-20-2021 03:53 PM
I'm not aware of a mechanism for aborting DAQmx Read once it's called. If you know or find one, please post back with it. Same for any good info you get from the service request.
All I know to do is iterate over lots of Reads with short timeouts, then ignore / clear the oft-expected timeout error. Somewhere in there you can also track your total cumulative wait time to implement your own version of timing out.
-Kevin P
05-20-2021 06:39 PM - edited 05-20-2021 06:41 PM
A read can be aborted by calling "DAQmx Control Task.vi" with the "abort" command. I just tested it and it works. You do get a -88709 error from the Read. ("The task has been aborted or the device removed from the system.")
I don't like the idea of iterating through reads with short timeouts, since there's always a small window on each iteration where the counters aren't armed.
NI's initial response to my service request matched ours--essentially, "that doesn't seem right". It's being escalated, and I'll report back when I learn more.
05-20-2021 07:16 PM
Thanks, and good call on "abort." I completely overlooked the possibility of branching the task refnum since it isn't the kind of thing I ever find myself wanting to do. This might be one of the worthwhile exceptions.
Out of curiosity, what version(s) of DAQmx are you seeing this with? I've only tried it on 20.1, but we have a number of installed systems that are still at 16.0 and I hope to have time to try the same experiments on one of them tomorrow.
-Kevin P
05-21-2021 04:44 PM
I've been using DAQmx 19.5.
Still no word from NI, other than that they are escalating the issue.
05-21-2021 07:02 PM
At the end of the day I did spot checks on a couple of older systems.
DAQmx 16.0 (Win 10, LV 2016) - same behavior
DAQmx 9.8 (Win Vista, LV 2013) - same behavior
Unfortunately, it looks like it's been this way for quite a while...
Maybe you could switch to buffered tasks with Implicit timing and then Read just 1 sample (which will be the earliest one, if more than one is in the buffer)? I'm not around hardware to test now, but I have some optimism. Most of my counter intution has come from buffered input tasks and continuous generation tasks. And my intuition is pretty strong that Start should have been enough to arm the counter fully and the subsequent Read should have retrieved an already-latched measurement.
Granted, the intuition was *wrong* for your unbuffered task, but I'm still pretty confident it'll be right for a buffered task.
-Kevin P