From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Trouble cascading counters in DAQ MX

Using LV 8.2 and DAQ MX, I'm trying to use two counters cascaded as a single counter.

First I CREATE CHANNEL (CI Count Edges, Dev1/Ctr0); I set that channel's CI.COUNTEDGES.TERM property to Dev1/10MHzRefClock. I start that task.

Then I CREATE CHANNEL (CI Count Edges, Dev1/Ctr1); I set that channel's CI.COUNTEDGES.TERM property to Dev1/Ctr0InternalOutput. I start that task.

So, when I want to read them, I call DAQmx READ for task one, and DAQmx READ for task two.

I then JOIN NUMBERS to combine the HI and LO parts into a single U64.

That all seems to work, except it seems vulnerable to the old 12:59 problem.

(If a clock is sitting at time 12:59, and you read the hi part and low part SEPARATELY, then it just might tick over in between your reads, and you get either 12:00 or 1:59, depending on which side you read first).

I MUST use two tasks, it seems, because the rules say I cannot use two counters on one task.

The HELP for CREATE VIRTUAL CHANNEL, CI CNT EDGES says: To read from multiple counters simultaneously, use a separate task for each counter.

But how can I READ two tasks simultaneously?

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 1 of 4
(2,640 Views)
CoastalMaineBird,

Are you trying to measure continuously buffered frequency using two counters?  LabVIEW ships with a number of examples of how to properly implement this and they can be found in the example finder: Help >> Find Example.

Dig down in the folder hierarchy to Hardware Input and Output >> DAQmx >> Counter Measurements >> Digital Frequency.  There you'll find a number of detailed examples that use two counters to measure a frequency.

Let me know if this isn't what you need or if you still have any questions.

Elijah Kerry
NI Director, Software Community
0 Kudos
Message 2 of 4
(2,631 Views)
Are you trying to measure continuously buffered frequency using two counters?

No.

I am trying to make a stopwatch for timing various parts of my (RT) program.

I want to set up a task, and call my timer VI's START function.

Some time later, I want to call its SAMPLE function, and have it return to me the number of clock ticks (or uSec) between the START and the SAMPLE calls.

I want a wide dynamic range, so I can use it on anything from uSec to sec, without having to guess.

I have it working, except that it seems like it would be susceptible to the 12:59 problem.

The example you cite, as far as I can tell, only works with frequency measurements, because the "high frequency with two counters" option is only available with the CI FREQ variants.

I am using the COUNT EDGES variant, and I see no such option available.

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 3 of 4
(2,625 Views)
Actually, I just now found the PRESCALER property. With a 10-MHz clock and a prescaler of 8 on a 24-bit counter, that gives me a resolution of 800 nSec, and a range of 13+ seconds. That's good enough for me.

Still, I'm curious as to how to implement the help's suggestion (to read two counters simultaneously, use separate tasks).

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 4 of 4
(2,622 Views)