Internal or external analog gain and offset for microcontroller ADC  - Page 1
Forum section: electronics / projects

author: joniengr081
author_rank: Regular Contributor
timestamp: March 22, 2018, 08:11:39 am
content: 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 range2- Read the analog input directly and subtract the offset and apply the gain in coding

author: chickenHeadKnob
author_rank: Super Contributor
timestamp: March 22, 2018, 10:45:00 am
content: 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.

author: ogden
author_rank: Super Contributor
timestamp: March 22, 2018, 12:15:22 pm
content: Quote from: joniengr081 on March 22, 2018, 08:11:39 amIt 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

author: MasterT
author_rank: Frequent Contributor
timestamp: March 22, 2018, 12:48:14 pm
content: 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.

author: xani
author_rank: Frequent Contributor
timestamp: March 22, 2018, 01:11:35 pm
content: Quote from: MasterT on March 22, 2018, 12:48:14 pmeven if it is like $2, 0.5$ (opamp) + 0$ (builtin micro ADC) is still cheaper than that

author: MasterT
author_rank: Frequent Contributor
timestamp: March 22, 2018, 01:30:25 pm
content: Quote from: xani on March 22, 2018, 01:11:35 pmNot 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.

author: ogden
author_rank: Super Contributor
timestamp: March 22, 2018, 01:56:57 pm
content: Quote from: MasterT on March 22, 2018, 01:30:25 pmDon't get too excited with 0.001% and low TC resistorsOP 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.

author: Zero999
author_rank: Super Contributor
timestamp: March 22, 2018, 02:03:38 pm
content: 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.

author: rstofer
author_rank: Super Contributor
timestamp: March 22, 2018, 02:12:09 pm
content: To offset and re-scale using an op amp see "Op Amps For Everyone", Chapter 4 -- Google for it.

author: MasterT
author_rank: Frequent Contributor
timestamp: March 22, 2018, 02:18:48 pm
content: Quote from: ogden on March 22, 2018, 01:56:57 pmThan 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.

author: ogden
author_rank: Super Contributor
timestamp: March 22, 2018, 02:50:58 pm
content: Quote from: MasterT on March 22, 2018, 02:18:48 pmWhy 24 bits?Quote2LSB 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 ADCrangeis completely fine for what he is planning to measure.

author: MasterT
author_rank: Frequent Contributor
timestamp: March 22, 2018, 03:29:03 pm
content: Quote from: ogden on March 22, 2018, 02:50:58 pmIn 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.

author: ogden
author_rank: Super Contributor
timestamp: March 22, 2018, 03:47:25 pm
content: Quote from: MasterT on March 22, 2018, 03:29:03 pmYou forgot to add smiley!Now people could misunderstand your joke and indeed think that external ADC is the only optionQuoteStop scaremongering, ok? It is not that hard to use just part of whole ADC range - if resulting resolution is OK.

author: xani
author_rank: Frequent Contributor
timestamp: March 22, 2018, 03:55:48 pm
content: Quote from: MasterT on March 22, 2018, 03:29:03 pmOr 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,