Optocoupler separated ground problem (solved)

Thread Starter

haman tamimi

Joined Jul 15, 2025
35
Hello everyone
So Iam trying to drive an optocoplur (pc817) with a PWM signal generated from comparator that compare triangle wave (single source )with dc analogue signal .
So the PWM is applied on the diode side of the optocoplur.
With a separated source used on the output side when visualising the output signal with oscilloscope it give nothing till connecting the output side ground to the input side ground,when connecting them the signal appears on the oscilloscope
Disconnect the ground from each other the signal is gone .
I have tried to use a capacitor coupling between the two ground but it didn't work (I did that because on Proteus simulation it works when adding the capacitor)

So does anyone know a solution for that as I have used the optocoplur in the first place for isolation it make no sense to reconnect the grounds together again?
 

meth

Joined May 21, 2016
298
Sorry maybe I don't understand the purpose of your circuit, you expect the current from the battery to "pulse" through the resistor with the PWM signal on the left side?
If you keep your probe on pin 4 of the optocoupler of course you will get constant 12V.
Am I missing something here?

The circuit should 100% work with separated ground, that is the point of the optocoupler.
If you remove the optocoupler completely, do you have the pulses on pin 7 of U2:B ?
 

Thread Starter

haman tamimi

Joined Jul 15, 2025
35
Sorry maybe I don't understand the purpose of your circuit, you expect the current from the battery to "pulse" through the resistor with the PWM signal on the left side?
If you keep your probe on pin 4 of the optocoupler of course you will get constant 12V.
Am I missing something here?

The circuit should 100% work with separated ground, that is the point of the optocoupler.
If you remove the optocoupler completely, do you have the pulses on pin 7 of U2:B ?
yes, when removing the opto I get the expected PWM signal and even when it's connected to the left side
the problem is on the output side that the signal is zero till connecting the two grounds together
 

MrChips

Joined Oct 2, 2009
34,627
As Dick suggests, you have to move the ground connection of your oscilloscope to the B1 battery.
Alternatively, you have to connect R8 or B1 to GND temporarily to observe the signal on the oscilloscope.
 

Thread Starter

haman tamimi

Joined Jul 15, 2025
35
As Dick suggests, you have to move the ground connection of your oscilloscope to the B1 battery.
Alternatively, you have to connect R8 or B1 to GND temporarily to observe the signal on the oscilloscope.
This is my problem j2 is the first ground and B1 negative terminal is the second ground why I have to connect them with each other to get a signal on the output.
if this the case I wouldn't use an opto in the first place
 

MrChips

Joined Oct 2, 2009
34,627
Your signal is present at the output even when the common ground connection is removed.
The problem is that the output and oscilloscope must share a common ground in order to view the signal on the oscilloscope.

Hence, there is nothing wrong with that part of the circuit. The problem lies with how you are using the oscilloscope.
 

Thread Starter

haman tamimi

Joined Jul 15, 2025
35
Your signal is present at the output even when the common ground connection is removed.
The problem is that the output and oscilloscope must share a common ground in order to view the signal on the oscilloscope.

Hence, there is nothing wrong with that part of the circuit. The problem lies with how you are using the oscilloscope.
Sorry maybe I didn't understand but let's assume that A is the positive terminal and B is the negative terminal of the oscilloscope, and this is the connection in the real kit ,is there any problem with this connection.
1752585992299.png
 

MrChips

Joined Oct 2, 2009
34,627
Sorry maybe I didn't understand but let's assume that A is the positive terminal and B is the negative terminal of the oscilloscope, and this is the connection in the real kit ,is there any problem with this connection.
View attachment 352689
Yes, there still is a problem.
You are showing a 4-channel oscilloscope and taking a differential reading between channels A and B.
The problem is that the output side of the optocoupler has no voltage reference.
 

meth

Joined May 21, 2016
298
He says B is the negative terminal of the scope, it is not the other channel.. its just the visual problem..
What is the frequency of your PWM signal? If you could put a LED in series with the resistor you can see if it is blinking or not (or if the frequency is above 30Hz it should be constantly ON). That way you will know if there is a problem with the output or your scope measurement method. Also you might check this maybe with multimeter in AC Voltage mode across the resistor.
 

Thread Starter

haman tamimi

Joined Jul 15, 2025
35
Yes, there still is a problem.
You are showing a 4-channel oscilloscope and taking a differential reading between channels A and B.
The problem is that the output side of the optocoupler has no voltage reference.
I am showing this 4-channel oscilloscope because Portus simulation has no other choice it's just a demonstration for the real case To clear the picture, the real word kit is two channel scope, and I am using only one channel the positive terminal is on A and the negative one is on B
 

Thread Starter

haman tamimi

Joined Jul 15, 2025
35
He says B is the negative terminal of the scope, it is not the other channel.. its just the visual problem..
What is the frequency of your PWM signal? If you could put a LED in series with the resistor you can see if it is blinking or not (or if the frequency is above 30Hz it should be constantly ON). That way you will know if there is a problem with the output or your scope measurement method. Also you might check this maybe with multimeter in AC Voltage mode across the resistor.
F =180 Hz
i have tried this but still the same it only light on when connecting the two grounds together
even the multimeter gives nothing
 

MrChips

Joined Oct 2, 2009
34,627
For the real circuit and the simulation, connect one side of B1 to ground.
You can remove the ground connection later for proper isolation.

Multimeter will only work for PWM lower than 1 Hz.
 

Thread Starter

haman tamimi

Joined Jul 15, 2025
35
For the real circuit and the simulation, connect one side of B1 to ground.
You can remove the ground connection later for proper isolation.

Multimeter will only work for PWM lower than 1 Hz.
if you mean the negative terminal of B1 to the first ground I have done this, and the result is as long as it's connected the output work as expected I get a PWM signal , the moment I disconnect the two grounds of each other the output become zero
 
Top