Sunday, August 28, 2011

New project pages

I've copied my project pages to my website at

You can also find my email address there. Feel free to email me with any questions about these projects.

Monday, February 28, 2011

555 Contest - "Whack-a-mole" Style Game

My second entry to the 555 contest is a game similar to the "whack-a-mole" games. By replacing the "moles" with LEDs and the hammer with your finger, this game discourages violence against underground critters, hopefully. The only ICs used are six 556 chips.

Here's how the game looks:

The rule is simple. During the game, the LEDs will light up randomly. You have a certain amount of time to turn off the lit LEDs by touching the electrodes next to them. Every time, you will get less and less time available. When a LED is not turned off by the time limit, the game ends and all the LEDs will light up. Turn them off to restart the game.

This is the overall schematic, and I will explain each individual block below:

Each of the nine cell blocks is responsible for sensing touch input and controlling one LED.
  • Touch input takes advantage of the Darlington input stage of the 555 trigger pin, just like a regular Darlington pair that can turn on a LED with a touch. The diode is there on the trigger pin to prevent a negative voltage spike that falsely triggers the other 555 timer on a 556 chip (learned it the hard way!). The trigger pin makes the output high, turning off the LED and releasing the discharge pin.
  • The LED is driven through the 555 output. When no LED is lit, each capacitor is charged by a constant current through the PNP, until one capacitor is at the control voltage, at which point the output and discharge pins go low, and the LED turns on.
  • When a LED is on, the /CONT signal goes high and charging stops. This pauses the game and prevents other LEDs from turning on before the player has turned off the on-LED. The /LIT signal connected to the discharge pin is used to tell the control circuit that a LED has turned on. All of the discharge pins for the 9 555s are connected together, taking advantage of the open collector output to form a wired-OR logic.
  • Whenever a LED is on, a random current will be fed from the DIS signal. This discharges the capacitor at a random speed, effectively setting a random delay before this LED is triggered again. To make sure that we only discharge the capacitors for LEDs that are on, the emitter of the NPN is connected to the 555 output.

This block contains the mechanism that controls the /CONT signal. Whenever /LIT is high, meaning no LED is on, a current goes through the NPN base and the diode-connected PNP is turned on, forming one-half of a current mirror. The /CONT voltage directs the other PNPs to mirror this reference current. However, when a LED is on and /LIT is pulled low, the NPN turns off and the current mirror turns off as well. The WAIT signal has the same meaning as /LIT, except WAIT has the right voltage to directly control other NPNs.

This block forms the heart of the game logic.
  • The 555 output is directly connected to the reset pins of the 9 LED 555s, which means if this 555 goes low, the game ends.
  • The capacitor is charged by a constant current source, but as you can see, when WAIT is high, meaning no LED is on, the capacitor is kept low. When a LED does turn on, the capacitor charges until the game ends or until all LEDs are turned off.
  • The charging current not only charges the 555 capacitor, it also slowly charges a larger, secondary capacitor. If the voltage on this capacitor is low, it shares some of the 555 capacitor charging current, taking it longer to charge up that capacitor. However, as the secondary capacitor voltage rises, it is able to share less and less of the current, which means the 555 capacitor will charge faster and faster, shortening the timeout period before the game ends. When the game does end, the RST signal goes low and the secondary capacitor voltage is reset.
  • The RST signal is only active for a short time before the trigger pin makes the RST signal high. This lets the user turn off the LEDs to start a game. Otherwise the RST signal will keep all of the LEDs on forever. The short pulse also makes a nice signal to control the reset buzzer sound.

This block is related to starting the game. Before the game starts, all LEDs are on. Normally this would activate the timeout circuit and the game will soon "end", even before it has started! To prevent this, the two coupled NPNs form a latch that is set by the RST signal going low and reset by the /LIT signal going high. When RST signal goes low, the third NPN keeps the reset 555 capacitor low, preventing timeout. When all LEDs are turned off to start a game, the /LIT signal goes high and the latch is reset, making it possible to timeout during normal game play.

This small block drives the red LED that gives a visual indication of time left during a turn (although when I'm actually playing the game, I'm too busy to even notice this LED is there). The transistors simply form a Sziklai pair in an emitter follower configuration. The voltage at the LED cathode will follow the reset 555 capacitor voltage. The high gain of the Sziklai pair makes sure the base current too small to disturb the capacitor. When the capacitor voltage is low, meaning there's more time left, the LED will be brighter due to higher voltage/current. As the capacitor voltage rises, the LED gets darker, indicating that the game will soon timeout.

This is the block that generates the random discharging current, which sets a random delay. The 555 is used to generate a free-running voltage ramp with relatively high frequency. The resistor on the discharge pin prevents the voltage from going too low. This voltage goes through an emitter follower and the resistor sets the current that is available through DIS. When WAIT is high, meaning no LED is on, DIS is pulled to ground, to prevent the DIS current from going through the collector-base diode on the discharge NPN.

Finally, this block generates the game audio. The 555 timer is used as an astable oscillator and both the RST and /LIT signals can turn it on. So sound is generate when a LED turns on and when the game ends. The /LIT signal goes through a capacitor to limit the LED-on sound to a short chirp. The RST signal also affects the output frequency. This makes it possible to generate two tones - the game over buzzer sound and the higher frequency LED-on sound. The output is buffered by emitter followers so most power is dissipated in the transistors instead of in the chip. This minimizes the effect that the sound circuit has on the other 555 timer in the 556 chip. The final output is high-pass filtered and drives the speaker.

And that's how the circuit works in a nutshell! When all the different circuit blocks are combined, the game works quite well. Then I get too excited playing and kept knocking transistors loose from the breadboard. Seems like I've lost too many rounds this way.

Thanks for reading and feel free to comment!

Tuesday, February 22, 2011

555 Contest - Simple Electric Guitar Tuner

My first entry for the 555 contest is an electric guitar tuner using one 556 IC, a few resistors and capacitors, and an LED as output.

The tuner only tunes to the A2 note (110Hz) which is the fifth string on the standard EADGBE tuning, so it's a very basic tuner. But for the number of components used I think it's pretty good.

The tuner works by outputting the beats between a reference 110Hz signal and the signal from the guitar. Basically, when two signals of different frequencies are added together, they interfere such that the resulting signal oscillates between high and low amplitudes. The frequency of this oscillation is the same as the difference between the two source frequencies. For example, if a 110Hz signal and a 112Hz signal are mixed together, the output will have a beat at 2Hz.

So in this circuit, the first 555 runs in the standard astable mode, and generates the reference signal at 110Hz. It's very important to trim the frequency accurately because the accuracy of the reference signal determines the accuracy of tuning. (Protip: not doing this also makes you look silly on video.)

The second 555 is where the magic happens: the reference signal is combined with the guitar signal.
The first problem is conditioning the guitar signal for the 555. Because the guitar output is floating, in this circuit I've attached the guitar ground to the control voltage pin of the 555. The output line goes directly to the threshold pin. This effectively level-shifts the signal so that the threshold pin now simply responds to the polarity of the guitar signal. A guitar has a relatively large output impedance of up to 10kOhms. This is no problem for the threshold pin which has an input impedance in the mega-ohms range. The large output impedance can also be used as part of a low-pass input filter by simply adding a capacitor. This helps filtering out harmonics present in the signal
The second problem is combining the two signals. In this circuit, the reference signal is connected to the trigger pin and keeps trying to make the output high with every cycle. However, the guitar signal is connected to the threshold pin and keeps trying to make the output low. The result is that whenever the two signals have different frequencies, the output will have a changing pulse width, resulting in a visible beat when shown on the output LED.
The second 555 drives the output LED directly, and there is a capacitor across it to filter out any potential high-frequency beats that cannot be perceived by the eye.
To tune a guiar, you play the fifth string, and look for the beats on the LED. Adjust the tuning knob so that the beat happens at a slower and slower frequency, until you can no longer notice it - the LED will be at a constant brightness. The fifth string is now tuned. The other strings can be tuned based on the A note.

And that's how this circuit works! Here's a recap in motion pictures form:

Of course, there are still a lot of things that can be improved. First, the reference signal has to be trimmed and is unstable. It can vary a lot with supply voltage and temperature differences, directly affecting the accuracy of tuning. The output is also a little hard to read. But still, using only two 555's and a handful of passive components, it's probably as simple as it gets!

Thanks for reading!