# How to wire up optocoupler for digitally controlled UV (under voltage) input protection?

What I am trying to build is an under voltage input protection. It will always limit the voltage flowing into the output end to the microcontroller to be 3.3V, but when the input goes below 380V, it will give value less than 3.3V to the microcontroller, telling it there's something wrong.

In my optocoupler, I don't know why, the output only follows the activation voltage, and doesn't behave as I would like it to be. Please help!  Well, i have a voltage divider there that gives 4.67V, so, any input V DC that gives above 3.3, will output 3.3, and anything lower than 3.3 (after voltage divider), it will reflect it, wouldn't it ? according to the simulation, it does do so.. the huge question, or rather, the question is the optocoupler wiring.. whatever the voltage goes into the LED side, it always gives the activation voltage (the one goes to the collector) :( simulate this circuit – Schematic created using CircuitLab

When V1 < 3.3V, Q1 OFF, V2 = 0

When V1 = 3.3V, Q1 ON, V2 = 5

Your sketch should work better than what you've experienced. It'll give you the inverted logics instead of what you expect (output high when undervoltage). Here's a simulation with TI TINA:  There are a few issues with your idea, however. First, the Zener is unneccessary: the threshold will be fundamentally determined by the Vf of the LED, and not the Zener voltage. So you can simplify your schematics. Increasing the output resistor would also make the transition sharper. There is another flaw of your idea: that resistor of 82k will dissipate about 2W at 400V DC. So, the current should be decreased (using larger resistors). Smaller wattage resistors usually have smaller max. voltage allowed, so instead of one resistor, two or three in series would be a better fit.  