Darlington output stuck at intermediate voltage when sensing mains - Page 1
Forum section: electronics / projects

author: crgarcia
author_rank: Regular Contributor
timestamp: October 05, 2025, 10:24:33 pm
content: Hi everyone,I’m working on a circuit to sense multiple mains channels using an ESP32.Each channel uses an optocoupler with a Darlington output. To compensate for the Darlington’s voltage drop, I added a 74LVCH8T245PWE4 (level shifter / bus transceiver) between the optocoupler and the ESP32 input.The optocoupler output is filtered and pulled down using a resistor (R64) and capacitor (C54) — the capacitor smooths the rectified sine wave, and the resistor pulls down when mains is disconnected.*(This is a simplified schematics, I removed all connections I considered not relevant. Full schematic link bellow)Full Schematics:https://raw.githubusercontent.com/crgarcia12/electronics-homeassistant-lightscontroll/3ae6f71d5cd0d70864b2a127d775114b991f9a17/PCB/schematics-v26.3/readme-media/schematics.svgHere’s the issue I’m seeing:When connecting the optocoupler output directly to the ESP32, it works fine (even with the darlington voltage drop)After adding the 74LVCH8T245PWE4, when I turn off the mains, the darlington output stays at an intermediate voltage (~2 V) instead of dropping to 0 V.If I briefly touch the node to GND, it then stays low.Reducing R64 from 10 kΩ -> 1 kΩ makes the circuit behave correctly and discharge as expected.According to online calculators:With 10 kΩ, I expect a discharge around 500 ms and about 0.3 mA current.With 1 kΩ, discharge should be around 40 ms and about 3 mA.So my question is:Why does the voltage remain at an intermediate level when using the 74LVCH8T245PWE4?I’m trying to understand what causes the node to hold this intermediate voltage after mains is off, so I can decide if using a smaller resistor is a proper solution — I don’t want to just do it “because it works.”Thanks!

author: Andy Watson
author_rank: Super Contributor
timestamp: October 05, 2025, 10:36:21 pm
content: The 74LVCH8T245 is doing what it was designed to do:Quotefrom the introduction of the Nexperia datasheet.Also, it is generally not a good idea to feed digital logic inputs with what is effectively an analogue signal. This is why "bus-holding" circuits exist!

author: Someone
author_rank: Super Contributor
timestamp: October 05, 2025, 10:42:01 pm
content: Floating OE can cause "analog" effects on what you expect to be digital.

author: Whales
author_rank: Super Contributor
timestamp: October 05, 2025, 11:01:31 pm
content: I am not exactly sure about the SN74LVCH8T245 strange behaviour, but I suspect that your optocoupler circuit's output may be very weak/marginal and that _might_ be causing the 74 chip to misbehave.Darlington pairs normally drop a few volts when used in a "common collector" configuration like you have drawn them. 3.3V feels a bit low for this configuration to be reliable and I note that the LDA210 datasheet only shows 5V circuits at a minimum.When I try to simulate a couple of approximations of your circuit (minus the cap) I get different marginal results. If I used other part/component models I would probably get even more unique results, because small changes to this circuit will probably cause it to behave quite differently:Suggestions:1. Use a "common emitter" arrangement instead of "common collector"; OR; use 5V instead of 3.3V.2. Don't use a 74 series logic level shifter, it's overkill, complicated and might backfeed in odd ways. I would recommend using some transistors instead, you can make them work predictably with weak signals.Eg this particular configuration, with the darlington opto in a common-emitter configuration and then a PNP common-emitter amplifier after that:The red trace is the signal from just the opto + resistor. It doesn't go all the way down to 0V, but it does go all the way to 3.3V, so a PNP common emitter amplifier is perfect to buffer it. That gives you the black trace, a beautiful 0-3.3V signal.Here's a version tweaked to suit your actual need of keeping a capacitor filled whilst mains is connected:

author: PCB.Wiz
author_rank: Super Contributor
timestamp: October 06, 2025, 12:39:37 am
content: Quote from: crgarcia on October 05, 2025, 10:24:33 pm#1 is correct.You need to read the data sheet, the 'H' in that part number is important, it is the wrong choice. 74LVCH8T245PWE4You also have added parts in VCCA doingA simple shifted schmitt is fine here, it does notneedbi-directional.So, a smaller, simpler part like Nexperia 74AHCT245PW or 74AHCT244PW will work, pick cheapest/easiest to layout.

author: BrianHG
author_rank: Super Contributor
timestamp: October 06, 2025, 01:22:02 am
content: Curious, you do know that there exist 16bit IO expanders with schmitt trigger inputs.Just in case you want to remove a chip...

author: PCB.Wiz
author_rank: Super Contributor
timestamp: October 06, 2025, 02:50:24 am
content: Quote from: BrianHG on October 06, 2025, 01:22:02 amGood point, I missed that right-most block was not the ESP32.The part the OP has chosen already has Dual VCC & translation, so they can omit the buffer and use the IO expander to give better threshold margin.A Darlington driving a 3v3 IO is 'probably' (just) ok but the GPIO VCC can be lowered slightly to improve the margin and lower the static Icc.The IO read latches the IP pins, so a formal schmitt is less critical.Addit: Another option for the OP is the simplicity of a 74HCS165, I see Nexperia are now 2nd sourcing the 74HCS parts originally from TI.Powered from ~ 2.7V that would take Darlington IN, and 3v3 CMOS logic, easily daisy chained.

author: crgarcia
author_rank: Regular Contributor
timestamp: October 06, 2025, 02:13:17 pm
content: Quote from: Andy Watson on October 05, 2025, 10:36:21 pmThank you Andy! I now understand why it is behaving as it does. Bus holding seems to be a nice feature for my use case. It helps deal with the AC signal.I will open another thread on this, because according to my calculations a 10k pull down resistor should be more than enough to break the holdQuote from: Whales on October 05, 2025, 11:01:31 pmThanks Whales! I am a beginner on transistors and I might be missing something. If i use common emitter, I think I will have the same problem but in reverse: voltage will never go to GND when mains is off. Your idea of using transistors is nice. I will see if I find a small IC that has 8 transistors and fit in my board.BTW, very nice simulations! what tool do you use?Quote from: PCB.Wiz on October 06, 2025, 12:39:37 amI did not manage to figure out what is the H in that part number :'(The darlington output goes from 0v to ~2.8v. I set a voltage divider to provide VccA 3v, to lower the voltage of the HIGH state

author: PCB.Wiz
author_rank: Super Contributor
timestamp: October 06, 2025, 07:02:14 pm
content: Quote from: crgarcia on October 06, 2025, 02:13:17 pmThe 'H' tags the bus hold variant.Quote from: crgarcia on October 06, 2025, 02:13:17 pmYou need to exceed the maximum snap current, which is about 400uA at 3v3If we guess about 1.35V at the low side for pulldown, at peak snap, that's needingless than 3.25k, which is why 10k fails and 1k works.Quote from: crgarcia on October 06, 2025, 02:13:17 pmYou can throw the 74LVCH8T245P away entirely, as your 6416 chip already has dual Vcc.~2.8V is a valid high for 3v3 logic, but with a dual Vcc part you can get more margin by lowering VCC pins to 2.7~2.8V

author: aeg
author_rank: Regular Contributor
timestamp: October 07, 2025, 12:36:31 am
content: I'd do the whole darned thing differently.Darlington outputs are for driving big loads; if possible, change to a non-Darlington optocoupler.Connect the phototransistors in the common-emitter configuration with the collector pulled up to 5 (!) volts. Level shift to full 0-5V swing with a 74HC04 powered by 5V, then mux with a 74AHC165 shift register powered by 3.3V. Have your microcontroller sample the inputs at a rate relatively prime to 50, 60 and 400. Filter in software, no capacitors.

author: floobydust
author_rank: Super Contributor
timestamp: October 07, 2025, 02:50:23 am
content: I second a revisit of the design. For a few reasons.The (IXYS) LDA210 opto-isolator is obsolete and an oddball. LDA100 is similar but not Darlington. Ditch the Darlington and its high saturation voltage.Good oldH11AA1/AA4but a piggy liking IF10mA which is too high.FODM214looks better.https://www.onsemi.com/products/interfaces/phototransistor-optocouplers/phototransistor-output-ac-sensing-input-optocouplersA problem I found in products is that you don't want the opto input super sensitive. Around 1mA current is a minimum but with the 300k resistor, will it trigger at say 40V?The product gave false indications of mains on a pressure switch. It was stray capacitance in the wiring could be enough to light the LED, or a few sites had moisture which was also enough leakage current.So I added a resistor across the LED, and for another model added series zener so "mains" had be 75% or more to qualify. But then mains brownouts triggered it.You can use a little bridge rectifier like MB6S and a single LED opto. I use two input resistors e.g. 2 of 150k for the higher breakdown voltage if mains transients are more than usual, like with motors.a bit morehttps://www.eevblog.com/forum/projects/circuit-for-detecting-a-220v-ac-signaland there is another thread on all this but I can't find it right now.

author: PCB.Wiz
author_rank: Super Contributor
timestamp: October 07, 2025, 03:46:41 am
content: Quote from: floobydust on October 07, 2025, 02:50:23 amYes, AC-in+Darlington Opto coupler is becoming a rare animal.You can get AC-in NPN-out in Dual and quads, for smaller PCBs but the gain groups of the combined parts is more restrictive.The high market volume seems to be single opto couplers, where you can find 1mA spec and tighter gain grouping.eghttps://optoelectronics.liteon.com/upload/download/DS70-2010-0066/LTV-214-G%20series%20Rev.F%20(Aug25).PDFA LITEON LTV-214-G IF =±1mA, VCE=5V, Ta=25'CGain Grouping 'AK' = 100~200Or AOTE LTV-214B where 'B' has gain grouping 100~300 at 1mA

author: crgarcia
author_rank: Regular Contributor
timestamp: October 08, 2025, 12:52:29 am
content: Quote from: floobydust on October 07, 2025, 02:50:23 amMy (hobbiest) thinking was that 300 kΩ resistors right at the opto input (LDA210) would prevent stray current or capacitance on the long wire. The noise would have to be generated after that resistor to affect the opto, and since they are next to each other, then it would be hard for it to happen.I guess my logic is wrong, no?Quote from: PCB.Wiz on October 07, 2025, 03:46:41 amThat was exactly my problem when I saw that the LDA was obsolete. I couldn’t find any alternative that supports AC input with two channels per IC — I don’t have space for single-channel DIP-4 packages.I just checked the ones you recommended (FOBM214 and LTV-214) — they’re really small and would actually work!