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!

10 comments:

  1. brilliant dude, all the IC are 555 or 556?

    ReplyDelete
  2. fantastic ..!!
    Are the 10 uF capacitors electrolytic in fig .1?

    ReplyDelete
    Replies
    1. You should use 10uF ceramic capacitors. Electrolytic capacitors may not work correctly.

      Delete
  3. HI! may I ask what specific materials you used? and also if you have a easier detailed documentation about how you did it in the 556 IC? i am not good with electronics but i want to try this one. please and thank you!

    ReplyDelete
  4. Hi!
    Im having difficulty on turning off the LEDs using the electrode.
    Can a simple spst tact switch can be use as an alternative to those electrodes? And how?
    thanks

    ReplyDelete
    Replies
    1. Yes, you should be able to use a switch. Just put the switch between the TRIG pin and GND. You may also need a large resistor (1MW for example) between the TRIG pin and VCC. Hope that helps!

      Delete
  5. how to make random led??
    please answer,,,,,,,,,!!!!!

    ReplyDelete