Xmega ADC with gain question

Go To Last Post
8 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

As far as I can tell there is a lot of confusion on how the ADC gain stage in the xmega devices works, and I was wondering if anyone could help with a simple example .

 

My current example circuit is a microphone connected to a opamp with feedback to give a voltage gain of 64. This is then connected to a ADC of a MegaAVR. The microphone has a dc blocking capacitor and the single supply opamp using a half-bias to ensure that signal is in the middle of the rails. The ADC then samples the signal using VCC as Vref and I just subtract of the half-bias in software.

 

I would like to simplify this circuit by removing the opamp and using the Xmega 64x amplifier to directly connect to the microphone (I'm not too concerned about gain errors and noise at this point, I just want to prove that xmega gain stage can replace a typical opamp amplifier circuit)

 

My concern about this is that AVR1300: Using the Atmel AVR XMEGA ADC application note states:

Negative values are not negative inputs on the I/O pins, but higher voltage level on the negative input in respect to the positive input. Even though the resulting value can be negative, voltages below GND or above VCC should under no circumstances be applied to any input port.

This would mean that the DC blocked microphone signal would not satisfy this requirement as it would pull below GND.

 

Another application note Atmel AVR1631: Single Phase Energy Meter using XMEGA A states this:

 

Differential measurement with gain stage is available inside to XMEGA A4U microcontroller which increases the dynamic range. Hence external gain amplifier and level shifter for negative signal is not required. This will reduce the product cost.

 

So my question is can the ADC gain stage be used as "traditional" opamp circuit, where you apply the signal (even though it theoretically takes the pin negative) to the inverting or non-inverting port and then a "half-bias" (or whatever voltage makes sense with reference to Vref) to the other input to amplify the signal and measure it in signed mode?

 

Thanks for any help!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well, I've not tried this...

 

How big is the Vout from the mic?

(The AC signal, Peak-to-Peak?)

 

You could try feeding the mic input to your DC blocking cap.

Other mic lead to Ground

 

DC blocking cap is 1 uF or 10 uf, (Non-polarized type).

 

The output of the cap goes to the ADC input.

 

Now put a resistor divider from +5 to Ground, with two resistors in series.

Also attach the midpoint of the resistor divider to the ADC input.

 

Make the resistor divider so that the DC output is very small, but greater than 0V.

For example, if the resistor divider puts out 50 mV, then the output of the gain stage would have a DC bias of 50mV x 64 = 3.2 V

The audio signal would be amplified x 64 and sit on top of this DC bias.

 

Make the resistor divider put out 40 mV, then the DC bias will be 2.56 V.

 

Worth giving it a try.

 

JC

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Posting schematics without testing them tends to get me into trouble, but here is the concept discussed above, (untested):

The R1 and R2 divider gives about 40 mV, which gives about 2.5 V DC bias after the gain stage inside the uC.

 

JC

 

 

Edit: Typo

 

OH Man, Note that the VCC should be +3 V, NOT +5 V.

 

JC

 

Last Edited: Sun. Apr 26, 2015 - 06:45 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you have signals that go beyond the input range of the pin put a current limiting resistor in series.   Clamping diodes take the current then; make sure you always use more than you feed in.    Not as they teach it in school but can be done.

 

Furthermore as far as I know the ADC reference voltage on Xmega has to be below the VCCA voltage (I think 0.6 volts).    Input voltage range is then 0..Vref.    And I don't think Xmega can handle 5 Volts supply.   

 

Otherwise the schematics should work although it may be an advantage to use differential mode with the same resistive divider connected to the negative input pin.
 

Last Edited: Sun. Apr 26, 2015 - 11:11 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I played with a xmega and found that you can potentially use negative numbers with gain. It is definitely not within any spec and who knows what it will do to the device, but you can measure negative numbers down to -.5 volts in differential mode and amplify them, but it is unknown what happens outside of that.

 

The schematic could work, I guess it would require the dc value to be calibrated out due to resistor tolerances. The easiest way may be to have a resistor divider at the negative input that applies a "half-bias" or virtual ground and then use a resistor to then add that to all the dc blocked signals that need to be measured. That way the signed mode would just do an accurate subtraction for you.

 

I'm guess I'm still confused by the fact that the app note 1631 states:

Differential measurement with gain stage is available inside to XMEGA A4U microcontroller which increases the dynamic range. Hence external gain amplifier and level shifter for negative signal is not required. This will reduce the product cost.

Maybe I am missing something in the context.

 

Anyway, it looks like there may be a  relatively simple way of using the gain stage to replace a simple opamp amplifier.

 

Thanks!

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

Why R2 is 80 Ohms?

I think to create a virtual ground, It should be 10K.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

The divider ratio needs to be high because of the gain of the internal amplifier ahead of the sample/hold.

 

I would not, however, use 80 ohms. I would guess that most microphones would not like that. I would make it at least a few KOhms the the upper resistor proportionately larger.

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Posting schematics without testing them tends to get me into trouble

That said, the cap and the two resistors form a HPF between the mic and the ADC, in addition to setting the DC bias point feeding the ADC.

 

The effective "R" of the HPF  has the value of R1 in parallel with R2, and a low "R" moves the HPF's cutoff frequency lower, closer towards 0 Hz.

 

The mic won't really care what the value of R2, or R1//R2 is, within reason, due to the cap playing a greater role in this regarding the load seen by the mic.

 

All that said, it is fine to scale the values up, (while being cognizant of the HPF's cutoff frequency).

 

The resistor divider ratio, however, has to severely attenuate the DC being fed into the ADC as this discussion assumes the uC's "gain stage" is in use, and the DC bias is amplified by the gain.

If the DC voltage feeding the input is too high, then when multiplied by the Gain Factor, the output will saturate (clip) at the V+ voltage.

 

JC 

 

Edit: Typo

Last Edited: Fri. Sep 13, 2019 - 09:56 PM