I am currently trying to find a method to use all the IO pins on a NodeMCU to control an 8-Relay Board. However, some pins on the board briefly switch to high during startup and that is a problem for my use. Thus I've decided to use an AND Gate IC and connected all of the Input As to a NodeMCU pin that is safe to use during boot. Is there an IC which does this or something similar internally as illustrated on the picture below (just a quickly photoshopped diagram of a 74HC08 IC)?
1 Answer
Your 7408-based solution sounds fine: just connect one input of all the AND gates to the common enable pin.
Other than that, there's a lot of 74xx series octal buffers with three-state output and an enable pin. the Cheapest I found on digikey is the 74LCX541FT, which has active-low enable pins, but that's not really a problem: pull them up with a resistor to Vcc, and pull them down using your microcontroller once everything is stable.
Also, since relay boards are incredibly slow in comparison to microcontrollers: The most straightforward way might be using a serial-in, parallel out shift register. That reduces the amount of NodeMCU pads needed to control your relays from 8 data pins + 1 enable to 1 clock + 1 data (+ 1 latch pin, if you're using one that doesn't automatically only latch after 8 data bits). I²C IO extenders would be another solution.
The beauty in reducing pin count is not only reduced wiring complexity, but also that you could very well opto-isolate these 2 to 3 lines; a feature that can be desirable, if the relay switching leads to any transients that you don't want to expose your nodeMCU to.
-
\$\begingroup\$ Ah yes, currently I'm connecting one input of the AND gates together but I was wondering if there was one which does it internally. I guess not. But I do have a 74HC595 that can work as a Shift Register so that's likely what I'm going to do. Thanks! \$\endgroup\$– BryanFeb 15, 2020 at 13:58
-
\$\begingroup\$ @Bryan have you read the second paragraph of my answer? There's plenty of such ICs. I even list an example. \$\endgroup\$ Feb 15, 2020 at 14:01
-
1\$\begingroup\$ If you don't want to get very digital, you can use your and-gates wire the second input to a single schmitt-trigger and put a RC-network on its input. \$\endgroup\$– AriserFeb 16, 2020 at 9:39