Light bulbs are blinking when controlling powerful heater with PWM via SSR

I'm creating a diy sous-vide rig using esp8266, a tubular heating element (1.5 kW) and a solid state relay (zero- cross, Fotek SSR-25DA)

I use a relatively powerful heating element, so that the water can quickly reach the desired temperature. However, once it's reached, I want more granular control, so I use 10 Hz PWM to open and close the SSR.

The problem is, my ceiling lights start to flicker when the duty cycle is not 100%.

I think this is due to the starting current of the heater, but I don't know how to approach fixing it.

Maybe I should increase the PWM frequency? But I'm not sure it will work at all, considering that the SSR is zero-cross. Or should I add some fat capacitor in parallel with the heating element?

I want to be able to limit the heating power because it takes some time (about 300ms) to get the temperature from the sensor (ds18b20), and leaving the heating element on for that time on full power easily overheats the water.

Here are some specifics:

• Water volume is about 3L
• The readout time for the sensor is 375 ms
• Typical temperature range is 60-65 degree Celsius
• I use the following cycle:

 read the temperature (t) if t >= target set duty to 0 if t < target - 3 set duty to 10/10 if t < target - 2 set duty to 7/10 if t < target - 1 set duty to 5/10 if t < target - 0.3 set duty to 2/10 else do nothing 

• depending on the water volume, once you reach the desired temperature, you only need to cycle the heater once every 10 seconds, or even longer .... you can experiment with a pot of water on a stove – jsotola Feb 27 '18 at 18:42
• Note also that your SSR is a fake. See UL warning. It might not be zero-cross at all. – Transistor Feb 27 '18 at 18:49
• Nice catch @Transistor – Trevor_G Feb 27 '18 at 18:55
• @Transistor How exactly did you look that up!! I'd like to be able to search for things like this. I put "futek" into the search bar on that site and did not get a result. So how did you find that, exactly? I'm really interested. – jonk Feb 27 '18 at 19:37
• @jonk: Try searching for Fotek instead! ;^) I think I first heard of the problem on this site and a web search can dig it up (UL+fotek+fake). It's scary. The odd thing is that they didn't copy the label artwork. See this Instructables counterfeit Fotek SSR teardown for more. The triac ratings in the fakes are 50% of the SSR nameplate. – Transistor Feb 27 '18 at 19:55

A little maths:

$$t = \frac {m \times \Delta T \times SHC}{P}$$

where $t$ is time taken in seconds, $m$ is mass in kg, $\Delta T$ is temperature change in K (or °C), SHC is the specific heat capacity of the mass in kJ/kg/K and P is the power (kW).

For your 3 L of water the time taken to raise the temperature 1°C is

$$t = \frac {3 \times 1 \times 4.2}{1.5} = 8.4 \ \mathrm s$$

We can easily use a zero-cross controller here with a 1 s duty cycle and maintain the temperature close to setpoint.

Figure 1. Zero-cross duty-cycle power control. Source: my answer to A question on zero crossing versus random-fire SSRs.

Note that your controller is running asynchronously with the mains (it doesn't know where the zero-cross is) so the SSR will delay turn on and off to the next zero-cross. Due to the likely random nature of this it should all average out to give the desired precise control. You will have 100 or 120 zero-crosses per second (50 / 60 Hz) giving you a rough 1% resolution on power control.

Looking at your code I suspect that your control algorithm isn't good enough. It might be time to look into PI, proportional-integral, control. For an introduction have a look at my answer to Understanding the flow of a PI Controller?.

Figure 2. PI control response for a car cruise control illustration from the linked article.

I'd try setting the proportional band to about 10°C and integral time to 60 s for starters.

• Even then it is getting close to marginal at 0.2 to 0.4C control though, esp. when you add in the thermal lag and 1/3 second temp read time. I wonder what the thermal losses are... – Trevor_G Feb 27 '18 at 20:39
• He won't notice due to the lights flickering. Decreasing $K_P$ and increasing $K_I$ should sort it out. – Transistor Feb 27 '18 at 20:41
• I think this is the answer I was looking for. I was already considering just experimenting and hard-coding some fixed times to run the heating element for (e.g. 1C diff -> 4 seconds, 0.5C diff -> 2s), and this answer gives me the right mathematical approach. I also appreciate not having to change my hardware. Thank you! – Vovcheg Feb 27 '18 at 21:19
• As good as this information is, it really doesn't answer the question.. +1 for well written added information anyway though. – Trevor_G Feb 27 '18 at 21:27
• Hmm, yes. In my head I had answered that in part in the comments about the fake SSR. I may have got lost in the problem. OP seems happy anyway. – Transistor Feb 27 '18 at 21:46

Add noise or a signal large enough to thermistor feedback . Instead of PWM, rely on ZCS to skip cycles and get proportional feedback with cycle skipping modulated by noise and ZCS for so sinusoid step current which ceiling lights may withstand.

Choose noise level to match your proportional range 1 to 10 deg or so depending on dT (‘C) in 300 ms

Line frequency noise may or may not be ok. In the late 70’s I had a waterbed heater. I designed OpAmpwith some AC noise so the relay switch so that it would skip cycles every 10s to 10 minute quietly with high derating to last 100k ~1M cycles to regulate within 0.1’C

Dual thermistor is better due to sense errors near heater.

If I assume you have 230Vac at 1.5kW or 6.5A load causing lights to flicker, I wonder why? are they LED or FL tubes with sensitive to line regulation errors? Then certainly higher PWM will work better with a different power supply , e.g. http://www.ti.com/tool/TIDA-00779

A more ideal solution.

Active Power Factor Correction, for noise immunity to interference to others and acceptable conducted & radiated noise, easily regulated and noise compatible. (good EMC design)

• "In the late 70’s I had a waterbed heater." -- Next time the EE.SE moderator elections are running, just use this as your campaign slogan. Guaranteed victory. – Wossname Feb 27 '18 at 18:51
• lol waterbed heater.. Me too. Not exactly in the same thermal response time range as the OP indicates his application is though ;) – Trevor_G Feb 27 '18 at 18:58
• yes slower response on cycle skip and heat response was 1 day rise time from 20C to 32C?? but same proportional noise effect. Here it can be skipping 1 or more cycles depending on noise injection level/1'C so that averaging in 0.5 second gets to 0.1'C or whatever specs are. Sensor attachment and location are critical as the bath/tank sensor location will have gradients much greater than this. An integrator and differentiator can be added for complete PID solution. – Tony Stewart Sunnyskyguy EE75 Feb 27 '18 at 19:06
• Has anyone built a waterbed cooler to go within 0.1 degree C? – winny Feb 27 '18 at 20:01
• @TonyStewart.EEsince'75 my lights are 230Vac halogen lamps – Vovcheg Feb 27 '18 at 20:03

If your thermal response time is that small (<0.3S) you need to change your design, Faster PWM won't help if you can only measure at ~3Hz.

You could use some form of TRIAC circuit with per cycle switching would get you more granularity but it likely will not help the power transients that are affecting your lights. But, again, your limiting factor is your measurement cycle time.

What you really need to do is drop the power / current you are switching.

You may be better off with two heater elements. A "quick-boil" to get you close to temperature, and a smaller "simmer" element, that uses less current, you can use to hold the desired temperature.