Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

NI-9402 on a cDAQ-9178 not reading frequency from a counter input channel

Hello,

I am using a NI cDAQ-9178 with the NI-9205 (in slot 1) and NI-9402 (in slot 2). I have a (Keysight 33220A) function generator generating a square wave at 100Hz (@5Vpp) and is connected to the ci0 of the NI-9402 module. The output of the function generator has been verified with an oscilloscope.

 

I am having trouble reading the frequency using a counter input channel. I am executing the DAQmx ANSI C example that shipped with NI-DAQmx version 14.5 named "Dig Freq-Low Freq 1 Ctr". Below is the error message that I observe when I attempt to execute the code:

 

 

DAQmx Error: Specified operation did not complete, because the specified timeout expired.
Task Name: _unnamedTask<0>

Status Code: -200474
End of program, press Enter key to quit

 

I have attached the corresponding C file to this post. I have NIDAQmx driver version 14.5 installed on my machine.
Is this a regression in the driver or a limitation in the NI hardware modules?  If this is a bug in the driver, can you please provide a CAR # related to the bug.

 

PS: I am able to use the NI tool to count edges using the exact same setup.

 

Thanks,

Varun Hariharan

The MathWorks

0 Kudos
Message 1 of 4
(4,719 Views)

You didn't specify which input terminal (you can use DAQmxSetCIFreqTerm) so the driver will use the default:

 

 

Default NI-DAQmx Counter Terminals for 9402:

Counter/Timer SignalDefault Pin NumberSignal Name
CTR 0 SRC 0 PFI 0
CTR 0 GATE 1 PFI 1
CTR 0 AUX 2 PFI 2
CTR 0 OUT 0 PFI 0
CTR 1 SRC 3 PFI 3
CTR 1 GATE 2 PFI 2
CTR 1 AUX 1 PFI 1
CTR 1 OUT 3 PFI 3
CTR 2 SRC 1 PFI 1
CTR 2 GATE 3 PFI 3
CTR 2 AUX 0 PFI 0
CTR 2 OUT 1 PFI 1
CTR 3 SRC 2 PFI 2
CTR 3 GATE 0 PFI 0
CTR 3 AUX 3 PFI 3
CTR 3 OUT 2 PFI 2
FREQ OUT 1 PFI 1

 

The frequency measurement takes its input signal on the gate of the counter.  CTR 0 GATE uses pin 1 by default.  If you connected your signal to pin 0 of the 9402 this would explain the problem.  It also makes sense that you can count edges with the same setup, since this would use the SRC terminal which is in fact pin 0 for ctr0.

 

To avoid issues like this, I pretty much always define my input terminals when possible rather than use defaults.

 

 

Best Regards,

John Passiak
0 Kudos
Message 2 of 4
(4,713 Views)

Hello John,

 

Thank you for that. I was able to modify the example to give me a frequency reading.

 

This example, however, used to work with the 9.x version of the driver. Is this a deliberate change in 14.x of the driver? Is this behavior expected going forward?

 

Regards,

Varun Hariharan

The MathWorks

0 Kudos
Message 3 of 4
(4,688 Views)

It's been ~3 years since I last worked at NI so I can't double-check this for you, but the behavior should be the same--as far as I'm aware the frequency measurement has always used the default gate terminal in DAQmx (the high frequency 2 counter method uses the source terminal though).  

 

Looking at the C Example... I realize the documentation at the top could probably be a bit more specific, but it does point in the right direction:

 

 

/*********************************************************************
* I/O Connections Overview:
*    The counter will measure frequency on the input terminal of the
*    counter specified in the Physical Channel I/O control.

*
*    This example uses the default source (or gate) terminal for the
*    counter of your device. To determine what the default counter
*    pins for your device are or to set a different source (or gate)
*    pin, refer to the Connecting Counter Signals topic in the
*    NI-DAQmx Help (search for "Connecting Counter Signals").
*
*********************************************************************/

 

 

Following the instructions, I found this in the DAQmx Help:

 

NI 9402 and NI 9435 (4-Channel)

MeasurementCtr0Ctr1Ctr2Ctr3
Count Edges
  • Edges: PFI 0
  • Count Direction: PFI 2
  • Edges: PFI 3
  • Count Direction: PFI 1
  • Edges: PFI 1
  • Count Direction: PFI 0
  • Edges: PFI 2
  • Count Direction: PFI 3
Pulse Width Measurement PFI 1 PFI 2 PFI 3 PFI 0
Period/Frequency Measurement (Low Frequency with One Counter) PFI 1 PFI 2 PFI 3 PFI 0
Period/Frequency Measurement (High Frequency with Two Counters) PFI 0 PFI 3 PFI 1 PFI 2
Period/Frequency Measurement (Large Range with Two Counters) PFI 0 PFI 3 PFI 1 PFI 2
Semiperiod Measurement PFI 1 PFI 2 PFI 3 PFI 0
Two-Edge Separation Measurement
  • Start: PFI 2
  • Stop: PFI 1
  • Start: PFI 1
  • Stop: PFI 2
  • Start: PFI 0
  • Stop: PFI 3
  • Start: PFI 3
  • Stop: PFI 0
Position Measurement
  • A: PFI 0
  • B: PFI 2
  • Z: PFI 1
  • A: PFI 3
  • B: PFI 1
  • Z: PFI 2
  • A: PFI 1
  • B: PFI 0
  • Z: PFI 3
  • A: PFI 2
  • B: PFI 3
  • Z: PFI 0

 

 

Best Regards,

John Passiak
Message 4 of 4
(4,681 Views)