ADC values are not stable, how to get stable ADC reading

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ADC values are not stable, how to get stable ADC reading

Jump to solution
3,313 Views
omkar_virkar
Contributor II

I am using mkl26z256vlh4 in which I am specifically observing pin 29 of port E i.e./ADC0_SE4B, my purpose is to get voltage of this pin and decide further action, but I am not getting stable ADC values. I am using 3.3v Vref and input is 3.3v.

I have configured it as 12bit ADC. I have enabled average mode for 32 samples which is giving me a more stable output than previous but the ADC values reading after averaging is differing than actual voltage of that pc. and one more thing i am using voltage divider with R1=470K   R2=220K.

#define DEMO_ADC16_BASE ADC0
#define DEMO_ADC16_CHANNEL_GROUP 0U
#define DEMO_ADC16_USER_CHANNEL 4U                   /* PTE29, ADC0_SE29_4B */

this is how I have defined ADC channel, is user channel correct for mentioned pin?

omkar
0 Kudos
Reply
1 Solution
3,276 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Have you test the ADC example(for example frdmkl26z_driver_examples_adc16_interrupt or frdmkl26z_driver_examples_adc16_polling) in MCUXpresso SDK?

Does the default ADC input pin(ADC0_SE23) of the example also get such unstable value?

The ADC0_SE4b on FRDM-KL26Z board is connect to RGB LED, so I am not able to test it at my side.

ADC0_SE4b SDK_2_2_0_FRDM-KL26Z.pngPTE29 LED_RED FRDM-KL26Z.png

ADCx_CFG2[MUXSEL] bit selects between ADCx_SEn channels a and b. Refer to MUXSEL description in ADC chapter for details.
Please check the value of ADC0_CFG2[MUXSEL] during debug, make sure MUXSEL=1 ADxxb channels are selected.

View solution in original post

5 Replies
3,301 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi omkar,

Please read: AN4373 Cookbook for SAR ADC Measurements

AN4373.png

voltage divider with R1=470K   R2=220K

3.6.1.1 16-bit ADC operating conditions.png

Can you list how the resulting values are unstable?

Best Regards,
Robin
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

3,296 Views
omkar_virkar
Contributor II

omkar_virkar_0-1644401627839.png

for the I/p of 3.3v this are ADC values I am getting whereas, I am getting 1.06 v reading on  DMM  

omkar
0 Kudos
Reply
3,277 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Have you test the ADC example(for example frdmkl26z_driver_examples_adc16_interrupt or frdmkl26z_driver_examples_adc16_polling) in MCUXpresso SDK?

Does the default ADC input pin(ADC0_SE23) of the example also get such unstable value?

The ADC0_SE4b on FRDM-KL26Z board is connect to RGB LED, so I am not able to test it at my side.

ADC0_SE4b SDK_2_2_0_FRDM-KL26Z.pngPTE29 LED_RED FRDM-KL26Z.png

ADCx_CFG2[MUXSEL] bit selects between ADCx_SEn channels a and b. Refer to MUXSEL description in ADC chapter for details.
Please check the value of ADC0_CFG2[MUXSEL] during debug, make sure MUXSEL=1 ADxxb channels are selected.

3,249 Views
omkar_virkar
Contributor II

#if defined(FSL_FEATURE_ADC16_HAS_MUX_SELECT) && FSL_FEATURE_ADC16_HAS_MUX_SELECT
ADC16_SetChannelMuxMode(DEMO_ADC16_BASE, kADC16_ChannelMuxB);
#endif /* FSL_FEATURE_ADC16_HAS_MUX_SELECT */

 

i was missing this in my program. after including ADC16_SetChannelMuxMode(DEMO_ADC16_BASE, kADC16_ChannelMuxB); ADC VALUES are stable.

 

thank you!

omkar
3,306 Views
bobpaddock
Senior Contributor III

If you are driving the ADC input from the junction of R1&R2 with those values, that impedance is way to high, cut them down by at least a factor of ten.  Always best to drive ADC with a proper driver Op-Amp.

Analog Devices has good ADC design information in their Tutorial/Seminar Series.

A Median filter is better than an Average for getting a stable reading.

Info on those here:

https://embeddedgurus.com/stack-overflow/?s=median


The Median is good for getting rid of the rare spike events, say a static discharge, were an Average will just sum in the crap.

If the input is complete crap, neither will help.