Phase cutting behaving weirdly.

Hi everyone,

I built a circuit which will work as a wifi thermostat but right now I'm just testing it with a lamp.
The circuit is based on zero crossing detection and phase cutting, that should allow me to have a more granular control of the temperature.

I used an arduino as an oscilloscope to check the output of my zero crossing detector circuit and it is a clean output.

That said, I still don't have a clean behavior. The light bulb randomly turn off and turn on for fractions of a second. This happens both if I try to fade it or if I try to keep it at 50% brightness.

Schematic is in the attachments.

Thanks in advance,
Lorenzo Benevento.

That circuit is directly connected to the mains and potentially a killer. You must opto-isolate the zero-cross detector as a matter of urgency. This a matter of life and limb.

MarkT is correct, even though you have 470K in series with the main, under some fairly typical situations it can cause someone's heart to stop working.

Other comments:

  1. Your Wemos D1 digital output is likely to only provide something less than 3 volts. Not sure exactly the value but its not 3.3V So we're not sure if the MOC3020 is adequately turned on.

You did not specify the Mains voltage or you intended load.
You did not specify the type of BT136 triac. They come in logic and standard versions.

  1. Its been a long time since I worked with Triacs powering AC circuits so you need to verify my following statement.
    You are using phase control (as opposed to zero crossing ON/OFF). If your mains is 120 VAC and we assume your triac is a standard type. If you delay the trigger until the input voltage reaches something like 140Volts, then trigger the output Triac, the current into the gate will be 140/220 = over 1/2 amp! This exceeds both the MOC3020 and BT136 gate current.

Most phase controls use a capacitor + resistor to limit the current into the output triac gate.

Assuming you are powering a resistance heater, you should consider controlling the cycles instead of phase control. This type of control does not have as fine a control but generates no electrical noise.

For instance: each cycle is a full 50 / 60 hz cycle.

  • 1 cycle off then 2 cycles on
  • 1 cycle off then 3 cycles on
  • 2 cycles off then 1 cycle on

you get the picture, the sequence of cycles would have to be calculated to give linear control.

John

The circuit is based on zero crossing detection and phase cutting, that should allow me to have a more granular control of the temperature.

It won't. No heater responds fast enough for phase cutting to make the slightest difference to the amount of granularity of the temperature control.

What you need to do is use slow PWM, how slow depends on what you are heating. For water, which has a high specific heat capacity, it can be minutes. If the heater is directly heating air then a few seconds will do. You need to use burst mode as per JohnRob's suggestion, with fewer on and more off cycles until the heater is off completely at or just above the set temperature.

The traditional approach of using hystereses is useless for fine control because the hystereses band gives you a built in band that you cannot control at all, plus a bit more and a bit less as the temperature repeatedly overshoots and then undershoots.

I should also add that standard resistors are not mains rated. They are not guaranteed not to flash-over,
they are not guaranteed to fail open-circuit, they are not guaranteed not to start fires unless "fusible".
Their pcb pads may be too close for correct creepage/clearance distance...

Mains may carry very high voltage spikes, well above the nominal, due to lightning on the lines or other
transients, so mains equipment has to be very carefully designed to be safe when these happen. You
need to use opto couplers with correct creepage/clearances (typically pcb slots are required for
creepage). Alternatively the whole circuit can be at mains voltage and double-insulated inside a
suitable insulated box. Much harder to safely work on developing such circuits though.

JohnRob:

  1. Your Wemos D1 digital output is likely to only provide something less than 3 volts. Not sure exactly the value but its not 3.3V So we're not sure if the MOC3020 is adequately turned on.

That depends on the series resistor into the LED. The LED's Vf is about 1.2V, no problem there.

You did not specify the type of BT136 triac. They come in logic and standard versions.

Irrelevant as the gate is driven from mains voltage.

If you delay the trigger until the input voltage reaches something like 140Volts, then trigger the output Triac, the current into the gate will be 140/220 = over 1/2 amp! This exceeds both the MOC3020 and BT136 gate current.

There's a current limiting resistor in the schematic (not annotated, no value given). A typical value is ~220Ω, which works fine for me (when switching 220V mains). I've never seen a schematic with a capacitor for gate control - an RC snubber, otoh, is common and required for switching inductive loads unless the TRIAC is a "snubberless" type.

MarkT:
You need to use opto couplers with correct creepage/clearances (typically pcb slots are required for
creepage).

The MOC3020 SMD comes in extra wide package, allowing for up to 8 mm PCB clearance between the two sides. I remember 5 mm is required for creepage (and just 1-2 mm between the high voltage traces themselves).

An MOV and filtering cap between L and N are good additions as well.

You may struggle here. The ESP8266 has a TCP/IP stack running in the background. It takes precedence over your program. You might have better luck with ESP32 as it has two CPU cores.

You may struggle here. The ESP8266 has a TCP/IP stack running in the background. It takes precedence over your program. You might have better luck with ESP32 as it has two CPU cores.

myiot23:
You may struggle here. The ESP8266 has a TCP/IP stack running in the background. It takes precedence over your program. You might have better luck with ESP32 as it has two CPU cores.

Good point. Missed that part.
No idea about the ESP32, I have one but never taken it out of the packing :slight_smile: Never tried to use an ESP for phase cutting, it's likely prone to glitches.