Jump to content

Debounce Boolean


Recommended Posts

I debounced a boolean. I feel like it could be better. 

This should take the initial value as output, and requires consistency for one second to change value. I'm curious what's out there or what has been tried?

What i like about this:

  • Simple to understand

What I don't like about it:

  • Small periodic blips could prevent state changes from ever occurring.
  • Uses time as a metric (I actually prefer non-time metrics, like voting algorithm as they need less consideration)
  • Uses two feedback nodes. (seems excessive).
  • Takes one call after debounce time to propagate output.
  • Functionally impure. (e.g. has statefulness although seems pretty necessary here)

 

Debounce.png

Edited by Taylorh140
impure
Link to comment

I do like the count. I was thinking about majority vote but it has the issue of being noisy around the 0 point. I think that this may correct at least periodic noise issue that the last method had:

This method counts True +1 and False -1 and sums them until they surpass the count by one, only then does the input pass through.

What i like about this:

  • Simple enough
  • Small periodic blips do not prevent state changes from ever occurring.
  • Does not use time as a metric (but still need to be considered based on sampling rate)

What I don't like about it:

  • Uses two feedback nodes. (seems excessive).
  • Functionally impure. (e.g. has statefulness although seems pretty necessary here)
  • Looks messy compared to last implementation.

Debounce2.png

Link to comment

That certainly fulfills the debounce nature in a more pure manner, debouncing both low and high. Mine is more of a conditional latch with optional single pulse output or latched high output. I think you got my point though about using a counter. As far as it being pretty or not, I don't know that I'd ever look at the BD again after finishing testing. The counts can be adjusted based on where you use it. Certainly sample rate will be a factor, but also expected noise/bounce vs desired responsiveness.

Link to comment
4 minutes ago, flarn2006 said:

When is this necessary? FPGA I assume?

FPGA certainly. I have use for the code I posted when say thresholding a value and wanting to ensure that it has exceeded that threshold for a period. That value could be anything. A plain signal or it’s derivatives, a float switch with a digital input, etc. At high rate in an FPGA you’d normally use it for say a mechanical switch that makes intermittent contact rapidly as the contacts first come into contact with each other. I’m sure there are more examples!

Link to comment

I haven't looked into the thread in detail, but for debouncing I usually use an "off delay". It works with a one-cycle spike in the raw measured data too.

mtxsoft_offdtmr_timing.jpg

I haven't implemented it in Labview, I use these off-delay blocks in Siemens Logosoft (PLC).

Link to comment

Yeah well the thread is labeled debouncing. But this can be used any time you want to be absolutely sure there is a transition in a boolean input. Say in a noisy environment you need to be sure that a transition is actually was that initial input really an edge? How can we be really sure?

I did find this reference useful:

https://my.eng.utah.edu/~cs5780/debouncing.pdf

It shows how different the debounce on switches can be as well.

  • Like 1
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.