Background:
I have a set of irrigation control valve solenoids (24V ac) that I control via a set of mechanical relays with the GPIO pins of a microcontroller (ESP32). The power supply does not have a large enough current to operate two valves at once, which is fine because the system also does not have enough water pressure to run two zones at once.
In theory, I should be able to limit the system to one valve at a time strictly in software, but I keep finding corner cases where I have not ensured that, and when I mess up the supply voltage to the IC drops below 3v and the system reboots, so debugging is a pain.
Question:
Is there a reasonably simple circuit I could construct that would prevent a second pin from going high if another one is already on?
Bonus points if there is an output that I can use to trigger an interrupt when this happens.
UPDATE:
Several people have asked about a software solution.
Yes, I did refactor my code so that pins were set in exactly one place. I missed one piece of code in the refactor. sigh I also had an interesting bug where an internal process still wrote to an external pin when writing to flash memory. The ESP32's GPIO matrix makes it pretty hard to ensure that a library never accidentally takes over a pin.
So while I agree that the software solution is ideal, my lived experence is that I would benefit from some hardware fault protection here.
The power supply does not have a large enough current to operate two valves at once, which is fine because the system also does not have enough water pressure to run two zones at once.
That's your choice...when I mess up the supply voltage to the IC drops below 3v and the system reboots
Wait a minute, is your microcontroller on the same power supply as your solenoids?Is there a reasonably simple circuit I could construct that would prevent a second pin from going high if another one is already on?
Yeah you could just put some type of delay in your circuit after opening a solenoid. \$\endgroup\$