Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Post History

71%
+3 −0
Q&A Isolated Digital Input - Overvoltage protection

To summarize, it seems you want a circuit that will detect an input voltage high/low with a threshold somewhere between 0 and 3.3 V, must operate correctly with 0-3.3 V input, but must tolerate inp...

posted 3y ago by Olin Lathrop‭  ·  edited 3y ago by Olin Lathrop‭

Answer
#2: Post edited by user avatar Olin Lathrop‭ · 2021-02-28T21:52:56Z (over 3 years ago)
  • To summarize, it seems you want a circuit that will detect an input voltage high/low with a threshold somewhere between 0 and 3.3 V, must operate correctly with 0-3.3 V input, but must tolerate input up to 32 V. Snap action (hysteresis) is not required. An opto-isolator is to be turned on when the input is high, and off when low. The input impedance of this detector circuit is unspecified, so we can draw whatever current is convenient for us. Response time is also not specified. Apparently, inverting when the opto is driven is also acceptable.
  • Here is a circuit that meets these specifications, with the opto being on when the input is high:
  • <img src="https://electrical.codidact.com/uploads/DCmc1VjBLGyTPCxXzCG9urCo">
  • <h3>Theory of operation</h3>
  • Q1 being on turns on the opto. Q1 is turned on when the IN+ input is high. R3 limits the base current thru Q1. R1 pulls the input high when it is left open. D1 blocks reverse flow onto the 3.3 V supply when the input goes above 3.3 V. D2 is not necessary according to the specification provided, but is a good idea for robustness. Stuff happens. D2 protects the circuit from negative input voltages that would cause too much reverse voltage across the B-E junction of Q1.
  • <h3>Part values</h3>
  • The diodes are easy because pretty much anything is good enough. I show the 4148 because that's my jelly bean part to use in such cases unless there is a reason not to. With at least 75 V reverse voltage and 100 mA forward current, no limits are being pushed.
  • R2 controls the current thru the opto when it is on. 1 mA is enough current for this kind of opto. Figure Q1 eats up 200 mV when in saturation, and the LED about 1.2 V. That leaves 1.9 V across R2. (1.9 V)/(1 mA) = 1.9 k&Omega;. 1.5 k&Omega; is a common value that leaves a little margin.
  • R3 needs to supply enough base current when the opto is supposed to be on. We've already said that we want 1 mA of opto current. Let's say we want to be able to use just about any transistor, so require a minimum gain of only 25. That means we need only 40 &micro;A of base current at whatever threshold voltage should be considered "high". Using 1.5 V as the threshold voltage, and figuring 700 mV for the B-E drop of Q1, leaves 800 mV across R3. (800 mV)/(40 &micro;A) = 20 k&Omega; for the maximum R3 can be. The common value of 10 k&Omega; will therefore work nicely with plenty of margin.
  • R1 is the pullup that keeps the input high when nothing is connected. If a mechanical switch is ever used to hold the input low, we want some minimum wetting current. I figured the input should source a minimum of 1 mA when held at ground. Assuming 700 mV across D1, that leaves 2.6 V across R1. (2.6 V)/(1 mA) = 2.6 k&Omega; maximum. The common value of 2.5 k&Omega; leaves a little margin.
  • <h3>Over-Voltage</h3>
  • This circuit must survive with the input has high as 32 V. When that happens, D1 is reverse biased, so D1 and R1 can be ignored. The base current of Q1 will be (31.3 V)/(10 k&Omega;) = 3.1 mA, which is nowhere near pushing any limits of Q1. The dissipation of R3 will be (31.3 V)<sup>2</sup>/(10 k&Omega;) = 98 mW. A 0805 package or large can handle that without issue.
  • <h3>Under-Voltage</h3>
  • Although it wasn't specified, it would be good to safely allow some negative voltage on the input. D2 will clamp the base voltage of Q1 to a safe level. The issues will be the currents thru, and therefore the dissipation of R3 and R1. Clearly, R1 will have the higher dissipation, so let's see how much negative voltage can be tolerated if R1 can dissipate 125 mW.
  • Sqrt((125 mW)(2.5 k&Omega;)) = 17.7 V. Considering that the right end of R1 is at 3.3 V, and the drop across D1, this threshold is reached with an input voltage of -15.1 V. We could therefore quite comfortably spec this circuit to have an absolute minimum input voltage of -12 V. At that voltage, there will be a drain of 2.5 mA on the 3.3 V supply. That's fine since no supply current limit was specified.
  • To summarize, it seems you want a circuit that will detect an input voltage high/low with a threshold somewhere between 0 and 3.3 V, must operate correctly with 0-3.3 V input, but must tolerate input up to 32 V. Snap action (hysteresis) is not required. An opto-isolator is to be turned on when the input is high, and off when low. The input impedance of this detector circuit is unspecified, so we can draw whatever current is convenient for us. Response time is also not specified. Apparently, inverting when the opto is driven is also acceptable.
  • Here is a circuit that meets these specifications, with the opto being on when the input is high:
  • <img src="https://electrical.codidact.com/uploads/DCmc1VjBLGyTPCxXzCG9urCo">
  • <h3>Theory of operation</h3>
  • Q1 being on turns on the opto. Q1 is turned on when the IN+ input is high. R3 limits the base current thru Q1. R1 pulls the input high when it is left open. D1 blocks reverse flow onto the 3.3 V supply when the input goes above 3.3 V. D2 is not necessary according to the specification provided, but is a good idea for robustness. Stuff happens. D2 protects the circuit from negative input voltages that would cause too much reverse voltage across the B-E junction of Q1.
  • <h3>Part values</h3>
  • The diodes are easy because pretty much anything is good enough. I show the 4148 because that's my jelly bean part to use in such cases unless there is a reason not to. With at least 75 V reverse voltage and 100 mA forward current, no limits are being pushed.
  • R2 controls the current thru the opto when it is on. 1 mA is enough current for this kind of opto. Figure Q1 eats up 200 mV when in saturation, and the LED about 1.2 V. That leaves 1.9 V across R2. (1.9 V)/(1 mA) = 1.9 k&Omega;. 1.5 k&Omega; is a common value that leaves a little margin.
  • R3 needs to supply enough base current when the opto is supposed to be on. We've already said that we want 1 mA of opto current. Let's say we want to be able to use just about any transistor, so require a minimum gain of only 25. That means we need only 40 &micro;A of base current at whatever threshold voltage should be considered "high". Using 1.5 V as the threshold voltage, and figuring 700 mV for the B-E drop of Q1, leaves 800 mV across R3. (800 mV)/(40 &micro;A) = 20 k&Omega; for the maximum R3 can be. The common value of 10 k&Omega; will therefore work nicely with plenty of margin.
  • R1 is the pullup that keeps the input high when nothing is connected. If a mechanical switch is ever used to hold the input low, we want some minimum wetting current. I figured the input should source a minimum of 1 mA when held at ground. Assuming 700 mV across D1, that leaves 2.6 V across R1. (2.6 V)/(1 mA) = 2.6 k&Omega; maximum. The common value of 2.5 k&Omega; leaves a little margin.
  • <h3>Over-Voltage</h3>
  • This circuit must survive with the input has high as 32 V. When that happens, D1 is reverse biased, so D1 and R1 can be ignored. The base current of Q1 will be (31.3 V)/(10 k&Omega;) = 3.1 mA, which is nowhere near pushing any limits of Q1. The dissipation of R3 will be (31.3 V)<sup>2</sup>/(10 k&Omega;) = 98 mW. A 0805 package or large can handle that without issue.
  • <h3>Under-Voltage</h3>
  • Although it wasn't specified, it would be good to safely allow some negative voltage on the input. D2 will clamp the base voltage of Q1 to a safe level. The issues will be the currents thru, and therefore the dissipation of R3 and R1. Clearly, R1 will have the higher dissipation, so let's see how much negative voltage can be tolerated if R1 can dissipate 125 mW.
  • Sqrt((125 mW)(2.5 k&Omega;)) = 17.7 V. Considering that the right end of R1 is at 3.3 V, and the drop across D1, this threshold is reached with an input voltage of -15.1 V. We could therefore quite comfortably spec this circuit to have an absolute minimum input voltage of -12 V. At that voltage, there will be a drain of 2.5 mA on the 3.3 V supply. That's fine since no supply current limit was specified.
  • <h2>A different circuit</h2>
  • Here is a circuit that also meets your specs, but this one keeps the opto off when the input is floating or high, and on when driven low:
  • <img src="https://electrical.codidact.com/uploads/ciN7G1qYXrP3BNBuhQEn4MbA">
  • This is better if the input will be mostly high or open, and you want to sense the occasional low level.
  • <h3>Theory of operation</h3>
  • When the input is left open, it is pulled high by R1. This keeps Q1 off. Driving the input low draws current from the base of Q1, turning it on. That turns on the opto.
  • <h3>Part values</h3>
  • R3 serves the same purpose as before, and has the same value. If the saturation voltage of Q1 is 200 mV, and the LED drops 1.2 V, then there is 1.9 V across R3. (1.9V)/(1.5 k&Omega;) = 1.3 mA. Even 1 mA is sufficient for this opto to be able to work against a 10 k&Omega; pullup or pulldown on its output at common logic voltages.
  • The resistors were sized to source about 1 mA of wetting current when the input is shorted to ground. This is useful if a mechanical switch is tied between IN+ and IN-. Figure D1 and the B-E junction of Q1 each drop 700 mV. When the input is shorted to ground, that leaves 2.6 V across R1 and 1.9 V across R2. The current thru R1 is (2.6 V)/(4.7 k&Omega;) = 553 &micro;A, and thru R2 is (1.9 V)/(4.7 k&Omega;) = 404 &micro;A, for a total of 957 &micro;A being sourced by the input when held at ground.
  • <h3>Threshold voltage</h3>
  • Even if Q1 had infinite gain, the input needs to drop about 1.4 V below the 3.3 V supply to bias D1 and the B-E junction of Q1 before any appreciable current flows. This means the upper limit of the threshold voltage is about (3.3 V) - (1.4 V) = 1.9 V.
  • Let's say that in the worst case Q1 only has a gain of 25 and that 1 mA is required thru the LED for the opto to be on. That means (1 mA)/25 = 40 &micro;A of base current is required for guaranteed on operation. The voltage across R2 will therefore be (10 k&Omega;)(40 &micro;A) = 400 mV. Making the same assumptions about the voltage drops of D1 and the B-E junction of Q1, this comes out to an input of 1.5 V.
  • The switching threshold is therefore somewhere in the 1.5 to 1.9 V range. This is from 46% to 58% of the 3.3 V supply.
  • <h3>Over-voltage</h3>
  • The absolute maximum input voltage comes from the reverse voltage capability of D1. This is easily 75 V, with some 4148 diodes specified to 100 V, plus the 3.3 V of the supply.
  • <h3>Under-voltage</h3>
  • The absolute minimum input voltage is limited by the dissipation of the resistors. It should be obvious that R1 is the limiting factor, since R2 has about 700 mV less across it. Using 125 mW maximum dissipation as before, the voltage across R1 can be sqrt((125 mW)(4.7 k&Omega;)) = 24.2 V. Taking into account the supply voltage and the drop across D1, that means the input can't go below -21.6 V. -20 V absolute minimum might be a good spec.
  • Let's look in detail what happens with -20 V input, which is what we would specify as the absolute minimum. The current thru R1 will be (22.6 V)/(4.7 k&Omega;) = 4.8 mA, and thru R2 (21.9 V)/(4.7 k&Omega;) = 4.7 mA, for a total input current of -9.5 mA. Q1 will clearly saturate, so there will also be 1.3 mA thru the LED. The total supply current is (4.8 mA) + (4.7 mA) + (1.3 mA) = 10.8 mA. This is acceptable since no current limit from the 3.3 V supply was specified.
  • The dissipation of R1 will be (22.6 V)<sup>2</sup>/(4.7 k&Omega;) = 109 mW.
#1: Initial revision by user avatar Olin Lathrop‭ · 2021-02-26T16:00:50Z (over 3 years ago)
To summarize, it seems you want a circuit that will detect an input voltage high/low with a threshold somewhere between 0 and 3.3 V, must operate correctly with 0-3.3 V input, but must tolerate input up to 32 V.  Snap action (hysteresis) is not required.  An opto-isolator is to be turned on when the input is high, and off when low.  The input impedance of this detector circuit is unspecified, so we can draw whatever current is convenient for us.  Response time is also not specified.  Apparently, inverting when the opto is driven is also acceptable.

Here is a circuit that meets these specifications, with the opto being on when the input is high:

<img src="https://electrical.codidact.com/uploads/DCmc1VjBLGyTPCxXzCG9urCo">

<h3>Theory of operation</h3>

Q1 being on turns on the opto.  Q1 is turned on when the IN+ input is high.  R3 limits the base current thru Q1.  R1 pulls the input high when it is left open.  D1 blocks reverse flow onto the 3.3 V supply when the input goes above 3.3 V.  D2 is not necessary according to the specification provided, but is a good idea for robustness.  Stuff happens.  D2 protects the circuit from negative input voltages that would cause too much reverse voltage across the B-E junction of Q1.

<h3>Part values</h3>

The diodes are easy because pretty much anything is good enough.  I show the 4148 because that's my jelly bean part to use in such cases unless there is a reason not to.  With at least 75 V reverse voltage and 100 mA forward current, no limits are being pushed.

R2 controls the current thru the opto when it is on.  1 mA is enough current for this kind of opto.  Figure Q1 eats up 200 mV when in saturation, and the LED about 1.2 V.  That leaves 1.9 V across R2.  (1.9 V)/(1 mA) = 1.9 k&Omega;.  1.5 k&Omega; is a common value that leaves a little margin.

R3 needs to supply enough base current when the opto is supposed to be on.  We've already said that we want 1 mA of opto current.  Let's say we want to be able to use just about any transistor, so require a minimum gain of only 25.  That means we need only 40 &micro;A of base current at whatever threshold voltage should be considered "high".  Using 1.5 V as the threshold voltage, and figuring 700 mV for the B-E drop of Q1, leaves 800 mV across R3.  (800 mV)/(40 &micro;A) = 20 k&Omega; for the maximum R3 can be.  The common value of 10 k&Omega; will therefore work nicely with plenty of margin.

R1 is the pullup that keeps the input high when nothing is connected.  If a mechanical switch is ever used to hold the input low, we want some minimum wetting current.  I figured the input should source a minimum of 1 mA when held at ground.  Assuming 700 mV across D1, that leaves 2.6 V across R1.  (2.6 V)/(1 mA) = 2.6 k&Omega; maximum.  The common value of 2.5 k&Omega; leaves a little margin.

<h3>Over-Voltage</h3>

This circuit must survive with the input has high as 32 V.  When that happens, D1 is reverse biased, so D1 and R1 can be ignored.  The base current of Q1 will be (31.3 V)/(10 k&Omega;) = 3.1 mA, which is nowhere near pushing any limits of Q1.  The dissipation of R3 will be (31.3 V)<sup>2</sup>/(10 k&Omega;) = 98 mW.  A 0805 package or large can handle that without issue.

<h3>Under-Voltage</h3>

Although it wasn't specified, it would be good to safely allow some negative voltage on the input.  D2 will clamp the base voltage of Q1 to a safe level.  The issues will be the currents thru, and therefore the dissipation of R3 and R1.  Clearly, R1 will have the higher dissipation, so let's see how much negative voltage can be tolerated if R1 can dissipate 125 mW.

Sqrt((125 mW)(2.5 k&Omega;)) = 17.7 V.  Considering that the right end of R1 is at 3.3 V, and the drop across D1, this threshold is reached with an input voltage of -15.1 V.  We could therefore quite comfortably spec this circuit to have an absolute minimum input voltage of -12 V.  At that voltage, there will be a drain of 2.5 mA on the 3.3 V supply.  That's fine since no supply current limit was specified.