Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

Sampling Frequency for Frequency Counter

Solved!
Go to solution

Hi,

 

I'm using a NI9401 card on  cDAQ-9174 chasis, and I'm trying to use a frequency counter to measure an oscillating frequency (100Hz to 100kHz). My understanding is that when setting a frequency counter one should use the implicit timebase for the counter and let DAQ-mx decides on what timebase to use. But I have a couple of questions (it's my first time trying to use a counter):

 

1) Can I specify at what rate to sample the frequency counter? I want to read the counter at 10kHz, so I tried setting a timed loop and the fasted it can go is 1Hz. Is there a better way to do this? Maybe using a buffer and reading into the buffer at 10kHz? But how would I set up that second task?

 

2) Is it possible to know what timebase DAQ-mx is using for the frequency counter?

 

I'm attaching the task I created and VI for the timed loop. Thanks for the help.

 

Luis

Download All
0 Kudos
Message 1 of 4
(2,419 Views)
Solution
Accepted by topic author lgga

Welcome to the wild, wonderful world of counters!  You'll be finding that they are a different sort of beast than the other DAQ subsystems (AI, AO, DI, DO) with special capabilities *and* challenges.

 

1. The best answer will come after rethinking and rephrasing the question.  There are many possible responses that are all arguably "right".  Sorry, this is one of the ways counters are *unique*.

    Usually, discrete measurements of timing signals trade off measurement precision against measurement speed.  When you understand the tradeoff, you'll probably end up preferring a lower measurement speed that can yield a smaller quantity of better quality measurement data than what you'd get by requiring a 10 kHz sample rate.

   I'll try to give more practical advice a little further along.

 

2. Yes it's possible to know, either by explicitly setting it or by querying it.  (And in many cases, it will simply be the device's maximum timebase which appears to be 80 MHz for the 9174 chassis.)

   The more you program with the standard DAQmx API (which you can see in many of the shipping examples for DAQ usage), the more access you'll have to these things.  I for one never use the DAQ Assistant.  I also never developed the habit of defining tasks in MAX, always building them in code using DAQmx API functions.  (Note: it's worthwhile to consider Jeff•þ•Bohrer's expert opinion that advocates *FOR* the use of MAX to generate project-owned tasks.  Here's one notable thread, here's some more possibly relevant unvetted search results from his profile page.  Though I haven't followed his advice, I respect his opinion on the topic and it deserves to be heard.)

 

I would most typically use a 1-counter buffered frequency measurement using implicit timing.  A shipping example (at least in LV 2016) named "Counter - Read Pulse Width and Frequency (Continuous).vi" would be a useful starting point.  This will let you get a continuous stream of frequency measurements, with known timing and no gaps.  From there, you can always post-process in software as needed.

 

Measurement timing will be controlled by the device hardware.  While Loop timing can (should) be controlled by the # of samples you ask for in your call to DAQmx Read.vi  A Timed Loop is unnecessary and will actually probably be detrimental (because you'll tend to overconstrain the timing).

 

 

-Kevin P

 

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
Message 2 of 4
(2,387 Views)

Hi Kevin, 

 

Thanks for your advice. I think I got it working now! I really appreciate the help.

 

-Luis

0 Kudos
Message 3 of 4
(2,344 Views)

Someone may benefit from your solution -- can you post it?

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 4 of 4
(2,339 Views)