ADC samples fluctation for Constant input voltage

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

ADC samples fluctation for Constant input voltage

2,920 Views
vaibhavi_padwal
Contributor II

Hi,

I am working on 12 bit ADC with custom board which has MK22FX512AVLQ controller. When I am giving a constant voltage to ADC, I am observing a considerable fluctuation in the samples.

The 3.3 V supply to the controller is stable. The voltage at the ADC input pin is also constant.

On the hardware side:

I have a RC on the ADC pin with R = 100Ohm and C = 220pF. I have also tried changing this capacitor to 1uF keeping R the same. I also tried adding 100nF Capacitor on VREF_OUT pin (pin number 37). But no improvement was observed.

On software side:

Clock configuration is as follows :

Core clock : 80MHz

Bus clock: 40MHz

 

ADC configuration is as follows:

                adc16_config_t s_adc_config;

                EnableIRQ(ADC0_IRQn);

                ADC16_GetDefaultConfig(&s_adc_config);

                s_adc_config.clockSource = kADC16_ClockSourceAlt0;/*Bus clock 40 Mhz*/

                s_adc_config.clockDivider = kADC16_ClockDivider4;/*Divided by 4*/

                s_adc_config.longSampleMode = kADC16_LongSampleDisabled;

                uint32_t ui32_freq;

                ui32_freq = CLOCK_GetFreq(kCLOCK_BusClk);

                ADC16_Init(ADC_BASE, &s_adc_config);

                while(kStatus_Success != ADC16_DoAutoCalibration( ADC_BASE ));

                if(ADC16_GetStatusFlags(ADC_BASE))

                {

                              printf("Failed");

                }

                uint32_t ui32_temp;

                ui32_temp =  ADC16_GetChannelConversionValue(ADC_BASE, ADC_CHANNEL_GROUP);

                ADC16_EnableHardwareTrigger(ADC_BASE, false); /* Make sure the software trigger is used. */

                ADC16_EnableDMA(ADC_BASE, true);

I have tried doing following modification on the software side,

  1. Changing Buc clock frequency
  2. Changing prescaler of the ADC clock
  3. Changing the sampling period (long sampling enabled)
  4. Adding an intentional delay after the auto caliberation function returns Success status

Still the fluctations persist.

I have attached the schematic and test results data for the reference.

Please help in resolving the issue.

Thanks and Best Regards,

Vaibhavi

Tags (1)
0 Kudos
15 Replies

2,431 Views
bobpaddock
Senior Contributor III

Assuming that you can not beat the hardware into submission (I've yet to find any on Micro ADC work to my satisfaction), the best way I've found to deal with any sensor input practically is a 13 sample Median filter, for which code can be found here:

Median filtering « Stack Overflow 

Peak detection of a time series « Stack Overflow 

Mathematician Georg Cantor tells us there will be 'noise'  between samples in any system given a long enough sample time.

Double check the Reference, again.  Be cognizance of ground-bounce in any psychical setup.

0 Kudos

2,431 Views
Alexis_A
NXP TechSupport
NXP TechSupport

Hello Vaibhavi,

 

One tip to improve the ADC accuracy is to do the measurements in low power mode, this will reduce the internal noise generated by the MCU. Also I will suggest to check the following application notes for more tips for ADC improvement:

 

How to Increase the Analog-to-Digital Converter Accuracy in an Application

AN4373, Cookbook for SAR ADC Measurements

 

Let me know if this helps you.

 

Best Regards,

Alexis Andalon

0 Kudos

2,431 Views
vaibhavi_padwal
Contributor II

Hi Alexis,

Thanks you for your suggestions.

I cannot put the controller in Low power mode while doing the ADC measurements due to reuirement constrains in my application. I have gone through the documents you suggested. The ripple on VDD and analog input signal is very low. Also I have added external RC as I mentioned in the query. 

The problem still persists. Can you suggest some other things that should be taken care of, both in software and hardware, for accurate ADC measurements? Please suggest any change in hardware or software configuration is required.

Thanks and Regards,

Vaibhavi

0 Kudos

2,431 Views
Alexis_A
NXP TechSupport
NXP TechSupport

Hello Vaibhabi,

Do you have other peripherals running in your custom board at the same time? Maybe you could try disabling anything else or test one of the ADC examples to see if this spikes are also present. You could try using the adc16_continuous_edma as usually using the continuous conversion improve the sampling rate after the first conversion.

Best Regards,

Alexis Andalon

0 Kudos

2,431 Views
vaibhavi_padwal
Contributor II

Hi,

Sorry for replying late. 

As there are no examples in the sdk which I am using, I referred to an example (adc16_interrupt) from FRDM K22 evalution board sdk.

I have tried similar ADC configuration in my code for MK22FX512AVLQ12. I have disabled all other modules and I am sampling only 1 channel (ADC0 SE11).

There's no ripple present in the signal on the pin. But I am still getting 3 to 4 samples which are way out of the expected DC value. Continuous conversion enabling had no significant improvements in results.

Please find the source code and test results as well as the schematic for controller peripherals.

Clock configuration: Core clock 80MHz

                                 Bus clock 10MHz

RC on ADC input Pin : 100Ohm and 0.01uF (As suggested in Refernce maunal of the controller)

Capacitor on VREF pin: 0.1uF (As suggested in Refernce maunal of the controller)

Please help in resolving the issue.

#kerry zhou

Thanks and Best Regards,

Vaibhavi

0 Kudos

2,431 Views
Alexis_A
NXP TechSupport
NXP TechSupport

Hi Vaibhavi,

I have tried this in the FRDM Board without the filter and the measurement stay in a narrow range, maybe this could be due to some noise causing in your development board. Maybe you could monitor the ADC input if there's some ripple in it?

Best Regards,

Alexis Andalon

0 Kudos

2,431 Views
vaibhavi_padwal
Contributor II

Dear Alexis,

I have used PE micro debugger and the board was connected to debugger while I took the samples. Did you take the samples while the debugger was connected or the board was already programmed and you took samples by simple power up and using UART? Also which IDE are you using to test? Please let me know.

Also I will request you do take a larger sample set of 10,000 or 100,000 samples and see if few samples are showing very high difference with respect to expected value. 

Request you to share the code and results of your testing on FRDM K22 board along with set up details.

Regards,

Vaibhavi

0 Kudos

2,431 Views
vaibhavi_padwal
Contributor II

Dear Alexis,

I have tried the same software configuration of ADC in my code for both my custom board MK22FX512AVLQ12 and FRDM K22 board. But the pattern for only 2 or 3 samples giving sudden difference of 20-25 counts (as in the results in excel sheet attached above) was not observed in case of FRDM K22. 

Also I have checked that there is no significant ripple in the input signal on my custom board. 

I request you to please review the schematic that is attached as well as the hardware components specification mentioned in the above communication and suggest if some changes with respect to hardware are required. 

Also it would be really helpful if you can share the code for which you have tested the FRDM K22 board on your side, So that I can verify and implement for my custom board.

Please help in resolving the issue.

Thanks and Best Regards,

Vaibhavi P

0 Kudos

2,431 Views
vaibhavi_padwal
Contributor II

Hi Alexis,

Have you tried the same configuration as I have used in the attached code?

Can you please share the code and the results for FRDM board so that I can verify the same results on my FRDM K22?

Thank and Regards,

Vaibhavi

0 Kudos

2,431 Views
dh1
Contributor II

Hi Vaibhavi

We also had strange positive peaks in the range of 40 digits.

By trial and error, we found out that the async clock was the culprit.

Try if the following helps:

k_adcConfig.enableAsynchronousClockOutput = false;

Regards,

Daniel

0 Kudos

2,431 Views
vaibhavi_padwal
Contributor II

Hi Daniel,

Thank you for your suggestion.

For the controller I am using, I have used BUS clock as the Clock source for ADC module.

s_adc_config.clockSource = kADC16_ClockSourceAlt0;

I have tried changing this to asyncronus clock also but issue is the same irrespective of the clock in case of my controller.

Current Configuration of ADC I am using is :

config->referenceVoltageSource = kADC16_ReferenceVoltageSourceVref;
config->clockSource = kADC16_ClockSourceAlt0; //Bus clock with frequency 20MHz
config->enableAsynchronousClock = false;
config->clockDivider = kADC16_ClockDivider2;//Clock divider of 2
config->resolution = kADC16_ResolutionSE12Bit;
config->longSampleMode = kADC16_LongSampleDisabled;
config->enableHighSpeed = false;
config->enableLowPower = false;
config->enableContinuousConversion = false;

Can you please review the software configuration of ADC I am using and suggest some other changes with respect to your configuration?

Also Please check the schematic I have attached with query and let me know if there's some difference with respect to  hardware .

Best Regards,

Vaibhavi

0 Kudos

2,431 Views
dh1
Contributor II

Hi Vaibhavi

We use a completely different processor, RT 1060. So the settings are probably not comparable.

But I remember that a colleague mentioned, that he had to set high speed conversion to true, to get reasonable results.

What I did to find our problem, is set up a firmware that quickly made 3000 samples and after that printed the average, min and max values to the console. This way, I could very rapidly try different adc settings, to see which one helps.

Regards,

Daniel

0 Kudos

2,431 Views
gauravmore
Contributor III

kerryzhou

Hi kerry,

Reagrding this ADC issue we are not able to get any reason for the same. Since we are using the evaluation board to check the fluctutation  in ADC so ther should be any noise.

We are simply providing DC inout to the ADC using RC filter mentioned above, But still getting the same result. 

We are not able to proceed for the development board since it is not getting resolved and we are not able to proceed further for our product development. It is on higher priority since we are in 3rd phase of product development.

alexisandalon ‌

Please share the code to check the fluctuation on FRDM board first. Also share the results if possible and snapshot of the setupt you have used for testing.

Thanks 

Gaurav More

0 Kudos

2,431 Views
dh1
Contributor II

Hello Gaurav

We are experiencing something similiar with our i.MX RT.

See https://community.nxp.com/message/1271640 

Have you found a solution in the meantime?

Regards,

Daniel

0 Kudos

2,431 Views
Alexis_A
NXP TechSupport
NXP TechSupport

Hello gauravmore‌,

To improve the accuracy for the sampling there's some configurations in the ADC that you could try:

  • Set the hardware average (ADC16_SetHardwareAverage(ADC_Type *base, adc16_hardware_average_mode_t mode))
  • Set the Long Sample mode.

With the hardware average I have the better results setting to the lowest average (kADC16_HardwareAverageCount4), if you don't want the sampling period to get affected I will suggest to decrease the divider feeding the module.

Let me know if this helps you.

Best Regards,

Alexis Andalon

0 Kudos