Free Electronics Course - Home Page Brunning Software - Home Page

Designing Logic Circuits

To finish this introductory look into fundamental electronic components we need to think about how logic circuits are designed. There are two main types of logic gates AND and OR gates. These gates are the basic building blocks of virtually every digital circuit.


Symbols for two input AND and NAND gates.
AND and NAND gates.....

The output of an AND gate is high only when all of its inputs are high. The NAND gate works just the same but has negative output logic - with a NAND gate the output is low only when all of its inputs are high.

Truth table:-
                    AND                  NAND

               A    B    Y            A     B    Y
               0     0     0            0     0     1
               0     1     0            0     1     1
               1     0     0            1     0     1
               1     1     1            1     1     0

A and B are the input levels and Y is the output level.


Symbols for two input OR and NOR gates.
OR and NOR gates.....

The output of an OR gate is high when one or more of its inputs is high. The NOR gate works the same but with negative output logic - with a NOR gate the output is low when one or more of its inputs is high.

Truth table:-
                    OR                     NOR

               A    B    Y            A     B    Y
               0     0     0            0     0     1
               0     1     1            0     1     0
               1     0     1            1     0     0
               1     1     1            1     1     0

A and B are the input levels and Y is the output level.


Simple dual input NOR gate.
Designing a NOR gate.....

It is very easy to modify the MOSFET switch to become a dual input NOR gate. The same basic circuit can be used but we need to devise a way of having two inputs connected to the gate of the MOSFET which must be isolated from each other.

With this circuit when either input is high the output will be low.

To understand the operation consider the situation where input 1 steadily rises while input 2 remains low. When the gate voltage starts to rise current will try to flow into input 2 but diode D2 becomes reverse biased and prevents the flow of current. With input 1 high diode D1 is forward biased so the voltage at the gate will be almost the same as the voltage at input 1.

In the other situation where input 1 is low and input 2 rises the operation of the diodes is reversed. In that case diode D2 is forward biased and diode D1 blocks the flow of current into input 1.


Simple dual input NAND gate.
Designing a NAND gate.....

To create a NAND gate we need a circuit which will only change its output from high to low when all its inputs are high. Trying to imagine a simple circuit that can do that is rather difficult.

If we study the truth table for a dual input NAND gate we can see that the output is high except when either or both of the inputs is low. That is much easier to visualise. We need a circuit which will change it output from low to high when any of its inputs is low.

With the NOR gate circuit the two inputs of the circuit pull the gate of the MOSFET up to 5 volts to turn it on, and when both inputs are grounded the 1M resistor pulls the gate of the MOSFET to ground. We now want a circuit with the opposite action which we can achieve by turning the diodes round and moving the 1M resistor so that it pulls the gate of the MOSFET up to 5 volts.

In this circuit the 1M resistor will turn the MOSFET on unless one of the inputs is grounded.

Optimising the power requirement.....

Both of these simple logic circuits have two major problems. They draw 5mA from the supply when the output is low regardless of the output drive current, and if any significant current is drawn from the output the voltage will not rise up to the full 5 volts.

The problem lies in the way that the output is pulled up to +5 volts. We are using a 1k resistor. The value was chosen to be a compromise between low enough to provide adequate output current and high enough to prevent excessive waste when the output is low. To get optimum efficiency we need the output pull up resistor to be low in value when the output is high and high in value when the output is low. The answer is to replace the resistor with another MOSFET. We can then use its gate voltage to adjust its effective resistance to give exactly what we are needing.



Dual input NOR gate with complementary output.
Circuits with this type of output are known as CMOS. The bottom MOSFET Tr1 must be N channel and the top MOSFET Tr2 must be P channel. Notice that the P channel MOSFET Tr2 is wired upside down with its source connected to +5 volts.

When either input is high Tr2 is turned off so it appears to be a very high value resistor, and Tr1 is turned on pulling the output to ground. A tiny current flows through Tr2.

When either input is low Tr1 is turned off so it appears to be a very high value resistor, and Tr2 is turned on pulling the output to 5 volts. A tiny current flows through Tr1.

Danger of floating inputs.....

A CMOS circuit takes virtually no current when its input voltage is low or high. However, if we start with the input voltage at ground with Tr2 on and Tr1 off and slowly raise the input voltage Tr1 will start to turn on while Tr2 is still on. As the voltage rises a significant current will flow. When the input voltage is midway between ground and supply the wasted current may be 20 milliamps or more.

You will understand from this why it is important when using CMOS circuits to ensure that none of the inputs are allowed to float. If unused inputs are not grounded or connected to the supply line the whole chip may malfunction.

The exception to this is where the input circuit is a schmitt trigger.


Exercises.....

1.  In the first experiment with resistors we connect the LED to the 5 volt supply via a 1000 ohm resistor. Answer these questions:-

    a. Why do we need the resistor?
    b. How much current flows into the LED?
    c. How much current flows if the supply voltage is increased to 6 volts.

2.  In the next experiment we use resistors in various combinations. How much current will flow into the LED if we connect it a 6 volt supply with two 1k resistors in parallel?

3.  In the third experiment what do you think would happen if the series resistor supplying the LED is reduced to 100 ohms?

4.  In the transistor experiment we use a 100k resistor in series with the transistor base. When we use the MOSFET there is no series resistor but instead we use a 1M resistor from the gate to ground. Why are the two circuit so different.

5.  Why is it important to ensure that CMOS inputs do not float?


Using the plugboard. Reading Resistors What is a Resistor? Series and Parallel R What is a Capacitor? Discovering Semiconductors. Using a Transistor Using a MOSFET Logic Circuits. PIC
Micro
Next