Atmega168 to generate sound

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Freaks,

I want to use the M168 to generate some music on the speaker. I did search the forums for this and found this thread:

[url]
https://www.avrfreaks.net/index.p...
[/url]

In this thread, dbvanhorn mentions that it is easier to store the samples and then clock them through R-2R ladder DAC.

Is there any more information on this? Is this approach better than using the PWM + filter approach? Which R-2R DAC would be suitable for this app.? I saw an AD558TD from Analog devices but would it be easier going discrete than a single chip?

I want to start with playback of stored samples in the AVR (look up table) and then proceed towards making my own samples and looping through a fixed set of samples.

Thanks.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

PWM and filter can be 9 or 10 bits. R2R needs real good Rs to be 8 bits. So the difference is a little better sound quality in the pwm-filter version, and a dozen fewer external components to hook up.

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

dbvanhorn might even mean to simply attach an R-2R-ladder to an AVR port. I guess some kind of filter would be needed on the output of this.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

There is no point using more than 8-bits of R2R discrete resistors. You would need 0.1% resistors anyway, and you can get 8 or maybe 10 bit R2R networks in single package.

Besides anything over 10 bits means you have to use two IO ports and you can only change 1 IO port signals at the same clock cycle, so changing 2 IO port signals may not be optimal. Unless you really need the levels, and can tolerate the ripple when changing.

Then there are these DAC chips. They can have R2R conversion or something else, and they can have parallel bus or something else like SPI.

All these require the actual components, while with PWM all you need is the filter, which you may need anyway with other ways of producing sound.

And of course you need an amplifier to drive the speaker. On many occasions, driving a FET with PWM pin is good enough, and then drive the speaker directly with the FET.