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

digital-logicopto-isolatoroptoelectronicsvoltage

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!

enter image description here

enter image description here

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) 🙁

Best Answer

schematic

simulate this circuit – Schematic created using CircuitLab

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

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