Arduino Forum

Using Arduino => Audio => Topic started by: Byte3 on Oct 24, 2019, 01:34 pm

Title: playing wav's on through a r2r 8 bit DAC
Post by: Byte3 on Oct 24, 2019, 01:34 pm
Hi all,

I have made a R2R Ladder 8-bit DAC and it operates okay. I'm looking for advice on how to play wav files through it. I have a sd-card reader hooked up. I'm looking to do it from scratch, unless there is an easy library already out there, I can't find it, I don't wanna buy a pre-built thing right now if I can code it from scratch.
Title: Re: playing wav's on through a r2r 8 bit DAC
Post by: Byte3 on Oct 24, 2019, 03:16 pm
I found a search has helped: https://forum.arduino.cc/index.php?topic=344846.0
Title: Re: playing wav's on through a r2r 8 bit DAC
Post by: Grumpy_Mike on Oct 25, 2019, 06:13 am
Quote
I have made a R2R Ladder 8-bit DAC and it operates okay.
You sure of that? You can't make one using 1% resistors you know. The problem will be the lack of monotonicity.
This means it will not be "true" 8 bit audio but worse than that.
Title: Re: playing wav's on through a r2r 8 bit DAC
Post by: Byte3 on Oct 25, 2019, 12:42 pm
Thanks Mike,


Quite right I wasn't sure. I have chosen to save myself some time and buy a pre-made 16 bit stereo wav all in one thingymagic.
Title: Re: playing wav's on through a r2r 8 bit DAC
Post by: Lucario448 on Nov 01, 2019, 12:23 am
If quality isn't an issue, then I would do something similar as TMRpcm does:


I know this sounds like a lot of work to do, but I couldn't just say reuse the TMRpcm library because it requires an effort on modifying it anyways.



PD: remember to arrange the ladder to the pins 0 to 7 (being the last one the MSB), a direct "port write" will set the state of all these 8 pins at once, also avoiding signal "glitches" in the way.

Also remember that the output has a quite high impedance; so to drive a speaker you need some sort of amplification.