beautypg.com

Conclusion, An299 – Cirrus Logic AN299 User Manual

Page 9

background image

AN299REV1

9

AN299

In most applications the simple exponential average of 64 would result in excessive output settling latency, so an
adaptive algorithm could be used to allow a quicker response to step changes in the input. The following code seg-
ment uses two thresholds to accomplish a quick response while improving noise-free performance by 3 bits for a
steady state input.

Figure 6. Adaptive Algorithm Code Example

In this code, if any step in ADC output over 8 bits is detected, the average is updated to the new value without any
software filtering. If continuous conversion mode is used there will still be a four-conversion latency. However, this
will minimize overshoot and if a faster word rate is used, the latency should be acceptable for most applications. If
the step size is between 64 and 256, a simple exponential average of 8 is used allowing reasonably fast settling as
the final value is approached. Once the new value is within 64 bits of the average value the algorithm switches to a
simple exponential average of 64. As long as the input remains within a ±64 LSB range, the simple average of 64
is maintained, resulting in 3 additional noise-free bits of performance for steady-state inputs. For slower microcon-
trollers which do not have floating point units, left and right shifts on integer values and subtraction and addition can
be used as long as the filter coefficients are powers of two.

7. CONCLUSION

As this application note explains, there are many factors that determine the success of a high-resolution ADC im-
plementation. The Cirrus CS5531/32/33/34 family of converters are some of the quietest converters on the market
and if careful mixed-signal design practices are observed, incredibly accurate high-resolution measurements of very
low-level DC signals can be achieved.

As always, Cirrus Logic applications support offers schematic and PCB layout review to our customers. In many
cases less-than-optimum designs or layout errors can be corrected before the PCB is produced.

while(1)

{

NewValue

=

ReadADC();

Difference = abs ( NewValue – Average );

if ( Difference > 256 )

/* No software average for large steps */

Average = NewValue;

else if ( Difference > 64 )

/* Exponential average of 8 for medium step size */

Average = Average * 0.875 + NewValue * 0.125;

else

/* Exp. ave. of 64 for steady state noise reduction */

Average = Average * 0.984375 + NewValue * 0.015625;

/* Scale the value for readout after averaging */

DisplayValue = ScaleValue( Average );

UpdateDisplay( DisplayValue );

}