Accuracy issue when performing readings with an ADC - Page 1
Forum section: electronics / beginners

author: ElCerrajero
author_rank: Newbie
timestamp: August 27, 2023, 03:58:45 pm
content: I'm working on a small project in which I'm using an attiny84 with a 7-segment display and an LM335z temperature sensor. What I do is read the temperature from the sensor and display it on the screen. My issue is that when I convert the ADC reading to voltage using the formula, I use the analog reference value which I connect to the AREF pin at 4.9V. The problem is that this value is never exactly 4.9V, causing the conversion to be inaccurate and resulting in different values in each conversion. How can I improve this? I'm thinking of adding a circuit to enhance the accuracy of the readings. The challenge is that the voltage value fluctuates, which I assume is due to variations in the power supplied to the components.

author: ledtester
author_rank: Super Contributor
timestamp: August 27, 2023, 04:15:47 pm
content: What exactly is your circuit and what is connected to the AREF pin?What are you setting REFS1 and REFS0 to (see attached chart).

author: ElCerrajero
author_rank: Newbie
timestamp: August 27, 2023, 04:19:23 pm
content: I directly connect Aref to +5V, which aren't exact 5V. The ADC configuration is correct; I set up the external voltage reference. The problem is that I never manage to have a stable external voltage at the AREF pin.

author: SuzyC
author_rank: Frequent Contributor
timestamp: August 27, 2023, 04:45:04 pm
content: Use a 5V LDO regulator to supply 5V power your Atiny and your reference voltage will be stable. Select Vref for the A/D to be Vdd 5V.

author: ledtester
author_rank: Super Contributor
timestamp: August 27, 2023, 05:02:41 pm
content: You need a stable reference for the ADC. Besides regulating the Vcc rail some other options are:1. Add a precision reference to your circuit - like a TL431 or LM4040. Use a reference that is higher than the highest voltage you want to measure with the ADC.2. Use the internal 1.1V voltage reference and scale down the output the LM335 with a voltage divider. There are some calculations you need to do to determine the resistor values. This answer goes over the calculations for a 50% divider:https://maker.pro/forums/threads/how-to-i-half-this-output-voltage.262717/#post-1568719

author: ElCerrajero
author_rank: Newbie
timestamp: August 27, 2023, 07:01:17 pm
content: Thank you very much, everyone. I'm going to design an auxiliary circuit using a voltage regulator to enhance stability.

author: Kleinstein
author_rank: Super Contributor
timestamp: August 27, 2023, 07:10:24 pm
content: Especially for slow changing signals like a temperature reading it can help to not just use a single reading, but average over multiple (e.g. a few 100) readings to conver 1 mains period. This can suppress mains hum as a source of scattering and gives added resolution to reduce rounding problems. It is quite common that one needs a scale factor from the ADC to sensor value (e.g. temperature). There is no needed to have 2 factors to get extra conversion to voltage as an intermediate number with added rounding errors.Driving a 7 seg LED display can cause variations to the supply current and this was voltage variations.

author: radiolistener
author_rank: Super Contributor
timestamp: August 29, 2023, 09:42:59 pm
content: Quote from: ElCerrajero on August 27, 2023, 03:58:45 pmYou cannot get exactly 4.9 V if you didn't apply very clean, stable and precise AREF from precise reference voltage source and the same clean and the same clean stable and precise voltage on ADC input. And even if you do that, any ADC has it's own noise figure and non linearity, so result still can be varied.Any wires also add interference for measurements, so you're needs to use proper PCB layout to minimize such interference. If you're using wires/breadboard to connect AREF or AIN, it is almost impossible to protect it from significant RF interference. As result you can get high noise on measurement results.Note that usual voltage regulator has not enough stability for using with AREF. You're needs to use precise reference voltage source chip.Also you're needs to understand that power rails don't have stable and clean 5V, it's actual voltage depends on current consumption which depends on MCU program. Also power rail for digital circuit consists a lot of digital noise. So using power rail as reference voltage is a bad idea. Even you're don't needs stable measurement, you're needs to add at least low pass filter with ferrite beads between power rail and AREF to reduce it's noise.

author: K-Zoltan
author_rank: Newbie
timestamp: September 01, 2023, 07:32:06 am
content: On 5V power how many uF capacitor did you add? Also separate 5V for Digital and for reference and add separate some 100NF, 1UF(ceramic cap) and 10-100uF to ref input near to chip pin. Big problem is led display, it consumes lot and with big current variations, eg. when change from displaying 8 (7 segments on) to displaying 1 (2 segments on). Best to add a separate 5v ref.