Help needed with isolating circuits with Optocouplers

Hi forum,

First posting here.:wink:
I am using PC817 opto coupler( about How Optocoupler Works and the Optocoupler Basics I want a 3.3 output voltage. In its 1st pin I am giving 12volt and 2nd pin is gnd. I have connected a pull down resistor on 3rd pin. But i am confused because when I am giving 3.3volt on 4th pin, and I am checking output from 3rd pin which is 1.5volt. How can I get 3.0 - 3.3volt output on 3rd pin.

I have tested it with 5 volt, means when I was giving 5 volt on 4th pin and when I was checking voltage on 3rd pin it was 4.7-4.8v which is I think correct. But I dont know what is happening in case of 3.3volt. PLease help.

Many thanks.

EDIT : i have attached a screenshot of proteus simulation. I actually didnt find the PC817 opto coupler but I got the similar opto coupler. I am getting an output voltage of 3.22. Please tell me that is this connection good. I mean if I make this connection in real, will this work?

This looks to be operating as designed (although Iā€™m not sure what you are trying to do exactly). With12V in you will get about 12millamps through the diode on the optocoupler which will be fine if that creates enough light to saturate the output transistor (the optocoupler data sheet should tell you that). At least in your simulation, that appears to be working correctly. The diode is producing light and has saturated the output transistor(which is appears to be dropping about .8volts collector to emitter). That would indicate the optocoupler is working correctly. If you run the simulation with the 12V to R1 disconnected then the voltage across R3 should drop to 0V as the transistor shuts off and that is presumably what you want. While the simulation is working you may find that the PC817 optocoupler needs more current through the diode to do the same thing (or not if is close enough to the one in the simulation). That would show up in a real life circuit as the voltage across R3 being less than the current 3.22V.