# AND gate - 4 inputs, 12V

I want to make multiple AND gate input device. I have 4 locks (3 wires each; common, lock and unlock state) I want to monitor those states from locks and connect them to inputs (IC inputs) so when I have all 4 locks in the same state (all lock state or all unlock state).

This is what AND gate is for, to have one active output if all 4 conditions are same. Basically I need two IC, (AND groups) one for LOCK, and another group for UNLOCK. I want to make it as simple as possible. If anybody can suggest how to connect it, drawing, power supply is 12V and I output needs to control small 12V relay. What IC is the best for this?

Table 1. Truth table for relay logic. OP to edit.

A  B  C  D  | RLY1  RLY2
------------+------------
0  0  0  0  |   1     0
0  0  0  1  |   0     0
0  0  1  0  |   0     0
0  0  1  1  |   0     0
...
1  1  1  0  |   0     0
1  1  1  1  |   0     1

• A relay! =-D... – Tyler Apr 9 '19 at 0:01
• The AND gate is only "for" saying that all its inputs are high -- not that they are all high or all low, and certainly not that they are all equal. You may want to make that part of your question into -- a question. – TimWescott Apr 9 '19 at 0:07
• Tyler:I know about relay but I can not use it, complicated I need to use same output later for lock and unlock state – Inteli Apr 9 '19 at 0:10
• TimWescott: thanks, I will add that I need two IC, AND group for LOCK, and another group for UNLOCK. – Inteli Apr 9 '19 at 0:12
• Is there any time when Lock=Unlocked={12V or 0V} from one source? Where is datasheet? – Tony Stewart Sunnyskyguy EE75 Apr 9 '19 at 2:51

Once you get the logic worked out, if you implement it using CD4xxx chips, they should work at 12V. Then you can drive the gate of a MOSFET to drive your relay.

Reading between all the lines, I'm gathering you have four SPDT switches, which may either be in the LOCK or UNLOCK position. So the following circuit may be appropriate and relatively simple and very cheap. So how about using no ICs? Instead, just four BJTs and four resistors and two diodes.

I've chosen to use the Omron PCB G2RL Relay as a proxy for your $$\12\:\text{V}\$$ relay. It has a coil resistance of about $$\360\:\Omega\$$ and a coil inductance (based upon the datasheet switch timing I read) of $$\1.8\:\text{H}\$$. Most relays are designed to engage at 70% of their specified voltage, so the small $$\V_\text{CE}\$$ drops of the saturated BJTs should not be a problem. Of course, your relays can be something different. If enough different, the following circuit will need to be modified. But you'll have to pick a relay, first.

simulate this circuit – Schematic created using CircuitLab

I had not tested the design through simulation before writing it out. But just to be sure it works, I did plug it into LTspice and used a 4-bit Gray code for activating the switch changes to provide coverage for all 16 permutations. (Using Gray coded switching helps avoid having to deal with "glitch" events during simulation.)

Here's the circuit I used for simulation (the two coils have a parasitic resistance equal to the relays mentioned above -- evidenced by the peak currents indicated.)

Here's the resulting information (including the state of each switch and relay):

A paltry bit of basic imagination, if I understood you well enough. I may have missed your meaning, though.

• +1 for all the work as usual, jonk. Have a look at my transistorless answer! – Transistor Apr 9 '19 at 21:07

you can build a consensus detector like this:

simulate this circuit – Schematic created using CircuitLab

• Thanks for answer, this seems to be the easiest way, most economy way. Do You know what is the output voltage and current on AND1, AND4? – Inteli Apr 11 '19 at 23:43
• 12V at a few millamps, – Jasen Apr 13 '19 at 6:46
• Thx Jasen, this circuit is the closest what I had in mind. I just needed somebody to put it all together from input to relays in the end. Somebody who is sure, or test similar thing before, that it will work when I solder it all together. – Inteli Apr 14 '19 at 14:24

simulate this circuit – Schematic created using CircuitLab

Figure 1. Two relays are used to provide ALL UP or ALL DOWN indication. With switches in the position shown the ALL UP relay will be energised.

The diodes prevent backfeeds.

There are a couple of points to watch:

1. The diodes will cause about 2.1 V drop so your relays need to be able to energise on reduced voltage - 10 V or so.
2. When not all switches are aligned the relays will have 6 V each across them. They therefore need to be able to drop out at 6 V otherwise the last one energised will remain on.

simulate this circuit

Figure 2. Modified circuit for 5 V relays. With switches in the positions show the ALL DOWN relay will be energised.

Adding the Zener diodes of Figure 2 and using popular 5 V relay coils should solve the hold-on problem.

• With the switches aligned the energised relay receives 12 V - 3 x diode - 1 x Zener = 12 - 3 x 0.7 - 5.1 = 4.8 V or so.
• With switches unaligned the relays will get $$\ \frac {12 - 2 \times 5.1}{2} = 0.9 \ \text V \$$ each which should be enough to guarantee drop out.
• I saw the first diagram a while back and immediately worried about your intent putting the two relays in series with each other. (And I didn't like it, at all.) The new one with the zeners also has a problem. Do you see it? (Aside from using 5 V when the OP wants 12 V.) Or, at least, I think it does. – jonk Apr 9 '19 at 22:31
• Go on - what have I missed? I assumed the 12 V relay was negotiable. – Transistor Apr 10 '19 at 6:10
• I think: 12V-4.7V-4.7V > Must release voltage – Huisman Apr 10 '19 at 6:22
• @Transistor There's still substantial current in the relays when they are supposed to be inactive. (Not enough to engage them, I grant.) Perhaps 15 mA or so? – jonk Apr 10 '19 at 7:15
• Not enough to engage them and, typically, not enough to hold them. I did cover that point in the last sentence. Thanks for the review, chaps. – Transistor Apr 10 '19 at 7:53

Now that I understand better what circuit function is desired, I have created two new ones. Figure 1shows a series connection; when all switches are in the up position relay one is on. When they are all in the down position relay two is on. The switch connection and D1 and D2 prevent either relay from acting with any other switch combination. Figure 2 shows a parallel connection; with all switches to the right relay 1 is on; with all to the left relay 2 is on.

• I think yours is potentially better than mine because I think the OP wants the one relay to be energised when all switches are in the same orientation. You can accomplish this by omitting RY2 and connect the two collectors together. – Transistor Apr 12 '19 at 14:08
• That is the function of the circuit I described in my first answer which he seemed to disagree with. – EinarA Apr 13 '19 at 18:33

When I first read the question l thought that a circuit I think of as a "4 input XOR gate" would work here. The output is high or low if all inputs are high or low. These don't exist as ICs, but can be made from resistors ,diodes and a transistor. After some thought I realized I don't know what the OP is doing, so I don't think this circuit is correct for his use.

• But I need indication only if all inputs are "closed contacts" for LOCK state, other ways it can be one close another open etc. in that case i don't need any indication, not active relay on the output. Same thing is for UNLOCK, all 4 another pair of contacts needs to be closed, that is why I mentioned another pair of GATE-s, if any of lock did not reach position, stuck in the mid position I don't need active relay on output. – Inteli Apr 9 '19 at 0:40
• Inteli: sorry I have no idea what you are talking about. – EinarA Apr 9 '19 at 0:44
• Thany You any way! It is quite simple, maybe I did not explain it well: I have 4 locks, each have 3 wires, common, lock and unlock contact. Each state lock or unlock I need to connect to separate IC (like quad 2 input and gate 7408). I need drawing how to connect it on 12V supply, and on output to trigger simple 12V relay. – Inteli Apr 9 '19 at 0:54
• It sounds like you just need an AND gate to drive a relay but I am not sure. If you are using Google translate it is coming through as mostly gibberish. Sorry. – EinarA Apr 9 '19 at 1:04
• Anyway. Look at listings of CD4000 ICs. You can find a four input AND gate there that will work with 12V. They can also be made from diodes and a FET. – EinarA Apr 9 '19 at 1:08