Hi. Recently, NerdKits was a sponsor for MIT’s
annual Battle of the Bands held during Campus Preview Weekend for incoming students. Since
we don’t like to miss any opportunities to build something cool here at NerdKits, we
decided to build a little demo for the event. We wanted to have something that would be
simple, interesting, show off the capabilities of microcontrollers, and be relevant to MIT
and to the Battle of the Bands theme. Our team of engineers decided to make a sound
meter that we could hang on the wall and would in some way represent the overall sound level
in the room. Here’s what we came up with. A keen observer will notice that that the
display looks an awful lot like an LED Marquee that we featured in our earlier video. And
indeed it was the exact same display. In fact, the code was even simpler since it only had
to display predefined bars and predefined text. The real trick to this project was measuring
the sound level in a room without a complicated microphone set up. And the answer to that
starts with a part that’s included in every single NerdKit, the piezoelectric buzzer.
The piezoelectric buzzer cannot only be driven with a voltage to create a sound, but it also
responds to a sound input with the voltage. This voltage is what we measure.
The voltage created by the buzzer is very small, way too small to read just using the
ADC on the microcontroller. However, we can use a single transistor amplifier to amplify
the signal. Because we don’t like to leave anything unexplained here at NerdKits, I’m
going to go over the basics of the single transistor amplifier we used. If you’ve never
done analog circuits before, it might be a bit complicated, so get ready.
Okay, so we have this little guy which is a bipolar junction transistor, which is one
of what we want to make our amplifier out of, and the first thing we need to do is build
a mathematical model of how this guy works so we can make a circuit out of it. So, let’s
build that mathematical model. This is the way we draw the schematic for the bipolar
junction transistor. It has three terminals: it has collector, and an emitter and a base,
and we’ll also define three currents: the current going in to the base, the current
going in to the collector and the current coming out of the emitter. And there’s also
some equations that govern how these currents and voltages interact with each other. The
most important ones are the following: the collector current is always going to be the
base current times beta, and for these bipolar junction transistors, beta is greater than
a hundred, which basically means that the collector current is a lot more than the base
current. There is also another equation that says that
the base current is IS — some number — that’s a constant times E to the VBE over VTH minus 1. VBE is the voltage
difference between the base and the emitter. IS is a constant. VTH is a constant. So what
does this tells us? This tells us that there’s an exponential relationship between VBE, the
voltage difference between the base and the emitter, and the current IB. Now why is that
important? Well, that’s important because if we were
to be at a point were VBE is some number, let’s called that .6 — that will be important
later — if we were to start off there then for a huge range of useful IB’s, a very big
range of currents, VBE only has to change by a little bit for us to get this huge range
of useful IB’s. You don’t know why that is important yet but it will be. And there’s one more equation that I’m going
to right down for you, IE is IC plus IB. This one is not that hard to see where it comes
from because this current is just these two currents added up. That’s just Kirchoff’s
current law saying that current or charge can’t add up inside this little device.
So let’s use this model and these three equations to sort of see how we can get an amplifier
out of it. In order to do that, I’m going to add some resistors, I’m going to add 2
resistors to our circuit and I’m going to call this RC and I’m going to call this RE.
Now we added these resistors so we have control of what the resistances are. We were going
to also go and define two nodes, I want to call this voltage VE, the voltage at the emitter
and this voltage VB, the voltage at the base. So let’s say for the sake of argument that
VBE was something that we knew, some number, that would mean that we have some current
IB coming in to the base which means that we have some current IC coming in to the collector
which defines an IE coming out of the emitter which tells us what VE is because VE equals
IR and we know RE and we know IE, so have VE equals RE times IE which is completely
defined assuming that VBE equals some number. So before we move on there’s one more thing
that I need you to convince you of. Let’s see how these currents are actually related
to each other. We know for a fact that IE equals IC plus IB — that is absolutely true.
We also know that IC is a hundred times or more IB, so that means that if IC was 100,
IB was just 1, which means that IE is 101. So IB is really just 100 of whatever IC is.
IB is really small compared to IC so we can approximate IE to be about the same as IC.
It’s not exactly true but its close enough, and yes it’s close enough.
Okay, so if we can say that IE is approximately the same as IC then we can start wiggling
these voltages and seeing what happens. So say for example that I put a delta VB, I changed
VB by just a little bit. Well I already manage to convince you that VBE stays approximately
the same so if I change VB by some amount, VE is going to change by just about some amount
so make a VB and I get a delta VE. Well since V equals IR and that’s always true, this delta
in VE causes a delta in IE. Well, I just convinced you that IE is about the same as IC, so by
changing this VB, I change this VE which change the IE and now I’ve got a change an IC. Well,
what did that do to this voltage here that I’m going to call VC, the voltage at the collector?
Well, a change in IC which is a current coming down through this resistor is going to cause
a negative change in VC times whatever RC is.
So what else do we know? Well we know that IE is approximately the same as IC so if I
divide in this equation both sides by RE then I get a delta VE over RE equals IE which is
the same as IC so I’m just gonna go ahead and replace that into this IC and I get a