Author Topic: STM32 ADC noise  (Read 20924 times)

0 Members and 1 Guest are viewing this topic.

Online iMo

  • Super Contributor
  • ***
  • Posts: 4784
  • Country: pm
  • It's important to try new things..
Re: STM32 ADC noise
« Reply #25 on: October 26, 2018, 05:55:49 pm »
What is your problem here? Your ADC works nice.
Your DC offset is +0.5 LSB and the noise is 0.9 LSB peak to peak.
That is an excellent result with that board and F407, imho..
 
The following users thanked this post: VanitarNordic

Offline VanitarNordicTopic starter

  • Frequent Contributor
  • **
  • Posts: 277
  • Country: 00
Re: STM32 ADC noise
« Reply #26 on: October 26, 2018, 06:00:41 pm »
What is your problem here? Your ADC works nice.
Your DC offset is +0.5 LSB and the noise is 0.9 LSB peak to peak.
That is an excellent result with that board and F407, imho..

My problem is that I want to measure the amplitude of the signal or detect amplitude changes. Therefore I have to take an integral, it means adding up the ADC values, but as you see the variance is high. if I take an average (divide the sum by 500), then the variation or small amplitude changes will be destroyed (naturally averaging normalizes the data). Do you have a suggestion?
« Last Edit: October 26, 2018, 06:02:19 pm by VanitarNordic »
 

Online iMo

  • Super Contributor
  • ***
  • Posts: 4784
  • Country: pm
  • It's important to try new things..
Re: STM32 ADC noise
« Reply #27 on: October 26, 2018, 06:05:09 pm »
Frankly, I do not understand what you want to do.
Could you describe in detail what measurements you want to provide?
 

Offline VanitarNordicTopic starter

  • Frequent Contributor
  • **
  • Posts: 277
  • Country: 00
Re: STM32 ADC noise
« Reply #28 on: October 26, 2018, 06:08:51 pm »
Frankly, I do not understand what you want to do.
Could you describe in detail what measurements you want to provide?

Tell me how to measure the amplitude of a signal in a given time frame?. what I do is to sample that time frame by the ADC and calculate the sum of these values. right?
Do you have another suggestion?
 

Online iMo

  • Super Contributor
  • ***
  • Posts: 4784
  • Country: pm
  • It's important to try new things..
Re: STM32 ADC noise
« Reply #29 on: October 26, 2018, 06:17:14 pm »
In order to measure an amplitude of the signal in given time frame you have to use a "peak detector".
With an ADC you sample the signal within the time frame and you take the sample with the highest value - that is the peak amplitude..
« Last Edit: October 26, 2018, 06:19:27 pm by imo »
 

Offline VanitarNordicTopic starter

  • Frequent Contributor
  • **
  • Posts: 277
  • Country: 00
Re: STM32 ADC noise
« Reply #30 on: October 26, 2018, 06:26:25 pm »
In order to measure an amplitude of the signal in given time frame you have to use a "peak detector".
With an ADC you sample the signal within the time frame and you take the sample with the highest value - that is the peak amplitude..

With your suggested method, can we measure if the input signal (in the given time frame) changes a few mV or hundreds of mV?
 

Offline VanitarNordicTopic starter

  • Frequent Contributor
  • **
  • Posts: 277
  • Country: 00
Re: STM32 ADC noise
« Reply #31 on: October 26, 2018, 06:34:28 pm »
Actually what I'm doing is the same but with ADC as described here: https://electronics.stackexchange.com/questions/35735/measure-ac-sine-wave-amplitude-with-adc
 

Online iMo

  • Super Contributor
  • ***
  • Posts: 4784
  • Country: pm
  • It's important to try new things..
Re: STM32 ADC noise
« Reply #32 on: October 26, 2018, 06:39:05 pm »
What you describe is following:
1. you sample a signal with 12bit ADC (3.3V Vref), the "resolution" is 1LSB = 0.8mV (theoretically), the ADC range is 0..3.3V
2. you make N samples within a timeframe T  [0..T]
3. you want to detect the MAXima of the signal during the timeframe T - that is done by "derivation" of the signal (the dV/dt will change the sign).
Is that correct?
« Last Edit: October 26, 2018, 06:57:52 pm by imo »
 

Offline VanitarNordicTopic starter

  • Frequent Contributor
  • **
  • Posts: 277
  • Country: 00
Re: STM32 ADC noise
« Reply #33 on: October 26, 2018, 06:45:03 pm »
What you describe is following:
1. you sample a signal with 12bit ADC (3.3V Vref), the "resolution" is 1LSB = 0.8mV (theoretically), the ADC range is 0..3.3V
2. you make N samples within a timeframe T  [0..T]
3. you want to identify the changes of xLSB during the timeframe T.
Is that correct?

any changes in the amplitude (measuring how much) in that time frame or within those N samples (for example 0 to T, as you mentioned)
 

Online iMo

  • Super Contributor
  • ***
  • Posts: 4784
  • Country: pm
  • It's important to try new things..
Re: STM32 ADC noise
« Reply #34 on: October 26, 2018, 06:48:14 pm »
You want to detect the changes (dV/dt) during the sampling or after the timeframe T (when all the samples are sampled)?
 

Offline VanitarNordicTopic starter

  • Frequent Contributor
  • **
  • Posts: 277
  • Country: 00
Re: STM32 ADC noise
« Reply #35 on: October 26, 2018, 07:06:19 pm »
You want to detect the changes (dV/dt) during the sampling or after the timeframe T (when all the samples are sampled)?

We have to do after because we don't know where it happens (in which sample or samples together), but we are sure in which time frame. Therefore the time frame is fixed from a to b.

I used to add all values together and compare with previous value but it did not work because of instability. Averaging increases the stability but small variations will be destroyed.
 

Online iMo

  • Super Contributor
  • ***
  • Posts: 4784
  • Country: pm
  • It's important to try new things..
Re: STM32 ADC noise
« Reply #36 on: October 26, 2018, 07:20:59 pm »
I think you have to amplify the signal changes only (ie. 100x). Through an RC derivative circuit (ie. with an opamp) + amplifier (opapm). Then do the sampling.

https://www.electronics-tutorials.ws/opamp/opamp_7.html
« Last Edit: October 26, 2018, 07:24:27 pm by imo »
 

Offline VanitarNordicTopic starter

  • Frequent Contributor
  • **
  • Posts: 277
  • Country: 00
Re: STM32 ADC noise
« Reply #37 on: October 26, 2018, 07:55:00 pm »
I think you have to amplify the signal changes only (ie. 100x). Through an RC derivative circuit (ie. with an opamp) + amplifier (opapm). Then do the sampling.

https://www.electronics-tutorials.ws/opamp/opamp_7.html

I've already done that. if you think no other way than averaging, I'll increase the gain
 

Offline splin

  • Frequent Contributor
  • **
  • Posts: 999
  • Country: gb
Re: STM32 ADC noise
« Reply #38 on: October 26, 2018, 09:30:50 pm »
What are the maximum and minimum amplitudes of the signal that you want to measure?

What accuracy do you need?

What frequency range does the signal have?

Is the signal a sine wave of a single frequency at any one time?

Is the signal constant and for how long?

Do you have to have a measurement result every 250us or could be longer or shorter

Could the signal have a constant DC offset?
 

Online iMo

  • Super Contributor
  • ***
  • Posts: 4784
  • Country: pm
  • It's important to try new things..
Re: STM32 ADC noise
« Reply #39 on: October 28, 2018, 09:33:41 am »
Look at this circuit - it amplifies 1mV (50us) pulse superimposed on 5V DC. It will do with "any DC" voltage ("DC" is "filtered out" by R1C1 time constant). Amplification of the diff amplifier set to 100x.
An example only, you have to modify it according to your reqs.
« Last Edit: October 28, 2018, 09:42:26 am by imo »
 
The following users thanked this post: VanitarNordic

Offline VanitarNordicTopic starter

  • Frequent Contributor
  • **
  • Posts: 277
  • Country: 00
Re: STM32 ADC noise
« Reply #40 on: October 28, 2018, 08:50:58 pm »
Look at this circuit - it amplifies 1mV (50us) pulse superimposed on 5V DC. It will do with "any DC" voltage ("DC" is "filtered out" by R1C1 time constant). Amplification of the diff amplifier set to 100x.
An example only, you have to modify it according to your reqs.

You mean this circuit just amplifies the 1mV and not the carrying 5DC?

Although I am using this circuit with AC coupling https://www.electronics-tutorials.ws/opamp/opamp_7.html

one limitation I have is that the circuit uses a battery and a single supply. I have to power the OpAmp with the single supply techniques. at the moment I inject a voltage to the + rail.
 

Offline aandrew

  • Frequent Contributor
  • **
  • Posts: 277
  • Country: ca
Re: STM32 ADC noise
« Reply #41 on: October 29, 2018, 12:00:45 pm »
The ST Nucleo is a 4 layers design? Actually, I want to design a PCB just for my own purpose (not a demo board or header board which uses all I/Os) and dedicate one layer completely for the ground and another one for traces.

The Nucleo-144 boards are 6 layer boards.
 
The following users thanked this post: VanitarNordic, thm_w

Online iMo

  • Super Contributor
  • ***
  • Posts: 4784
  • Country: pm
  • It's important to try new things..
Re: STM32 ADC noise
« Reply #42 on: October 30, 2018, 08:44:56 am »
Look at this circuit - it amplifies 1mV (50us) pulse superimposed on 5V DC. It will do with "any DC" voltage ("DC" is "filtered out" by R1C1 time constant). Amplification of the diff amplifier set to 100x.
An example only, you have to modify it according to your reqs.

You mean this circuit just amplifies the 1mV and not the carrying 5DC?

Yes - see the simulation above..

The circuit amplifies only changes which are "faster" than t=R1C1 time constant. The "DC" is slower than R1C1.

When the "background signal" is "slower" than "a pulse superimposed on the background signal" it will amplify the superimposed pulse only. 

"Slower" means its "fastest changes periods" are longer than t=R1C1 (or better N*R1C1)..

Or something like that :)

PS: see below:

yellow signal: a 20mV 50us long pulses (with 50ms period) superimposed on a 1Vpp 2Vpp 0.2Hz sine wave, while the sine wave is offset at 3V DC

green signal: the pulses amplified 100x with above circuit.

Mind there is the DC coupling..
« Last Edit: October 30, 2018, 10:43:55 am by imo »
 
The following users thanked this post: VanitarNordic

Offline VanitarNordicTopic starter

  • Frequent Contributor
  • **
  • Posts: 277
  • Country: 00
Re: STM32 ADC noise
« Reply #43 on: October 30, 2018, 10:27:33 am »
Quote
The circuit amplifies only changes which are "faster" than t=R1C1 time constant. The "DC" is slower than R1C1.

No way to run this circuit with a single supply?
 

Online iMo

  • Super Contributor
  • ***
  • Posts: 4784
  • Country: pm
  • It's important to try new things..
Re: STM32 ADC noise
« Reply #44 on: October 30, 2018, 10:33:02 am »
Try with a single rail (rail-rail) opamp. Avoid input/output voltages close to VCC and GND (closer than 100-300mV), better consult the datasheet.

PS: the above sine wave is 2Vpp at 3V DC.

PPS: it works somehow with a cheapo LM358 single supply opamp, thus it should work fine with any modern single supply r-r opapm..
« Last Edit: October 30, 2018, 11:07:14 am by imo »
 
The following users thanked this post: VanitarNordic

Offline aandrew

  • Frequent Contributor
  • **
  • Posts: 277
  • Country: ca
Re: STM32 ADC noise
« Reply #45 on: October 30, 2018, 03:03:24 pm »
No way to run this circuit with a single supply?

You can run it on a single rail if your inputs don't go below 0V and are happy with some distortion around 0V.

Alternatively, you can use a little trick to generate a weak/noisy negative rail. You don't need the rail to be very clean because you're only using it for some headroom for the op-amp to do its work.

Take an LM2776 to invert the supply and feed the output to the -V of the opamp. This is a very inexpensive way to get clean output down to 0V. You can make it even more inexpensive if you use an MCU pin to generate the pulses which drive the switched capacitor inverter.

There is also the LM7705 which generates a very precise/well regulated -0.23V which can be used on devices which cannot take a negative voltage rail but where you want to get an undistorted signal around 0V.
 
The following users thanked this post: VanitarNordic

Offline VanitarNordicTopic starter

  • Frequent Contributor
  • **
  • Posts: 277
  • Country: 00
Re: STM32 ADC noise
« Reply #46 on: October 31, 2018, 12:17:16 am »
No way to run this circuit with a single supply?

You can run it on a single rail if your inputs don't go below 0V and are happy with some distortion around 0V.

Alternatively, you can use a little trick to generate a weak/noisy negative rail. You don't need the rail to be very clean because you're only using it for some headroom for the op-amp to do its work.

Take an LM2776 to invert the supply and feed the output to the -V of the opamp. This is a very inexpensive way to get clean output down to 0V. You can make it even more inexpensive if you use an MCU pin to generate the pulses which drive the switched capacitor inverter.

There is also the LM7705 which generates a very precise/well regulated -0.23V which can be used on devices which cannot take a negative voltage rail but where you want to get an undistorted signal around 0V.

in this specific application, we want to amplify mV range signals and measure them by the ADC, then do you think using a charge pump such as 7660 (or the ones you mentioned) does not inject wild noises to the circuit?
 

Offline aheid

  • Regular Contributor
  • *
  • Posts: 245
  • Country: no
Re: STM32 ADC noise
« Reply #47 on: November 04, 2018, 12:47:56 pm »
With your suggested method, can we measure if the input signal (in the given time frame) changes a few mV or hundreds of mV?

What's the time frame like? If it's fairly long, can't you just use a low-pass filter (in code)? Or am I misunderstanding you?
 

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 16615
  • Country: us
  • DavidH
Re: STM32 ADC noise
« Reply #48 on: November 06, 2018, 01:32:35 am »
The usual test for ADC noise is the standard deviation of the output which directly returns RMS noise.  Sometimes peak-to-peak noise is used in applications where it is more relevant.

Microcontroller ADCs are usually very noisy because ground currents from the digital side get directly into the ADC via the signal and reference grounds. This can be somewhat ameliorated by using instrumentation amplifiers to drive the analog and reference input referenced to the microcontroller's ground.
 
The following users thanked this post: VanitarNordic

Offline VanitarNordicTopic starter

  • Frequent Contributor
  • **
  • Posts: 277
  • Country: 00
Re: STM32 ADC noise
« Reply #49 on: November 06, 2018, 08:14:33 am »
The usual test for ADC noise is the standard deviation of the output which directly returns RMS noise.  Sometimes peak-to-peak noise is used in applications where it is more relevant.

Microcontroller ADCs are usually very noisy because ground currents from the digital side get directly into the ADC via the signal and reference grounds. This can be somewhat ameliorated by using instrumentation amplifiers to drive the analog and reference input referenced to the microcontroller's ground.

I read that the digital and analog grounds must be connected in just one point, it means separated ground planes but connected in 1 point. it seems ground separation does not help to reduce the noise. if you think an external ADC is more stable, then I gonna test an external one.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf