Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Get count only when active gate set.

Solved!
Go to solution

Hello,

I am new to this, and I am trying to read count from counter ctr0, with external gated pfi 38 active low. I am using PCI-6601 on window 7, with Version=9.7.0.30 installed.

I am trying to test this in the c# code. The code below works without using the gate, but I needed a gate for my test. Any help on this would be appreciate. Thanks alot.

 

public void SetCounter1()
{
try
{
if (_TaskCounter0 != null)
_TaskCounter0 = null;

_TaskCounter0 = new Task();

string counter0Config = "Dev1/ctr0";
CIChannel CIChannel0 = _TaskCounter0.CIChannels.CreateCountEdgesChannel(counter0Config
, "COUNTER0"
, CICountEdgesActiveEdge.Rising
, 0
, CICountEdgesCountDirection.Up);
_TaskCounter0.Control(TaskAction.Verify);
CIChannel0.CountEdgesTerminal = "/Dev1/PFI39";

_CounterReader0 = new CounterReader(_TaskCounter0.Stream);
_CounterReader0.SynchronizeCallbacks = true;
_TaskCounter0.Start();

}
catch (Exception ex)
{
_TaskCounter0.Dispose();
throw new DaqException("Counter0: ", ex);
}
}

0 Kudos
Message 1 of 2
(2,226 Views)
Solution
Accepted by topic author seanluc2007

I figure it out, and here is the codes if any run across it.

public void SetCounter1()
{
try
{
if (_TaskCounter0 != null)
_TaskCounter0 = null;

_TaskCounter0 = new Task();

string counter0Config = "Dev1/ctr0";
CIChannel CIChannel0 = _TaskCounter0.CIChannels.CreateCountEdgesChannel(counter0Config
, "COUNTER0"
, CICountEdgesActiveEdge.Rising
, 0
, CICountEdgesCountDirection.Up);

string triggerSource = "/Dev1/PFI38";
_gateLevel = DigitalLevelPauseTriggerCondition.High;
_TaskCounter0.Triggers.PauseTrigger.ConfigureDigitalLevelTrigger(triggerSource, _gateLevel);

_TaskCounter0.Control(TaskAction.Verify);
CIChannel0.CountEdgesTerminal = "/Dev1/PFI39";

_CounterReader0 = new CounterReader(_TaskCounter0.Stream);
_CounterReader0.SynchronizeCallbacks = true;
_TaskCounter0.Start();

}
catch (Exception ex)
{
_TaskCounter0.Dispose();
throw new DaqException("Counter0: ", ex);
}
}

0 Kudos
Message 2 of 2
(2,163 Views)