People have managed to get Doom running on just about everything over the years. Calculators, cameras, ATMs, printers, and plenty of other devices that were never intended to run a first-person shooter have all been pressed into service. So I decided to see if I could play Doom on a couple of 555 timers.
Well, sort of.
This project doesn't actually run Doom. Instead, it plays the opening riff from "At Doom's Gate, " the music from the first level of the original game. It does that without a microcontroller, computer, or any software whatsoever.
The circuit uses two 555 timers, some 7400-series logic, a diode matrix, analog switches, and a small audio amplifier. One 555 establishes the tempo while the second generates the actual notes. Everything in between keeps track of where the circuit is in the riff and tells the audio oscillator which pitch it should generate.
How It Works
The circuit can be divided into five main sections:
- Tempo clock
- Sequence counter and decoder
- Diode note matrix
- Pitch selection and audio oscillator
- Audio amplifier
The complete signal path looks like this:
555 tempo clock
|
v
74LS161
binary counter
|
v
74LS154
4-to-16 decoder
|
v
1N4148 diode matrix
|
v
74HCT14
|
v
2 x CD4066
analog switches
|
v
555 audio oscillator
|
v
PAM8302
|
v
speaker
Setting the Tempo
The first NE555 is configured as an astable oscillator. A capacitor repeatedly charges and discharges through a pair of resistors, causing the output on pin 3 to continuously switch between high and low.
This oscillator runs at approximately 7.33 Hz, producing a new clock pulse about every 136 milliseconds.
The 555 isn't producing audio at this point. Its only job is to set the timing of the riff.
A trimmer potentiometer in the timing network makes it possible to fine-tune the clock frequency. I adjusted it while measuring pin 3 with a logic analyzer.
Counting Through the Notes
The clock output goes directly into a 74LS161N, a four-bit synchronous binary counter.
Each clock pulse increments the counter by one:
0000
0001
0010
0011
0100
...
Four bits provide 16 possible states, which works out nicely because this circuit needs 15 positions for the section of the riff being played.
The four counter outputs feed a 74LS154N 4-to-16 decoder. Rather than having to work with a four-bit binary number elsewhere in the circuit, the decoder provides an individual output for each count.
When the counter is at zero, Y0 is selected. At one, Y1 is selected. Then Y2, Y3, and so on.
The 74LS154 outputs are active-low, meaning the currently selected output goes low while all of the others remain high.
That gives the circuit one physical wire corresponding to every position in the sequence.
Making a 15-Step Counter
There are 16 possible counter states, but I only need 15.
The final decoder output, Y15, is therefore used to reset the counter rather than play another note.
Y15 controls a small inverter/driver circuit built from two 2N3904 NPN transistors. When Y15 becomes active, the transistor circuit pulls the active-low CLEAR input of the 74LS161 low.
The counter immediately returns to zero.
A pushbutton connected to the CLEAR input also provides a manual reset.
Storing the Music With Diodes
The counter now knows where it is in the riff, but something still needs to determine which pitch belongs at each position.
That's handled by 15 1N4148 diodes.
There are 15 note positions in the sequence, but only six different pitches. I created six note buses corresponding to those pitches. Each output from the 74LS154 connects through a diode to the bus for the pitch that should be played at that position.
For example, several positions play the repeated low E. All of those decoder outputs therefore have diodes leading to the same E2 bus:
Y0 ---- diode ----+
Y1 ---- diode ----+
Y3 ---- diode ----+
Y5 ---- diode ----+---- E2
Y7 ---- diode ----+
...
Other decoder outputs connect to the buses for the other pitches.
This diode matrix is effectively the circuit's musical memory. There is no ROM, RAM, or program containing the sequence. The sequence is encoded by the physical placement of the diodes.
Converting the Note Signals
Each note bus has a pull-up resistor that normally keeps it high.
When the 74LS154 selects a position, its output goes low. The corresponding diode then pulls the appropriate note bus low as well.
That's a problem because the analog switches used later in the circuit need a high signal when they should turn on.
A 74HCT14N hex Schmitt-trigger inverter takes care of that.
There are six inverters inside the chip, which happens to be exactly how many are needed. Each note bus goes into one inverter.
The six outputs from the HCT14 now provide clean active-high signals indicating which of the six pitches should be playing.
Selecting the Pitch
Those six signals control switches inside two CD4066BE chips.
The CD4066 contains four bilateral analog switches. When a switch's control input is low, its two signal terminals are effectively disconnected. Bring the control input high and the connection closes.
Six of these switches are used, one for each pitch.
Each switch connects a different resistor network into the timing circuit of the second 555:
pitch resistor -- switch --+
/ |
pitch resistor -- switch -----+
/ |
555 pin 7 -----+-- pitch resistor -- switch ---+---- 555 pins 2/6
\ |
pitch resistor -- switch -----+
\ |
etc. -----------------------+
Generating the Notes
The second NE555 is another astable oscillator, but this one operates at audio frequencies.
Its timing capacitor continually charges and discharges through the selected resistor network. Changing that resistance changes how quickly the capacitor can charge and discharge, which changes the oscillator's frequency.
A larger resistance produces a lower frequency and therefore a lower musical pitch. A smaller resistance produces a higher frequency and a higher pitch.
The six resistor networks correspond to:
- E2
- B♭2
- B2
- C3
- D3
- E3
Each network includes a trimmer potentiometer. Rather than relying entirely on calculated resistor values and component tolerances, I manually selected each pitch and measured the second 555's output frequency.
The trimmers were then adjusted to the desired frequencies.
For example, E2 is tuned to approximately 82.41 Hz, while the other networks are adjusted to their corresponding note frequencies.
Once calibrated, the CD4066 switches can rapidly jump between the six resistor networks as the sequence advances.
Making Some Noise
The output on pin 3 of the audio 555 is a square wave.
That isn't going to sound exactly like the original electric guitar, but the tune is recognizable all the same.
The 555 output passes through a coupling capacitor before reaching a PAM8302 amplifier module. The capacitor blocks the DC component of the 555 output while allowing the changing audio signal through.
The PAM8302 then provides enough power to drive a small speaker.
Nick Bild