External dedicated ADC vs Internal ADC in (PIC) MCU - Page 1
Forum section: electronics / projects

author: Buriedcode
author_rank: Super Contributor
timestamp: March 24, 2025, 02:09:52 am
content: Hi,I have an application measuring a sensor with moderate (12-bit) resolution. It's ratiometric with the sensor outputing a voltage as a ratio of its supply voltage, so that'll be the reference, meaning the absolute accuracy of the reference isn't particularly important. It's also virtually DC, so sample rate isn't a concern.I often just use the internal ADC of micros, PIC16/18 and AVR's, but the 12-bit requirement narrows this down significantly (they do exist though), and I'm wondering if I would just be better off using an external ADC? A one-chip solution is nice, but this is a small run, so cost isn't a major concern, nor is power consumption or space.The PIC16F1788 has 12-bit ADC, along with built-in opamps (I'll have to buffer the sensor before ADC) but looking at the specs in the datasheet, and knowing that whilst the ADC's in PIC16 tends to be pretty good, dedicated ADC devices *can* be better for a given resolution, and the opamp specs are less than stellar. The application requires other things to be sampled, but without much concern for accuracy, so any 8/10-bit ADC (MCU internal) will do for those. I'm leaning towards a single channel, single ended external ADC for the main sensor measurement. This of course, opens a can of worms, and digging into datasheets.So, to ask briefly - PIC16F** 12-bit internal ADC? Or MCP3201? I have never used that device before, but it seems simple enough to avoid potential "gotchas" but there are always the unknowns. I will have to test one out flly, but thought I'd post for peoples experiences - I did search that part number and got plenty of results, and couldn't find a "oh, but the chip does xxxx which I hate".

author: dobsonr741
author_rank: Frequent Contributor
timestamp: March 24, 2025, 02:30:40 am
content: You need to know your speed and accuracy requirements. It seems you do, and the internal ADC meets those. Then you have no reason to use an external, don’t you?

author: moffy
author_rank: Super Contributor
timestamp: March 24, 2025, 02:47:30 am
content: For micro internal ADCs, I would knock a couple of bits off the resolution, because of noise and sometimes device specific issues e.g. for the NXP ARM processors with 16 bit ADCs, only certain pins and sometimes packages can be used for the full resolution, also it's ADC specs are somewhat vague, you have to dig through the literature to find the caveats. With an external ADC you have much more control over the analogue side and could if you wanted, upgrade since any of the ADCs you'll use will probably be SPI.

author: David Hess
author_rank: Super Contributor
timestamp: March 24, 2025, 07:06:15 am
content: According to the specifications given in its datasheet, the accuracy of the PIC16F1788's 12-bit ADC is more like 8 bits in the worst case, so if you really require 12 bits of accuracy, an external ADC will be required.

author: xvr
author_rank: Frequent Contributor
timestamp: March 24, 2025, 06:42:34 pm
content: You might want to look at AD microcontrollers (if you can afford to use them instead of a PIC). AD markets these microcontrollers as "ADCs with an integrated microcontroller", so they are much more accurate than any other.

author: eugene
author_rank: Frequent Contributor
timestamp: March 25, 2025, 06:16:56 pm
content: If the signal is essentially DC, then the resolution can be increased by oversampling (i.e. averaging a bunch of individual samples.) Roughly, the increase in resolution is equal to the square root of the number of samples that are averaged.Assuming the PIC has an effective resolution of 8 bits, then to get to 12 bits requires 16x better resolution, so you need to average 256 8-bit samples to get one 12-bit sample. That's not hard to do. The PIC gives you a 12-bit sample of which only the lower 8 bits can be trusted. If you add together 256 of these you will essentially have a 20 bit number. Now right shift 8 bits and you will have a good 12 bit number of which all 12 bits can be trusted.Again, this assumes a slow moving signal that doesn't change much (except for noise) during the 256 samples.EDIT: There are many documents out there that discuss oversampling from the point of view of digital signal processing. DSP is in fact what we're doing, but the context might leave the explanation more confusing than it needs to be. This document does a reasonable job of dumbing it down just enough for our purposes.https://www.silabs.com/documents/public/application-notes/an118.pdfNote from the above application note that noise in the signal is required for any of this to work. Fortunately, there is noise, which is more or less proven by the fact that the 12 bit ADC sample has only 8 bits of not-noise information. The lowest 4 bits are assumed to be all white noise.Note also that they discuss starting with a 12 bit ADC and increasing the resolution to 16 bits via oversampling. In the example I gave above, I know the ADC outputs 12 bits, but I also know that the ENOB (Effective Number Of Bits) is really only 8, so I talk about starting with essentially 8 bit resolution and increase it to 12. The complicating factor is that we really are adding together 12 bit numbers. We need 20 bits to hold 256 samples added together, so a 32 bit integer is required.Hopefully i made sense. It's not as complicated as it sounds provide the assumptions are all valid.

author: David Hess
author_rank: Super Contributor
timestamp: March 25, 2025, 10:20:08 pm
content: Quote from: eugene on March 25, 2025, 06:16:56 pmIn this particular case, the PIC16F1788 is not limited by resolution but by linearity. The datasheet says that with 12 bits of resolution, 10 bits of resolution with no missing codes, and less than 9 bits of linearity. There is a conflict however because it says no missing codes at 10 bits of resolution with +/-1.4 bits of differential non-linearity which makes no sense; that would be 9 bits with no missing codes.This sort of performance is typical for a microcontroller ADC where 12 bits is a fantasy.

author: Buriedcode
author_rank: Super Contributor
timestamp: March 26, 2025, 07:14:23 am
content: Yeah, this is why I leant towards an external ADC - I rarely need more than 10-bits, and if true accuracy is required, I add the facility to calibrate out offsets.But in 12-bit land (Actual 12-bit), whilst I have used an old PIC18LF4553 many years ago, I remember being less than impressed with it.As I said, its a very small run, so I dont think going for a newish micro and testing out its ADC is really worth the time when I can throw a reasonably priced 8 pin external ADC at the issue. I'll still need calibating, but we'll see how it turns out.Cheers!

author: BadeBhaiya
author_rank: Regular Contributor
timestamp: March 26, 2025, 08:00:16 am
content: MCU ADCs always seem to be good enough for basic tasks and if you're not in any time constraint to sample, maybe you can add an integrator circuit and oversample the signal.Also remember to characterise the ADC output and apply a correction table/whatever to remove any non linearities. Without this, any MCU ADC is almost unusable.