answers to your points above:
0. in needs to go to L_IN, at the solder pad, which is what it looks like you have. this bypasses the analog high-pass filter. you also need to set ADCHPD 1 in the code, which the example above does. this shuts off the digital high-pass filter on the codec.
1. with the code above, you no longer use loop(), so this shouldnt be a problem. the ISR is called automatically, at a rate set by SAMPLE_RATE. i would reccomend setting SAMPLE_RATE to the lowest value you can get away with. this will give you maximum processing time.
2. the codec on the shield can theoretically go to 24bit, but the noise level in the codec isnt much better than 16b, and your signal will probably not be any better than that as well, so to go to 24b would just make things more complicated for very little gain. also, the codecshield library isnt setup to handle 24b numbers. so some new functions would need to be written.
1. the values are int because they are 16b signed numbers coming out of the codec. that is how the codec produces the data
2. the ADC that is being referred to in the read_me is on the arduino, not the codec. so the arduino ADC is limited to 10b, but the codec ADC is 16b.
3. i would reccomend using the interrupt, as it will keep the timing better, give more processing time, and you wont have to worry if your variables are getting clobbered during the interrupt. the interrupt is required for the codec to operate. if you need to do some things in the main loop, let me know, and i can help with that. it is a bit complicated, as you need to declare some variables volatile, and then disable interrupts while certain variables are being altered. its a bit of a pain, and should be avoided.
- It is currently Tue Jun 28, 2022 1:57 am • All times are UTC - 8 hours [ DST ]
DAC in Audio Codec Shield
23 posts
• Page 2 of 3 • 1, 2, 3
Re: DAC in Audio Codec Shield
digitalwrite() takes a really long time.
in setup() put this line:
DDRD |= 0x4; // sets pin2 to output
then replace digitalwrite with:
PORTD = (PORTD & 0x04) ^ PORTD; // toggles pin2
in setup() put this line:
DDRD |= 0x4; // sets pin2 to output
then replace digitalwrite with:
PORTD = (PORTD & 0x04) ^ PORTD; // toggles pin2
- guest
- Site Admin
- Posts: 449
- Joined: Thu May 20, 2010 11:58 pm
Re: DAC in Audio Codec Shield
audiocodec_init() kills the delay timer. the codec needs to be run at a very consistent timing interval, or it stops sending data, and the delay timer messes with this. so you cant use delay(). this is also why audiocodec_data() needs to be in the ISR. another thing, is that variables altered in the ISR need to be declared as "volatile", otherwise the compiler doesnt know its being changed. this is probably the main thing thats causing trouble.
- guest
- Site Admin
- Posts: 449
- Joined: Thu May 20, 2010 11:58 pm
Re: DAC in Audio Codec Shield
Hi,
I would like to use the ADC on the board and also the DAC, similarly to what has been here reported. The problem that I am facing is that I am not able to read signals from 0 to 3.3 V but rather from 250 mV to 3V. Any ideas why? and how to solve this?
I do not see why I can't read signals below 250mV if the resolution should be more than enough (16 bits)
Thanks for your time.
I would like to use the ADC on the board and also the DAC, similarly to what has been here reported. The problem that I am facing is that I am not able to read signals from 0 to 3.3 V but rather from 250 mV to 3V. Any ideas why? and how to solve this?
I do not see why I can't read signals below 250mV if the resolution should be more than enough (16 bits)
Thanks for your time.
- liner
- Posts: 6
- Joined: Fri Jun 29, 2012 2:11 am
Re: DAC in Audio Codec Shield
interesting. ive never measured the actual DC input range of the DAC or ADC. it might be that the internal opamps are not rail-to-rail, so those last values are truncated. it might be possible to reduce your input signal, so that a 0-3.3V signal gets shrunk to 1v-2.5v or so, and therefore fits in the range.
what is your test setup? how are you applying the singal, measuring the input voltage, and measuring the output values?
what is your test setup? how are you applying the singal, measuring the input voltage, and measuring the output values?
- guest
- Site Admin
- Posts: 449
- Joined: Thu May 20, 2010 11:58 pm
Re: DAC in Audio Codec Shield
Hi,
Thanks for your answer. Do you have any suggestions in doing that shrink on my input signal?
In a summary, I would like to have an analogue input, read it and according to it adjust the output signal from the DAC. So, what I have done so far is to read the analog signal using the IN pins provided by the Audio Codec Shield and if the voltage is below 250 mV the read value is always the same. Only when going above 250 mV it starts to change.
Thanks for your answer. Do you have any suggestions in doing that shrink on my input signal?
In a summary, I would like to have an analogue input, read it and according to it adjust the output signal from the DAC. So, what I have done so far is to read the analog signal using the IN pins provided by the Audio Codec Shield and if the voltage is below 250 mV the read value is always the same. Only when going above 250 mV it starts to change.
- liner
- Posts: 6
- Joined: Fri Jun 29, 2012 2:11 am
23 posts
• Page 2 of 3 • 1, 2, 3
Who is online
Users browsing this forum: No registered users and 2 guests