Author Topic: Internal or external analog gain and offset for microcontroller ADC  (Read 1963 times)

0 Members and 1 Guest are viewing this topic.

Offline joniengr081Topic starter

  • Regular Contributor
  • *
  • Posts: 154
  • Country: no
Hello,

I am wondering what is the appropriate choice regarding the gain and offset substation to the analog input for microcontroller ? The input signal which I have is between 2 V to 4 V and the ADC range is 0 to 4.5 V. Here are two options.

1- Use Op Amp to subtract the offset and adjust the gain accordingly to the ADC range
2- Read the analog input directly and subtract the offset and apply the gain in coding

 

Offline chickenHeadKnob

  • Super Contributor
  • ***
  • Posts: 1054
  • Country: ca
Re: Internal or external analog gain and offset for microcontroller ADC
« Reply #1 on: March 22, 2018, 10:45:00 am »
This is a pure engineering choice and either of your listed options could be justified depending on additional factors which you trade off. Generally your first choice which preserves the full dynamic range of your ADC and additionally buffers the input signal which typically has high source impedance is the most desirable.
 

Offline ogden

  • Super Contributor
  • ***
  • Posts: 3731
  • Country: lv
Re: Internal or external analog gain and offset for microcontroller ADC
« Reply #2 on: March 22, 2018, 12:15:22 pm »
Hello,

I am wondering what is the appropriate choice regarding the gain and offset substation to the analog input for microcontroller ? The input signal which I have is between 2 V to 4 V and the ADC range is 0 to 4.5 V. Here are two options.

1- Use Op Amp to subtract the offset and adjust the gain accordingly to the ADC range
2- Read the analog input directly and subtract the offset and apply the gain in coding

It depends what *you* need. If you are using 1/2 of the ADC range but still are within desired accuracy limits, then obviously save $ and do not add opamp :)
 

Online MasterT

  • Frequent Contributor
  • **
  • Posts: 783
  • Country: ca
Re: Internal or external analog gain and offset for microcontroller ADC
« Reply #3 on: March 22, 2018, 12:48:14 pm »
When price for good 16-24 bits ADC falls down to a few bucks, nobody care about amplification at the input anymore. You just select ADC that fits best, setting pga/ranges/noise as a search pattern.
 

Offline xani

  • Frequent Contributor
  • **
  • Posts: 400
Re: Internal or external analog gain and offset for microcontroller ADC
« Reply #4 on: March 22, 2018, 01:11:35 pm »
When price for good 16-24 bits ADC falls down to a few bucks, nobody care about amplification at the input anymore. You just select ADC that fits best, setting pga/ranges/noise as a search pattern.
even if it is like $2, 0.5$ (opamp) + 0$ (builtin micro ADC) is still cheaper than that
 

Online MasterT

  • Frequent Contributor
  • **
  • Posts: 783
  • Country: ca
Re: Internal or external analog gain and offset for microcontroller ADC
« Reply #5 on: March 22, 2018, 01:30:25 pm »
When price for good 16-24 bits ADC falls down to a few bucks, nobody care about amplification at the input anymore. You just select ADC that fits best, setting pga/ranges/noise as a search pattern.
even if it is like $2, 0.5$ (opamp) + 0$ (builtin micro ADC) is still cheaper than that
Not like that, OP don't need OPA, rather PGA. Even good OPA itself with low offset, R2R, linearity better than 0.001% (16-bits) costs more than 2$.  LM358 can't be used. Summing up cost of the switches, resistors (low TC), etc, amplifier 'd go well above 2$ 18-22 bits ADC price.
 

Offline ogden

  • Super Contributor
  • ***
  • Posts: 3731
  • Country: lv
Re: Internal or external analog gain and offset for microcontroller ADC
« Reply #6 on: March 22, 2018, 01:56:57 pm »
OP don't need OPA, rather PGA. Even good OPA itself with low offset, R2R, linearity better than 0.001% (16-bits) costs more than 2$.  LM358 can't be used. Summing up cost of the switches, resistors (low TC), etc, amplifier 'd go well above 2$ 18-22 bits ADC price.

Don't get too excited with 0.001% and low TC resistors :) OP mentioned uC built-in ADC with 4.5V input range. I bet it's 10-bit ADC of AVR, used w/o dedicated reference but VCC rail. So question here is - 1/2 range meaning 9 bits is OK or not.
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19344
  • Country: gb
  • 0999
Re: Internal or external analog gain and offset for microcontroller ADC
« Reply #7 on: March 22, 2018, 02:03:38 pm »
An op-amp might already be required, if the input signal source is high impedance. If so, it would make sense to add an offset, as it doesn't cost much.

If a higher power supply voltage than 5V then the old LM358 will probably do, otherwise use a rail to rail op-amp, such as the MCP602.
« Last Edit: March 22, 2018, 02:50:16 pm by Hero999 »
 

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9886
  • Country: us
Re: Internal or external analog gain and offset for microcontroller ADC
« Reply #8 on: March 22, 2018, 02:12:09 pm »
To offset and re-scale using an op amp  see "Op Amps For Everyone", Chapter 4  -- Google for it.
 

Online MasterT

  • Frequent Contributor
  • **
  • Posts: 783
  • Country: ca
Re: Internal or external analog gain and offset for microcontroller ADC
« Reply #9 on: March 22, 2018, 02:18:48 pm »
Don't get too excited with 0.001% and low TC resistors :) OP mentioned uC built-in ADC with 4.5V input range. I bet it's 10-bit ADC of AVR, used w/o dedicated reference but VCC rail. So question here is - 1/2 range meaning 9 bits is OK or not.
Than why 9-bits? Typical "Absolute accuracy (Including INL, DNL, quantization error, gain and offset error)" of the AtMega328 is 2 LSB.  One more argument for using external ADC.
 

Offline ogden

  • Super Contributor
  • ***
  • Posts: 3731
  • Country: lv
Re: Internal or external analog gain and offset for microcontroller ADC
« Reply #10 on: March 22, 2018, 02:50:58 pm »
Than why 9-bits?

Why 24 bits?

Quote
Typical "Absolute accuracy (Including INL, DNL, quantization error, gain and offset error)" of the AtMega328 is 2 LSB.  One more argument for using external ADC.

2LSB absolute accuracy in your opinion means 10bit ADC degraded to 8bit or what?

Look, OP did not mention *any* accuracy specs. Could be so that 8-bit ADC range is completely fine for what he is planning to measure.
 

Online MasterT

  • Frequent Contributor
  • **
  • Posts: 783
  • Country: ca
Re: Internal or external analog gain and offset for microcontroller ADC
« Reply #11 on: March 22, 2018, 03:29:03 pm »
Than why 9-bits?

Why 24 bits?

Quote
Typical "Absolute accuracy (Including INL, DNL, quantization error, gain and offset error)" of the AtMega328 is 2 LSB.  One more argument for using external ADC.

2LSB absolute accuracy in your opinion means 10bit ADC degraded to 8bit or what?

Look, OP did not mention *any* accuracy specs. Could be so that 8-bit ADC range is completely fine for what he is planning to measure.
   In my opinion, considering time / costs/ reliability - external ADC is the only option. 
 The question is what is better: using external ADC or build an amplifier. Having 10 bits internal ADC and spending a lot of efforts for re-scaling/ offsetting to get what, just 1-bit (!) more?
O'k, you may buy MCP602 (offset 3.0-4.5 mV ) for 0.5$, and get may be  9 bits (see offset). OR spend 2$ and get 16-24 bits (the more the better, isn't it). The choice is obvious.
 For pure academical purpose, putting economic aside, could be good exercise, atmel has AVR465 app note on topic.
 

Offline ogden

  • Super Contributor
  • ***
  • Posts: 3731
  • Country: lv
Re: Internal or external analog gain and offset for microcontroller ADC
« Reply #12 on: March 22, 2018, 03:47:25 pm »
   In my opinion, considering time / costs/ reliability - external ADC is the only option. 

You forgot to add smiley!
Now people could misunderstand your joke and indeed think that external ADC is the only option  :palm:

Quote
The question is what is better: using external ADC or build an amplifier. Having 10 bits internal ADC and spending a lot of efforts for re-scaling/ offsetting to get what, just 1-bit (!) more?

Stop scaremongering, ok? It is not that hard to use just part of whole ADC range - if resulting resolution is OK.
 

Offline xani

  • Frequent Contributor
  • **
  • Posts: 400
Re: Internal or external analog gain and offset for microcontroller ADC
« Reply #13 on: March 22, 2018, 03:55:48 pm »
   In my opinion, considering time / costs/ reliability - external ADC is the only option. 
 The question is what is better: using external ADC or build an amplifier. Having 10 bits internal ADC and spending a lot of efforts for re-scaling/ offsetting to get what, just 1-bit (!) more?
O'k, you may buy MCP602 (offset 3.0-4.5 mV ) for 0.5$, and get may be  9 bits (see offset). OR spend 2$ and get 16-24 bits (the more the better, isn't it). The choice is obvious.
 For pure academical purpose, putting economic aside, could be good exercise, atmel has AVR465 app note on topic.

Or just get a micro with 12 bit ADC. Some even have some differential inputs.

I mean sure, from technical perspective it will always be better to have separate one just because you can put it far away from "digital garbage", but if application doesn't warrant it why bother?

And apparently there are even micros in $2 range that have 16 bit ADCs, altho I imagine getting anything more than ~13-14 would be very hard,
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf