MIDI to SN76489 to chip music, part 1-B: diving into an amplifier circuit

Mathieu Favréaux · May 22, 2022

This article is part 1-B (see part 1, then part 2, part 3) in a series were we try to build a MIDI instrument from a bunch of SN76489s, which is the sound chip used in the Sega Game Gear, the BBC Micro, the Neo Geo Pocket and quite a few others.

If you’ve read the previous installment, you may have noticed this little aggregation of curious things:

Itty bitty amplifier on the breadboard
Itty bitty amplifier on the breadboard

That’s an amplifier, that’s what! Although a pretty bad one. In this article we’ll dive into the design I used here, and start exploring the fascinating, daunting, seemingly-infinite territory of how transistors work.

Note before we start: I’m really out of my depth here, and just trying to have fun. I’ve completely forgotten the little formal training I might have ever had in electronics. I don’t know what I’m talking about, so don’t quote me on anything. You have been warned.

Why an amplifier

The SN76489 chip can output up to 10 mA, which while enough to drive a small load for test purposes, begs for some amplification. Moreover, a few components I had bought or salvaged1 a while ago were looking at me with begging eyes, so this provided a good excuse to indulge and build an amplifier. However, we only need it for testing and we’ll drop it pretty soon: it does not have to be perfect, and only has to drive my little speaker.

This article will actually be a bit of a time warp: at the time when I actually build the amplifier, I did not have any measurement tools so I couldn’t validate nor understand what this was really doing. This was a bit frustrating. Since then though, I bought a little EspoTek Labrador, so we can now take on the challenge.

Quick & dirty design

I settled on the simplest-looking2 amplifier design I could get my hands on3, which you can see below. It’s pretty bad (for multiple reasons), and will damage your speaker if left on for too long. Thankfully this is only for testing, so that’s OK. It looks like this:

Amplifier schematic. It's a bad design, don't use it for real applications.
Amplifier schematic. It's a bad design, don't use it for real applications.

What do we have here? From left to right:

  • A signal source. We’ll simulate our TI chip here as a 1 KHz sine4 wave signal.
  • R2: a current-limiting resistor to simulate the limited current.
  • C1: coupling capacitor.
  • R1: resistor for biasing the transistor. Its exact value isn’t too clear, some use 2 KΩ. We’ll talk about that.
  • Q1: transistor to provide the amplification.
  • SPKR: either a speaker or a funny hat, you decide. Most speakers are about 4 Ω or 8 Ω, but not mine, no sir. 52 Ω for you.
  • And to the right, our voltage source to feed the amplification. It’s only 5 V so I can power it from the Arduino.

Input stage

Let’s look at the input stage first:

Zoom on the input part
Zoom on the input part

I configured the signal generator to output a 2 V amplitude sinewave. Combined with the 5 KΩ resistor, we get a current amplitude of 0.4 mA. That’s small, but since the usual β\beta factor for current amplification is around 100, we get a maximum amplitude of 40 mA.

However, just as is the case with the TI chip, the generated signal is not centered on zero but always positive. To remove that positive bias and get a nice AC signal, we must use a coupling capacitor. Now, while this is again super common stuff, I found that notion interesting enough to warrant its own measurement:

Measurements before / after the capacitor on a 3 V signal
Measurements before / after the capacitor on a 3 V signal

On the left is the signal voltage, while on the right we have the voltage at the terminals of R2. The signal looks cut at the bottom, but I think that’s an artifact of my signal generator, or of my setup here.

Note that even without this DC bias from the input source, the coupling capacitor would have been required anyway to block the bias we’ll apply on the transistor’s base.

A word about transistors

Throughout this article, we’ll focus on NPN BJT transistors and ignore the other categories.

An transistor allows a certain current through its collector based on the current flowing through its base (both flow to the emitter). Note I’m talking about current only: this is probably more complicated than that, but transistors are inherently current devices. I found it easier to reason about current first, and introduce voltage only where necessary.

Transistor with its voltages
Transistor with its voltages

You get Ic=βIbI_c = \beta I_b, which is why you can amplify a signal: small signal in input, bigger signal in output, mostly constant factor between the two.

There is a minimum IcI_c for the transistor to turn on. When this threshold is reached, VbeV_{be} is at its maximum (≅0.7 V) and mostly stays there, and the transistor starts allowing current through the collector. In a real circuit, this will result in variations of VceV_{ce}, to respect the above relationship between IcI_c & IbI_b. However, the transistor only allows current through the collector, it does not create current: if not enough can be provided by whatever source is connected to the collector, VceV_{ce} reaches a minimum (≅0.3 V) — this condition is called saturation.

It must be noted that β\beta varies a lot with operating conditions (IbI_b, temperature, etc.) and with transistors (even within the same model you get different values). It seems common to assume a value of 100, at least for a start. It can easily vary between 50 and 300, so good circuits are designed as to not depend on the exact value too much.

Biasing the transistor’s base

We want to amplify a signal that varies between -1 V and 1 V. When amplifying a signal we must bias the base of the transistor up (meaning, apply a DC voltage) for two reasons:

  • First a transistor only works one way, so AC signals are a no-go — we must get a positive signal only. Thanks to our coupling capacitor C1, applying a voltage will not alter the signal: it simply moves it up, exactly how we moved it around 0 in the section above.
  • Second, even if our signal is 0-2 V, our transistor will constantly turn off when reaching 0 V and then back on — this would heavily distort the signal. Hence, we want to positively bias the transistor so our lower input value will still keep the transistor on.

This is the reason we have R1, to force a DC voltage at the base. The input signal will then pull or push current at this same point, influencing IbI_b, which in turn will influence IcI_c. Magic!

This is also one of the reason why this particular amplifier design is bad: when on, even without signal, we’ll always have some current running through our speaker. Better designs work around that issue with a different placement of the speaker allowing the use of another coupling capacitor.

Initial current values

We will talk in more details about the exact value and effect of R1 in a section below, because it is a treat. Notably, I’ve seen a value of 2 KΩ used here and there, but at this point we have no idea why.

What we do know is that a value too great will not let enough current through to turn the transistor on. So for a start, let’s choose a big value as a potential maximum and calculate its current in the circuit in normal operation mode, if only to check that there is enough to turn the transistor on in the first place.

Let’s start simple: while the transistor is off, no current flows through the collector so we have both Ic=0I_c = 0 and Ib=IR1=IspkrI_b = I_{R1} = I_{spkr}.

In turn, the base current is Ib=VR1+VspkrR1+Rspkr=VccVbeR1+RspkrI_b = {V_{R1} + V_{spkr} \over {R_1 + R_{spkr}}} = {V_{cc} - V_{be} \over {R_1 + R_{spkr}}}. The lowest current we can get at the base while the transistor stays off is when VbeV_{be} approaches 0.7 V.

We have Vcc=5VV_{cc} = 5\,\mathrm{V}. Let’s take a big R1=10KΩR_1 = 10\,\mathrm{K\Omega} as a starting point. This also makes RspkrR_{spkr} above small enough to ignore.

We get: Ic=4.310000=0.43mAI_c = {4.3 \over 10000} = 0.43\,\mathrm{mA}. This is above 0.1mA0.1\,\mathrm{mA} which the 2N2222A’s datasheet seems to imply as the minimum base current, so we’re good: we can turn the transistor on.

Operating current values

But wait! Now that current is flowing through the collector, a significant portion of IspkrI_{spkr} is diverted away from the base, and the whole situation has changed. So the above calculation, while a nice way to get us warmed up, is just not valid — at least not while operating the transistor.

Transistor now turned on
Transistor now turned on

Let’s start again with this new condition and see if we can solve it easily:

Vbe+VR1+Vspkr=VccV_{be} + V_{R1} + V_{spkr} = V_{cc} Ib+Ic=IspkrI_b + I_c = I_{spkr} Ic=βIbI_c = \beta I_b

We’re trying to determine IcI_c, and we know VccV_{cc} and some of the resistances so let’s start from there and make IbI_b pop in every non-constant:

Vbe+R1Ib+IspkrRspkr=VccV_{be} + R_1 I_b + I_{spkr} R_{spkr} = V_{cc} Vbe+R1Ib+(Ib+βIb)Rspkr=VccV_{be} + R_1 I_b + (I_b + \beta I_b) R_{spkr} = V_{cc} Ib=VccVbeR1+(1+β)RspkrI_b = {V_{cc} - V_{be} \over {R_1 + (1 + \beta) R_{spkr}}}

Which gives us now:

Ib=50.710000+(1+100)520.28mAI_b = {5 - 0.7 \over {10000 + (1 + 100) 52}} \approx 0.28\,\mathrm{mA}

Hurray! That’s still above 0.1mA0.1\,\mathrm{mA} with a nice margin.

Before we move on, let’s get a feeling of what the above equation for IbI_b implies:

  • The lower the resistance R1R_1, the greater the base current.
  • Similarly, the lower the resistance RspkrR_{spkr}, the greater the current in the circuit, so the greater the base current.
  • Interestingly, the greater the β\beta, the more diverted current into the collector, so the lower the base current.

In operation without signal

Now that we have our circuit and sort-of understand how this is supposed to work, let’s build it and start measuring. As opposed to the above section, let’s start with a small R1R_1 because at this point, I figure the lower the bias resistor, the greater the base current, the better (spoiler alert: this is wrong).

Will we get the expected results according to the equation above?

Well, close but not exactly.

First measurements

Confounded by the early results, I decided to do measurements with 2 R1R_1 values. Here are the results:

  R1=1KΩR_1 = 1\,\mathrm{K\Omega} R1=4.7KΩR_1 = 4.7\,\mathrm{K\Omega}
IspkrI_{spkr} 75mA75\,\mathrm{mA} 60mA60\,\mathrm{mA}
IbI_b 0.40mA0.40\,\mathrm{mA} 0.26mA0.26\,\mathrm{mA}
β\beta 187187 233233

Wow, OK, our assumption of β=100\beta = 100 was way off. And this factor does indeed vary a lot. However, if we use the corrected β\beta value in the equations above, we do get the correct relationship between IbI_b and R1R_1 so at least we’re good here.

However something really strange happened: when testing both circuit, I got a clearly stronger amplification with the biggest R1R_1. Why is this?

We see in the table that β\beta looks higher with a greater resistance. Could this be the reason (Spoiler alert: nope)? And if so, what is the biggest value we can get?

Exploring Beta

I got all worked up about this β\beta thing, so let’s measure it on our transistor.

It’s not too hard to do: with the signal generator, I can create a voltage sweep from 0 V up, and through a fixed resistor create a known IbI_b. Then, supplying a small load at the Collector with a fixed voltage, I can measure the resulting voltage drop across the load and deduce IcI_c.

This looks like this:

Beta measurement setup schematic
Beta measurement setup schematic

Or like this on my breadboard with a nut for, ah, scale:

Beta measurement setup photo
Beta measurement setup photo

Note I dropped the speaker for an actual resistor: the speaker was causing too much noise when the transistor suddenly turned on.

Out of this, we get the following voltage measurements:

Beta Measurements of a 2N2222A: voltages
Beta Measurements of a 2N2222A: voltages

You can’t see it too well, but VR1V_{R1} starts with a plateau, were most of the voltage drop is (I guess) eaten up by the base’s diode, and very little current is passing through. Then, we get a nice linear-ish relationship, until we approach saturation and VloadV_{load} plateaus again.

What we really want to observe are the currents and resulting β\beta values. However the measurements are very noisy: the Espotek’s resolution isn’t too great5, so we need to average the heck out of this:

Beta measurements of a 2N2222A: averaged currents
Beta measurements of a 2N2222A: averaged currents

We get similar-looking current curves, and a beta approximation. Again, the spikes at the beginning are probably due to the measurement resolution, which is not sufficient at the start of the graph even when averaged. The low resolution really hurts when the values are small.

While the exact β\beta values are not too exploitable, this tells me a great deal about this parameter:

  • It does vary, especially (as expected) when nearing saturation.
  • A value between 150 and 250 is to be expected at low currents, although huge variations are indistinguishable from measurement errors.
  • It seems to drop a little when the base current gets higher, before saturation — although again it’s hard to tell if it’s just the error factor getting lower.

However, this does not tell much about the difference in sound output relative to R1R_1. I suspect the variations we were observing previously are measurement errors that don’t explain the significant difference in power output I was hearing.

We need more measurements while the thing is operating.

In operation with signal

Let’s measure the influence of the input signal on the output, and try to understand it.

Initial assumptions

Let’s be naive for a moment. If we consider the current amplitude of the input signal applied to the base, the amplitude of the output should be relative to β\beta, right? We apply a 2V2\,\mathrm{V} amplitude to a R2=4.7KΩR_2 = 4.7\,\mathrm{K\Omega} resistance: we expect Iamplc=βIamplb=2002/470085mAI_{ampl_c} = \beta I_{ampl_b} = 200* {2/ 4700} \approx 85\,\mathrm{mA} of current amplitude in the output.

To actually measure the output signal, we’ll measure the voltage drop across multiple points, and get the bias & the amplitudes. We’ll repeat the operation with multiple R1R_1 values.

Here is a plot of the output currents. I also added their measured ranges, along with the naively expected ranges and a percentage of the former over the latter:

Output amplitude measurements with multiple R1
Output amplitude measurements with multiple R1

Note Iload is considered interchangeable with Ic for simplicity in this graph, but this does not change the results too much

This invalidates our naive calculation above, and confirms what I was hearing: while a lower R1R_1 values drives the mean current lower (as expected), the amplitude gets bigger so the sound is louder. Why is that?

Negative feedback

Well, poking around in the circuit, I finally got the answer. It turns out the approach above completely overlooks the fact that the transistors varies the voltage at the collector to regulate the current, which influences R1, and in the end its base current. Let’s see what it looks like:

Influence of signal (yellow) over collector voltage (blue).
Influence of signal (yellow) over collector voltage (blue).

In the above image, we see the input signal vs. the collector voltage (from which the bias current is derived). Their phases are opposed, ain’t that a treat? The more current must get drawn into the collector, the lower VceV_{ce} must be, so less voltage drop is available for the biasing resistor. The bias goes against the signal, which dampens the effect of the latter. I guess that this is textbook negative feedback, and that it’s been painfully obvious for a while for the more electronic-savvy of our readers.

I may be completely off the mark with what’s about to follow, but let’s try to calculate all that. Let’s start from IR1I_{R1}, dropping the assumption that it is equal to IbI_b:

IR1=VceVbeR1=VccRloadIloadVbeR1I_{R1} = { { V_{ce} - V_{be} } \over R_1 } = { { V_{cc} - R_{load} I_{load} - V_{be} } \over R_1 } IR1=VccRload(Ibβ+IR1)VbeR1I_{R1} = { { V_{cc} - R_{load} (I_b \beta + I_{R1}) - V_{be} } \over R_1 } (1+RloadR1)IR1=VccVbeR1βRloadR1Ib(1 + {R_{load} \over R_1})I_{R1} = { { V_{cc} - V_{be} } \over R_1} - \beta { R_{load} \over R_1 } I_b IR1=VccVbeR1+RloadβRloadR1+RloadIbI_{R1} = { { V_{cc} - V_{be} } \over { R_1 + R_{load} } } - \beta { R_{load} \over { R_1 + R_{load} } } I_b

Let’s assume that R1RloadR_1 \gg R_{load} so we can gain some clarity without losing too much precision :

IR1=VccVbeR1βRloadR1IbI_{R1} = { { V_{cc} - V_{be} } \over R_1 } - \beta { R_{load} \over R_1 } I_b

This hints at the relationship we observed above: IR1I_{R1} shrinks as IbI_b grows, by a value inversely proportional to the R1R_1 resistance value.

Let’s now try to see the influence of the signal. At any point in time, we can express Ib(t)I_b(t) as a function of the current pushed (or pulled) by the input signal Is(t)I_s(t):

Ib(t)=IR1(t)+Is(t)I_b(t) = I_{R1}(t) + I_s(t)

Which we can expand as:

Ib(t)=VccVbeR1βRloadR1Ib(t)+Is(t)I_b(t) = { { V_{cc} - V_{be} } \over R_1 } - \beta { R_{load} \over R_1 } I_b(t) + I_s(t) Ib(t)(1+βRloadR1)=VccVbeR1+Is(t)I_b(t) (1 + \beta { R_{load} \over R_1 }) = { { V_{cc} - V_{be} } \over R_1} + I_s(t)

Let’s rename the constants to make this readable:

A=VccVbeR1+βRload,B=1+βRloadR1A = { { V_{cc} - V_{be} } \over { R_1 + \beta R_{load} } }, B = 1 + \beta { R_{load} \over R_1 } Ib(t)=A+1BIs(t)I_b(t) = { A + { 1 \over B } I_s(t) }

Again, this confirms that the influence of Is(t)I_s(t) over Ib(s)I_b(s) (and so over Ic(t)I_c(t)) is relative to the value of R1R_1 — the greater the R1R_1, the lesser the input signal is dampened (up to no dampening at all when R1R_1 reaches \infty), and the greater the output’s current amplitude.

Let’s plot that to compare against our previous measurements:

Output amplitude measurements with multiple R1 - fixed calculated expectations
Output amplitude measurements with multiple R1 - fixed calculated expectations

Not too far off! Again, I have no idea if the calculations above are anything correct but this is encouraging. I’ll consider that good enough for now.

In any case we understand why going with a greater R1R_1 helps: it limits the negative feedback that is dampening the signal’s influence on the output. Also, it reduces the constant current applied to the speaker which, while this whole thing is definitely a bad design anyway, helps a little.

Conclusion

And there we go! We started with a completely unknown amplification circuit diagram and managed not only to make it work, but understand and visualize the use of each of its components. We took a detour to measure the β\beta factor of our transistor. We also dug into the negative feedback applied to the transistor’s bias, and managed to find a calculation that reproduces our measurements.

Now this raises some questions:

  • Why not connect R1 from the voltage source directly instead of at the collector?
  • Could we place the speaker somewhere else so it does not suffer from the constant DC voltage even without signal?

Well, I would guess that’s why an actual Class A amplifier looks the way it does. And no, I’m not going to build one, that’s a rabbit hole for another time. It’s time to go back to our project.

See you in part 2.

  1. Salvaged from an oven circuit board that fried when I spilled milk on it, but life, huh, finds a way. For capacitors, at least. 

  2. I would not necessarily make the very same choice now: simple-looking does not necessarily equate to easily understandable. 

  3. There are good, simple amplifier designs to be found everywhere, along with tons of details & explanations. Notably, Electronics Tutorials is probably a source I’ll get back to in the future. However, as a complete neophyte, I found the Simply Put YouTube channel to provide a very approachable perspective when trying to form an intuitive understanding of what’s where and why. His Simple and Quick Audio Amplifier presents the design I copied here. 

  4. I chose a sine signal instead of a square signal because this makes it much easier to visualize distortion and clipping in the output signal. 

  5. As we can see in the documentation, there is a mode to get a 12-bit resolution using both inputs at the same time in the Multimeter mode, but I couldn’t manage to export a csv file to exploit the values, so I’m stuck 2 channels, 8 bits. I guess that’s kind of fitting for this project, though. 

Twitter, Facebook