Pages: [1]   Go Down
Author Topic: Arduino DAC  (Read 3411 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi all,
  I'm new to the forum and I have a question about using an Arduino Uno as a digital to analog converter to use for listening to .MP3's or .WAV files. I know there are shields available to do this, but I wanted to use the Uno to do the actual conversion itself, so I can listen to music through it. Can anyone point me in the right direction? I have also made an 8-bit R-2R ladder DAC to create a simple sine wave, but I want to be able to stream an 8-bit audio file and in the future an actual high fidelity audio file. Any help is greatly appreciated. Thanks.
  Hevle
Logged

Offline Offline
Edison Member
*
Karma: 22
Posts: 1164
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The Arduino does not have a DAC.   It has a 10-bit ADC with multiple inputs. And, it has 8-bit PWM outputs which can substitue for analog output for some applications.  But, it won't work for good-quality voice or music. 
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 508
Posts: 31429
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The arduino will not be able to read MP3 files, it does not have enough memory and is too slow to decode them in real time.
However WAV files are possible. But 8 bits is not very good. If you made it yourself I would be surprised if it is true 8 bits, that is I don't think you will have monoticity.

Anyway look at the LadaAda wave shield for examples of how to read from an SD card. What do you expect to stream the audio data from?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have an audio cd that is 8 bit music, and I can rip it to my pc in .WAV format. I have seen the SD shields, and I think that would be a good place to put the audio file since the arduino memory is so small. I was hoping to be able to have the audio input over a serial connection from the pc. This is also just a first attempt at this project. The audio codec shields and DAC shields would probably work perfectly, but I was hoping to figure out how a high end DAC works and implement a simple one of my own.
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 508
Posts: 31429
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

It uses R 2R ladder, but you can't make one yourself unless you have the capacity to make resistors with incredaably well matched values. Do the math, but I think you need 0.1% matching for an 8 bit converter.
If you have 8  bit audio samples then you can simply strewn them from the serial port but the sample rate has to match exactly the rate you can transfer data.
Logged

Offline Offline
Jr. Member
**
Karma: 6
Posts: 73
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi, I did very long research efforts on how to get good audio out of Arduino. It will be at least close to Hifi. This are the three secrets:

1. Use PWM with  only 8-Bit but highest frequency: You can achive sample rates up to 62.500Hz which is very good and often you don't need a low-pass filter anymore. Believe me, even 8-Bit with 31kHz sounds better than 16-Bit with 11kHz.

2. To get high resolution the best way is to use an R-256R network to combine two 8-bit pwm outputs to one 16-bit output.

3. Arduino sounds only as good as its supply voltage. And Ardu's supply is often very noisy due noise from AVR itself and noise coming from USB supply. You can clean noisy PWM signals by running them through a Schmitt-Trigger that has a better filtered supply.

Here is the circuit that I actually use with impressive results: http://hackerspace-ffm.de/wiki/index.php?title=Datei:SSDA_Better16bit.png

I think I really should do a video on that for all non-believers...

Tuttut
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 508
Posts: 31429
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

That is a very simplistic view of digital sound.
How accurate is your R-256R ratio? You are fooling yourself if you think that gives you 16 bit resolution. There will be no monoticity.
I do not doubt that the results sound alright but they will be no where near to the quality of a true 16 bit system.
Logged

Offline Offline
Jr. Member
**
Karma: 6
Posts: 73
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I simply you a trimmer as one part of that voltage divider. I trim it just by listening to the sound. Therefore I play a low volume audio part and adjust the trimmer to minimum audible noise. Of course, that DAC never reaches true 16 bit, but there is still a big audible improvement over 8 bit, that is especially audible on lower volume parts or if something fades out. Remember: It is made with simplicity in mind - one resistor and one pot and that's it.
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 508
Posts: 31429
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I trim it just by listening to the sound. Therefore I play a low volume audio part and adjust the trimmer to minimum audible noise
Fair enough.
Quote
Of course, that DAC never reaches true 16 bit
Yes that's right.

There are two main causes of noise in a digital audio system, one is quantization noise of the amplitude of the signal, and the other is the noise introduced by the quantization of time or sampling period. By over sampling you can cut down the latter but the former is down to the number of bits on the D/A I got very good results in the 70s with 13 bit converters, which in those days cost the same as three months research grant.

The best titled academic paper I read during my lit search was:-
The effects of alcohol on perceived quantization noise.

Which surprise surprise concluded that the more alcohol you gave some on the less they noticed quantization noise.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 29
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I trim it just by listening to the sound. Therefore I play a low volume audio part and adjust the trimmer to minimum audible noise
Fair enough.
Quote
Of course, that DAC never reaches true 16 bit
Yes that's right.

There are two main causes of noise in a digital audio system, one is quantization noise of the amplitude of the signal, and the other is the noise introduced by the quantization of time or sampling period. By over sampling you can cut down the latter but the former is down to the number of bits on the D/A I got very good results in the 70s with 13 bit converters, which in those days cost the same as three months research grant.

The best titled academic paper I read during my lit search was:-
The effects of alcohol on perceived quantization noise.

Which surprise surprise concluded that the more alcohol you gave some on the less they noticed quantization noise.

Where can we find the academic paper:
The effects of alcohol on perceived quantization noise
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 29
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The newest Due board supports DAC out audio. Could you test it? The Due is compatible wtih ADK 2012.
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 508
Posts: 31429
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Where can we find the academic paper:
The effects of alcohol on perceived quantization noise
It was in the American Journal of Audiology, I saw it in my university libary in 1974 in a bound volume so it was some years before that.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 29
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Where can we find the academic paper:
The effects of alcohol on perceived quantization noise
It was in the American Journal of Audiology, I saw it in my university libary in 1974 in a bound volume so it was some years before that.
So we can't find it in internet. or can we get a soft copy?
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 508
Posts: 31429
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

So we can't find it in internet. or can we get a soft copy?
I have no idea but probably not, not everything is on the internet you know especially 60s / 70s research papers.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for all of the input guys. I think I am going to try to implement a simple DAC using an FGPA board, but I haven't given up on the Arduino! I recently purchased the WAV shield for the Arduino that comes with a 10-bit DAC. For the Arduino project itself, I am going to try to make a basic audio player, much like an MP3 player with it. If anyone knows any more on the topic I would love to hear it, and I will post updates on my progress. Thanks again!
Logged

Pages: [1]   Go Up
Jump to: