I'm building a new brain for a broken pool cleaning robot. It has two motors to move the thing and one for suction. I'm using an esp32 and five relays, one of the suction motor, and two for each of the drive motors in h bridge arrangements to provide forward and reverse. 5v for the ESP32 and relay coils is supplied by a voltage regulator that uses the same 24v that powers the motors. The supply claims to be a 400w unit (an LED PSU from AliExpress) and I think total load from all motors is under 200w.
When the motors start, all is well, but when they are stopped, the system usually crashes with the serial monitor showing that the last thing to happen was cutting the power to the motors.
I'm assuming I have some kind of EMF or power spike causing the microcontroller to crash. It does not reboot by itself so it doesn't seem to be simply loosing power. I could try a large PSU (1000w borrowed from my 3d printer) or try doing something to smooth the output from the 5v regulator. Or perhaps add a permanent load to the 24v supply so it's not dropping back to zero when motors stop. I also read about something called snubbing to address the EMF but I'm unclear on how to go about this.
Any advice?
Ps. I previously tried mosfet H bridge pwm modules which allowed me to gradually apply and withdraw power but these all blew up after a few minutes of use so I switched to using relays.