From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, 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: 

How to do edge counting on PFI line like in the test panels (in C#)?

I have a 6052E board and am using C#/DAQmx. I tried something like this, in the normal asynchronous read pattern:

_triggerTask.CIChannels.CreateCountEdgesChannel(_clock, String.Empty,   CICountEdgesActiveEdge.Rising, 0, CICountEdgesCountDirection.Up);

_triggerTask.Timing.ConfigureSampleClock(triggerLine,

  SAMPLE_RATE, SampleClockActiveEdge.Rising,

  SampleQuantityMode.ContinuousSamples, 250);_reader = new CounterReader(_triggerTask.Stream);

_reader.BeginReadMultiSampleUInt32(NUMBER_OF_SAMPLES, ReadCounter, _triggerTask);

 But I got a very low number of reads (45 vs known triggers of 175). All I want to do is know when an event happens on a PFI line so I can keep count. The rate is ~250Hz, but they come in bursts. So, I have to count the pulses in the bursts.

 

Thanks!

 

John Duddy

 

0 Kudos
Message 1 of 6
(3,133 Views)

Hi John,

 

The way I got it is that you want to count the edges on your counter input. If this is the case, and even if your data comes in bursts,  you can  set a counter task that counts the rising edges of the incoming signal without the need of a trigger. ( unless you are using the trigger for something else).

You might also want to check the signal quality of the trigger.

Please let me know if I can provide further assistance.

 

Best regards,

Faris

Bueller
0 Kudos
Message 2 of 6
(3,113 Views)

I think you understand my need correctly - I want to cound the edges on a PFI line, and I need to be able to know about the ends of the bursts as they occur. I need to correlate the number of edges with a motor position that I am polling.

 

How do I do that (in C#)?

 

Thanks!

0 Kudos
Message 3 of 6
(3,111 Views)

Hi John,

 

I recommend that you start with the Count Digital Events example. If you are using windows XP, you can find that example at

C:\Documents and Settings\All Users\Documents\National Instruments\NI-DAQ\Examples\DotNETX.X\Counter\Count Digital Events\CountDigEvents\cs

 

Best regards,

Faris

Bueller
0 Kudos
Message 4 of 6
(3,096 Views)

I am already familiar with that example. IT doesn't do what the edge counting test panel does.

 

The example returns arrays of numbers (usually all 0). The test panel for edge counting increments a single number.

 

I have not been able to find in the documentation how to map from one to the other. I tried simply counting the number of readings and ignoring their value, but I did not get the same value as the edge counting test panel.

 

 

 

 

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

Hello jdlogicman,

 

I just finished looking at the specified example, the example performs a single point read and does not return an array of numbers.  The command of interest is on line 419 with the command:

 

reading = myCounterReader.ReadSingleSampleUInt32();

 

This example should perform the same as the edge counting test panel in Measurement and Automation Explorer.

Regards,
Dan King

0 Kudos
Message 6 of 6
(3,057 Views)