Author Topic: STM32G0B1 noisy adc values  (Read 1324 times)

0 Members and 1 Guest are viewing this topic.

Offline jordannedevTopic starter

  • Contributor
  • Posts: 20
  • Country: bg
STM32G0B1 noisy adc values
« on: August 10, 2022, 07:26:32 am »
Good day colleagues.
In my current project I'm using STM32G0B1 but I have some issues with reading ADC values. The ADC is in oversampling mode in order to read 16bit values. There is a lot of noise in the readings and I can't figured out what is the reason for that. I set up the ADC to be updated by TIM2 with different frequencies but the results were the same. On the input I try with different sources - DAC and function generator. For now the only thing that help was moving averaging filter with window of 100 elements and low ADC update speed of 1kHz but this introduce a lot of delay in reading the value. Now I'm thinking to put on the input active low pass filter in order to reduce the high frequency noise. If someone have experience with such a problems, please share ideas how to solve this issue.
 

Offline wek

  • Frequent Contributor
  • **
  • Posts: 486
  • Country: sk
Re: STM32G0B1 noisy adc values
« Reply #1 on: August 10, 2022, 07:33:05 am »
The ADC is in oversampling mode in order to read 16bit values.
Don't have unrealistic expectations. You are using an ADC embedded in what's essentially a massive noise source (thousands of transistors switching synchronously). A couple of LSB noise on the raw 12-bit results is to be expected even with perfect hardware design - and it HAS to be quite perfect, every millivolt of deviation/noise in VSSA/VREF-/VDDA/VREF+ is directly reflected on the ADC output. Averaging won't do magic.

Read AN2834.

Try with a low-impedance DC signal source first.

JW

 
The following users thanked this post: thm_w

Online thm_w

  • Super Contributor
  • ***
  • Posts: 6278
  • Country: ca
  • Non-expert
Re: STM32G0B1 noisy adc values
« Reply #2 on: August 10, 2022, 11:11:36 pm »
Schematic?
Oscilloscope capture of input?
Oscilloscope capture of Vdda/Vref?
Profile -> Modify profile -> Look and Layout ->  Don't show users' signatures
 

Offline jordannedevTopic starter

  • Contributor
  • Posts: 20
  • Country: bg
Re: STM32G0B1 noisy adc values
« Reply #3 on: August 11, 2022, 02:39:17 pm »
The problem is solved. I change the way of taking samples and the algorithm for calculating final ADC value. Now the calculation is much faster and the final compute value is stable.
 

Offline eugene

  • Frequent Contributor
  • **
  • Posts: 493
  • Country: us
Re: STM32G0B1 noisy adc values
« Reply #4 on: August 12, 2022, 01:07:37 pm »
Care to share what you learned?
90% of quoted statistics are fictional
 
The following users thanked this post: Bassman59, newbrain

Offline jordannedevTopic starter

  • Contributor
  • Posts: 20
  • Country: bg
Re: STM32G0B1 noisy adc values
« Reply #5 on: August 13, 2022, 07:27:49 am »
I'm using timer to update the ADC(update event) with freq. of 100kHz. In the DMA buffer I take 100 values. Then in the ADC callback I make the calculation from the 12bit values for the oversampled 16bit value.
The calculation in the callback is :

avg = 0;
for(int16_t i = 0; i < nsamples; i++)
avg += samples;
adcVal = ((avg * (1 << (adcOver- adcNative)) + nsamples/ 2) / nsamples);

where:
avg is sum of the taken samples
nsamples number of samples (in my case 100)
adcOver is 16
adcNative is 12
adcVal is calculated 16bit adc value


 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf