Basic DAC and Audio amplifier for RP2040 microcontroller

Thread Starter

k1ng 1337

Joined Sep 11, 2020
911
Hi I'm building a speaker driver for an alarm clock project. The problem I am having is I cannot get the audio loud enough. I have tried LM386, active op amp first order amplifiers and discrete class A and B amplifiers. I was able to boost the volume a bit but nowhere loud enough to fill a room. At best the volume is about double that of a direct unfiltered connection to the microcontroller which is barely audible.

The circuit is RP2040 (Pi Pico) running CircuitPython with the default .WAV sketch here:

CircuitPython Audio Out | CircuitPython Essentials | Adafruit Learning System

The speaker is a piezo buzzer salvaged from a multimeter. I have tested the device and it is functional across the audible spectrum with reasonable room filling volume at the desired frequencies (100-10000) using the 3.3V PWM driver of the microcontroller. I suspect the issue is no DAC on the Pico with my attempts to filter and boost the audio signal being out of range. I figured the problem might be the piezo so I tried an 8ohm speaker and managed to destroy it. The original plan was to use the piezo to save space so I'd like to try to make this setup work or at least understand why it does not. I'm happy to provide more information, thanks.
 
Last edited:

MrChips

Joined Oct 2, 2009
30,488
A piezo buzzer is going to produce very lousy audio.

There are two kinds of piezo devices, (a) a passive piezo-electric transducer and (b) an active piezo buzzer that outputs a single frequency or noisy harmonics.
 

Thread Starter

k1ng 1337

Joined Sep 11, 2020
911
A piezo buzzer is going to produce very lousy audio.

There are two kinds of piezo devices, (a) a passive piezo-electric transducer and (b) an active piezo buzzer that outputs a single frequency or noisy harmonics.
I'm certain it is A and I forgot to add that I don't care much about audio quality as I'm going for a robot theme. I just need VOLUME!
 

Audioguru again

Joined Oct 21, 2019
6,610
A piezo is a squeaker, not a speaker. Maybe your "robot theme" has a voice that uses frequencies that are too low than the squeak sounds from a piezo.
 

Thread Starter

k1ng 1337

Joined Sep 11, 2020
911
A piezo is a squeaker, not a speaker. Maybe your "robot theme" has a voice that uses frequencies that are too low than the squeak sounds from a piezo.
I had the same problem with the 8ohm speaker before I wrecked it, the volume was low. Maybe it's a problem with the microcontroller but the piezo sounded fine when I played a square wave from the same pin using PWM at 100-25000Hz plus it is listed as a supported device. I was surprised that it worked through almost the whole audible spectrum so I don't think the squeaker is the issue and even if it is a squeaker, I can shift the frequency of the clip in Audacity. I'm just looking for a basic circuit with some values I can work with. I'll buy another speaker if I have too but the project doesn't really need it.

The sound clips I'm recording are my voice saying the time like a phone operator: "The time is:" - "Seven" - "Fourty" - "Five". Nothing fancy required.
 
Last edited:

MisterBill2

Joined Jan 23, 2018
17,814
I am currently also investigating how to increase the volume of a piezo sounder for an alarm clock. But mine is an actual alarm clock, not a micro programmed as an alarm clock.
The problem is that in addition to the AC to drive the piezo sounder there is also a large DC bias, 9 volts in my case. The DC into an amplifier will certainly fry a speaker at the output.
 

Audioguru again

Joined Oct 21, 2019
6,610
The piezo is a capacitor then the 9VDC bias has no effect on it.
An 8 ohms speaker in series with a 470uF capacitor (with the proper polarity) will probably overload and burn out the piezo driver circuit.
Add a real loudspeaker with a series coupling capacitor as above, an audio amplifier and a power supply for the amplifier.
 

Ian0

Joined Aug 7, 2020
9,503
Output the audio as PWM and drive the loudspeaker directly using a MIC4428. That will drive it with double the supply voltage.
 

Audioguru again

Joined Oct 21, 2019
6,610
A piezo transducer does not care if it is fed DC because it is a capacitor.
A real speaker must NEVER be fed DC so it is fed AC from a series coupling capacitor that blocks the DC.
 

Thread Starter

k1ng 1337

Joined Sep 11, 2020
911
Turns out the audio clips I've been trying needed to be significantly amplified with Audacity. I'm now getting good volume with a direct connection to the microcontroller. There is severe distortion at low frequencies but the audible spectrum is audible. The odd part is any attempt to filter and amplify the drive signal resulted in 90-100% attenuation at the output. A plausible explanation is the capacitive effect of the piezo element on the rest of the circuit whereas a speaker appears inductive. I also think I fried my speaker giving it a large DC bias wagering the devices were theoretically interchangeable. I learned a lot from these experiments.
 
Last edited:

Thread Starter

k1ng 1337

Joined Sep 11, 2020
911
A piezo transducer does not produce medium and low frequencies. The severe distortion you hear are the higher frequency distortion harmonics.
Why then are 100-10000Hz square waves audible? The distortion was not preset until I amplified the .WAV files in software. Is it not more accurate to say there is increasing attenuation as we get away from the resonant frequency determined by the dimensions of the crystal / plate? If this is the case, the least amount attenuation for the same voltage drive signal occurred around 10-15k.

IMG_20231024_165043170.jpg
 

Audioguru again

Joined Oct 21, 2019
6,610
The frequency response of a fairly good speaker is almost a straight line from a low frequency to a high frequency.

Squarewaves are made from a fundamental sinewave low frequency that you might not hear plus many louder higher frequency harmonic frequencies.

Here is a graph of the frequency response of a typical piezo transducer in its small enclosure. It produces NO low and medium frequencies and but has four loud very narrow high frequency resonances. A piezo is usually used with a high frequency oscillator
to produce warning beeping at its loudest resonant frequency.
 

Attachments

MisterBill2

Joined Jan 23, 2018
17,814
Getting much more sound out of the piezo alarm in my alarm clock has been a goal for some time. Nothing simple and obvious has popped into my mind yet. (not intending to hijack the thread, folks!)
 

Thread Starter

k1ng 1337

Joined Sep 11, 2020
911
The frequency response of a fairly good speaker is almost a straight line from a low frequency to a high frequency.

Squarewaves are made from a fundamental sinewave low frequency that you might not hear plus many louder higher frequency harmonic frequencies.

Here is a graph of the frequency response of a typical piezo transducer in its small enclosure. It produces NO low and medium frequencies and but has four loud very narrow high frequency resonances. A piezo is usually used with a high frequency oscillator
to produce warning beeping at its loudest resonant frequency.
I'll chew on the graph but I'm still confused as to why you maintain it produces no low-med frequencies. I'm seeing three band stop regions in the audible spectrum with a bandwidth of a few thousand Hz each between sharp slopes. This means the bands on either side of the slopes aren't cut as much which must be why I have some response 100-20000 Hz. My disc measures 20mm and the quantity on the Y axis is new to me so maybe I'm missing something.

Getting much more sound out of the piezo alarm in my alarm clock has been a goal for some time. Nothing simple and obvious has popped into my mind yet. (not intending to hijack the thread, folks!)
Hijacking my threads is impossible. What progress have you made? I got interested in piezo elements after building quartz timing circuits.
 
Last edited:

MisterBill2

Joined Jan 23, 2018
17,814
So far I have found that the drive includes a large DC component which does not help produce any sound, and that the elements are not mounted in anything close to a resonant enclosure. Also, the mounts include a lot of glue and so any adjustment takes a whole lot of effort. AND, it seems that all of my digital alarm clocks investigated thus far include very small power transformers, so additional power may not be available.
 

Ian0

Joined Aug 7, 2020
9,503
So far I have found that the drive includes a large DC component which does not help produce any sound, and that the elements are not mounted in anything close to a resonant enclosure. Also, the mounts include a lot of glue and so any adjustment takes a whole lot of effort. AND, it seems that all of my digital alarm clocks investigated thus far include very small power transformers, so additional power may not be available.
You need to build a horn:
http://www.p10hifi.net/planet10/TLS/downloads/Dinsdale-Horns-3parts.pdf
it might need to be as big as the room.
 
Top