Lies, Damn Lies and Analog Inputs (Comparing ADCs on ESP32, Pico and Arduino)
doctormonk.com
doctormonk.com
Having said all that, I have heard the analogue inputs aren't that great on the ESP32.
Yeah they have wide deadzones and just aren't great, they're really only useful for really coarse things, like reading a photoresistor to turn a light on/off
But usual practice is to use the 10% to 90% range of the ADC anyway. Too many people are unwilling to learn about basic op amp circuits to buffer and condition the input signal.
It would also be useful to have a function generator hooked up and simultaneously digitizing the signal, that's usually how I do my comparisons but does require some more expensive tooling.
Except, you'd need a phononic representation of the signal pre/post ADC and/or better voltage quantization.
Is this level of component variance the reason we can't do quantum computers with electron charge?
Qubit > Physical implementations does list Electron spin and also Electron charge, which ADCs quantize: https://en.wikipedia.org/wiki/Qubit#Physical_implementations
Compared to a $3 ESP32 and a $6 Pico without a RTC Real Time Clock,
HiFiBerry DAC ADC Pro has a "Dedicated 192kHz/24bit high-quality Burr-Brown ADC" https://www.hifiberry.com/docs/data-sheets/datasheet-dac-adc...
ADC: Analog-to-digital converter: https://en.wikipedia.org/wiki/Analog-to-digital_converter :
> In electronics, an analog-to-digital converter (ADC, A/D, or A-to-D) is a system that converts an analog signal, such as a sound picked up by a microphone or light entering a digital camera, into a digital signal. An ADC may also provide an isolated measurement such as an electronic device that converts an analog input voltage or current to a digital number representing the magnitude of the voltage or current. Typically the digital output is a two's complement binary number that is proportional to the input, but there are other possibilities.
Integral linearity: https://en.wikipedia.org/wiki/Integral_linearity
When I'm making something that requires precision, though, I never use them and go with a dedicated ADC instead.
Or maybe they aren't licensing the (expensive) analogue silicon design tooling.
For example, they have no 5Ghz model. The ADC performs really poorly. The RF capabilities don't seem to have changed for a decade. Etc.
Wrangled out some decent results at an impressive 80kHz sample rate in continuous mode, using DMA for near-zero CPU involvement. Here's a plot captured at the time (along with an analog probe for comparison): https://imgur.com/a/5zfy9LZ
I'm not sure if [m]any other people have done this, and one day I'd love to get around to posting sample code along with a little writeup.
It was a real uphill battle to get there. Discovered and reported dozen[s] of errata in documentation to EspressIf (most of which was acknowledged and queued for correction in their next Technical Reference Manual update, although I admit after a couple months I stopped checking to see if surfaced). Lots of undocumented bits had to be deciphered (including basic ones in SYSTEM_PERIP_RST_EN0_REG and SYSTEM_PERIP_CLK_EN0_REG to reset the ADC peripheral and enable it's clock, and power control bits in SENS_SAR_POWER_XPD_SAR_REG).
ADC2 is write-off for anything high-speed, as the entire digi controller was 'dropped' from support due to bad silicon (there's some interesting history and trends if you read up on ADC errata across earlier ESP32 models - it's clear EspressIf really struggled with analog, but they're inching forward with progress as the lineup evolves). Unfortunately when they yanked the documentation for it, they went a little overboard and removed some whole sections that relate to the still-working ADC1 (e.g. all mention of APB_SARADC1_DATA_STATUS_REG, which stores the most recently sampled ADC1 result, was lost in collateral damage).
Other minor documentation pains included mistakes in DMA descriptors, subtly incorrect command sequencing in the ADC Pattern Table (that one cost a couple evenings of debugging to track down), incorrect and sometimes senseless information referring to the use of a flag in GDMA_OUT_AUTO_WRBACK_CHn for a receive channel, ADC_ATTEN_DB_11 constant being used all over the place even though it's actually 12dB (granted that's a nitpick), unintuitive and undocumented behavior that seems in some circumstances to cause GDMA to not move onto the next descriptor until DMA_IN_SUC_EOF is generated, certain actions like pausing and resuming DMA (e.g. for diagnostic instrumentation code to retrieve a consistent snapshot of all the involved registers) seems to corrupt the descriptor pointer (that one might turn out to be by design), and other little mistakes like copy/paste errors or other ambiguities. That all said, it's still not the worst documentation I've seen.
Hardware ADC calibration can significantly improve results, but it's unfortunately buried under undocumented ROM functions required to initialize and enable the feature (via an undocumented I2C configuration bus); without this my readings were off by ~50%. (There's something called an "Internal Calibration Bus" which sadly isn't mentioned once in the docs).
All in all a fun project, though in retrospect it would have taken a lot less time to get up and running with a dedicated ADC chip in my BOM.
Where did this number come from?
AFAIK all pins should operate at 3.3v, and I see no mention of a 1v maximum for that board, or the esp-chip either.
https://docs.espressif.com/projects/esp-idf/en/v4.4/esp32/ap...
The Micropython code the post has at the bottom initializes the ADC to the default, which I think 0 DB attenuation setting, which gives you a range of roughly 0.1-0.95 V. It'll be fine physically if you hook it up to 3.3 V, but the readings will saturate unless you use the higher attenuation setting. There's not much advantage to enabling the attenuator for this test regardless, it just adds more noise.
A 1V band gap voltage reference is common.
You could also use 3.3V Vcc instead, but there is no guarantee that that’s actually 3.3V as it's provided by an external circuit.
The band gap voltage is always 1V, so I see why it would be the default.
Sigh. No they don't. RP2040 ADC has output resolution of 12 bits with ENOB of about 8.7. MicroPython probably scales those up.
Also, 65535.
This is surprisingly low quality blog post for HN standards.
https://docs.espressif.com/projects/esp-idf/en/release-v4.4/...
It even has almost the same graph showing the linearity and dead zone, none of this is a surprise. It's just not got the best ADC ever and I've chosen different parts because of it before. Other parts have better ADCs... and that Mega has a far lower sampling rate.
Is there any microcontroller that manages to have a 16-bit ADC? And if so, are all 16 bits actually usable?
>> The RL78/I1E features a 24-bit delta-sigma A/D
-------
That being said: even just 5V at 16-bits implies a LSB step of 76uV, which means you can only get to 16 usable bits if you have significant work on noise-reduction.
Going to 24-usable bits is probably impossible in practice, but it does mean that the 24-bit ADC there won't be the noise problem / bottleneck in your circuit.
------
Honestly, if any EE came to me and asked about more than 12-bits of ADC precision, I'm beginning to think that they don't understand their problem lol. I kinda feel like anything beyond 12 bits is asking for a lot of noise / hardcore analog signal conditioning circuits that most hobbyists really shouldn't be doing in their projects.
> And if so, are all 16 bits actually usable?
If you know for sure that you have white-noise, you can oversample + decimate to reach absurdly accurate levels. Maybe not 24-bits but yeah, you can reach 16-bits with probably 100k oversamples with effectively 1Hz sample rate
It really depends however. If your bandwidth is low enough then you at least have one way to do make those 16th or 18th bits usable.
Old standlone ADCs hit 16-bits pretty reliably.
Nah. Lets look at it from a db perspective... I don't believe that the typical electrical engineer is in the business of circuits accurate to -96db levels of precision.
Those circuits may have used a 16-bit ADC, but there's no way the typical circuit reached anywhere close to that level of precision. The bottom bits would be all noise in the vast majority of use cases. Even a 12-bit ADC takes a degree of effort to keep your errors and noise down.
16-bits means making no mistake in your entire circuit, across all temperatures, across all kinds of usages, such that your ADC line never drifts more than a few dozen microvolts off reality. That's just not typical circuit design. Temperature effects alone will screw you over and prevent you from reaching there.