PWM sound effect for embedded MCU

May 23, 2016 8 Replies

I need to generate sounds using a piezoelectric buzzer for my embedded MCU.



Anybody know of some form of sound library on the net that has different sound effects using PWM?



I need to generate button press sounds and some kind of alarm sounds. Reply correct input with some kind of happy sound and error input with a sad sound :-)



A piezoelectric buzzer is ill suited to reproducing sounds of many kinds, due to its narrow resonance band. The situation does not change by feeding badly suitable PWM to it.

About the only way to produce messages with it is some kind of Morse code.

-TV

I agree with your response but I wonder if it might be possible to craft a heavily modified (or not) source audio file (like a voice command) that will sound acceptable on a piezo buzzer.

JJS

Any sound that could be produced will sound very tinny with the characteristic frequency of the element overwhelming. In addition, the high Q of the buzzer element makes all sounds start and end slowly.

-TV

Do you have a choice in the transducer being used? I.e., MUST it be a piezo? (You'd have more flexibility with a small speaker)

I think you're going to end up with beeps (at the piezo's fundamental frequency) of various cadences: beeeeeeeeep! beep beep beep beep beep beeeeeeep etc. A piezo is really only good at "getting attention", not conveying information.

I think it's doable. A rising tone for happy and a falling tone for sad.

There was an ancient DOS golf game which used the PC piezo sounder to generate speech commentary and other sounds using PWM. It was tinny, but perfectly understandable.

Cheers

Syd

The PC sounder was not a piezo, but a small speaker connected to the timer chip output.

You can produce rough but understandable sound from a speaker with single bit feed by feeding it with fast enough PWM or sigma-delta.

-TV

You're right, I stand corrected.

Cheers

Syd

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required