I have implemented mic input reader using a Arduino Due board for my DSP project. I configured ADC by using SAM libraries to 10 bit resolution. It reads values from my microphone pre amp, but all values has an offset around 2034. When nothing is connected to the ADC channel it shows a value of 2034 continuously. What am I missing?
2034 is more than 10 bits.
Can you show your circuit? A hand-drawn diagram photographed with a phone is okay.
What did you expect to get for the value of "nothing"? There is no expectation, so any value you claim has no meaning. Try connecting that pin to ground or 3.3V, then see if the values show what you expect (zero for ground, 1023 for 3.3V).
(removed crosspost)
I configured ADC by using SAM libraries to 10 bit resolution.
Are you sure you're really crippling Due's 12-bit ADC (0-4095) to 10-bit (0-1023)?
Is the mic output capacitive coupled to the Due's analog input? If so, wouldn't the Due's ADC reading want to drift to center value (2048)?
Oh, I should have asked this first ... could you post your circuit?
MorganS:
2034 is more than 10 bits.Can you show your circuit? A hand-drawn diagram photographed with a phone is okay.What did you expect to get for the value of "nothing"? There is no expectation, so any value you claim has no meaning. Try connecting that pin to ground or 3.3V, then see if the values show what you expect (zero for ground, 1023 for 3.3V).
Thank you for your reply! I attached my circuit to this post
I am continuously getting that value when the A0 pin is empty, that means no wire connections to the A0 pin.
If it is a meaningless value what is it and how can I remove it?
I tried what you said, connecting A0 to GND and 3.3v. They give me 0 and 4095( it's the 12bit maximum. I don't know why). I'll upload my code. Then you can check it too
This is my void setup!
void setup() {
pmc_enable_periph_clk (ID_ADC);
adc_init (ADC, SystemCoreClock, ADC_FREQ_MIN, ADC_STARTUP_FAST);
adc_disable_interrupt (ADC, 0xFFFFFFFF);
adc_set_resolution (ADC, ADC_10_BITS);
adc_configure_power_save (ADC, ADC_MR_SLEEP_NORMAL, ADC_MR_FWUP_OFF);
adc_configure_timing (ADC, 1, ADC_SETTLING_TIME_3, 1);
adc_set_bias_current (ADC, 1);
adc_disable_tag (ADC);
adc_disable_ts (ADC);
adc_stop_sequencer (ADC);
adc_disable_channel_differential_input (ADC, ADC_CHANNEL_7);
adc_disable_all_channel (ADC);
adc_enable_channel (ADC, ADC_CHANNEL_7);
adc_configure_trigger (ADC, ADC_TRIG_SW, 1);
Serial.begin(115200);
adc_start( ADC );
}
dlloyd:
Are you sure you're really crippling Due's 12-bit ADC (0-4095) to 10-bit (0-1023)?
This is how I did it.
adc_set_resolution (ADC, ADC_10_BITS);
And also this 2034 - 2033 values occur when the A0 pin is empty.
Here, he uses use port 0 for ADC channel 7.
nimantha_kasun:
I am continuously getting that value when the A0 pin is empty, that means no wire connections to the A0 pin.
If it is a meaningless value what is it and how can I remove it?
If there's nothing connected to A0 then don't use analogRead(A0). That will remove any values by not reading them.
Now if you have your microphone interface circuit connected to A0 and you don't connect a microphone, then there might be a value you expect to get. For the circuit presented, there isn't really a good expectation because there's just a capacitor. There's nothing to set the DC level of the analog input. That circuit will be fine for AC signals but there's no DC at all.
Thank you! I'll change my circuit and post the results