Hi all,
First post. I am a computer engineer getting into electronics from the software side (Raspberry, Arduino, ...). I only have a basic electronics knowledge. I have had some courses a long time ago but that's it. Please be gentle.
I am building a optically isolated and debounced 24V swich input for a microcontroller for a home automation application.
I came up with the circuit below by simply replacing the switch in JG Ganssle's (?) debouncer with an optocoupler. The circuit seems to work. I did experience severe problems initially (Schmitt trigger settling at intermediate voltages) but these seem to have disappeared by grounding all unused inputs and adding a decoupling capacitor (I did not expect that, the 6 triggers seemed independant).
I am attaching a couple of screenshots that I took with a usb scope. The switch I am using bounces significantly when closing but does not bounce when opening. Red is Schmitt trigger output (OUT in schematic below), blue is switch input (IN in schematic below) or capacitor voltage (top of C1 in schematic below). Switch input is scaled by 10x.
I have the following questions about this circuit:
1/ How do I optimally pick values for R1, R2 and C1 in this circuit? The circuit seems to work equally well with e.g. R1 and R2 = 100K and C1 = 47n. This makes sense since the charging / discharging time constants are the same. However, there must be other boundary conditions, like current through the optocoupler (which seems quite small in any case so I do not expect CTR issues) or voltage at the Schmitt trigger input?
2/ I have added the optional diode because I like symmetry. In this case both time constants are the same. Some sources (e.g. http://www.electronics-tutorials.ws/io/input-interfacing-circuits.html) argue that R2 should be smaller than R1 so that C1 discharges more quickly. However, I do not see why this would be the case. Given that the bounces seem unpredictible it seems to make more sense to handle opening and closing symetrically. Does that make sense or am I missing something?
3/ Does it matter which 74X14 Schmitt trigger I use (HC, GCT, AHC, AHCT, ...)? I have chosen the HC version because I am hoping to be able to make a 3.3 V version by only changing component values of R's and C's, and HC seems to work for both 3.3 and 5 V. Is that correct? Or am I again missing something?
4/ Do I need more protection at the optocoupler side for my application? Some sources use a TVS diode. Some sources split R3 in two resistors at both leads. But I am not sure what I (reasonably) need in my application?
5/ It would probably be possible to move the debouncing components to the 24 V side of the optocoupler. Would that be a better or worse design? Pro's and con's? I did not go that route because it seemed more tricky to get everything right since the same current charges the capacitor and lights the LED. In the circuit below (I think) this is independant.
Other comments are of course also welcomed!
schematic:
switch input (x10) and Schmitt trigger output when closing the switch
switch input (x10) and Schmitt trigger output when opening the switch
voltage at capacitor and Schmitt trigger output when closing the switch
voltage at capacitor and Schmitt trigger output when opening the switch
switch input (x10) and Schmitt trigger output when "double clicking" the switch
capacitor voltage and Schmitt trigger output when "double clicking" the switch
First post. I am a computer engineer getting into electronics from the software side (Raspberry, Arduino, ...). I only have a basic electronics knowledge. I have had some courses a long time ago but that's it. Please be gentle.
I am building a optically isolated and debounced 24V swich input for a microcontroller for a home automation application.
I came up with the circuit below by simply replacing the switch in JG Ganssle's (?) debouncer with an optocoupler. The circuit seems to work. I did experience severe problems initially (Schmitt trigger settling at intermediate voltages) but these seem to have disappeared by grounding all unused inputs and adding a decoupling capacitor (I did not expect that, the 6 triggers seemed independant).
I am attaching a couple of screenshots that I took with a usb scope. The switch I am using bounces significantly when closing but does not bounce when opening. Red is Schmitt trigger output (OUT in schematic below), blue is switch input (IN in schematic below) or capacitor voltage (top of C1 in schematic below). Switch input is scaled by 10x.
I have the following questions about this circuit:
1/ How do I optimally pick values for R1, R2 and C1 in this circuit? The circuit seems to work equally well with e.g. R1 and R2 = 100K and C1 = 47n. This makes sense since the charging / discharging time constants are the same. However, there must be other boundary conditions, like current through the optocoupler (which seems quite small in any case so I do not expect CTR issues) or voltage at the Schmitt trigger input?
2/ I have added the optional diode because I like symmetry. In this case both time constants are the same. Some sources (e.g. http://www.electronics-tutorials.ws/io/input-interfacing-circuits.html) argue that R2 should be smaller than R1 so that C1 discharges more quickly. However, I do not see why this would be the case. Given that the bounces seem unpredictible it seems to make more sense to handle opening and closing symetrically. Does that make sense or am I missing something?
3/ Does it matter which 74X14 Schmitt trigger I use (HC, GCT, AHC, AHCT, ...)? I have chosen the HC version because I am hoping to be able to make a 3.3 V version by only changing component values of R's and C's, and HC seems to work for both 3.3 and 5 V. Is that correct? Or am I again missing something?
4/ Do I need more protection at the optocoupler side for my application? Some sources use a TVS diode. Some sources split R3 in two resistors at both leads. But I am not sure what I (reasonably) need in my application?
5/ It would probably be possible to move the debouncing components to the 24 V side of the optocoupler. Would that be a better or worse design? Pro's and con's? I did not go that route because it seemed more tricky to get everything right since the same current charges the capacitor and lights the LED. In the circuit below (I think) this is independant.
Other comments are of course also welcomed!
schematic:
switch input (x10) and Schmitt trigger output when closing the switch
switch input (x10) and Schmitt trigger output when opening the switch
voltage at capacitor and Schmitt trigger output when closing the switch
voltage at capacitor and Schmitt trigger output when opening the switch
switch input (x10) and Schmitt trigger output when "double clicking" the switch
capacitor voltage and Schmitt trigger output when "double clicking" the switch