Why do switch Bits need a resistor and a capacitor?

I just started to learn the basic concepts of electrical circuits and want to build my own custom switching Bit, using a proto Bit and a magnetic contact switch (door sensor).

So I imagined a good place to start is to look at the circuit of the default i3 button Bit:


In this circuit I can see that - besides the switch itself - there is a resistor and a capacitor.
I know a capacitor can store energy, and it’s probably there to “debounce” the button element (so a single push on the button doesn’t result in multiple on/off signals).

But: how exactly does this work? And: why is the resistor there?

Any technical insights would be appreciated!

1 Like

Hi @DionoiD,

The resistor keeps the input from floating. A floating input can have an "undefined voltage level"and picks up a lot of noise and by adding this resistor (it is added to nearly all bits) the input side is much more stable.
The capacitor on the outside is indeed there to minimize the bouncing effect of the mechanical switch.
The capacitor is charged and works as a sort of “slow buffer” when the switch very quickly interrupts the signal. It tries to keep its voltage level unchanged when the switch opens, so very quick interruptions will not be present on the output sig connection.
Hope this answers your questions…
There is a lot of literature in then internet, see for example
http://www.labbookpages.co.uk/electronics/debounce.html

Hi @alexpikkert, thanks for your explanation!

However, in this “i3 switch Bit” diagram the capacitor is on the left (input, male) side of the Bit, probably to store energy while the switch is still open. I think the capacitor will decharge when the switch closes, and in case the switch “bounces”, the energy from the capacitor still flows for a short while through the resistor to the output SIG. But that’s just guessing, I’m not sure about this.

It also looks like the resistor is keeping the output signal from floating, instead of the input signal.

Or am I switching “input” and “output” around?

1 Like

I am flabbergasted…
It does not match the theory of debouncing I think.
So there must be other reasons to add these components.
@JackANDJude, can you explain this maybe ?

1 Like

Sorry, I don’t know. It’s one of those fun little mysteries. If we really want to investigate, let’s compare different bits within the same version.

:smiley:

Bits to compare in this vein include the button, slide switch, toggle switch, and even the roller switch (very fun bit to make at home, btw).

It doesn’t really matter what order they are in. Since we are dealing with a mechanical switch, the only time there is a circuit, is when the switch is closed. When it is closed, the position of the cap and the resistor are topologically identical. A floating signal has no effect on the action of the switch when it’s open. @JackANDJude is on the right track I believe. A quick look at the other switches reveals that the toggle and slide switches do away with the capacitor entirely, with 100K resistors on either side, while the roller switch looks similar to the button.

@alexpikkert or @chris101, do you remember that discussion about the newest button version? If so, can you please link it here? I just came across some new info I can share. :smiley:

1 Like

Hi Jude @JackANDJude,
The discussions you refer to are in this topic (nearly at the end)
:smiley:

AHA! Thank you, @alexpikkert! :slight_smile: AND thanks for starting this discussion @DionoiD :slight_smile: .

SOOOO, a little birdy (@theodore_littlebits) :bird: shared this discussion thread with the engineers, and they gave us some updated info about the button!

You can now find the button, version 4 on github.:link: with all it’s bells and whistles.

The new design greatly improves debounce. :basketball:

In engineer speak: "“The old switch was passive and as such could not drive its output when it was open. The new version both drives its output, and also has improved debouncing, while maintaining good frequency response.”

More updates in gitHub to come… @theodore_littlebits & I will do our best to keep you in the loop! :slight_smile:

2 Likes

That’s a lot of stuff for a button function…
It must be a super button…
:scream:

Sa-weet!

I can follow most of what I see there. The actual button turns the FET on and off. When the ‘gate’ is high (ie, the button is up), the connection from the input of op-amp #2 goes low, and so does the output. When the button is pressed, no current flows to the FET, and the gate stays open, so current goes from op-amp #1 to op-amp #2, and the output goes high (with up to the current limit of the LV321 op-amp.

Very cool!

The part I’m not completely clear on is L1. Is that a ferrite bead, used to filter out EMI?