# Keeping the employee satisfied II

Case study: Measuring the weight of coffee beans

**Phenomena analysis**

The first step involved detailed signal analysing using the ASN filter Designer’s signal analyser. After loading a captured waveform into the signal analyser, we were able to perform a detailed analysis of the phenomena, by zooming into the region of oscillation.

*Finding phenomena: ASNFD high resolution spectral analysis *

As seen, the source of the oscillation comes from two frequencies at 52 and 61Hz respectively. Armed with this information we were able to design a suitable loadcell filter.

**Loadcell filter**

Traditionally, many designers use a Butterworth IIR (infinite impulse response) lowpass filter for measurement applications, but the relatively slow attenuation characteristics and high filter order make it undesirable for many practical situations. Thus, a Chebyshev Type II IIR filter was chosen as the main filter building block as it has a faster roll-off characteristics than an equivalent order Butterworth filter. Although the Butterworth has the advantage of a smooth monotonic response, the Chebyshev Type II has a maximally flat passband, which is ideal for DC measurement applications, such as the application considered herein.

**Fine tuning of the poles and zeros**

Fine tuning of the poles and zeros positions was easily undertaken with the ASN Filter Designer’s interactive P-Z plot editor.

The tool’s interactivity allowed us to zoom into a region of interest and nudge the pole-zero positions and tweak the filter performance while assessing the filtering results in real-time – all of which was done with the mouse!

**Post filter**

The post filter serves to further smooth out the DC amplitude estimation from the main filter by lowpass filtering the data a second time. The post filter is based on a 2nd order IIR alpha-filter, i.e.,

\(H_{pf}(z)=\Large{\frac{1 + 2𝑧^{−1} + 𝑧^{−2}}{1 + 2\alpha𝑧^{−1} + \alpha^2𝑧^{−2}}}\) ; Gain at DC: \(\Large{\frac{1 + 2\alpha + \alpha^2}{4}}\)

Mapping this filter into ASN FilterScript (shown below), and experimenting with various values, a value of \(\alpha=-0.94\) was choosen as the most optimal.

Main() alpha=-0.94; Num = {1,2,1}; // define numerator coefficients Den = {1,2*alpha,alpha^2}; // define denominator coefficients Gain = (1+2*alpha+alpha^2)/4; // define gain

**The result**

A filter that settled to within ±1 ADC counts or ±25mg in approximately 350msec.