Hi,
from reading the Micropython Docs (ESP32) about setting up the ADC it is unclear to me, what Attenuation will
acchieve.
Background: My board (TTGO T-Energy) has a 18650 LiPo charging/protection circuit. The raw voltage is fed to IO35
via a voltage divider (2 x 100k) to ground.
I want to read the ADC and I am interested especially in the range of voltage, where the batteries gets empty.
Max voltage of the LiPo cell when freshly charged via the board is about 4.2-ish V.
A 9DB attenuation would be nice - I thought: When the cell is fully charged it will read 4095 (12bit resolution) and stay there
as long as the cell is above 4V.
If its drops below 4V the ADC gets below 2V and reading the ADC will result in values < 4095.
But...I am unsure, whether this Attenuation-thingy will move the absolute maximum voltage allowed for the ADC pin
or whether it simply moves the range of the ADC internally so that it would not harm the ADC even when I am
beyond 2V but below 3.6V physical input.
(I am no native english speaker and the result may be that I not understood something which is absolute clear
to native speakers....sorry).
Cheers!
mcc
(ADC) Unclear: Attenuation changes the physical or the digital range of the ADC?
Re: (ADC) Unclear: Attenuation changes the physical or the digital range of the ADC?
Attenuation and resolution are separate topics. The attenuation setting affects the physical range. So for 11dB it's about 0-3.5V.
The resolution setting of the ADC sets the maximal value you get at the maximal input voltage, 4095 for 12 bit, 511 for 9 bit.
Note: For reliable readings add a small capacitor to GND as close as possible to the ADC input pin to have low dynamic impedance. Value etc. 1 nF . Depends on the Bandwidth you want to read. The ADC takes about 50 µs for a sample. That's the upper limit you have to consider.
The resolution setting of the ADC sets the maximal value you get at the maximal input voltage, 4095 for 12 bit, 511 for 9 bit.
Note: For reliable readings add a small capacitor to GND as close as possible to the ADC input pin to have low dynamic impedance. Value etc. 1 nF . Depends on the Bandwidth you want to read. The ADC takes about 50 µs for a sample. That's the upper limit you have to consider.
Re: (ADC) Unclear: Attenuation changes the physical or the digital range of the ADC?
Hi Robert,
(you again! Thank you! )
I repeat here only for makeing sure I understood correctly -- I don't to fry my ESP32...
The value of the attenuator limits the maximal allowed voltage at the ADC pin. Is it correct,
to imagine the attenuator like a tuneable voltage divider right in front of the ADC silicone ... ?
(only to describe its effect not its implementation!)
That is:
The LiPo cell has a max voltage of 4.3 V when charged via the board. Its voltage is divided by 2 via
an external voltage divider...results in 2.15 V. This is fed into IO35.
2.15V is greater than 2V, which is allowed for an attenuation of 9db.
So I need the full range up to 3.6V and an attenuation of 11DB...possibly combined with a
resolution of 12bit.
The code will check the ADC value only from time to time to keep an eye on the LiPo cell..
...so no extra fast scanning is needed here.
Hopefully I have understood the whole thing correctly...
Cheers! Happy Holiday and stay healthy!
mcc
(you again! Thank you! )
I repeat here only for makeing sure I understood correctly -- I don't to fry my ESP32...
The value of the attenuator limits the maximal allowed voltage at the ADC pin. Is it correct,
to imagine the attenuator like a tuneable voltage divider right in front of the ADC silicone ... ?
(only to describe its effect not its implementation!)
That is:
The LiPo cell has a max voltage of 4.3 V when charged via the board. Its voltage is divided by 2 via
an external voltage divider...results in 2.15 V. This is fed into IO35.
2.15V is greater than 2V, which is allowed for an attenuation of 9db.
So I need the full range up to 3.6V and an attenuation of 11DB...possibly combined with a
resolution of 12bit.
The code will check the ADC value only from time to time to keep an eye on the LiPo cell..
...so no extra fast scanning is needed here.
Hopefully I have understood the whole thing correctly...
Cheers! Happy Holiday and stay healthy!
mcc
Re: (ADC) Unclear: Attenuation changes the physical or the digital range of the ADC?
That's all right. The capacitor is needed to reduce the impedance during ADC sampling. Not for speed. The ADC requires a low dynamic impedance. and your external voltage divider has 50k impedance. That's too high for a good ADC reading, and therefore the capacitor.
Re: (ADC) Unclear: Attenuation changes the physical or the digital range of the ADC?
I've done the same idea to test my battery voltage , but with 2 * 50k resistors instead .
What happen if you set any attenuation and it over the 1v ? maximum voltage ? it just shows the maximum value 4096.
So if you don't go over 3.5v into the chip without attenuation it just shows 4096 .
I pushed 2.1 volt without attenuation it just showed 4096 , set the attenuation to 11 and worked out what I needed to divide by to get 4.2 volts real and round to 2 digits , no problems.
- MostlyHarmless
- Posts: 166
- Joined: Thu Nov 21, 2019 6:25 pm
- Location: Pennsylvania, USA
Re: (ADC) Unclear: Attenuation changes the physical or the digital range of the ADC?
According to the ESP32 Datasheet the maximum High Level input voltage is VDD+0.3V, which makes it 3.6V since the supply voltage is 3.3V.
It is my understanding that this is the maximum input voltage no matter what the attenuation is. The attenuation only affects the range, in which the ADC will produce a result smaller than max. So if you have it configured to the 0..1V range, then any input voltage between 1V and 3.6V will simply return the maximum (capped) value. Only a voltage above 3.6V will damage the chip.
Regards, Jan
It is my understanding that this is the maximum input voltage no matter what the attenuation is. The attenuation only affects the range, in which the ADC will produce a result smaller than max. So if you have it configured to the 0..1V range, then any input voltage between 1V and 3.6V will simply return the maximum (capped) value. Only a voltage above 3.6V will damage the chip.
Regards, Jan