Today’s microcontrollers are crammed with useful features that have obviated the need for going off chip in order to gain useful functionality. So-called “system-on-chip” or SoC platforms have streamlined product development cycles. They have done this by allowing engineers to spend more time focusing on value-added work and less time on the more mundane glitches that tend to crop up when interfacing multiple discrete components. Even with the increase in on-chip integration it is often necessary to interface with external devices such as sensors. For example, analog signals from sensors sometimes need to be conditioned before being inputted to a microcontroller. Given the limited ability to source current, an output signal from a microcontroller may need to be amplified to drive larger loads.
With this in mind let’s take a look at a basic way that a microphone could be interfaced with a microcontroller analog input pin. For the sake of discussing some of the basic principles of transistor biasing let’s select a simple common-emitter amplifier arrangement using a NPN bipolar junction transistor (BJT). The key thing to remember when using transistors for analog signal amplification versus on/off switching is the need to properly bias the transistor to achieve a workable quiescent point. That is to say, the surrounding components (the resistors) need to set the voltage level of the transistor base to a level that allows for the output to fully swing from peak to trough in response to the input signal. Since an audio signal of a microphone can swing equally in either positive or negative direction we want to set the quiescent point to be half of the supply voltage (VCC). For the example given, if the VCC is 5V the quiescent point will be 2.5V (VC).
In practical terms this means that when no sound is entering into the microphone the output will be approximately 2.5V. This is important so as to prevent the output from clipping when the inputs are at a peak. If you have ever cranked up the volume too loud on a radio and heard the accompanying nasty distortion then you have experienced clipping.
Let’s also arbitrarily select a quiescent current (IC) of 10mA as balance between performance and efficiency. The last piece of information we need is the transistors current gain which is typically found on the transistor datasheet as b or hfe. For the example we will use a b of 100.
With that information we can begin to calculate the ideal values for the four resistors — R1, R2, RC and RE. To begin, we start with the collector-emitter loop and calculate RE:
IE = IC x [ (b+1) / b ] = 10mA x [ (100+1) / 100 ] = 10.1mA
VE = 0.1 x VCC = 0.1 x 5V = 0.5V
RE = VE / IE = 0.5V / 10.1mA = 50 W
Next to determine RC we begin by calculating VRC.
VRc = VCC – VC = 5V – 2.5V = 2.5V
RC = VC / IC = 2.5V / 10mA = 250 W
Moving on to voltage divider circuit we first examine R2. The equation that governs that resistor’s value is:
R2 = 0.1 x b x RE = 0.1 x 100 x 50 = 500 W
Lastly we can calculate R1. To do so, recall that the voltage drop of a silicon PN junction is 0.7V, thus the value for base-to-emitter voltage (VBE). With that in mind the following set of equations are used:
VB = VBE + VE = 0.7V + 0.5V = 1.2V
R1 = R2 x [ (VCC – VB) / VB ] = 500 x [ (5V – 1.2V) / 1.2V ] = 1583 W
Don’t forget that calculating the resistance value is only half of what is needed to select the proper resistors. It is also necessary to determine the power rating for each resistor by accounting for the resistance value and the current flowing through the resistor. The equation P(Watts)=I2R can be used. When dealing with a 5V supply voltage then 1/4W resistors are likely to be sufficient. With that the circuit is primed for operations when VCC is 5V. If the circuit is to be reused in designs with a different operating voltage, the resistor values will need to be recalculated.