I want to build a very simple circuit that will sound a tone with the press of a button and once the button is released, have the tone decay gradually instead of instantly switching off. If I use a square waveform, this could be as simple as feeding the signal into the collector of an NPN BJT, connecting the emitter to a speaker thru a current limiting resistor, and connecting the base (thru a resistor of course) to a voltage source that decays when the button is released.
As it happens I built such a circuit to test this idea and i am not satisfied with the result. For the decaying voltage part i just connected a button (supplying 5v when depressed) to the base of the BJT thru a 1k resistor with a 100 uf capacitor going to ground (in a low pass filter type configuration ya know). That way as the cap discharged the voltage would decay.
Heres the problem. At first, i had it set up so when the button wasnt being pressed, the the transistor base was basically floating (except that it was connected to ground thru the cap). The result was that because the discharging of the cap isnt linear, when the button was released the sound didnt just gradually fade to nothing, it went from full loudness to somewhat quiet very quickly and then verrrry slowly died away (seemingly never quite reaching the point where you couldnt hear it). This basically made it so you could always hear the beep very quietly, even when the button wasnt being pressed. So i tried using a pull down resistor on the output of the button, which made the beep quieter when the button wasnt being pressed (although it was still audible which i absolutely do not want) and also made the sound fade much too quickly.
Is there an easy way of accomplishing this with the parts i am already using? Or should i use an op amp or something like that. To be honest i dont like using op amps because i only have a single ended power supply and the single supply opamps i have used so far have been very unreliable.
As it happens I built such a circuit to test this idea and i am not satisfied with the result. For the decaying voltage part i just connected a button (supplying 5v when depressed) to the base of the BJT thru a 1k resistor with a 100 uf capacitor going to ground (in a low pass filter type configuration ya know). That way as the cap discharged the voltage would decay.
Heres the problem. At first, i had it set up so when the button wasnt being pressed, the the transistor base was basically floating (except that it was connected to ground thru the cap). The result was that because the discharging of the cap isnt linear, when the button was released the sound didnt just gradually fade to nothing, it went from full loudness to somewhat quiet very quickly and then verrrry slowly died away (seemingly never quite reaching the point where you couldnt hear it). This basically made it so you could always hear the beep very quietly, even when the button wasnt being pressed. So i tried using a pull down resistor on the output of the button, which made the beep quieter when the button wasnt being pressed (although it was still audible which i absolutely do not want) and also made the sound fade much too quickly.
Is there an easy way of accomplishing this with the parts i am already using? Or should i use an op amp or something like that. To be honest i dont like using op amps because i only have a single ended power supply and the single supply opamps i have used so far have been very unreliable.