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?
Solved! Go to Solution.
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.
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.
Hi omkar,
Please read: AN4373 Cookbook for SAR ADC Measurements
voltage divider with R1=470K R2=220K
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.
-------------------------------------------------------------------------------
for the I/p of 3.3v this are ADC values I am getting whereas, I am getting 1.06 v reading on DMM
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.
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.
#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!
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.