06-08-2021 08:35 AM
A couple notes for you:
1. There's no need (and some danger!) unpacking those time stamps into "date-time records" before doing all your math to figure out delta time. All you need to do is subtract one timestamp from another! The result will be delta time in seconds, including sub-millisec resolution.
The "danger" is that your method will fail when time wraps around midnight to a new day. That may or may not affect you, depending on when this equipment can be running.
2. Another concern with your debounce method is that you're setting yourself to react to the *beginning* of bounce. If every bounce always ends up with a stable transition to a different state, you'll be ok. But if the bounce might end by reverting back to the original state, then you'll have reacted to a false transition.
Looking back to the beginning of the thread, I see you're using an X-series device that will support debounce in the hardware via "digital filtering". That method will only pass through stable states after all the bounce is done, so the issue raised above wouldn't affect it.
-Kevin P
06-09-2021 11:59 PM
Hi Kevin,
thanks for the hint with the subtraction of timestamps; didn't now that and this really helps!!
regarding the debouncing:
can I set the debouncing on an element which I'm watching for events?
like this:
(thought this does not work so this require hardware debouncing or "selfmade" software debouncing)
06-10-2021 06:49 AM
I'm not 100% sure I've done that, but I strongly suspect it should work fine. The digital filter operation would have to be upstream of the change detection circuitry for it to make any sense.
Dig around in the DAQmx Channel property node and you should find what you need to set up a digital filter on the line(s) of interest.
-Kevin P