Re: Generating sound at microcontroller pin using pwm



On May 15, 12:20 am, Rohit <papakap...@xxxxxxxxx> 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
.



Relevant Pages

  • Re: can anyone recommend me a microcontroller
    ... and PWM also but not much of anything else.... ... low power would be great but ADC and DAC are the main things I'm looking ... instruction set that is small but is a very good fit with C -- it also ... Need to learn how to apply control theory in your embedded system? ...
    (comp.arch.embedded)
  • Re: can anyone recommend me a microcontroller
    ... I'm in need of a small microcontroller that has ADC and DAC capabilities ... and PWM also but not much of anything else.... ... instruction set that is small but is a very good fit with C -- it also ...
    (comp.arch.embedded)
  • Re: Wieviele Bits netto aus ATMega PWM DAC?
    ... Hab' ich ehrlich gesagt nie probiert, ich finde die Programmierung des PWM ziemlich unerfreulich und wenn du gute DC Performance brauchst erscheint mir ein externer DAC immer besser geeignet. ... Ok, wenn SPI schon drin ist geht das ohne viel Bit-Banging Aufwand, aber beim PWM ist nur ein Register zu beschreiben. ...
    (de.sci.electronics)
  • Re: Filter to use PWM signal as DAC?
    ... I am wondering if there is a simple circuit I can use to ... > convert the PWM output to an analog DC voltage. ... > Can anyone tell me specifically what type of filter I need, ... Also see the two-wire, serial, 8-bit DAC also at that location if speed is not ...
    (sci.electronics.design)
  • Re: PWM in a digital control loop
    ... like yielding what a sigma-delta would, however being forced to do it ... so I was thinking of using 16-bit PWM from a microcontroller. ... For example, if full power is at 50% duty cycle, and I want to ... PWM-powered things are generally quite linear. ...
    (sci.electronics.design)