Saturday, 14 July 2012

Switch logic: OR and AND

The following diagrams are the first circuits we explore: an OR circuit and an AND circuit.
While the diagrams are drawn as if these are electrical circuits (a light goes on if the correct
switches are closed), we actually demonstrated these with a water circuit, consisting of a
reservoir on top, a catch basin at the bottom, tubes instead of wires, and valves for switches.
George Boole’s switch logic works for water just as it does for electricity!
For the diagrams below, imagine a teacher asking a question. If they think the answer is “Yes”,
then the students press a switch on their desk.
In the OR circuit, if either Annie or Bert say “Yes” (press their switch) then the light goes on.
(It also works if they both press their switch).
In the AND circuit, both Annie and Bert have to agree that the answer is YES, and both have to
press their switches for the light to go on.


Examples of OR circuits:
Ÿ Electric car windows: either the driver or a passenger can open the passenger’s side window.
Ÿ Interior light in a car: goes on when any door is opened (driver’s side door or passenger’s
side door or driver’s side back door or ...). But you have to think a little: when the car door
is opened, an electrical switch (usually in the door jamb) is actually closed to allow the
current to flow to light up the lamp. Can you find those light switches on your car?


Example of AND circuit:
Ÿ Again the electric car window: a master switch (at the driver’s seat) has to be on and a local
switch needs to be pressed for the window to operate.


The “SAME” circuit above is a combination of AND and OR. The effect is that the light will be
on if Annie and Bert both say “yes”, or both say “no” to a teacher’s question, in other words, if
they both agree. The logic is: (yes_A AND yes_B) OR (no_A AND no_B).
This is also known as an “equivalence” circuit.
If the yes_A and no_A switches were reversed, then this would be a “NOT-THE-SAME” circuit
(no_A AND yes_B) OR (yes_A AND no_B). Such a circuit is also known as an
exclusive OR”: The light goes on if Annie OR Bert says yes, but not both (they disagree -- just
as you would expect from Annie and Bert!). An abbreviation for “exclusive or” is XOR, and it
turns out that this is a very handy circuit to have around.
“Same” or “not-the-same” circuits are used wherever a computer makes comparisons.
Another example of a “SAME” circuit (though wired differently): hall lights in a house with an
upstairs and downstairs switch.
The other circuit, above on the right, looks very similar. The difference is who controls the
switches. In the “CHOICE” circuit, the top two switches are controlled by the teacher, who
makes to choice to listen to Annie or to listen to Bert. If the teacher switches on Annie, then
Annie can answer a question by pressing her switch, and Bert’s answer is ignored. And the other
way round.
The fancy name for such a circuit is a “multiplexer”, and it is used wherever a choice is made in
a logic circuit.

With AND and OR gates, almost any logic can be made. The missing element is a NOT.
For example, in the choice circuit above, a NOT circuit could be connected between the
Listen_A and listen_B switches, so that at any time one is closed, and the other is open
(thus, the teacher listens to Annie or to Bert, but cannot switch them both off).
With just AND, OR and NOT, any logic circuit can be made!

Look Ma, no fingers...
How does this work in electronics, without lots of fingers to push lots of switches?
Well, the switches are special. They are called transistors, and work with electrical voltages
acting as the “fingers” pushing them open or closed.
As if, in the circuits above, the light from the lamp would push on a switch in the next circuit,
and that one on the next, and the next.... Only, no lamps either. Only voltages and currents.
Exactly how all that works does not matter, though. Switch logic works as well with water valves
as it does with finger-actuated switches, as it does with transistors.
(It is just that transistors are faster.... much, much faster...).

0 comments:

Post a Comment