Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

PCIe-6323: Enabling digital filtering on a counter input in VB.NET ?

Solved!
Go to solution

Dear all,

 

I am trying to count digital pulses generated by a volumetric gas counter using a counter input of my PCIe-6323 card. Unfortunately, there are multiple noise sources in the environment and I have issues with voltage spikes that are interpreted as digital pulses by the counter input. I already improved my setup by using shielded cable and in minimizing its length. However, the measurement quality is still suboptimal and I would like to implement a digital filter with a minimal pulse width threshold setting.

 

For diverse reasons, I use VB.Net instead of Labview to develop this application. I used the example "CountDigEvents" (see attachment) provided by NI with the card software as a basis, then I modified it to read the count every minute. Finally I tried to enable the digital filter :

 

counter_task0 = New Task()

counter_task0.CIChannels.CreateCountEdgesChannel("Dev2/ctr0", "Count Edges", CICountEdgesActiveEdge.Rising, 0, CICountEdgesCountDirection.Up)

counter_task0.Timing.DigitalFilterEnable = True

Unfortunately, I receive the following error : "The specified property is not supported by the device or is not applicable to the task."

I dont understand why I get this error since the PFIs of the card are supposed to have filtering feature :

Digital line filter settings

160 ns, 10.24 μs, 5.12 ms, disable

 

Could somebody advise me on the best approach to achieve my objective ? Actually, I wonder if digital filtering is possible with single point edge counting and if I would not try another method (For example : https://forums.ni.com/t5/Example-Code/Enabling-Digital-Filtering-Using-Dummy-Counter/ta-p/3526254). In this case, I would appreciate if someone could help me with some VB.NET code example (not Labview). Indeed, I couldn't find anything useful in the examples provided by NI.

 

Thank you in advance and all the best 🙂

 

Sébastien

0 Kudos
Message 1 of 7
(1,345 Views)

I only program in LabVIEW, but by way of analogy, I *think* the problem is that you are trying to set up filtering as a Timing property, which normally refers to sample clock timing.   Over in LabVIEW, you would set this up as a an edge-counting "Input" property, designating that the input signal whose edges you're going to count should have a digital filter applied first.

 

Sorry, I don't know any of the VB syntax.  Look around for either Input properties, or Edge Count task properties.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 2 of 7
(1,328 Views)

Dear Kevin,

 

Thank you for your answer. You were correct : the digital filtering property depends of the sample clock timing. When I configure a sample clock, I dont get this error anymore. I guess it means that digital filtering is not possible for single point (on-demand) edge counting. Therefore, I tried to perform buffered edge couting for my application using NIMAX (so without any digital filtering). I configured counter 0 as in the screenshot in attachment using PFI9 as the source of the sample clock. Problem : I get a new error "Some or all of the samples requested have not yet been acquired." when the 10sec timeout is reached. I guess it was because no edge was detected during this period. However long periods without any pulses are probable for my application. Do you see a way to solve this problem?

 

Thank you in advance and have a nice day 🙂

 

Sébastien

0 Kudos
Message 3 of 7
(1,307 Views)
Solution
Accepted by topic author SL_Bel

I *think* you partially misunderstood me.  It isn't that digital filtering *depends* on sample clock timing, it's that the specific way you configured your filter would make it *apply* to the sample clock rather than to the signal whose edges you want to count.  There should be a *different* way to configure filtering so it applies to the edge-counting signal.

 

Here's what I found in the help file for the C API.  There's a DAQmx Channel property for Edge Counting at "Input->DigitalFilter->[Enable, Minimum Pulse Width].   This is the one you *need*.

 

Kevin_Price_0-1698425970224.png

 

 

 

There's a distinct and separate General property at Counter Timebase->Digital Filter->[Enable, Minimum Pulse Width].  This is the one I think you've been configuring so far.

 

Kevin_Price_1-1698426156245.png

 

 

Again, sorry, but I don't know anything about the specific VB syntax to access those properties.  There are ways to solve the error problem, one of which is to simply ignore that specific error because you know ahead of time that it might happen under normal running conditions.  You can also query the task for the # of available samples and only attempt a read when the # is > 0.   (With this method, you should build in some delay timing to give the CPU a break during times when no samples are available.  You almost certainly won't need to query the task 1000's of times a second to keep finding that out.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 4 of 7
(1,292 Views)
Solution
Accepted by topic author SL_Bel

There are two different CIChannel classes in .NET, CIChannelCollection and CIChannel.

We use CIChannels (CIChannelCollection class) to create the task. The properties you tried to access belong to the CIChannel class.

ZYOng_0-1698429385816.png

 

The following code use All property to set properties to all channels in the task. It should match the settings in Enabling Digital Filtering Using Dummy Counter

                myTask.CIChannels.CreateCountEdgesChannel (counterComboBox.Text, "Count Edges", 
                    edgeType, Convert.ToInt64(initialCountTextBox.Text), countDirection);
                myTask.CIChannels.All.CountEdgesCountDirectionDigitalFilterEnable = true;
                myTask.CIChannels.All.CountEdgesCountDirectionDigitalFilterMinimumPulseWidth = 1;

 There is some problem with my Visual Studio and I am not able to run the code, but I believe it should work.

-------------------------------------------------------
Control Lead | Intelline Inc
0 Kudos
Message 5 of 7
(1,286 Views)

Hello ZYOng,

 

Thank you very much for your code example! Instead of the property "CountEdgesCountDirectionDIgitalFilterEnable", I used the property "CountEdgesDigitalFilterEnable" and it seems to work 🙂

 

Here is my code :

 

counter_task0 = New Task()

counter_task0.CIChannels.CreateCountEdgesChannel("Dev2/ctr0", "Count Edges", CICountEdgesActiveEdge.Rising, 0, CICountEdgesCountDirection.Up)
counter_task0.CIChannels.All.CountEdgesDigitalFilterEnable = True
counter_task0.CIChannels.All.CountEdgesDigitalFilterMinimumPulseWidth = 0.00512 
myCICounterReader0 = New CounterReader(counter_task0.Stream)

counter_task0.Start()

Curr_Count_0 = myCICounterReader0.ReadSingleSampleUInt32()

 

However, I am not 100% sure digital filtering will solve my problem. Indeed the maximal value of the parameter "Minimum Pulse Width" tolerated by PCIe-6323 card is 512ms. I suspect this value is too low to have an effect in my situation since I still count edges while my volumetric counter is not rotating. Strangely, the phenomenon is not continuous : It is like 10 pulses generated during a minute, then no pulses during multiple hours...

 

Have a nice day,

 

Sébastien

0 Kudos
Message 6 of 7
(1,200 Views)

Hello Kevin,

 

Thank you very much for your answer 🙂 Indeed, I was trying to enable the digital filter property on the class "Timing" while it applies to the class "CIChannel". I finally managed to enable a digital filter for on-demand edge counting.

 

However, i am not sure it will solve my problem of false pulses (cf. my answer to NYOng)...

 

Have a nice day !

 

Sébastien

0 Kudos
Message 7 of 7
(1,194 Views)