Electronic – Huge drop in voltage when connecting output to pin of microcontroller

avrmicrophonevoltage

I have an electret microphone pre amplifier and peak detector circuit that's working great. The microphone picks up sounds and I get a steady DC voltage that, depending on the volume of the sound the microphone is listening to, is somewhere between 0 and ~3.5v

I need to feed this into an ADC pin on a AVR microcontroller though so that I can read in the relative volume that the microphone is getting.

The only problem is that when I connect the circuit to the ADC pin on the microcontroller, my peak voltage drops from 3.5v to about 100mV.

I'm connecting the pre amp and peak detector circuit to an STK board that the chip is running off. When the board is powered off the peak voltage I'm reading with an oscilliscope (and with a multimeter) is correct but it massively drops down when I power it on. I still does exhibit the same sort of behaviour as it should though (the peak rises when there's noise) but I need the peak to be around 3.5v (not 100mV) as I need to a great resolution in the ADC value I read in in my software.

I have connected the grounds of both circuits to the STK board's ground so I don't think that that is the issue.

Can anyone give me any sort of idea about what might be going wrong? Is it something to do with the internal resistance of the microcontroller? Am I perhaps putting too much current into the ADC pin? I'd really appreciate any help.

edit: I'm using pin A7 on an atmega16.

edit 2:

This is the pre amp circuit I'm using: http://www.zen22142.zen.co.uk/Circuits/Audio/lf071_mic.htm

and this is the peak detector/rectifier:
peak detector

and the code to get the ADC value:

unsigned int ADC_read(unsigned char ch)
{
    ADMUX = 0b11000111;

    ADCSRA|=(1<<ADSC); // start conversion

    while(!(ADCSRA & (1<<ADIF))); // waiting for ADIF, conversion complete
    {
        ADCSRA|=(1<<ADIF); // clearing of ADIF, it is done by writing 1 to it
    }

    return (ADC);
}

I can't see how the code would have any effect though.

Best Answer

Are you absolutely sure the pin/port is configured as an analog input, and not a digital output that's been set low?

An accidental digital low on the port could be what's loading the peak detector output.

I'm not an expert on your particular architecture, but in general, micro I/O pins are multiplexed - you need to explicitly set registers to configure them as inputs, outputs or ADC channels. Setting up an internal ADC still requires you to manually configure its input pin appropriately.