Author Topic: Accuracy issue when performing readings with an ADC  (Read 3274 times)

0 Members and 1 Guest are viewing this topic.

Offline ElCerrajeroTopic starter

  • Newbie
  • Posts: 9
  • Country: es
Accuracy issue when performing readings with an ADC
« on: August 27, 2023, 03:58:45 pm »
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.
 

Offline ledtester

  • Super Contributor
  • ***
  • Posts: 3036
  • Country: us
Re: Accuracy issue when performing readings with an ADC
« Reply #1 on: August 27, 2023, 04:15:47 pm »
What exactly is your circuit and what is connected to the AREF pin?

What are you setting REFS1 and REFS0 to (see attached chart).

 

Offline ElCerrajeroTopic starter

  • Newbie
  • Posts: 9
  • Country: es
Re: Accuracy issue when performing readings with an ADC
« Reply #2 on: August 27, 2023, 04:19:23 pm »
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.
 

Offline SuzyC

  • Frequent Contributor
  • **
  • Posts: 792
Re: Accuracy issue when performing readings with an ADC
« Reply #3 on: August 27, 2023, 04:45:04 pm »
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.
 

Offline ledtester

  • Super Contributor
  • ***
  • Posts: 3036
  • Country: us
Re: Accuracy issue when performing readings with an ADC
« Reply #4 on: August 27, 2023, 05:02:41 pm »
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
 

Offline ElCerrajeroTopic starter

  • Newbie
  • Posts: 9
  • Country: es
Re: Accuracy issue when performing readings with an ADC
« Reply #5 on: August 27, 2023, 07:01:17 pm »
Thank you very much, everyone. I'm going to design an auxiliary circuit using a voltage regulator to enhance stability.
 

Online Kleinstein

  • Super Contributor
  • ***
  • Posts: 14214
  • Country: de
Re: Accuracy issue when performing readings with an ADC
« Reply #6 on: August 27, 2023, 07:10:24 pm »
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.
 

Offline radiolistener

  • Super Contributor
  • ***
  • Posts: 3390
  • Country: ua
Re: Accuracy issue when performing readings with an ADC
« Reply #7 on: August 29, 2023, 09:42:59 pm »
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.

You 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.
« Last Edit: August 30, 2023, 03:43:42 am by radiolistener »
 

Offline K-Zoltan

  • Newbie
  • Posts: 3
  • Country: hu
Re: Accuracy issue when performing readings with an ADC
« Reply #8 on: September 01, 2023, 07:32:06 am »
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. 
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf