BUY ALL NEW LOGIC CHIPS AND/OR TEST ALL EXISTING ONES

Note for future years: Should have a MINIMUM of 200 $\Omega$ for a load on each output, they're only rated for 25 mA max.

Digital Logic

At the end of this course, we'll delve a little into the realm of digital logic.  In practice, it is very unusual to work with individual chips to do digital calculations anymore.  That being said, there are two critical reasons you may need to know about digital circuits for physics experimentation:

  1. Computers don't work with analog signals, so to record data or control analog devices you'll need to convert signals from digital to analog or vice versa.
  2. Field Programmable Gate Arrays (FPGAs) are currently key for processing data from particle physics experiments.  They're affordable, reprogrammable, and much, much faster than microcontroller devices (e.g. Arduino).  From a user side they act like a bunch of customizable logic gates, so knowing at least the basics will help you get started in working with them.

Digital Logic Signals:

When working with digital circuits, voltages are essentially mapped to either High (1) or Low (0).  There are quite a few different standards out there for what voltages are mapped to which, but we'll work with a 5V standard:

  • 5V standard (Used by Transistor Transistor Logic (TTL) and some Complementary Metal Oxide Semiconductor (CMOS))
    • Above 2V is HIGH
    • Below 0.8V is LOW
    • Between 0.8V and 2V is UNDEFINED (Don't do this!)
What about other logic families?

3.3V is the other dominant logic family used by modern devices, but there are other standards for even lower power consumption.  The trade off is that they are much less tolerant of any noise

Image courtesy of a Texas Implements application report

Logic Operations

Now that we've defined what voltages correspond to what logic states, let's talk about the actual operations. Our inputs are denoted as letters A and B (and C, D, etc for more exotic gates), and the output is denoted Q.  The behavior of Q for given inputs is summarized in the table below:

Operation Q High Q Low Circuit Symbol Mathematical Expression Chip
AND All inputs are high Any inputs are low $Q = A \land B$ SN74XX08
OR Any inputs are high All inputs are low $Q = A \lor B$ SN74XX32
Not And (NAND) Not all inputs are high All inputs are high $Q = \lnot(A \land B)$ SN74XX00
Not Or (NOR) All inputs are low Any inputs are high $Q = \lnot(A \lor B)$ SN74XX02
eXclucive Or (XOR) Exactly one input is high Both inputs are high or low $Q = A\underline{\lor}B$ SN74XX86
Buffer Input is High Input is Low $Q = A$ No specific chip (Build a follower)
Inversion (NOT) Input is Low Input is High $Q = \lnot A$ SN74XX04
Symbols courtesy of https://commons.wikimedia.org/wiki/Category:ANSI_logic_gates

Most of the chips we'll use for this share the same pinout, which makes our lives quite a bit simpler.  The inversion gate is the exception, because it can fit 6 gates rather than 4.

Pinout for all chips but the NOT gate.  Note that the ordering shifts pattern on the right-hand side. Pinout for the NOT gate.  This one differs because there's only one input per output.
What's with the XX in the chip names?

Nowadays there are many, many families of logic chips designed for different needs. Some run faster, some are more tolerant of noise, some run on very low voltages, etc. Wikipedia has an overwhelming list comparing various groups. In our labs, we've got multitudes from four different families:

  • The original 7400 series
  • The LS series, which is slower but uses far less power when running
  • The HC series, which operate using CMOS logic levels (also very low power)
  • The HCT series, which are can operate using CMOS or TTL logic levels.
    • These are quite handy when you're not quite sure what interface you'll be getting signals from.

If you don't have any idea what this all means, that's fine. The main takeaway is that you should probably stick to using only a single family of chips in a given circuit unless you enjoy having lots of mysterious errors due to parts not reliably communicating.

Using a Button for Logic Input

It will be useful to be able to produce logic level signals with a button in this lab. However, you can't just connect 5V to one side of a button and ground to the other; that would short the power supply and generally be bad for your health.  

How to place your button in the breadboard Button circuit A, with pull-down resistor Button circuit B, with pull-up resistor
Predict what $V_{out}$ will be for circuits A and B both with and without the button pressed (i.e. 4 predictions)

Test your predictions, and comment on any disparities

Leave button circuit B built, you'll be using it later.

We're planning on using the LS series of logic for this, which should be able to drive 40mA of current or so. This lets us drive LEDs directly, whereas the HCT or HC families would need a transistor to act as a current amplifier.

Making an LED as Readout

To visualize the logical state (HIGH or LOW) for a circuit's output, it can be handy to use an LED. 

A basic LED and resistor circuit useful as a lighting indicator.  Exact resistor values aren't critical, replace the 1k with a smaller resistor for a brighter light.
Using your button circuit, test the LED indicator.  Does the LED properly turn on when the button output is high?
How does the voltage change when the indicator is attached versus having no indicator?
Is the logic level still the same (i.e. above 2V or below 0.8V)?

Prep Work: Grounding Unused Inputs and adding filter capacitors

Now that you've got some inputs and outputs, its time to set up your logic chip. We'll be using a SN74HTC08N (AND) chip and a SN74HTC04N (NOT) chip (aka a hex inverter) to start, so obtain one of each and place them on the board.

Hex Inverter?

The chip gets this name because there are six (Hex in Greek) NOT gates, which invert a logic signal. Possibly also because somebody thought it was funny.

After powering the chips, there are two steps before you start using them.  You should connect all of the inputs you aren't using (pins 4 & 5, 9 & 10, and 12 & 13 for the AND; pins 3,5,7,9,11 for the NOT) to ground so that their outputs won't be trying to change due to stray noise. 

Secondly, you should connect a small capacitor ($1nF$ will do) across the power and ground pins Physically near the chip. This helps keep fluctuations in voltage from other parts of circuit from affecting our logic chips. They are even more temperamental than op-amps this way.

Which pins to ground for AND or NOT gates. Throughout this lab you'll use $V_{CC} = 5V$ unless stated otherwise.

Remember that pins start at 1 in the top-left corner and continue counter-clockwise.  If in doubt, check the diagram.

AND Truth Table

Now that you've got everything started, its time to map out the behavior of the AND gate for all permutations of inputs.  To do this, you'll want to connect the inputs to voltages you can toggle (via the button, movable wires, or the function generator) and observe the output for all four combinations that the inputs could be.  Remember, inputs should always either be 5V (High) or 0V (Low)

The schematic symbol for an AND gate.
A B Q
H H
H L
L H
L L
Fill in the truth table in your report

Floating Input Issues

Remember how we told you to ground your unused inputs? 

Disconnect the inputs from one of your unused AND gates, and observe what happens to the associated output.

Does the output change in this case, and is this the behavior you'd like?  Why or why not?

A New Device: the Rotary Encoder

We'll take a moment here to introduce you to the potentiometer's digital cousin: the rotary encoder. More specifically we'll use a variant known as an Incremental Encoder, which has two outputs that each alternate low or high as the knob is turned.

A top-down view of the rotary encoder. Note channel A is to the left and B is to the right. A schematic for how to connect the encoder to produce stable outputs. When the switch leading to either A or B is closed, the associated capacitor will discharge through a 10k resistor and the voltage at the connection drops to 0. When the switch opens, the capacitor will charge through the pair of resistors to 5V.

Take your encoder and connect it as shown in the diagram. Observe the voltages $V_{out,A}$ and $V_{out,B}$ on the scope. You may want to turn the time scale way up (to 100 ms or so) so you don't have the display stutter as you turn the knobs.

A Puzzle: Visualizing direction

Right now, we've got a knob that can turn and give us back a changing set of two different outputs as it does so. However, consider the case that some physical device (maybe a water wheel or a motor) is the thing that's turning the knob in a place that isn't visible to us. Wouldn't it be nice to have a way of visualizing what's going on?

Well, that is your task for the next part of the lab. Using your rotary encoder, AND gates, and NOT gates, create a circuit that will:

  • Have 4 different outputs corresponding to the 4 possible states of the encoder wheel
  • Have each output high for only one combination of inputs and low otherwise
  • Connect each of the outputs to an LED and
  • Have the LEDs lined up so that the order they light up in is the same as the direction of the wheel turning.
    • i.e., if we turn the shaft to the right, the lights should turn on from left to right.
A very general block diagram of your circuit. Note that the Signal Routing block just indicates connecting the correct logic output to the correct LED.

Plan what combination of logic gates you'll need for each of the 4 input combinations (Neither A nor B, A but not B, B but not A, A and B). Then, one at a time, build each logic circuit and test that it only output a signal for the correct combination of inputs. Note that you will need to disconnect some of your (formerly unused) inputs from ground to use more logic gates here.

Seriously, please don't try to build the entire thing at once. That would make it far, far more difficult to troubleshoot issues as they come up.

Sketch/diagram the combinations of AND/NOT gates you used for each logic circuit.

Build 4 LED circuits, and wire them such that turning the encoder to the right makes the light scroll right.

Test all four possible inputs for your setup and verify that it behaves as expected.
Document the order you hooked the LEDs up to the outputs to get the correct scrolling behavior.