i am trying to design a battery back for my microcontroller circuit.I am sensing the mains using optocoupler. when the mains is On the controller pin is low and vice-versa. But on testing the circuit the microcontroller pin does not go low when the mains in ON. it comes down to 2.6V from 3.3V. Do i need to change any of the component value. Please Reply.
Your Circuit have error like +5Volts Connected to GND of microcontroller, GND connected to VCC of microcontroller. and you have shown some other GND Symbol for Optocoupler Emmiter.
Check the Optocoupler Emitter Is Connected to GND of Microcontroller and the PIN is configured as INPUT PORT.
Which Optocoupler you are using?
Thanks for the reply, yes there was a little bit mistake in drawing. I am using 4N35 optocoupler. Auxilary supply is nothing but a battery backup. please check the corrected diagram
Circuit is ok.
Is it opto isolator is necessary simple circuit like
+5V---resistor(low value)----PIN-----PIN----resistor(high value)---GND can also detect Mains Fail
from where is the logic pin of the Microcontroller getting +5V? Is it from Mains? I think that logic pin should be pulled up to Vcc. Basicaly the pin should work when either of the two supplies are present.