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.

Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Confused by counters

I am trying to read a tachometer signal from a fan using my NI PXIe-6341, X Series Multifunction DAQ with SCB-68A accessory.  I believe I need to connect my tachometer signal to the counter’s gate and route a timing source to the counter’s source.  According to the manual for this board, counter 0 source goes to pin 37 (PFI 😎 and counter 0 gate goes to pin 3 (PFI 9).  Also according to the manual, it has a built in 100 MHz, 20 MHz, and 100 kHZ time base and,“You can route Counter n Source out to any PFI <0..15>, RTSI <0..7>, or PXIe-DSTARC terminal. All PFIs are set to high-impedance at startup.”  I am confused by what I need to do to route the timing source?  Do I need to attach a wire to something?  Do I need to specify the timing source in the program somehow?  I am using the DAQmx CI frequency vi.  I assume I also need to use the DAQmx timing VI, but I don’t understand how to.  Help please.

Message 1 of 6
(5,170 Views)

Hi HeatherRalph,

I found a resource which helps with frequency measurements and how to set them up.

Also for the programming aspect, LabVIEW has example code which you can use as a base. To get to the example in 2012, go to Help»Find Examples, and in the pop up that occurs go to Hardware Input and Output»DAQmx»Counter Input» Counter-Read Pulse Width and Frequency (Continuous).vi or any of the other examples which measure frequency.

Hope this helps.

Paolo F.
National Instruments
Applications Engineer
0 Kudos
Message 2 of 6
(5,146 Views)

Thank you Paolo,

 

I have looked at the examples and tried to use the express VI and still can't figure out how to use an internal timebase as my sample clock.  I would like to avoid needing another piece of equipment to generate a sample clock.  Can anyone help.

 

Using the Express VI - DAQ assistant - Acquire signals - Counter input - frequency, it seems to indicate that the VI will select an internal timebase to use.  Specifically, the description of the VI says,"To measure the frequency of a signal using the counters of your device, use the time base rate of your counter as a reference frequency. To configure your measurement, specify the expected range of the input signal, so that NI-DAQmx can choose its timebase to provide the highest resolution for the measurement."

 

Using the example code Counter - Read Pulse Duty Cycle and Frequency (Continuous).vi, I set the counter to ctr0, the pulse frequency terminal to PFI9, and min frequency to 2 and max frequency to 100.  Then I tried many setting for the External Clock Source.

* Using OnboardClock, I got error -200303 "External sample clock  source must be specified for this application."

* Using PFI10, PXI_Trig0, PXI-Star, ai/ReferenceTrigger, ai/SampleClock, ao/SampleClock, di/SampleClock, do/SampleClock, ChangeDetectionEvent, PXIe_DStarA, Ctr1SampleClock I got a timeout error -200284 "Some or all of the samples requested have not yet been acquired. To wait for the samples to become available use a longer read timeout or read later in your program. To make the samples available sooner, increase the sample rate. If your task uses a start trigger,  make sure that your start trigger is configured correctly. It is also possible that you configured the task for external"

* Using PXIe_Clk100, ConvertClockTimebase, SampelClockTimebase, Cnt0Source, I got error -89136 "Specified route cannot be satisfied, because the hardware does not support it."

* Using 100kHzTimebase with a sample rate of 1e+7, I got error -201002 "Sample Clock Rate must match the frequency of the internal timebase specified as the Sample Clock Source.To use the specified Sample Clock Rate, set the Sample Clock Source to OnboardClock. To use the specified timebase as the Sample Clock, set the Sample Clock Rate to the frequency of that timebase."

* Using 100kHzTimebase with a sample rate of 100000 and Ctr1Source, I got error -201314 "Multiple Sample Clock pulses were detected within one period of the input signal. Use a Sample Clock rate that is slower than the input signal. If you are using an external Sample Clock, ensure that clock signal is within the jitter and voltage level specifications and without glitches."

* Using Ctr0SampleClock, I got error -200326 "An attempt has been made to perform a route when the source and the destination are the same terminal.  In many cases, such as when configuring an external clock or a counter source, you must select a PFI, PXI Trigger, or RTSI line as the source terminal."

 

Any help on understanding timebases and how to route internal sample clocks would be helpful.

0 Kudos
Message 3 of 6
(5,126 Views)

Can you send a screenshot of the code and the inputs you are using when you run the code? Maybe it has to do with the inputs you are using.

 

Also 100kHz is 1e+5, not 1e+7

Paolo F.
National Instruments
Applications Engineer
0 Kudos
Message 4 of 6
(5,090 Views)

The sample clock and the source are not the same thing.  In all likelihood you don't need/want to be using a sample clock for this task at all.  Without a sample clock configured, when you call the read function the frequency measurement will be returned on the next complete period of your tachometer signal (assuming it is indeed connected to the gate of the counter).

 

The sample clock feature is useful for averaging multiple periods together for increased timing resolution on your measurements.  The downside though (in addition to having to provide a sample clock) is that if you don't have any samples in your buffer when the sample clock edge occurs (i.e. the signal being measured is a lower frequency than the sample clock) the hardware will report an error and the task must be restarted.

 

It can also be kind of useful if you are trying to synchronize a counter measurement with some other task.  You can have the sample clock latch in the frequency/period which was taken immediately before the sample clock edge (so not quite synchronized, but usually pretty close).

 

 

Best Regards,

John Passiak
Message 5 of 6
(5,063 Views)

Thanks you all for your help.  I was making a silly error.  The fan needed a pull up resistor between the 5V and the tach wire and a capacitor between the tach wire and ground to generate a signal.  With that in place, I was able to get a simple DAQmx Counter input frequency and DAQmx read  working.  Sorry to take up your time and hopefully the next person who needs to read a tach and doesn't have their circuitry right will be helped by this.

 

-Heather

0 Kudos
Message 6 of 6
(5,060 Views)