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:
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:
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.
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:
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.
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.
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.
To visualize the logical state (HIGH or LOW) for a circuit's output, it can be handy to use an LED.
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)?
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.
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.
Remember that pins start at 1 in the top-left corner and continue counter-clockwise. If in doubt, check the diagram.
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)
A | B | Q |
H | H | |
H | L | |
L | H | |
L | L |
Fill in the truth table in your report
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?
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.
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.
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:
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.