Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

using nidaqmx C, how can i setup a counter with source as the internal timebase and gate being an external high/low signal?

I am using NIDAQ 6024E. I need to count the edges on the internal timebase as long as my gate signal is high. I couldn't find any functions that would let me do so. I am first creating a channel using DAQmxCreateCICountEdgesChan() and then setting the source to 20 MHz timebase using DAQmxSetCICountEdgesTerm(taskHandle, "Dev1/ctr0", "/Dev1/20MHzTimebase"). Doing this would let me count the edges on the timebase but the counting does not stop when I set the gate low.
0 Kudos
Message 1 of 6
(3,512 Views)

To do event counting with a “pause” when the gate signal goes low you need to setup a DAQmx Pause Trigger.  This is usually done with three functions (see the DAQmx C help for more details):

Type:                   DAQmxSetPauseTrigType(taskHandle As Long,data As DAQmxTriggerType4)
Source:               DAQmxSetDigLvlPauseTrigSrc(taskHandle As Long,data As String)
Pause When:     DAQmxSetDigLvlPauseTrigWhen(taskHandle As Long,DAQmx_Val_Level1_High/Low)


Example (written in C#):

DAQmx - Count Digital Events with Pause Trigger - C#.NET


You might also check out this discussion forum:

http://forums.ni.com/ni/board/message?board.id=40&message.id=4809&requireLogin=False

Jared T.
0 Kudos
Message 2 of 6
(3,492 Views)
Is there a way to reset the count when I "pause"?
0 Kudos
Message 3 of 6
(3,469 Views)
Hi krithikapatel,

It sounds like you are trying to measure pulse width. If so, I would recommend using DAQmxCreateCIPulseWidthChan() instead of
DAQmxCreateCICountEdgesChan(). The DAQmx shipping example Counter\Measure Period or Pulse Width\Pulse Width demonstrates how to use this channel type to measure pulse width in seconds, but you should be able to change the units parameter to DAQmx_Val_Ticks and use DAQmxReadCounterScalarU32() without too much trouble. (Here's how to find the C shipping examples.)

Brad
---
Brad Keryan
NI R&D
0 Kudos
Message 4 of 6
(3,460 Views)
The problem with using DAQmxCreateCIPulseWidthChan()  is that I can only measure a pulsewidth od 0.83 seconds. I am expecting a pulsewidth of atleast a few minutes.
0 Kudos
Message 5 of 6
(3,441 Views)
Hi krithikapatel,

The PCI-6024E has 24-bit counters, so counter rollover is limiting your maximum range:
2^24 / 20e6 Hz ~= 0.83 seconds
2^24 / 100e3 Hz ~= 167 seconds

Note that using the 100 kHz timebase requires increasing the minimum pulse width to 20e-6 seconds or larger.

If the decrease in precision is acceptable, you could generate an even slower timebase (such as 1 kHz) using a pulse train generation task on the other counter. Then call DAQmxSetCICtrTimebaseSrc(taskHandle, "", "Ctr1InternalOutput") and DAQmxSetCICtrTimebaseRate(taskHandle, "", 1e3) on the pulse width measurement task.

If you need the increased precision of a faster timebase, switching to an M Series (62xx) or TIO (66xx) board may be adequate, because they have 32-bit counters.

Brad


Message Edited by Brad K on 03-25-2008 11:23 AM
---
Brad Keryan
NI R&D
0 Kudos
Message 6 of 6
(3,433 Views)