Debouncing problems | LabJack
 

Debouncing problems

2 posts / 0 new
Last post
roccotuna
roccotuna's picture
Debouncing problems

I have a U3 using a cheapo SPDT microswitch to count machine cycles. The machine cycles at 3Hz, closing the switch for about 200ms each time. I have the U3 configured in Python thusly:

                thisU3.configIO( TimerCounterPinOffset = 4, NumberOfTimersEnabled = 1 )
                thisU3.getFeedback( u3.Timer0Config(TimerMode = 6, Value = 1) )

The counter works, but I'm getting a double count every 10-15 cycles or so. The switch currently goes from low to high when the machine cycles, though I have tried it high to low. I've also messed with the delay value. But I still get the double count.

Before I try a hardware solution, is there something I could have overlooked with the software method?

Thank you!

 

LabJack Support
LabJack Support's picture
It could be your switch is

It could be your switch is doing something that the U3 debounce feature can't handle.  Seems like you can use a timer value of 15 or so, but it sounds like you have already tried higher timer values (delay).  If you set it real high does it start to block proper counts?

 

I would suggest a couple tests not using debounce to see if the debounce timer is helping at all:

Try using a hardware counter.  Does it give multiple counts every time?

Try using timer mode 5.  Does it give multiple counts every time?

Perhaps do all 3 (counter, timer mode 5, timer mode 6) at the same time and connect your signal to all 3 at the same time.

 

I would add that our T-series devices have much more flexible debounce options:

https://labjack.com/support/datasheets/t-series/digital-io/extended-features/interrupt-counter-debounce