2. Remembering Sensor State with a Flip-Flop Latch 1-bit Memory Chip

(article continued from previous page)

At this point, the laser-pointer detection circuitry is able to determine when a laser light is aimed at a particular photosensor. If the laser is aimed at the top sensor, the comparator chip outputs “on”. If the laser is aimed at the bottom sensor, the comparator chip outputs “off”.

The circuit could be considered complete if you wanted something to be turned on only while the laser is aimed at the on sensor. However, if you want the circuit to remember whether the “on” sensor or the “off” sensor was most recently selected, then you’re going to need to hook those outputs to a memory chip.

Looking back at the schematic, you'll notice that the output names of “on” and “off” have little lines above the words. Usually an output is high (5V) when a condition is true, but the line above the word means the output is low (0V) when the condition is true. The line stands for “opposite”, “not”, or “negate”.

The reason that the comparator has been wired to do this is because the memory chip on this page needs the information in that format. However, should you have a circuit that needs normal outputs, simple swap IC1 pin 5 with IC1 pin 6, and IC1 pin 2 with IC1 pin 3. Flipping the input pins on the comparator provides the opposite output.

Single Bit Memory

This circuit only needs to remember whether the final output should be on (5V) or off (0V). This is the smallest, most rudimentary amount of memory. It is called a “bit”; which stands for “binary digit”. A bit can only be on or off.

The 7474 chip is a basic logic chip that contains a 1-bit memory cell. For convenience, just like the comparator chip on the previous page, the 7474 includes two independent copies of this feature on a single chip. Therefore, the 7474 has two independent 1-bit memories on the chip.

We only need one bit for this circuit, so the top half of the schematic shows one side of the chip is unused. Tying those unused inputs to 5V prevents them from receiving random noise. (Don’t tie those pins to ground, because pins 10 and 13 on the 7474 chip aren’t logically permitted to be 0V at the same time).

A 74AC74 D-type flip-flop 1-bit memory remembering a comparator output to control a blue LED.

A 74AC74 D-type flip-flop 1-bit memory remembering a comparator output to control a blue LED.

This circuit is incredibly straightforward. “On” is connected to the set pin. “Off” is connected to the clear pin.

If the “on” sensor output is low, it sets (pin 4) the IC2 output (pin 5) to high. A high output (5V) will provide power to the big blue LED (LED3). The blue LED is prevented from receiving too much current by a resistor (R30).

If the “off” sensor output is low, it clears (pin 1) the IC2 output (pin 5) to low. Because the output is low (0V) and the other end of the LED-resistor pair is also low (connected to GND which is 0V), no current flows. LEDs only light up when current flows through them. Therefore, the LED doesn’t light up.

The purpose of the 74AC74 chip is to remember whether it was last set or cleared. The other pins are not used in this circuit, but provide fancier memory techniques such as remembering the data input (pin 2) only when the clock (pin 3) goes from low to high. By the way, this configuration of the chip is technically considered an SR latch (set-reset), as opposed to a full D-type flip-flop.

Besides remembering the last state, the other valuable service this chip performs is outputting greater current than the comparator chip can. In fact, this 74AC74 chip is rated at 24mA @ 4V when the chip is connected to a 5V supply. That’s plenty for an LED.

What’s with the Extra Letters on Part Number?

The exact chip I selected is a Texas Instruments SN74AC74N. It has the standard 7474 pin layout and functionality. The extra letters provide a little more specific information.

Chip manufacturers include letter prefixes to indicate that it came from their company. In this case, “SN” is the brand manufactured by Texas Instruments.

Chip manufacturers include letter suffixes to indicate the type of package, guaranteed temperature range, legal compliance (hazardous materials), and whether it comes on a reel. In this case, the letter “N” at the end of the Texas Instruments part name says that it comes on a plastic DIP chip that is the right size for a solderless breadboard. If you order this same chip with the letter “D” at the end, it will be a smaller surface-mount chip (SOIC) that is better suited for automated placement on a printed circuit board.

For our purposes, the middle letters are the most critical. The middle letters specify the semiconductor technology used to implement this 7474 functionality. “AC” stands for “Advanced CMOS”. When an engineer sees "AC", he or she knows the voltage range, speed, noise emitted, and current output. None of that says what the chip does, only the conditions under which it performs.

There is a whole variety of semiconductor technologies for this chip available today: 74S74, 74LS74, 74C74, 74HC74, 74HCT74, 74VHC74, 74ACT74, 74AC74, and so on. Because they use different voltages and have differing characteristics, you usually cannot interchange them in a circuit. That is, if you tried to put a 74LS74 into this circuit, the LED would not light up, because the LS doesn’t provide enough output current. Furthermore, the 74LS74 requires a low input to be no more than 0.8V, which is difficult to achieve while the debugging LEDs are connected to the comparator outputs.

Long story short, buy the exact manufacturer’s part number SN74AC74N (Digi-Key #296-4342-5-ND, Mouser #595-SN74AC74N, or Jameco #261403).

Bypass/Decoupling Capacitors

In the descriptions of both schematics, I skipped over the capacitors labeled C1 and C2.

C1 and C2 are ordinary 0.1-microfarad capacitors that provide local power storage for a circuit. It is common to include one small capacitor per chip to reduce circuit noise and to eliminate logic glitches.

In reality, the reduced power usage and decreased noise of newer chips makes this less necessary than in years past. However, because hobbyists often use noisy circuit layouts, and because these capacitors are so inexpensive when compared to a hobbyist’s free time that would be spent diagnosing a noise glitch, I still highly recommend sprinkling capacitors liberally near the power pins on chips.

That leads us to actually building the entire circuit on a solderless breadboard...