Driving a 8 Ohm speaker from a 3.3V sine wave (biased +3.3/2) - Page 1
Forum section: electronics / projects

author: NivagSwerdna
author_rank: Super Contributor
timestamp: January 06, 2023, 06:57:56 pm
content: OK... so I am a total newbie at this analog stuff...I have a circuit I would like to adapt which has an existing PCB mounted 8 ohm speaker (AST-03208MR-R) driven by a BC817-25 transistor; these already exist and I would like to re-use them...The uP driving this is a ESP32 and is capable of generating a cosine wave 3.3V (ish) peak to peak in the range 0-3.3VI'm not really sure what I am doing... but I randomly played with a voltage divider for bias and a coupling capacitor and there seems to be a transfer to the speaker.Does this look reasonable? (Yellow parts are existing)If I wanted to control the volume (using a small pot)... where would I put it?Thanks in advance

author: ledtester
author_rank: Super Contributor
timestamp: January 06, 2023, 07:23:57 pm
content: I would use a small amplifier board like this one:https://www.adafruit.com/product/2130Also see:https://learn.adafruit.com/adafruit-pam8302-mono-2-5w-class-d-audio-amplifier/pinoutsfor more information about how it works and how to use it.Here's video on playing .wav files with a ESP32 + PAM8302.https://youtu.be/SCAKQsGt9wIIt uses this audio library:https://www.xtronical.com/the-dacaudio-library-download-and-installation/

author: NivagSwerdna
author_rank: Super Contributor
timestamp: January 06, 2023, 08:02:10 pm
content: I was tempted to say that was overkill but now I'm not so sure!I've been looking through the interweb and seeing that in the common collector output I have the majority of designs have the speaker capacitively coupled with a resistor to ground which is definitely not what the existing circuit has.I don't need amazing frequency response... but I am after a nice clear 700Hz (ish) tone.

author: Benta
author_rank: Super Contributor
timestamp: January 06, 2023, 09:42:55 pm
content: Is this driven by the ESP32 DAC or the PWM?

author: NivagSwerdna
author_rank: Super Contributor
timestamp: January 07, 2023, 12:37:18 am
content: By the DAC

author: Swainster
author_rank: Frequent Contributor
timestamp: January 07, 2023, 10:20:07 am
content: The way you have it hooked up is more like driving an electromagnetic buzzer than a speaker. To avoid damaging the speaker and to improve the sound, using a single transistor, then you are probably stuck with a class A amplifier I.e. you need to add a low value resistor where the speaker is, and use a large coupling capacitor from the output to the speaker... that said, i dont think it will be very loud so I'd use an MC34119 or one of it's clones

author: CaptDon
author_rank: Super Contributor
timestamp: January 07, 2023, 01:38:29 pm
content: I haven't looked up the specs on the MC34119 but what you want is an I.C. (or circuit) that operates in a 'bridged' mode. Your speaker would not be referenced to supply or ground and there would be no need for a coupling capacitor. At idle both sides of the speaker are at B+/2 or half your supply voltage. In the bridge mode amplifier you have two amplifiers with one being driven by an inverted signal. this would allow one side of the speaker to go fully to the supply voltage and one side to go fully to ground (or negative rail) and then shift to the opposite polarity on the other half of the sine wave. Many Pro Audio amplifiers use this technology. This type of circuit could add 3 to 6 Db of sound pressure level over a single channel single ended amplifier. One problem I see is your 3.3vdc being so low it may be hard to find a bridge amplifier I.C. to work at that voltage. Best wishes!!! Audio stuff is fun and the test instruments needed for audio work can definitely be at the low end of the cost spectrum.

author: Terry Bites
author_rank: Super Contributor
timestamp: January 08, 2023, 05:05:02 pm
content: Cosine drive, very star trek if I may say so.Try this cheap and nasty amp you might get 50mW :3V will overdrive it so you have to use R1, R2 to attenuate the signal. Experiment.The transistor (any 100mA+ npn) will need a clip on heatsink.

author: Swainster
author_rank: Frequent Contributor
timestamp: January 08, 2023, 05:10:52 pm
content: Indeed CaptDon, those are the exact reasons I suggested the MC34119... of course, that also dates me a bit. These days a class D would probably be the go to solution.A 'few' years back I used to work for a company which made POTS CPE equipment I.e. Land line phones. The MC34119 was popular for use in line powered speakerphone applications because it could still drive a speaker at the end of a long loop.

author: NivagSwerdna
author_rank: Super Contributor
timestamp: January 08, 2023, 08:27:55 pm
content: Quote from: Terry Bites on January 08, 2023, 05:05:02 pmPeople used to use sine waves but it was just a phase they were going through.ESP32 has hardware "Cosine Waveform Generator"

author: RogerThat
author_rank: Regular Contributor
timestamp: January 10, 2023, 10:26:46 pm
content: I've just built something that you are looking for. It is a class b push-pull,https://en.wikipedia.org/wiki/Push–pull_output.It consist of one npn on top of a pnp(3604, 3906). Speaker(load) is driven thru a capacitor to avoid current flowing when there is no signal. The op amp + input is biased at mid voltage and driven via a capacitor from the sine source.My volume control is a digital pot between the uP and the input capacitor to the op amp.Power consumption is good and price is low.EDIT: the 3604 and 3904 might not be the best bjt to use, the Vsat limits the useful output voltage...and they are also just 100mA.

author: james_s
author_rank: Super Contributor
timestamp: January 10, 2023, 10:45:29 pm
content: That's a weird way to drive a speaker, it almost looks like a class A amplifier but not quite.This is how it would normally be done with a single transistor:https://www.electronics-tutorials.ws/amplifier/amp_5.htmlI would probably be looking at class B or AB, or just use an IC like the LM386. The latter is super simple, just a few external passives, capacitor couple the input and you're done.

author: Terry Bites
author_rank: Super Contributor
timestamp: January 11, 2023, 08:33:57 am
content: You're going off on a tangent...aaagain!Snort snort chuckle.

author: DavidAlfa
author_rank: Super Contributor
timestamp: January 11, 2023, 12:18:05 pm
content: If you only want to make buzzing / alarm noises without any concern about quality, will be fine for a few milliwatts.You can't really push any real power with that transistor.Speakers need to be driven by push-pull, that circuit only pushes, so with higher power it would probably damage the speaker, will reach the membrane limits and cause mechanical distortion, putting a lot of stress (Also sounding terrible).You have really cheap class-h drivers at AliExpress in soic-8 packages capable of 0.5-1W.There're npn push-pull circuits, but I'm not familiar at designing or calculating them (To me it looks like it's going to have a lot of cross-conduction):source

author: Zero999
author_rank: Super Contributor
timestamp: January 11, 2023, 10:35:28 pm
content: There will always be a bit of voltage loss in the output stage.I had a play with LTSpice. This will have a bit of cross-over distortion, but probably okay for a basic tone.Through habit I selected capacitors for operation down to 20Hz, you might want to go smaller.

author: NivagSwerdna
author_rank: Super Contributor
timestamp: January 12, 2023, 11:57:30 am
content: Quote from: DavidAlfa on January 11, 2023, 12:18:05 pmActually the requirement is to make a "nice" 700Hz intermittent sine wave which has exponential smoothing when it is turned on and off.. think... dits and dahs!I appreciate your reference... John Laurence Linsley-Hood was a colleague of my father's back in the day; an inspiration to those who worked with him... especially my dad!

author: james_s
author_rank: Super Contributor
timestamp: January 12, 2023, 06:41:48 pm
content: The easiest solution to reach that goal is probably a LM386 or similar part. Otherwise build a small class AB amplifier with discrete transistors, it's pretty simple. If you don't care about efficiency, class A is even simpler.