Electronic – LED current at output of AND gate

currentlogic-gatestransistors

Preface: Def a beginner at EEing.

I'm building out a proof of concept where I'm using transistors to create a logical AND gate to control LEDs. I'm using reed switches to trigger the transistors and putting the transistors' collectors/emitters in series so that both transistors have to be triggered for the final LED to light up.

Here's the schematic that made to work out the logic:

schematic

And here's the wired up bread board:

wiring

And this works … mostly.

When I trigger the first reed switch it lights up the first yellow LED only. Good.

first switch

When I trigger both reed switches the two yellow LEDs come on AND the red LED comes on. Good!

both switches

But here's where the bad comes in: if I activate only the second reed switch, the one that leads directly to the red LED there's enough current passing through to faintly light up the red LED. Bad :'(

second switch, current passing through

I'm not sure how to stop the current from the second transistor to the final LED. I'm assuming that it's the current from the gate pin on the second transistor passing through to the red LED, but I'm not sure how to stop it.

I tried adding a pull down resistor on the red LED's anode leg and that does help, but of course the red LED dims since the current has a different option to flow in.

Is there a way to keep the red LED off until both transistors are triggered?

I def want this to work, but I also want to understand why it's happening.

UPDATE

Here's the updated schematic and working circuit based on the replies I got here. Thanks again everyone for the help. It's very cool to see it working and to get it!

working circuit

Second led working!!

https://vimeo.com/394545735

Best Answer

Your analysis of the problem is correct. You have chosen a poor AND gate circuit - but one that is promoted in many tutorial sites.

A couple of comments on your schematic:

  • The battery is connected backwards.
  • The convention is to have the positive rail at the top, ground at the bottom.
  • Circuit should generally read from left to right with current flowing generally from top to bottom.

Your circuit would be close to correct if you rotate it 90° clockwise.

enter image description here

Figure 1. An AND gate made of a NAND gate followed by an inverter. Source: Circuits Today.

Why is this better?

  • Switching on X or Y on their own will not allow current to pass from R3 to ground. Q3 will be biased on and Z will be 0 V.
  • When both X and Y are on the collector of Q1 will be pulled low. This is a NAND operation.
  • When Q1's collector is pulled low Q3 will turn off and Z will be pulled high by R4. Q3 is forming a NOT gate (an inverter) and a NAND followed by a NOT is an AND.

You will see a similar arrangement in some logic series.

enter image description here

Figure 2. A CMOS AND gate. Source: All About Circuits.

Notice that the AND gate is more complex than a NAND gate and there will be some propagation delay due to the inverting stage. The linked article should be worth a read.


A few comments on your updated schematic:

You've got the top to bottom right now but your schematic is reading right to left. Here's a flipped version (but I didn't flip the text). Some of the points you had addressed already but I'll comment on them anyway.

enter image description here

Figure 3. Rough schematic edits.

As explained, convention is that current flows from top to bottom so positive rail on top. For reading left to right we generally put the inputs on the left and the outputs on the right.

  1. Battery right way up.
  2. +V on top.
  3. Since you've got grounds on R4 and R5 you need to indicate what these are connected to. Here we add the GND symbol to the negative rail. All the grounds are now connected.
  4. We'll draw the LED and resistor vertically. Now it's clear that current will flow through it from top to bottom. You don't have to be too strict about this but in this case the clarity gained is worth the little bit of extra height on the schematic. In this case LED3 is the output of the circuit so it makes sense to locate it on the far right of the circuit.
  5. Transistors right way up. For these NPN transistors the emitter arrow shows the current direction and so we have them pointing down towards GND.
  6. Same as 5.
  7. Input switch on the left.
  8. Vertical LED is good. Vertical LED would be nice too but would add to height. Current flow is quite obvious in this case.
  9. The GND symbol represents a cut section of the ground rail which is normally drawn horizontal. For this reason the symbol should be inserted as an upside-down T. The other 'earth' symbol (see Ground, earth and chassis explained written by me) represents parallel plates buried in the ground so there is a correct orientation for it too.