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.

Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

Digital filtering on input channels (counter input) on 6601, DAQmx, .net/C*#, 200µs filter

Solved!
Go to solution

Hi

 

Anyone know how to setup digital filtering using DAQmx on 6601 input channels. Maximum default filter is 5µs but i need a 200µs filter.

 

The channels to filter are input channels on X1 linear encoders (on A, B and gate inputs).

 

I am using DAQmx in .net/C#

 

Thanks,

 

Simon

 

0 Kudos
Message 1 of 5
(3,885 Views)

Hi Simon,

 

By default TIO devices have four filter settings; 5µs, 1µs, 500ns and 100ns. However, you wanted a 200µs filter and this is not possible with the built-in filter clocks.

 

You would then have to use a PFI, RTSI or even an internal signal as the filter clock timebase. It is recommended that you use filter clocks with a duty cycle as close to 50% as possible. Digital filtering is discussed in great detail in the NI 660x User manual and I have provided the link to it below:

http://www.ni.com/pdf/manuals/372119c.pdf#page=26

 

Since the digital filters are not enabled by default in your device, you would enable it in your program. The following link discusses how to enable the digital filters, and has a bit at the end where it discusses the functions that have to be used to enable the programmable filter in order to specify your digital filter timebase source and rate:

http://digital.ni.com/public.nsf/allkb/220083B08217CFD686257131007E5D2C?OpenDocument

 

These should help you set up the digital filters for your NI 6601.

 

Kind Regards,

 

Jeneni

Message 2 of 5
(3,829 Views)

Hi Jeneni

 

Thanks for the reply. I cannot seem to get it to work however 😞

 

My test setup applies a simple signal with pulsewidths from 140µs to several ms. To simplify the code I tested using a CICountEdges channel. However It must be used on two independent LinearEncoders (X1 quadrature, one with gate signal aswell).

 

Here is my test code:

private static string device ="Dev1";

public static double FilterFrequencyHz = 1000d;

private const string PollCounterNumber = "/ctr0";

private static Task m_pollCounterTask;  
private static CounterSingleChannelReader m_pollCounterReader;

private const string FilterCounterNumber = "/ctr2";

private static Task m_counterFilterTask;

 

m_counterFilterTask = new Task("Filter Counter Task");
m_counterFilterTask.COChannels.CreatePulseChannelFrequency(device + FilterCounterNumber, "Filter Counter Channel", COPulseFrequencyUnits.Hertz, COPulseIdleState.Low, 0, FilterFrequencyHz, 0.5);

m_counterFilterTask.Start();

 

m_pollCounterTask = new Task("Polling Counter Task");

var pollCounterChannel = m_pollCounterTask.CIChannels.CreateCountEdgesChannel(device + PollCounterNumber, "Polling Counter Channel", CICountEdgesActiveEdge.Rising, 0, CICountEdgesCountDirection.Up);

var filterSource = device + FilterCounterNumber + "InternalOutput";
pollCounterChannel.CountEdgesDigitalFilterTimebaseSource = filterSource;
pollCounterChannel.CountEdgesCountDirectionDigitalFilterTimebaseRate = FilterFrequencyHz;
m_pollCounterReader = new CounterSingleChannelReader(m_pollCounterTask.Stream);
m_pollCounterTask.Start();

 

Adding this filter changes nothing in the counting. I tried applying signals with periods from 140µs to 50ms - it counts all pulses.

0 Kudos
Message 3 of 5
(3,817 Views)

The frequency of 1000 Hz gives a period of 1ms for the filter.

According to the 660X user manual a change in input signal is filtered away unless it is persistent across at least two rising edges of the filter clock.

This means that pulses below 1ms should be filtered away and pulses above 2ms are guaranteed to pass with a filter clock of 1000 Hz.

0 Kudos
Message 4 of 5
(3,814 Views)
Solution
Accepted by Simon_Stenfeldt

It seems like the filter frequency can actally be adjustly freely simply by calling DAQmxSetCIFreqDigFltrEnable and DAQmxSetCIFreqDigFltrMinPulseWidth . I have tested it using pulse width of 5µs, 50µs and 100 µs where the filtering cleary kicks in at the correct pulse widths.

In Measurement Studio (C#) the settings depend on what type of channel you are using, as I am using a Linear encoder X1 the properties were:

#Channel#.EncoderAInputDigitalFilterEnable = true;

#Channel#.EncoderAInputDigitalFilterMinimumPulseWidth = FilterWidth;

for both A and B.

0 Kudos
Message 5 of 5
(3,786 Views)