Is a Voltage Divider the right option for driving my photocoupler? - Page 1
Forum section: electronics / beginners

author: mtwombley
author_rank: Newbie
timestamp: December 20, 2021, 06:50:18 pm
content: I'm connecting an induction sensor to my 3D printer. The sensor is an LJA183-8-Z/BX and I have it powered with 24V. The Z-axis stop is 3.3V and just connects to a switch. The photocoupler I have is a PS2561A. I was wiring it up like this;I'm thinking that the photocoupler will act as a switch on the 3.3V side.

author: wraper
author_rank: Unknown
timestamp: December 20, 2021, 06:58:56 pm
content: You don't need any dividers, only a single resistor in series.

author: fourfathom
author_rank: Super Contributor
timestamp: December 20, 2021, 07:10:18 pm
content: Wired as shown, when the opto LED is powered the opto transistor will short +3.3V to GND2. If +3.3V is an actual power supply then this is a problem.If you just want the opto LED to turn on when 24V is present then (as wraper said) you can just use a single series resistor. If you want it to only activate when the voltage rises above some particular voltage then the divider can be used. Even with the divider, you don't really need that resistor between the divider and the LED, just the two divider resistors. The divider will not give you a hard switching off/on opto behavior, but more of a linear current transfer.

author: Gyro
author_rank: Super Contributor
timestamp: December 20, 2021, 09:16:31 pm
content: People wanting to use voltage dividers to drive things or generate supply rails seems to come up a lot in this section. A voltage divider is just that, it divides a voltage when there is zero output current (a high impedance load). Stick a load current on it and it doesn't work as expected.In the above case you want a simple series resistor, calculated to pass the desired current through the LED in the optocoupler, as wraper says.

author: mtwombley
author_rank: Newbie
timestamp: December 20, 2021, 11:06:00 pm
content: Thanks everyone, I wasn't sure if I needed to lower the voltage on that or not. As for the 3.3V to GND2, isn't really going to GND but is just acting like a switch. Right now there is a micro switch and I figured this would just replace it.

author: rstofer
author_rank: Super Contributor
timestamp: December 21, 2021, 08:15:47 am
content: The forward voltage drop of the LED is 1.2V at 10mA (Typical) so the resistor is (24V - 1.2V) / 10 mA or 2280 Ohms.I would just use 2200 Ohms and expect the current to be a little higher at 10.36 mA. That's a long way below the maximum current of 30 mA.https://media.digikey.com/pdf/Data%20Sheets/NEC%20PDFs/ps2561aRev2009.pdf

author: Zero999
author_rank: Super Contributor
timestamp: December 21, 2021, 09:03:21 am
content: Quote from: wraper on December 20, 2021, 06:58:56 pmAgreed, a potential divider isn't needed, but it can be useful to prevent it from triggering at too lower voltage. If that's the intention, remove R3.

author: wraper
author_rank: Unknown
timestamp: December 21, 2021, 02:45:27 pm
content: Quote from: Zero999 on December 21, 2021, 09:03:21 amTo reliably trigger only at higher voltage at least a zener diode or TL431 in series with optocoupler emitter is needed. Just playing with resistors will not give consistent results. Optocouplers have varying CTR which also degrades with time.

author: fourfathom
author_rank: Super Contributor
timestamp: December 21, 2021, 04:19:40 pm
content: Quote from: wraper on December 21, 2021, 02:45:27 pmThis of course depends on your definition of "consistent". If the requirements are loose enough then a divider may be adequate. Anyway, it sounds like the OP just wanted a simple "is the power supply on?" detector. The single resistor is the way to go then.

author: Zero999
author_rank: Super Contributor
timestamp: December 21, 2021, 05:24:11 pm
content: Quote from: fourfathom on December 21, 2021, 04:19:40 pmYes, that's the idea.Without a potential divider, the LED will start to illuminate, when the voltage exceeds 1.2V, which is very low, compared to the 24V it's monitoring and could make it prone to noise pick-up. A potential divider consisting of 10k and 1k will ensure it triggers at around 13V. Of course this is an approximate figure, the output might go high when the input is 10V, or 16V. The assumption is the tolerance is loose. If precision is required the TL431 is the way to go.

author: Gyro
author_rank: Super Contributor
timestamp: December 21, 2021, 07:37:25 pm
content: If you want a bit more of a threshold detection, a cheap minimal solution would be to put a Zener (say, 18V) in series with the single series resistor. Then size the resistor to pass 10mA through the LED from the remaining 6V (nearest values 470R or 510R).The only potential downside is that the LED current will rise more steeply if the rail goes significantly above 24V - with a 470R resistor, it would reach the Absolute Maximum 30mA LED current at 33V.

author: Ian.M
author_rank: Super Contributor
timestamp: December 21, 2021, 09:12:15 pm
content: It gets a lot more complex if you need the circuit to tolerate excessive input voltage well and still have a reasonably sharp switching threshold. About five years back, I posted an approach using a 100V Darlington to limit the max voltage applied to the resistor + Zener + OPTO LED as suggested by Gyro.Its protected up to 100V DC and also against reverse polarity, though unfortunately the MPSA29 Darlington, although still (nominally) available can no longer be regarded as 'jellybean'.https://www.eevblog.com/forum/beginners/best-approach-24vdc-digital-signal-with-5v-logic/

author: GerryR
author_rank: Frequent Contributor
timestamp: December 22, 2021, 11:49:38 am
content: Quote from: Zero999 on December 21, 2021, 05:24:11 pmGyro has the right idea; if you want a different threshold, put a zener from the opto diode cathode to ground, but it will still turn on instantaneously when the 24V is applied. The divider you show can't help as Mr. Thevenin shows that the equivalent circuit is 2.18V with a .9K resistor feeding the opto diode, giving just shy of 1 mA through the opto diode, assuming a 1.2V drop of the diode, again, instantaneously when 24V is applied. The CRT of the 817 opto is from 50% to 600%, quite a range, so output current might be anywhere from .5mA to ~6mA. If you need the opto to turn on at a specific threshold, then use a comparator circuit with the reference set to your desired value, or an R-C delay to get you where you want to be. Unless I'm missing the point here the dividers proposed will not help in this configuration. Please correct me if I am wrong.

author: Zero999
author_rank: Super Contributor
timestamp: December 22, 2021, 12:15:18 pm
content: Quote from: GerryR on December 22, 2021, 11:49:38 amFair enough, perhaps R3 is a little on the low side, for a CTR of 50%. Increase it to 10k and the circuit will work more reliably.You've still missed the point though. It doesn't give a precise threshold, which isn't the idea. It's only supposed to be approximate. If all that's required is more noise immunity and to be pretty sure it won't turn on at too lower voltage, it will work fine. The LED has a certain forward voltage, below which the forward current will be far too low to turn on the phototransistor. Forget the CTR for now. What if the input voltage is only 6.6V? R1 and R2 divide the input voltage by 1.1, giving 0.6V, causing a tiny current to flow through the LED, far too low to turn on the output transistor.

author: GerryR
author_rank: Frequent Contributor
timestamp: December 22, 2021, 12:32:01 pm
content: The OP didn't state the input voltage span requirements for the circuit to work; he only shows 24V. Just lose R2 and the circuit will work much better.

author: Zero999
author_rank: Super Contributor
timestamp: December 22, 2021, 01:24:09 pm
content: Quote from: GerryR on December 22, 2021, 12:32:01 pmHe asked "Is a Voltage Divider the right option for driving my photocoupler?" The answer is: it depends on the requirements.If you're not bothered about noise immunity and just want it to trigger, when the input voltage exceeds 1.5V, or so, then fine, just use a resistor, but if you want to ensure it doesn't get triggered by stray signals and noise, then a potential divider is much more robust.I've seen this sort of arrangement used in the real world. I have a cheap rechargeable power screwdriver. It has a crude battery gauge, consisting of three LEDs, red, yellow and green and potential dividers. When the battery is fully charge, they all light brightly, as it discharges a little, the green LED goes off, then the yellow LED, leaving only the red LED when the battery is nearly discharged.

author: GerryR
author_rank: Frequent Contributor
timestamp: December 22, 2021, 01:45:23 pm
content: Quote from: Zero999 on December 22, 2021, 01:24:09 pmThe R2 resistor is shunted by the opto diode and has virtually no effect on the turn-on of the diode but sinks some current away from the diode. If the "noise" gets to 1.2 to 1.5V, R2 isn't going to help because the diode will have turned on. The opto diode is what is controlling the voltage across R2, not the other way around, as long as the supply is connected.The circuit you mentioned for monitoring the battery is a different application.

author: Zero999
author_rank: Super Contributor
timestamp: December 22, 2021, 02:00:51 pm
content: Quote from: GerryR on December 22, 2021, 01:45:23 pmYes that's right, but only when the voltage across R2 is is above the forward voltage of the LED. It has to exceed the LED's forward voltage, before the IR LED will turn on and clamp the voltage.If the voltage across R2 is below around 1.2V, the current through the IR LED will be very low, so it will produce hardly any light and will not turn on the phototransistor. This means low level input voltages below 10V or so will be ignored.QuoteYes, a different application, but it works on exactly the same principle, of an LED connected to a potential divider, only turning on when the forward voltage is exceeded.

author: GerryR
author_rank: Frequent Contributor
timestamp: December 22, 2021, 03:36:48 pm
content: "Yes that's right, but only when the voltage across R2 is is above the forward voltage of the LED. It has to exceed the LED's forward voltage, before the IR LED will turn on and clamp the voltage.If the voltage across R2 is below around 1.2V, the current through the IR LED will be very low, so it will produce hardly any light and will not turn on the phototransistor. This means low level input voltages below 10V or so will be ignored."Maybe I'm just having a minor problem with your terminology; the voltage across R2 can never exceed the opto diode forward voltage. The voltage across R2 is clamped by the diode. The voltage can hover in the knee region, as you stated, preventing enough current from flowing to fully turn on the phototransistor. If the input voltage is such that this happens, and that is not acceptable, i.e. you want it to operate at 10V, then this is the wrong circuit for that application.

author: fourfathom
author_rank: Super Contributor
timestamp: December 22, 2021, 04:37:36 pm
content: Can we agree that without the LED, the divider tap has 1/11 of the applied voltage? And the LED draws virtually zero current below a 1V junction voltage? So, it will take more than 11V applied to the divider before the opto starts to conduct.

author: Zero999
author_rank: Super Contributor
timestamp: December 22, 2021, 05:14:12 pm
content: Quote from: GerryR on December 22, 2021, 03:36:48 pmTrue.QuoteThat's the point of using a potential divider, rather than a single resistor: to ensure it doesn't trigger at too lower voltage!Here's a simulation circuit I posted previously, but with 10k for R3. The X axis is V1, the input voltage, which is swept from 2V to 24V. The voltage across the LED is linear, up to around 0.9V, when it starts conducting. The idea is the output only goes high, when the input voltage exceeds around 13V. With the model used it turns out to be about 15V, for Vout to be 3V, 90% of 3.3V, but it's not a precision circuit and it isn't intended to be. The potential divider just ensures the output is near 0 for input voltages below around 11V.

author: Ian.M
author_rank: Super Contributor
timestamp: December 22, 2021, 07:06:35 pm
content: I'd like to see that swept for temperature (assuming the PC817A model supports temperature sweeps) over its rated operating range and also swept for CTRR from its min. specified to max. specified.If the transition region stays between 8V and 16V input over the application temperature range, and there's enough CTRR margin to guarantee it stays saturated after the LED has lost 50% of its emission due to aging, call it good!Edit: fixed two typos - 50% not 5%and spelling of sweeps.

author: fourfathom
author_rank: Super Contributor
timestamp: December 22, 2021, 08:31:50 pm
content: Quote from: Ian.M on December 22, 2021, 07:06:35 pmFor some arbitrary value of "good". If we're going to design a "simplest practical voltage threshold detector", let's at least define the requirements.

author: Zero999
author_rank: Super Contributor
timestamp: December 22, 2021, 09:05:14 pm
content: I wouldn't worry too much about models. Simply using the worst case figures for CTR and VFwill do.

author: GerryR
author_rank: Frequent Contributor
timestamp: December 22, 2021, 10:34:40 pm
content: The OP is probably more confused than when he started. For his purposes, the first response by wrapper is all he needed; the rest is "icing."