10-27-2014 02:53 PM
I am working on a C# NIDAQmx application for a hardware configuration that uses a PCIe-6321 to interface with downstream hardware. There is a DI signal from a manual switch on the downstream hardware that I must monitor for the start/stop signal for my application's data acquisition operations.
I was having inconsistent results using the ConfigureChangeDetection NIDAQmx functionality. So I used the ReadDigChan_ChangeDetection sample and using Debug.WriteLine statements have verified that when the switch on the hardware is toggled, multiple ChangeDetected events are thrown before the signal settles into the actual High or Low state.
Since I am not a hardware guru, I consulted another engineer, and was told that this is common with switches, and the signal and/or change detection needs to be "debounced".
Can this be done purely through additional configuration of the NIDAQmx DI task? I saw properties for digital filtering, but don't understand their use. I looked at the ReadDigChan_ChangeDetection_DigFilter sample, but it seems to imply that some other DI needs to be connected on the card to be used as the filter, which I don't have. Only one DI is coming from the downstream hardware.
Any help and/or advice will be greatly appreciated.
10-27-2014 04:11 PM
I believe I have found the solution. By searching the forums I came across a couple of posts that pointed to this article
http://digital.ni.com/public.nsf/allkb/220083B08217CFD686257131007E5D2C?OpenDocument
So i started playing with the corresponding properties in the C# task, and it looks like I may have to only set the following properties:
myTask.DIChannels[0].DigitalFilterEnable = true; myTask.DIChannels[0].DigitalFilterMinimumPulseWidth = 10.240000e-6;
According to error messages, the DigitalFilterMinimumPulseWidth for the PCIe-6321 can only be set to specific values.
Using this in the ReadDidChan_ChangeDetection_Events sample appears to be successfully debouncing the ChangeDetection events to only 1 per physical switch toggle.
If this is not the approach I should be using, please advise otherwise.