0
\$\begingroup\$

I have a product with a non isolated power supply which has 220 VAC live line as the GND reference:

psu

My MCU receives 3.3 VDC from the same circuit.

I want to detect the presence of 220 VAC (same phase which powers up the device) using GPIO. (you might be wondering why bother because device will switch off if the 220 VAC is not present. However this is not the case. Phase is same but power line is connected directly to the 220 VAC live line and the GPIO sensing is required on a switch. When switch is closed, I will get 220 VAC, if switch is open, I will get nothing. This is what I intend to sense using GPIO.)

This is what I am planning to do:

There are two ways to do this:

1) Opto coupler way where I use an intermediate opto coupler to protect my GPIO as shown below:

opto

2) Direct connection to GPIO as shown below:

switch sense

I want to use the second circuit because of these reasons:

1) Cost is lower

2) Simplicity

3) First circuit is voltage dependent. If I am designing for 220 VAC and line voltage drops down to 110 VAC, the circuit won't work because optocoupler will not turn ON. If I design for 110 VAC and use it in 220 VAC, it will get damaged due to excessive heating/current.

My questions are as follows:

1) Since I am using non-isolated power supply circuit, does it even make sense to use opto couplers?

2) Since my GND is referenced to 220 VAC, do I need to bother about voltage spikes on phase line?

3) What protection should I put in place for my IO lines against voltage spikes (if it's a concern)?

\$\endgroup\$
  • \$\begingroup\$ Why is neutral connected to earth via a 1 amp fuse? \$\endgroup\$ – Andy aka Sep 2 '18 at 18:55
  • \$\begingroup\$ I am sorry @Andy. I should've had removed that before posting. There is no connection in the actual device. I guess one of the engineers left it there by mistake. Maybe I should delete the question and repost it in a more structured manner. \$\endgroup\$ – Whiskeyjack Sep 2 '18 at 19:27
  • \$\begingroup\$ You can edit out the rogue connection. \$\endgroup\$ – Andy aka Sep 2 '18 at 19:51
  • \$\begingroup\$ You should also be using a GND symbol and not the 'earth' symbol which suggests a connection to mains earth and, therefore, a dead short between live and earth. \$\endgroup\$ – Transistor Sep 2 '18 at 20:42
2
\$\begingroup\$

The second circuit will not work. In fact, it will fail in spectacular fashion.

Microcontroller GPIOs are not 220V-tolerant. Connecting 220V to a microcontroller will destroy it -- and probably make it catch fire! -- and is likely to cause collateral damage to other parts of your circuit as well.

Use an optocoupler. If you need the circuit to work at 120V as well, increasing the value of R185 (the collector pulldown) may allow the optocoupler to "turn on" with a lower current.

\$\endgroup\$
  • \$\begingroup\$ 220 VAC is not 220 V when my GND reference is 220 VAC, I guess. Connecting to 220 VAC is like connecting to GND. \$\endgroup\$ – Whiskeyjack Sep 2 '18 at 18:02
  • \$\begingroup\$ Then I'm confused what you're expecting to happen here. If that node is ground, then it's always going to be ground, whether the device is being powered or not. \$\endgroup\$ – duskwuff Sep 2 '18 at 18:21
  • \$\begingroup\$ I want to sense whether the switch is closed or open. When switch is closed, I will get LOW in GPIO. when switch is open, I will get a HIGH due to the 20K pullup. I am talking about the second circuit. \$\endgroup\$ – Whiskeyjack Sep 2 '18 at 18:26
  • \$\begingroup\$ @Whiskeyjack if you are connecting the switch to the board's ground net even if it is riding on the line voltage then what you are connecting it to is the local ground, not 220v. You will still have real safety issues, and potentially damage issues if there is any way you can get load-induced voltage difference between the circuit points. But if you are connecting it to a different phase or return, then your circuit will never even work at all, but rather instantly fail. \$\endgroup\$ – Chris Stratton Sep 2 '18 at 20:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.