The circuit is built around a digital decade counter, namely the CD4017B IC. This counter is commonly used in applications to perform frequency division, divide-by-N counter, decimal decode displays and so on. The IC has the following inputs:
- Clock: This is the clock input where each rising edge advances the counter by one.
- Clock inhibit: This input controls whether to advance the counter or to freeze it.
- Reset: Resets the chip to the starting state where pin 0 is high.
A simple diagram showing the counter in action, assuming reset and clock inhibit are low:
The maximum input clock frequency, running at 10V, is 5MHz. This is well above the required 20kHz that we are dealing with.
Using music as a clock signalNow, the counter expects a clear square wave input at the clock. Unless you listen to some heavily synthesized music, this is not what we have. Instead, we have sine waves, at frequencies spanning from 20Hz to 20kHz, not really an ideal clock signal.
However, just because a circuit expects a signal to look and behave in a certain way, doesn’t mean that we need to conform to it to get it to work, even though the result may be less than ideal. Instead of a clean square wave, let’s just use the music’s sine waves to trigger the counter. This presents two problems:
- The input needs to have an amplitude large enough to trigger the counter into counting.
- The input signal needs to be in the range -0.5V to VDD + 0.5V, according to the documentation.
The first problem is solved by amplifying the signal from the microphone. The electret microphone is a condenser mic with a FET output buffer. This means that we need a pull-up resistor to bias the transistor, as shown below. There is also a capacitor in series with the output, to only get the AC signal, since we do not want to amplify the DC bias in the next stage.
The output from the mic goes in to a two-stage amplifier, since only a single stage was not enough to bring the signal up to a decent level. The first stage amplifier is a common emitter (CE) amp. The bias is a simple resistor divider, setting the base bias to 0.82V. The emitter resistor R_E
is 1k, setting the transistor quiescent current (I_Q) to (0.82 - 0.6) / 1k = 0.22mA. With a collector resistor, R_C, of 33k, the quiescent voltage (V_Q) is 1.7V. The first stage including bias is shown below.
The second stage does not need to have its own bias network. Instead, we can use the DC voltage at the Q-point in stage one to bias the second amplifier. Similar to stage one, we use a CE amp and set the Q-points to a reasonable value. As said before, amplification solves our first problem that the signal needs to have a large enough amplitude to trigger the counter.
To combat the second problem, that the input can not be negative, we need to set the output from our amplifier roughly in the middle of the voltage swing. According to the documentation, there is a schmitt trigger at the clock input, allowing for fast rise and fall times, as well as some buffer to keep the circuit stable. Powering the circuit with 10V sets the lower limit to 3V. This is the maximum voltage at which the circuit interprets the input as a zero (low). The upper limit is 7V, where the circuit interprets the input as a one (high). Since a fully charged 9V battery reads at around 9.5V, it seems resonable to set the output DC voltage between 4.5V - 5V. Now, as long as the amplitude goes beyond 3 and 7V, we are in the clear. Note that clean amplification is not needed here, we might as well overdo the amplification to make sure we hit well below 3V and well above 7V.
Setting the gainThe amplification of a CE amp is determined by the collector and emitter resistors, Gain = R_C / R_E. This means that the amplification of our circuit is fixed. This is not optimal, since the input signal from the mic is based on the volume of the music as well as the distance to the speaker. It would be nice to let the user set the amplification based on the environment. Would a simple potentiometer do? Sadly no. Changing for example R_E in any stage would also change the Q-points (this is also true for R_C).
What to do then? Remember that we are only interested in amplifying AC signals, and not DC. A capacitor is seen as infinite impedance to a DC signal, but a “normal” impedance for AC (although frequency dependent). We can connect a capacitor in parallel to R_E by replacing R_E with a potentiometer, shown below.
Notice here, that we do not change the resistance of R_E, only how much we let AC signal bypass R_E. If the capacitor is all the way “down” to GND, it does not conduct, since we have the same voltage potential on both sides, so signals has to flow through R_E, and the gain is, as before, R_C / R_E. If the capacitor is all the way “up”, then AC signals bypass R_E completely (a capacitor is basically a short circuit for AC). This means that the AC gain is R_C / R_E = R_C / 0 = infinity! Of course, in practice, the gain is far from infinity, but let’s save those details for another post.
All in all, we now have a way of controlling the gain, thus the sensitivity of the circuit, neat! The complete amplifier circuit is shown below.
The output from the amp goes directly in to the clock of the counter. The outputs from the counter is connected to 10mm super bright LEDs.
Adding a few components and spending a couple of hours in Altium, it finally turned out like this:
That’s it! The schematic and layout was done in Altium (and ordered from JLCPCB) and can be found on my GitHub.
Comments
Please log in or sign up to comment.