Monday, October 8, 2007

Clap Activated Remote

An infra-red or wireless remote control has the disadvantage that the small, handy, remote transmitter is often misplaced. The sound operated switch has the advantage that the transmitter is always with you. This project offers a way to control up to four latching switches with two claps of your hand. These switches may be used to control lights or fans – or anything else that does not produce too loud a sound. To prevent an occasional loud sound from causing malfunction, the circuit is normally quiescent. The first clap takes it out of standby state and starts a scan of eight panel-mounted LEDs. Each of the four switches are accompanied with two LEDs – one for indicating the ‘on’ and the other for indicating the ‘off’ state. A second clap, while the appropriate LED is lit, activates that function. For example, if you clap while LED10 used in conjunction with Lamp 1 is lit then the lamp turns on. (If it is already on, nothing happens and it remains on.) A condenser microphone, as used in tape recorders, is used here to pick up the sound of the claps. The signal is then amplified and shaped into a pulse by three inverters (N1 through N3) contained in CMOS hex inverter IC CD4069. A clock generator built from two of the inverter gates (N5 and N6) supplies clock pulses to a decade counter CD4017 (IC2). Eight outputs of this IC drive LEDs (1 through 8). These outputs also go to the J and K inputs of four flip-flops in two type CD4027 ICs (IC3 and IC4). The clock inputs of these flip-flops are connected to the pulse shaped sound signal (available at the output of gate N3). Additional circuitry around the CD4017 counter ensures that it is in the reset state, after reaching count 9, and that the reset is removed when a sound signal is received. Outputs of the four flip-flops are buffered by transistors and fed via LEDs to the gates of four triacs. These triacs switch the mains supply to four loads, usually lamps. If small lamps are to be controlled, these may be directly driven by the transistors. If this circuit is to be active, i.e. scanning all the time, some components around CD4017 IC could be omitted and some connections changed. But then it would no longer be immune to an occasional, spurious loud sound. The condenser microphone usually available in the market has two terminals. It has to be supplied with power for it to function. Any interference on this supply line will be passed on to the output. So the supply for the microphone is smoothed by resistor-capacitor combination of R2, C1 and fed to it via resistor R1. CD4069, a hex unbuffered inverter, contains six similar inverters. When the output and input of such an inverter is bridged by a resistor, it functions as an inverting amplifier. Capacitor C2 couples the signal developed by the microphone to N1 inverter in this IC, which is configured as an amplifier. The output of gate N1 is directly connected to the input of next gate N2. Capacitor C3 couples the output of this inverter to N3 inverter, which is connected as an adjustable level comparator. Inverter N4 is connected as an LED (9) driver to help in setting the sensitivity. Preset VR1 supplies a variable bias to U3. If the wiper of VR1 is set towards the negative supply end, the circuit becomes relatively insensitive (i.e. requires a thunderous clap to operate). As the wiper is turned towards resistor R4, the circuit becomes progressively more sensitive. The sound signal supplied by gate N2 is added to the voltage set by preset VR1 and applied to the input of gate N3. When this voltage crosses half supply voltage, the output of gate N3 goes low. This output is normally high since the input is held low by adjustment of preset VR1. This output is used for two things: First, it releases the reset state of IC2 via diode D1. Second, it feeds the clock inputs to the four flip-flops contained in IC3 and IC4. In the quiescent state, IC2 is reset and its ‘Q0’ output is high. Capacitor C4 is charged positively and it holds this charge due to the connection from R5 to this output (Q0). IC2 is a decade counter with fully decoded outputs. It has ten outputs labelled Q0 to Q9 which go successively high, one at a time, when the clock in put is fed with pulses. IC3 and IC4 are dual JK flip-flops. In this circuit they store (latch) the state of the four switches and control the output through transistors and triacs. At the first clap, the output of gate N3 goes low. Diode D1 is forward biased and it conducts, discharging capacitor C4. The reset input of IC2 goes low, releasing its reset state. All the J and K inputs of the four flip-flops are low and so these do not change state, even though their clock inputs receive pulses. When the reset input of IC2 is low, each clock pulse causes IC2 to advance by one count and its outputs go high successively, lighting up the corresponding LEDs and pulling high the J and K inputs of the four flip-flops, one after the other. Resistor R8 limits the current through LEDs 1 through 8 to about 2 mA. Larger current might cause malfunction due to the outputs of IC2 being pulled down below the logic 1 state input voltage. If a second clap is detected while the J input of a particular flip-flop is high, its Q output will go high, regardless of what state it was in previously. Similarly, if its K input was high, the output will go low. (If both J and K are high, the output will change state at each clock pulse.) Thus although all flip-flops receive the clap signal at their clock inputs, only the one selected by the active output of IC2 will change state. Resistor R9 and capacitor C6 ensure that the flip-flops start in the off state when power to the circuit is switched on, by providing a positive power-on-reset pulse to the reset input pins when power is applied. The preset input pins are not used and are therefore connected directly to ground. When, after eight clock pulses, output Q8 of IC2 becomes high, diode D2 conducts, charging capacitor C4, thereby resetting IC2 and making its Q0 output high. And there it stays, awaiting the next clap. The four Q outputs of IC3 and IC4 are buffered by npn transistors, fed through current limiting resistors and LEDs (to indicate the on/off state of the loads) to the gates of four triacs. Four lamps operating on the mains may thus be controlled. For demonstrations, it might be better to drive small lamps (drawing less than 100 mA at 12V) directly from the emitters of the transistors. In this case the triacs, LEDs and their associated current limiting resistors may be omitted. It has to be noted that one side of the mains has to be connected to the negative supply line of this circuit when mains loads are to be controlled. This necessitates safe construction of the circuit such that no part of it is liable to be touched. The advantage is that it may be mounted out of reach of curious hands since it does not need to be handled during normal operation. It is advisable to start with the low voltage version and then upgrade to mains operation, once you are sure everything else is working satisfactorily. CMOS ICs are used in this circuit for implementing the amplifying and logic functions. Use of a dedicated supply is recommended because the integrated circuits will be damaged if the supply voltage is too high, or is of wrong polarity. An external power supply may get connected up the wrong way around, or be inadvertently set to too high a voltage. Therefore it is a good idea to start by constructing the power supply section and then add the other components of the circuit. If the clock is working, you may turn your attention to the amplifier. LED9 should be off, and should flash when the terminals of capacitor C2 are touched with a wet finger (the classic wet finger test). Preset VR1 may need to be adjusted until LED9 just turns off. The output of gate N2 will be at about half the supply voltage. The output of gate N3 would normally be high. The voltage at the input of gate N3 should vary when preset VR1 is varied. High-efficiency LEDs should preferably be used in this circuit. The microphone has two terminals, one of which is connected to its body. This terminal has to be connected to circuit ground, and the other to the junction of resistor R2 and capacitor C2. These wires are preferably kept short (one or two centimetres) to avoid noise pickup. With the microphone connected, a loud sound (a clap) should result in LED9 blinking. Adjust preset VR1 so that LED9 stays off on the loudest of background noises but starts glowing when you clap. If the clap-to-start feature is not required, it may be disabled by omitting components D1, D2, R5, C4 and connecting a wire link in place of diode D2. Then IC2 will be alive and kicking all the time.

1 comment:

Unknown said...

Nice one..Thank you.
Explanation and workflow is awsome..makes sense..