I need help with my circuit (optocoupler, transistor, relay)

Thread Starter

kbesdjordje

Joined Mar 17, 2020
12
Hello, i've got a newbie question, i hope some of you more experienced guys can give me an answer. I've recreated a simple circuit, that closes relay contacts using optocoupler and transistor, just for fun and i've found out that it's not working, after some time i've succeded to get the circuit working as it should, but i still don't understand why it didn't worked the first time. I posted 2 pictures of my circuit (please forgive me for the ugly looking circuit, but i hope you will get it). The circuit in the first picture, named "This circuit doesn't work" is my non working circuit, and the other schemtic is my working circuit. I want to know more about electronics, and i am just confused, why the circuit in the first schematic doesn't work, and in the other one it is working just fine? Can somebody please tell me what am i doing wrong and point me to the topic i need to research to get more knowledge in this area. If i've made some spelling mistakes, forgive me i am not a native speaker. Thanks, have a great day :)This circuit doesn' work.pngThis circuit works.png
 

Audioguru again

Joined Oct 21, 2019
6,673
The current for the relay coil is VERY important but is not shown. Also the relay coil must have a diode parallel with it to absorb the flyback high voltage produced when the transistor turns off.

The circuit with the 10k resistor produces a base current of about 0.41mA in the C1815 transistor.
The circuit with the 40k resistor produces a base current of about only 0.28mA which might not be enough (the datasheet for most little transistors say that the base current should be 1/10th the collector current when a transistor is used as a switch.

The datasheet for the PC817x optocoupler shows that without a letter (the x I show) example PC817x, then the sensitivity of the coupling has a wide range. so your coupler might be very sensitive or has a poor sensitivity.
 
Hello,

Optocouplers are frequently used to decouple grounds, so it possible and normal that the ground at the input stage and the output stage are different. In this kind of circuits, they are used to avoid that the 5Volt power supply is damaged by the relay currents. For that reason, it is also important to install the freewheeling diode in parallel with the relay.
 

Thread Starter

kbesdjordje

Joined Mar 17, 2020
12
Well there is your answer, basic electronic theory...

Current can only flow in a complete circuit.
Well there is your answer, basic electronic theory...

Current can only flow in a complete circuit.
So the base of the transistor Q2 and the emiter need to be from delivered from one supply. Can i make the voltage divider and close a circuit with a resistor to a V1 power supply.
 

Thread Starter

kbesdjordje

Joined Mar 17, 2020
12
The current for the relay coil is VERY important but is not shown. Also the relay coil must have a diode parallel with it to absorb the flyback high voltage produced when the transistor turns off.

The circuit with the 10k resistor produces a base current of about 0.41mA in the C1815 transistor.
The circuit with the 40k resistor produces a base current of about only 0.28mA which might not be enough (the datasheet for most little transistors say that the base current should be 1/10th the collector current when a transistor is used as a switch.

The datasheet for the PC817x optocoupler shows that without a letter (the x I show) example PC817x, then the sensitivity of the coupling has a wide range. so your coupler might be very sensitive or has a poor sensitivity.
I attached the flyback diode but forgot to put it in this schematic, i know i can use only a relay but i i recreated this circuit just for fun, thank you for all the answer. I will research this more.
 

Thread Starter

kbesdjordje

Joined Mar 17, 2020
12
Hello,

Optocouplers are frequently used to decouple grounds, so it possible and normal that the ground at the input stage and the output stage are different. In this kind of circuits, they are used to avoid that the 5Volt power supply is damaged by the relay currents. For that reason, it is also important to install the freewheeling diode in parallel with the relay.
Thanks for the answer, but why didn't it work for the first time (when the GNDs are different)
 

ElectricSpidey

Joined Dec 2, 2017
2,758
I already gave you the answer...

Current cannot flow from the positive terminal of the 5volt supply thru the transistor to the negative terminal because there is no return path.

It's the most basic electronic theory, it's the first thing you learn when learning electronics.
 

Thread Starter

kbesdjordje

Joined Mar 17, 2020
12
I already gave you the answer...

Current cannot flow from the positive terminal of the 5volt supply thru the transistor to the negative terminal because there is no return path.

It's the most basic electronic theory, it's the first thing you learn when learning electronics.
I am an idiot, i forgot that transistor closes with the current flow, not with the voltage being present, took me long to realise that haha. Thanks for everything. Best regards!
 
Top