EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

Generating sound at microcontroller pin using pwm

Started by Rohit May 13, 2009
On Thu, 14 May 2009 08:32:06 -0500, Vladimir Vassilevsky
<antispam_bogus@hotmail.com> wrote:

>Rohit wrote: > >> On May 14, 4:37 am, Vladimir Vassilevsky <antispam_bo...@hotmail.com> >> wrote: > >>>For gunshots, blasts and such, generate the stream of random numbers and >>>apply rapid attack - slow decay envelope to it. >> >> I do not understand this. could you please explain the process to do >> this. I do not want to use a DAC. > >You got the general directions. However I am solving other people design >problems as the business. If you want me to work on the project, the >contact is at the web site.
I'm frustrated that the OP didn't take your comments further before asking that question, but this comment from you also makes me think this is the primary reason you post. It wouldn't have been hard to go another inch or two for the OP. To each their own. Jon
On May 15, 12:20=A0am, Rohit <papakap...@gmail.com> wrote:
> > I do not understand this. could you please explain the process to do > this. I do not want to use a DAC. > Can i implement what you are suggesting with just pwm? Currently I am > generating square waves of 50% duty cycle > with different frequencies to produce different notes of keyboard.Do > you mean i must also vary duty cycle of the pulses.
You seem confused on what PWM is - you claimed to be using it, then state here that you always use 50% ?. If you want to vary the amplitude, you need other than 50% - Varying the duty cycle is a cheap way to vary the energy, but it does also affect the spectrum - if you want to preserve harmonic shape, then you need an external means of Amplitude control. In a simple uC, you could use one PWM as a slower DAC for envelope shape, and a 2nd PWM driving an external SPCO Analog switch, to give frequency control. Or, you can just move up in frequency, and use single PWM as a faster DAC, and use the uC to 'play back' a recorded waveshape. That will give the best sound-effect quality by far, and large flash memory really is cheap. -jg

The 2024 Embedded Online Conference