how to cut PWM signal when board freezes or reboots

gdanov
Posts: 9
Joined: Sat Feb 05, 2022 10:53 pm

how to cut PWM signal when board freezes or reboots

Postby gdanov » Mon Mar 28, 2022 11:29 am

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?

Craige Hales
Posts: 94
Joined: Tue Sep 07, 2021 12:07 pm

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

Postby Craige Hales » Mon Mar 28, 2022 2:08 pm

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.
Craige

gdanov
Posts: 9
Joined: Sat Feb 05, 2022 10:53 pm

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

Postby gdanov » Mon Mar 28, 2022 9:38 pm

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.

Craige Hales
Posts: 94
Joined: Tue Sep 07, 2021 12:07 pm

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

Postby Craige Hales » Tue Mar 29, 2022 12:36 am

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.
Craige

gdanov
Posts: 9
Joined: Sat Feb 05, 2022 10:53 pm

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

Postby gdanov » Tue Mar 29, 2022 7:45 am

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...

Craige Hales
Posts: 94
Joined: Tue Sep 07, 2021 12:07 pm

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

Postby Craige Hales » Tue Mar 29, 2022 12:42 pm

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.
Craige

Craige Hales
Posts: 94
Joined: Tue Sep 07, 2021 12:07 pm

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

Postby Craige Hales » Tue Mar 29, 2022 11:55 pm

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.
Craige

gdanov
Posts: 9
Joined: Sat Feb 05, 2022 10:53 pm

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

Postby gdanov » Wed Mar 30, 2022 10:14 am

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.

Who is online

Users browsing this forum: No registered users and 108 guests