Page 1 of 1

how to cut PWM signal when board freezes or reboots

Posted: Mon Mar 28, 2022 11:29 am
by gdanov
I'm controlling heater via SSR. The SSR on it's side is controlled by ESP32's PWM library with zerocross sync configured.

Sometimes the board freezes or enters reboot loop (when code is buggy for example) and in 1 of 50 of such cases the pwm output remains high and the heater works non-stop and that's very dangerous.

How can I secure the SSR control and make sure the board won't leave it high unattended?

Re: how to cut PWM signal when board freezes or reboots

Posted: Mon Mar 28, 2022 2:08 pm
by Craige Hales
Pure software solutions can fail.
https://en.wikipedia.org/wiki/Therac-25

Microwave ovens may use a hardware interlock that uses multiple switches when opening the door while running. The third switch in the sequence is a crowbar switch https://en.wikipedia.org/wiki/Crowbar_(circuit) that is supposed to blow a fuse if the first two switches have not cut the power already.

Maybe you could do something similar with an external thermostat.

Re: how to cut PWM signal when board freezes or reboots

Posted: Mon Mar 28, 2022 9:38 pm
by gdanov
there is second thermostat that cuts off power at higher temperature and thermal fuse at even higher temperature. But I'd prefer not to have to rely on them.

I just need to understand if it's normal to have the pwm output freeze in high mode during board restart (for example) and can I do something ... like pulling it down via resistor.

Re: how to cut PWM signal when board freezes or reboots

Posted: Tue Mar 29, 2022 12:36 am
by Craige Hales
I have not used PWM, but my experience has been a few pins on the device I used come up high, or busy doing something, until my code starts running. Most pins come up low(?). I think it is documented, but didn't read it soon enough...
I also had issues with restart on a few devices; I believe 200uF filter was too much on the 290ma power supply and made the rise time too slow for a reliable boot. That left the pins in the high state if the boot did not complete.
This article https://randomnerdtutorials.com/esp32-p ... nce-gpios/ mentions a number of pins you might want to avoid...both the picture and a list at the end...look at both.

Edit: looking back...those low pins may actually be inputs during boot, not driven low or high. You might need a pull down resistor.

Re: how to cut PWM signal when board freezes or reboots

Posted: Tue Mar 29, 2022 7:45 am
by gdanov
I'm using pin 12 for pwm output and that seems to be totally OK. Pin 12 has internal pulldown anyway as per the authorative boot mode description: https://docs.espressif.com/projects/esp ... ction.html

adding pull-down resistor won't help if the pwm subsystem is able to get "stuck" in high output mode. That's the question — how can I take precautions to prevent the pwm module from staying high. I'm open to some basic external timer that cuts the pwm signal...

Re: how to cut PWM signal when board freezes or reboots

Posted: Tue Mar 29, 2022 12:42 pm
by Craige Hales
I just took a look at https://www.espressif.com/sites/default ... eet_en.pdf table on page 62, which I wish I'd studied earlier. It agrees with what you are saying.

Make sure the power supply is good...watch with a scope when it is failing. The dev boards I got from amazon did not work reliably with some USB cables on some USB power supplies.

Re: how to cut PWM signal when board freezes or reboots

Posted: Tue Mar 29, 2022 11:55 pm
by Craige Hales
Also, in a different thread you said
added 4.7uf capacitor GND <> RST and reset works as expected.
I think that may be related. I removed that (10uF) capacitor at the same time I reduced the 200uF filter on the power supply. One of those fixed the boot issue for me.

Re: how to cut PWM signal when board freezes or reboots

Posted: Wed Mar 30, 2022 10:14 am
by gdanov
Thanks for the suggestions. I don't really have boot problems anymore. I'm concerned about problems typically caused by bugs in the software. I sometimes upload firmware that aborts and causes reboot loop for example. Sometimes the board gets "frozen" — doesn't reboot but is also not working properly. The watchogs should catch such situations but there are cases where they don't seem to have the chance.

These are the situations I'm concerned about.