0
\$\begingroup\$

I am trying to read the voltage from analog sensor via ADC of pic18 microcontroller. It has 10 bit ADC i.e. 1024 steps. But measuring a voltage of 2 V range (approx) my result keeps fluctuating + and -2 the exact value. However the range i am working is narrow and precision is required. I checked the value of signal input at ADC pin of microcontroller ther i saw 70-100 mV disturbance, using capacitors i got it reduced to 30 - 40 mV but now it's not reducing further. Capacitor used 0.5 micro Farad.
I want to know how can we filter it further. Also i need a stable ADC output (should not fluctuate). Please help.

\$\endgroup\$
1
  • \$\begingroup\$ So, it's got nothing to do with the ADC's ability to convert an analogue input voltage into a digital output value, yes? <you need to disclose more about the circuit and the sensor so, please post a schematic cropped to the relevant area and link the sensor's data sheet. \$\endgroup\$
    – Andy aka
    Commented Jul 2, 2023 at 17:58

3 Answers 3

3
\$\begingroup\$

Average 8 readings. This will help with noise.

\$\endgroup\$
8
  • \$\begingroup\$ Averaging can be a really good solution here. Using averaging I have designed circuits that could reliably make measurements to within ±1 ADC count and where in my case one ADC count was only ±2uV. \$\endgroup\$
    – user4574
    Commented Jul 3, 2023 at 0:33
  • \$\begingroup\$ thanks, thats helpful. \$\endgroup\$
    – newbie
    Commented Jul 3, 2023 at 7:10
  • \$\begingroup\$ hi user4574, my adc count is 5 mV but still after averaging 15 terms i am getting +-1 unit ADC fluctuation(though it's better than without averaging). How have you managed to get that good accuracy. \$\endgroup\$
    – newbie
    Commented Jul 3, 2023 at 7:13
  • \$\begingroup\$ i tried to get better resolution via applying lower reference voltage but it lead to more oscillations. \$\endgroup\$
    – newbie
    Commented Jul 3, 2023 at 7:16
  • 1
    \$\begingroup\$ @newbie If the averaged value is quite exactly between two digital values, you will experience jumping between these. No more averaging will help here. (BTW, the ratio will tell you the fraction of the LSB.) To avoid this jumping, you need to insert some hysteresis. \$\endgroup\$ Commented Jul 3, 2023 at 7:33
0
\$\begingroup\$

We refer to Microchip's specifications for PIC18F devices. You can bet that these specs are obtained with a very carefully set up test bed, with very stable and smooth supply voltages. OP's requirements are near these limits, which are quite likely RMS values. Expecting a never-changing result with a DC voltage applied is expecting a bit too much.

Microchip PIC18Fxx generic data sheet

Pay attention to how these were measured - under different conditions (for example, measuring a source having higher source resistance/impedance) results can degrade. Also, a reference voltage less than +5v will likely degrade these specs.

OP's noise measurement at ADC input (30mV-40mV) can easily account for measurement fluctuations. Noise of reference voltage or noise on Vss can also add noise, so ensure that Vdd doesn't vary. This is especially important if DC supply (REFerence voltage) comes from a noisy switching supply. Filtering ADC input alone isn't enough. With a reference voltage of 5V, a least-significant-bit fluctuation of 5mV can flip the least-significant bit of the result.
Since the ADC is a successive approximation type sampling period is short (perhaps as short as 100ns). If sampling occurs on a noise peak, next sample likely gives a different result.

\$\endgroup\$
2
  • \$\begingroup\$ ok so if we try to reduce the Vref in hope of greater accuracy or better resolution. We might actually get more fluctuations. \$\endgroup\$
    – newbie
    Commented Jul 3, 2023 at 7:07
  • \$\begingroup\$ Is there any way to keep op amps noise in check \$\endgroup\$
    – newbie
    Commented Jul 3, 2023 at 7:14
0
\$\begingroup\$

You can try a median (not average) filter in software, if the goal is primarily to have a stable output. Median filters generally produce a very stable output as they completely disregard outliers.

One downside is they require a fair amount of computation power, since you need to sort your samples somehow.

\$\endgroup\$
2
  • \$\begingroup\$ can you please elaborate how to use them , how to implement in program. \$\endgroup\$
    – newbie
    Commented Jul 3, 2023 at 7:05
  • \$\begingroup\$ i am using Mplab x \$\endgroup\$
    – newbie
    Commented Jul 3, 2023 at 7:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.