The AND gate is a fail safe mechanism for the circuit. I want the power to the relays to be cut-off when the switches are opened. The micro checks if the switches are closed and then if the start button is pressed, turns on the relay. But in the case of the micro failing(stuck in the infinite loop, I use the internal WDT but still want to be safe) or something, I want to be able to cut-off the supply once the switches are opened. Thus, the AND gate. I'm open to suggestions and would like to if there is a better way to do it.
You'd probably want to debounce those switches. Use a small capacitor between SWOUT and ground.
Also, unless you need the µC to know the state of SWOUT independently, you could connect those switches to TRIG instead of +5V, so you wouldn't need the AND gate.
Thank You! Will a 0.1uF cap be enough? Yes, the microcontroller should be able to read the output from the switches.
You're doing an overall 3 input AND, two switches and this TRIG signal.
Depending on safety consideration and whether this is some fail safe, you could do this logic anywhere.
Me? I'd feed the two switches separately to the µP and do the logic there.
This would also give you the benefit of identifying switch failures.
OTOH, if this goes to a detonator you want to have the logic near the output.
You could put the two switches on the output of the ULN2003 or even after the relay.
Thank you. I have the micro controlling the logic already. This is a fail safe backup.
It is good to have debounce on a switch. Software or hardware. If you use software debouncing, then you do not need AND gate, you can write this logic in your code and just output signal to drive ULN2003A.
If this switch needs to act independently from code, then you need to add hardware debounce. But simple debounce like resistor and capacitor will produce slow edges, so you need to use a gate with schmitt trigger inputs.
Thank You. I will check out gates with schmitt trigger inputs.