| Electronics > Projects, Designs, and Technical Stuff |
| Stabilizing analog read on a potentiometer |
| << < (5/5) |
| ogden:
--- Quote from: Siwastaja on July 21, 2019, 09:59:16 am ---c) capacitor (between the ADC input and ground) orders of magnitude larger than the ADC sampling capacitor - say 10nF to 100nF is often just right. The capacitor solution is obviously the cheapest and simplest (and the way to go) --- End quote --- ^^^ This. 10k POT + 0.1uF, 10-20 samples/sec. No software averaging/integration whatsoever. --- Quote from: David Hess on July 22, 2019, 03:22:03 am ---The potentiometer will be quieter than practically any microcontroller ADC but the potentiometer's limited settability places a limit on precision so there is no reason not to filter the ADC output down to 7 or 8 bits at best removing most or all of the noise. --- End quote --- Right. You just take 8 most significant bits out of ADC and you are done. |
| mikerj:
--- Quote from: langwadt on July 21, 2019, 05:08:40 pm --- --- Quote from: mikerj on July 21, 2019, 12:42:59 pm --- --- Quote from: Sterno on July 19, 2019, 08:29:22 pm ---I have had good luck filtering a noisy analog signal by taking 16 sucessive readings on the ADC, storing these in an array, summing the total and then shifting that result 2 bits to the right. If I recall, method is called "decimate and shift" and is said to preserve accuracy which can be lost through standard averaging. --- End quote --- This is using oversampling to generate more bits of resolution e.g. samplinge 16 times and you get 2 more bits of resolution, providing you have more than 0.5 LSB of noise present. This will not reduce noise in the final value, in fact it will most likely increase it. --- End quote --- with a few assumption on the noise such as a zero mean it can --- End quote --- If you have zero noise then a) oversampling won't get you any more resolution, and b) you don't need any noise filtering to start with. |
| langwadt:
--- Quote from: mikerj on July 22, 2019, 09:08:49 am --- --- Quote from: langwadt on July 21, 2019, 05:08:40 pm --- --- Quote from: mikerj on July 21, 2019, 12:42:59 pm --- --- Quote from: Sterno on July 19, 2019, 08:29:22 pm ---I have had good luck filtering a noisy analog signal by taking 16 sucessive readings on the ADC, storing these in an array, summing the total and then shifting that result 2 bits to the right. If I recall, method is called "decimate and shift" and is said to preserve accuracy which can be lost through standard averaging. --- End quote --- This is using oversampling to generate more bits of resolution e.g. samplinge 16 times and you get 2 more bits of resolution, providing you have more than 0.5 LSB of noise present. This will not reduce noise in the final value, in fact it will most likely increase it. --- End quote --- with a few assumption on the noise such as a zero mean it can --- End quote --- If you have zero noise then a) oversampling won't get you any more resolution, and b) you don't need any noise filtering to start with. --- End quote --- zero _mean_ |
| Nominal Animal:
langwadt is correct. While it might be unintuitive, it is easy to see how this happens if we apply a bit of math here. (Lemme know if you don't want me to post this kind of posts, BTW.) To describe the noise, we need to know two of its parameters: its mean (which we assume is zero here), and its standard deviation σ. The noise distribution does not need to be Gaussian, as we only use σ as a measure of the noise magnitude: by definition, 68.3% of noise samples are within σ of its mean. When we average samples, zero-mean-noise tends to cancel itself. With an N-sample average, the standard deviation of the noise is σ/N. To work this out, let xi be the noiseless samples, and yi be the corresponding sampled noise, so that the actual measurement i is (xi + yi). When you take the average of those N actual measurements, you can split the sum into two, and get the mean of the noiseless samples plus the average mean of the noise samples. (If you do the same keeping the standard deviation labeling, using any notation you want, you'll see that averaging over N samples, the standard deviation of the noise is indeed σ/N.) (In fact, if we know both the mean and the standard deviation of the noise, and the original signal is sufficiently stable (low change rate), the noise can be compensated to give a similar result, i.e. 1/N reduction in the magnitude of the noise, if their dependency on the original signal is such that every unique measurement mean corresponds to a specific original signal mean. But you might get stuff like differential equations that have to be numerically solved to do that. It is useful with e.g. very sensitive low-temperature sensors, where the thermal noise can we well characterized and thus compensated for.) My own post above attempted to point out that if you use integer math (and with microcontrollers, you usually prefer integer math, unless your microcontroller has fast hardware floating point capabilities at sufficient precision), you'll want to do hysteresis and other similar analysis in the sum, prior to the division, because although the noise is higher, the added precision allows correspondingly more precise controls. My example shows that if your noise is ±0.5 bits (-1-0 or 0+1, or something in between) in the averaged value, with a bit of smart hysteresis in the sum you can keep the averaged value stable and noise-free. |
| Navigation |
| Message Index |
| Previous page |