Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

How to setup a gated counter in DAQmx (.NET)

Solved!
Go to solution

Very simple application that works in VB6, but can't get to work wth DAQmx in .NET 2008.

 

Simply trying to count pulses while gate signal is high. I'm using a 6025E card.  Following code works without problem.

 

MyGatedCounterTask = New NationalInstruments.DAQmx.Task("GatedCounter")
Dim MyCounterChannel As CIChannel =
MyGatedCounterTask .CIChannels.CreateCountEdgesChannel("Dev1/ctr0", "GatedCounter", _

                                         CICountEdgesActiveEdge.Rising, 0, CICountEdgesCountDirection.Up)
MyCounterChannel.CountEdgesTerminal = "/Dev1/PFI8"
MyGatedCounterTask.Triggers.PauseTrigger.ConfigureDigitalLevelTrigger("/Dev1/PFI9", DigitalLevelPauseTriggerCondition.High)
MyCounterReader = New CounterReader(MyGatedCounterTask.Stream)

 

 

Starting the task works as expected (counter resets and starts counting).

MyGatedCounterTask.Start()

Reading the counter works as expected (get increasing values over time)

 

Dim intCounts As Integer = MyCounterReader.ReadSingleSampleInt32()

Stopping the task works as expected (counter stops counting).

MyGatedCounterTask.Stop()

But the gating doesn't work.   Event when gate is high (or low) it always counts.  What am I missing here? 

 

thanks!

 

 

0 Kudos
Message 1 of 4
(6,749 Views)

Hi vstrom-

 

     What function calls did you use in VB6 that worked?  Was it a pause trigger function call?

 

     I think what you will want to use is a pause trigger. Mytask.Triggers.PauseTrigger.ConfigureDigitalLevelTrigger().  You then give this function the terminal you want to use for the pause trigger and the level you want it to pause on (low or high).  This will stop the acquisition when the level trigger goes low or high (whichever you specify).  Using this function should accomplish what you are trying to do.

 

     Best of luck with your application!

 

Regards,

Gary P.
Applications Engineer
National Instruments
0 Kudos
Message 2 of 4
(6,731 Views)

Gary, thanks for replying.

 

Yes, as stated in my original post, I am using the PauseTrigger.ConfigureDigitalLevelTrigger() function.  There was no equivalent function in VB6, you just setup the OCX control.

 

 

0 Kudos
Message 3 of 4
(6,726 Views)
Solution
Accepted by topic author vstrom

Hi vstrom-

 

     My mistake, I now see that you were already using the PauseTrigger function.

 

     I found a tutorial online that you might try.  Let us know how it works - hopefully it will get you pointed in the right direction.

 

     Best Regards,

Message Edited by GParente on 04-14-2010 10:30 AM
Gary P.
Applications Engineer
National Instruments
Message 4 of 4
(6,716 Views)