Amplifier Design - A Documentation

Started by Bunkey, February 20, 2021, 11:10:28 PM

Previous topic - Next topic

Bunkey

Welcome.

I'm designing & building an amplifier. This thread is going to document the process.

This is my first amplifier and I'm self-taught, so I'm treating it as a learning process - hopefully it might be of some interest.

I've made a couple of threads previously, asking about specific elements relating to the power supply, but rather than bits and pieces floating around I thought it'd be nice to amalgamate the information under the one subject heading. It might also help to keep things concise if I need assistance with anything further.

So here goes...




Electronic engineering eluded my interest at school (I'm nearly 30 now) but I am an engineer at heart and I've always played guitar. A few years ago I started building fuzz pedals using reclaimed components in an effort to expand my tone a little. Naturally, and with little else taking up my time, things have progressed since then. I've dabbled in tiny speaker cabinets and dreamt about one day partnering them with a separate head of a similar design but the concept of actually designing a functioning amplifier had seemed a distant prospect - That was until I discovered you can get a power amplifier on a chip, capable of driving an actual guitar speaker with nothing more than a power supply and a few supporting components. This was quite a revelation.

The amp I'm building here is of solid-state topology based on the simple LM386 chip; there are a few LM386 amplifiers out there already using a minimum parts count, similar to what is outlined in the LM386 datasheet (check out the Ruby & Little Gem amplifiers for an idea) - but unlike these afternoon projects, I plan to build something that resembles a real amplifier on a miniature scale. As I will come to realise, there is a lot more involved in the process if one is to do it properly - and do it properly I shall.


Concept.

As I understand it, an amplifier can be split into 3 main sections:

    - The power supply, to convert the power source (230v AC here) into a suitable DC supply of the correct voltage for each part of the amp.
    - The pre-amp, responsible for signal processing and tone shaping.
    - The power amp, to amplify the processed signal and drive the speakers attached to its output.


In this case the pre-amp is responsible for shaping the tonal character/colour of the sound, rather like a pedal (boost, overdrive, whatever flavour you like), and the power amp (the LM386) simply makes that sound louder and adds power; imparting no particular colour of its own.
By applying this approach, it seems possible to make a very good sounding amp from even a basic LM386 power chip as long as you work within its limitations.

I'd been designing a pedal for a friend for quite some time whilst I learned the basics of electronics, first exploring Bazz Fuss topology and then the LBP and Electra type distortion - very simple - I'm using 2 BJT gain stages in my latest iteration, diode clipping and I've added a tone stack. You can see how this ticks the criteria for the pre-amp section above. By following it with an LM386 power stage to amplify that signal and drive a speaker, suddenly I've gone from something resembling a basic effects pedal to a functioning amplifier. Et voila! Amplifiers don't have to be as complicated as they first seem.


2 x 4" in series, 12ohm. 25w combined.


This particular amplifier has separate gain and volume controls. The tone is pre-set to match the voicing of the miniature cabinet it's being paired with. I'm employing two LM386N-4's in a bridged configuration (space permitting) for the maximum possible output whilst leaving them set to the internally limited 20x gain - I don't find op-amp distortion pleasant (read: working within limitations) so this should help retain the tone and detail coming from the pre-amp as it's intended to be heard.

In keeping with the miniature design, I'm using an external supply with 18v DC input to the amp. I can't be sure what the recipient of this amp (or anyone else) is going to plug into it so with that in mind I'm including an onboard reservoir capacitor and LM317 regulator to supply a clean 15v to both the BJT pre-amp and LM386 power amp(s). I've spent a lot of time studying hifi applications of this regulator and came across a wealth of information about its implementation, the key aspect (outwith the datasheet) being that it doesn't like low impedance caps on its output.

Here are a few things I brought back from my travels:
http://www.tnt-audio.com/clinica/regulators_noise1_e.html
http://www.tnt-audio.com/clinica/regulators2_impedance1_e.html
http://www.acoustica.org.uk/t/3pin_reg_notes1.html


Provisional regulated supply:



As you cans see the enclosure is built and there are considerations to be made for EMI suppression (it's a wooden box), heat management and how the amplifier is laid out in regards to supply/signal/ground wiring so these things don't start to wreak havoc on each other ...A lot to think about.

The first breadboarded amp worked well and sounded great (I did post a clip on another thread but at midnight volume levels, it wasn't very flattering).
I'm in the process of breadboarding the amp a second time to better resemble the layout of the finished thing, including a bridged pair of 386's so I can tweak the supply to suit.
A big part of this process is how to route the signal wires separate from the supply and output whilst squeezing it onto the board I've chosen to fit the enclosure.

There's a decent page here which goes some way in explaining how to lay out the supporting components for an IC amplifier, most of it can be extrapolated: https://www.edn.com/circuit-board-layout-guidelines-for-class-d-amplifiers/

I'll admit that using protoboard for the base isn't ideal but this is how I'm thinking of setting out each LM386 (hiding under the heatsink):




There's a 100nf decoupler right on the supply leg & the FG cap behind it is a 10uf bypass on pin 7 - I'll ground these on Row 23 and join that to the ground rail at the back. There I have another 10u decoupler across the rails. The big cap is the 220u output. The second (inverting) LM386 will go next to that one in the same layout, copy/pasted to rows 23-17. All the input signal and reference grounds are going to be kept separate on the near side of the board.
The pre-amp section is going far left, top and bottom banks probably with stage coupling caps bridging across the centre. Tone stack will end up in the middle somewhere. Control panel is located to the front of the board on the signal side of the power amps.

I was reluctant to use both adjacent +ve and -ve (ground) rails on each side (prefered to have one side dedicated to supply and one side to ground) but I think that would mean running flying leads all over, crossing over the signal path and such so it's maybe best just to join the rails at the bridging points and be mindful of where, on each 'U' rail, I connect the B+ supply from the regulator and the chassis ground. More on that later.


A few resources I've come across so far and thoroughly recommend absorbing as a pre-face to designing an amplifier (or a pedal):

www.valvewizard.co.uk - Just a big old tutorial on everything about designing an amp, it's great. The grounding and supply info is useful in this case.

www.electrosmash.com - Breakdown and analysis of all historically significant pedals, as well as the LM386 and assoiated amps. This site is A+ material - I'm really grateful to whoever is involved!

(More to be added)


I can't promise comprehensive updates as I go along but I'll at least try and talk to myself, noting anything particularly interesting or insightful.

The circuit design for the audio shaping part of the amplifier (ie. the pre-amp) is pretty much complete so this will be more of a 'bringing together' of concepts as a functioning amp. There is still much to do.


Cheers
...just riffing.

Rob Strand

I don't think I've ever seen such a pristine looking board.
Send:     . .- .-. - .... / - --- / --. --- .-. -
According to the water analogy of electricity, transistor leakage is caused by holes.

amptramp

I love pre-patterned boards like this and yours seems to be easy to lay out with the row and column numbers printed on the board.  The five rows of holes on each side of centre is a luxury I haven't had yet.  The proximity of supply rails makes it easy to get good decoupling.  This looks interesting - I will be following your progress as you continue your design and build.

iainpunk

#3
you can also use the LM386 as a class D power amp. and use another opamp as the modulator, a simple triangle wave oscillator and a comparator that compares the triangle with the audio signal. the comparator directly drives the 386.
you are still limited to 1W, and some voltage limiting should be applied to keep the chip from dying through over current, but it keeps the chip from getting hot, and it consumes less current overall. (no quiescent current anymore.)

i'd been looking at similar boards, and also different pasterns, but i am already committed to single hole per pad, since i accidentally bought 100 boards instead of 10... they were only 4 euro tho, so no big deal.

cheers, Iain
friendly reminder: all holes are positive and have negative weight, despite not being there.

cheers

Bunkey

#4
Quote from: Rob Strand on February 21, 2021, 03:17:45 AM
I don't think I've ever seen such a pristine looking board.
Quote from: iainpunk on February 21, 2021, 09:32:04 AM
i'd been looking at similar boards, and also different pasterns, but i am already committed to single hole per pad, since i accidentally bought 100 boards instead of 10... they were only 4 euro tho, so no big deal.
Quote from: amptramp on February 21, 2021, 09:07:16 AM
I love pre-patterned boards like this and yours seems to be easy to lay out with the row and column numbers printed on the board.  The five rows of holes on each side of centre is a luxury I haven't had yet.  The proximity of supply rails makes it easy to get good decoupling.

You should feel the weight in them!
The company is based in Seoul but I can only find them selling through amazon; £12 for a pack of 5 plus a mini board that I'm using as a base for the regulator assembly. I've contacted them to see if they'd consider selling the mini boards in black seperately as they're ideal for small pedals. The quality is so good. I have no complaints about using them for small scale production.




The trial-and-error prototyping I do on that solderless board, which saves me a lot in toasted components and is useful for hot-swapping components in A-B listening testing.


As for decoupling, I was worried about the proximity of the rails interfering with each other at first but maybe this isn't so much of an issue at 15v.

The +ve supply will be fed into that top corner of the board serving the power amps first, with the pre-amp BJTs drawing from further along the rail on the bottom side using their own decoupling caps. Similar to how a traditional guitar amp supply is set out, as can be seen on page 7 of this great resource: http://www.valvewizard.co.uk/Grounding.pdf

The ground will be taken from the opposite corner so the pre-amps are closest to the central ground point at the input jack.
The ground traces on the top side of the power section are for bypassing/filtering supply pins 6 & 7, the traces on the lower side are the unused input and reference ground pins 2/3 & 4. This should hopefully keep the more sensitive stuff grounded on the cleaner side of the board and the supply to the the pre-amp the most filtered, with the shortest supply distance to the heaviest current draw of the power amp section.


...just riffing.

iainpunk

Quotewhich saves me a lot in toasted components and is useful for hot-swapping components in A-B listening testing.
i don't like hot swapping, and don't recommend doing it, but i do it all the time. i try to swap luke-warm, (effect in bypass but power still connected) but i often forget to switch the bypass.

cheers, Iain
friendly reminder: all holes are positive and have negative weight, despite not being there.

cheers

Bunkey

Quote from: iainpunk on February 21, 2021, 12:22:32 PM
Quotewhich saves me a lot in toasted components and is useful for hot-swapping components in A-B listening testing.
i don't like hot swapping, and don't recommend doing it, but i do it all the time. i try to swap luke-warm, (effect in bypass but power still connected) but i often forget to switch the bypass.

cheers, Iain

Ah yes the perilous excitement of introducing a discharged reservoir capacitor to a live circuit  :icon_twisted:
...just riffing.

Bunkey

Hot swapping is a bit of a necessary evil at times..
The immediate auditory information that your brain processes (useful for making direct comparisons) has a risidual effect lasting about 10 or 20 seconds at best, after which you're only recalling a memory of the sound you heard - and that's about as good as guessing. It's a bit like having a small amount of RAM in front of a selective HDD; the RAM is the only true representation of the information going in but it's being constantly overwritten, especially by any unrelated sound or transient that ocurrs in the 20 second window between A and B.

- Just something I like to remind myself of any time I intend to do comparitive listening tests.
...just riffing.

Bunkey

#8
IC a potential issue here... (you see what I did there?)
It comes in the form of supply decoupling on the power amps.

The idea of decoupling is to provide a short reserve of energy for fast transients where the the rails can't keep up with the sudden change of current due to unavoidable impedance over the length of wire from the regulator.

As it is, the 100nf decoupling cap right on the supply pin is going to do a great job at providing a low impedance path for the positive side, but the negative side is routed to the power amp's ground right around the rail on outside of the board, incurring its own impedance along the way - as far as the chip is concerned this is like having series resistance in line with the decoupling cap, which defeats the purpose. However bad it is for the amp closest to the side of the board, it's even worse for the one in the middle as this ground path is twice the length




What I need to do to improve transient response and solve potential instability issues before they arise is ground the 100nf decoupling cap more like the drawing below; this makes for the least impedance possible as far as the chip is concerned. The 10uf decoupler across the rail I think will be fine where it is given that it's slower to react anyway (I guess that's why the 100nf is used too) and the relative impedance of the rail isn't going to affect it the same.





The 10uf pin 7 bypass cap (not shown here) I believe can stay where it is, grounded to that upper rail, as it's there simply to filter AC noise from the +ve supply as opposed to providing a short reserve of energy.

That's the difference between decoupling caps and bypass caps in a nutshell  :icon_cool:


PS. Where's RG and PRR - This is what you guys were eluding to in my audio cap esr thread isn't it? Thanks, I got there eventually :)
...just riffing.

R.G.

Yep, that's one way to describe what Paul and I were talking about.

When power amps (and all electronics, really) need power, they need it QUICKLY. wire and PCB traces have resistance and inductance, so the only way to get fast pulses of power to the chips is to have a "bucket" of charge right next to them - a capacitor across their power pins as close as possible. Big value capacitors have bigger ESL than smaller ones, so you often need a combination of high-value electrolytics and small, low-ESL capacitors to ensure read power when the chips need it.

Good work, and good self teaching!
R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

Bunkey

#10
So, I'm not really sure how densely I can populate the board before it turns into a noise generator   :-\

Any advice on this?

This is how I have the inverting and non-inverting bridge amplifiers placed side by side. The small caps are all decoupling/bypass, the big caps are the 220u blocking/filtering caps on each output.


...just riffing.

iainpunk

that looks allright, but i recommend sockets, in case you accidentally blow one of the IC's (i did that on my first IC amp build, oops)

cheers
friendly reminder: all holes are positive and have negative weight, despite not being there.

cheers

Bunkey

#12
Thanks.

We'll see about sockets; having it attached directly to the board should help to dissipate the heat better and it's one less mechanical interface in the the ground and signal paths.
I'm going to re-assemble it on the solderless board anyhow, so hopefully we can rule out the possibility of creating an incendiary device before it gets to this stage  :icon_razz:
...just riffing.

PRR

> attached directly to the board should help to dissipate the heat better

Audio power amp chips are available from 0.4W to 68W.

"Design" might mean not using 1/16" cable to suspend yourself over the alligator pool. Or not using the lamest chip and over-volting it to ignition.
  • SUPPORTER

Bunkey

You mean to tell me Paul that in all your wisdom you don't select components based on how cute they are in principle?  :o
...just riffing.

Bunkey

#15
Iain, your suggestion of manhattan style upright components is proving useful!




Looking forward to trimming these leads is all I can say..

I've used a few offcuts of old wire insulation to slip over the leads in key places, avoiding the problem of shorting things together before it gets tidied.
...just riffing.

marcelomd

Quote from: Bunkey on February 23, 2021, 12:24:46 PM
I've used a few offcuts of old wire insulation to slip over the leads in key places, avoiding the problem of shorting things together before it gets tidied.

Looks tidy enough for me =)

iainpunk

Quote from: iainpunk on February 21, 2021, 09:32:04 AM
you can also use the LM386 as a class D power amp. and use another opamp as the modulator, a simple triangle wave oscillator and a comparator that compares the triangle with the audio signal. the comparator directly drives the 386.
you are still limited to 1W, and some voltage limiting should be applied to keep the chip from dying through over current, but it keeps the chip from getting hot, and it consumes less current overall. (no quiescent current anymore.)

i'd been looking at similar boards, and also different pasterns, but i am already committed to single hole per pad, since i accidentally bought 100 boards instead of 10... they were only 4 euro tho, so no big deal.

cheers, Iain
i just realised that you can't actually use a LM386 as a class D audio amp, since its slew rate is way to low, the time i used the 386 as a pwm driver was when i was driving a motor at 2kHz... ignore my earlier post

that upright breadboarding looks super slick! my BB's generally look like a rats nest,,, haha

cheers
friendly reminder: all holes are positive and have negative weight, despite not being there.

cheers

antonis

Quote from: iainpunk on February 23, 2021, 04:39:47 PM
that upright breadboarding looks super slick!

And super non-uniform heat dissipation for vertically mounted resistors.. :icon_lol:
"I'm getting older while being taught all the time" Solon the Athenian..
"I don't mind  being taught all the time but I do mind a lot getting old" Antonis the Thessalonian..

Bunkey

#19
Heck! It's an amplifier..




I spent a bit of time refining and making a few observations this morning:


First and foremost: The power supply has a huge influence on the sound...

Volume maxed, I still had quite a bit of mains hum even with all the smoothing, decoupling and bypass capacitors; I don't think the ripple rejection of the IC's is really much to go on here.
I've added some series resistance to the transformer side of the regulator just before the reservoir capacitor using a pair of beefy 100ohm 2W metal oxide power resistors; one on the +ve line and one on the -ve (shouldn't have to worry about inrush current with these in place either). This did a lot to fix the hum but it's also brought out so much detail -
I said the same about the series resistance on the regulator output cap: it's as if the guitar isn't getting swallowed up by the supply any more.

The sound was quite a bit darker before, very focused around the mids, limited almost; I thought this was a trait of the diodes used in the pre-amp and quite easily could have made the mistake of trying to tweak the EQ to compensate when really the highs (and the lows) were just getting lost in the mud.

Making an effort to clean up the supply before it hits the regulator has resulted in the old 'opening a window' analogy - there's an air and presence about the sound now; the cabinet no longer sounds like a small box; I can almost hear the space around the strings, the plectrum, the resonance in the things I'm not playing; I just touch the thing and it sounds musical  :icon_lol: Even through these 4" speakers it's quite awesome and not something I've had the pleasure of playing before. A good way of describing this, as a guitarist, might be that it makes you want to play less notes and just enjoy the sound between them.

Based on this experimentation, I would say a clean supply is the trick to getting a crisp, clear top end & presence whilst still sounding warm and sweet; it's expanded the perceived bandwidth of the amplifier as a whole and definitely seems like the first thing to address before reaching for the tone control.


Right, waxed lyrical enough about that..




I've upped the reservoir cap to 4700u to account for the bridged pair of LM386's and parallelled this with a cap of a few hundred uF's. The response of this smaller cap has again brightened things up but I'm going to play around with it as the value affects the frequency it influences - 180u sounds good for now but a 220u or even up to a tenth of the big cap's value might blend a little better here and make the highs less peaky.

I'm going to try setting these LM386's to a slightly higher gain with a resistor & cap across pins 1 & 8 too, if I can avoid distortion.
Bridging them has added a sense of power, the amp handles itself better and it's brought the clean volume level up to something appropriate, but the sound projecting from the cabinet doesn't seem that much louder than it did with a single LM386 - a nice volume but not quite what I imagined it would be. Maybe there's some mechanical dampening at the speaker end which limits the output to an extent, or something, I don't think these are the most efficient speakers, but I'll see if I can squeeze a bit more from this configuration and save the LM380's for a bigger build.
...just riffing.