
Rob Toulson, Tim Wilmshurst, in Fast and Effective Embedded Systems Design, 2012 5.3.3 Applying Averaging to Reduce Noise This is a very simple example of digital signal processing.ĪDCdata=ADCdata+Ain∗3.3 //sum 10 samples Note that while this sort of approach gives some benefit, the actual measurement now takes 10 times as long. Try running the revised program and see if a more stable output results. You will see that this code fragment sums 10 ADC values and takes their average. Try inserting the for loop shown below, replacing the ADCdata=Ain line in Program Example 5.4. This should help to find the underlying average value and remove the high frequency noise element. If you look with the oscilloscope at the ADC input (i.e., the “wiper” of the potentiometer) you are likely to see some high frequency noise superimposed on this exactly how much will depend on what equipment is running nearby, how long your interconnecting wires are, and a number of other things.Ī very simple first step to improve this situation is to average the incoming signal. Several effects may be at play here, but almost certainly you are seeing the effect of some interference, and all the problems it can bring.

You may already have noticed that the PWM value in Sections 5.2.2 or 5.2.3 also appeared to vary, even when the potentiometer was not being moved.

If you leave Program Example 5.4 running, with a fixed input and values displayed on Tera Term or CoolTerm, you may be surprised to see that the measured value is not always the same but varies around some average value. Rob Toulson, Tim Wilmshurst, in Fast and Effective Embedded Systems Design (Second Edition), 2017 5.3.3 Applying Averaging to Reduce Noise
