# Multirate Control System Transfer Functions

I'm interested in oversampling the inputs to a digital controller to increase the SNR of the input process variable signal. I've read on this site and in articles like the one below that it is not accurate to apply the z-transform to an up-sampling or down-sampling operation along with frequency domain techniques because the sample rate change operation is linear but not time invariant.

Lyons, R., "Do Multirate Systems Have Transfer Functions?".

I'm curious to evaluate the reduction in proportional bandwidth of the loop gain of my servo system due to the anti-alias filter that would proceed the rate change operation. Although I have a time-domain, state-space model of my system as well, I thought it would be straight forward to approximate the bandwidth in the frequency domain.

Can anyone suggest an approximation that would allow me to insert either a decimating or interpolating CIC filter in a z-transform transfer function?

I am aware of $$H(z) = \big(\frac{1-z^{-Rm}}{1-z^{-1}} \big)^N$$ but I am concerned that this does not effectively represent the effect of the sample rate reduction.

• I wouldn't use a CIC filter in a control-loop context. They are basically moving-average filters. They will introduce a large phase delay that could create instability. Why not use a single sample-rate?
– Ben
Sep 22 at 17:51
• A single-stage CIC filter actually works very well. It gives you nulls right at all the non-zero harmonics of the sampling frequency; for the amount of attenuation it gives you within $\pm 10%$ of the sampling frequency it has lower delay from 0Hz to the typical loop closure frequencies. Sep 22 at 17:58
• When you talk about "an interpolating CIC" are you talking about putting an $n^{th}$-order hold on the controller output? Sep 22 at 18:01
• We were using 16-bit ADCs, which had noise with variance of 2 to 4 LSBs. We got the noise down to something like 1/8 of an LSB (while very carefully issuing disclaimers about accuracy, and tutorials about accuracy vs. precision). Sep 22 at 18:18
• Could you edit your question to put that link in the appropriate spot in the question's text? Also -- are you interested in oversampling the ADC, and if so is it for noise reduction, or are you interested in filtering the DAC output for some reason (filtering the DAC output is usually a Bad Idea, because most plants are, themselves, adequate low-pass filters, so all your lowpass filtering does is add delay). Sep 23 at 1:05

The primary impact of a CIC filter in a control loop is the delay it introduces, as a linear phase filter, in addition the change in amplitude within the loop bandwidth. The gain reduction actually helps our stability margin, but the phase impact can significantly reduce it. See the further details below on the equivalence of a CIC filter to a moving average filter: A moving average of $$N$$ samples will have a constant group delay of $$(N-1)/2$$ samples. When the moving average is done at a higher rate and then decimated by $$D$$, the delay in output samples is reduced by $$D$$ (every $$z^{-1}$$ becomes $$z^{-1/D}$$ at the output rate.).

Prior to decimation or after interpolation, the CIC transfer function is identical to a moving average filter (an FIR filter with all unity gain coefficients; ie the moving sum of the current and prior $$N-1$$ samples). Most CIC filters are a cascade of several sections (such as a $$CIC^2$$ is identical to the cascade of two such moving average filters).

This is demonstrated in the graphic below showing the equivalence of a 4 sample moving average (I say "moving average": if we scaled the output by four it would be the true average of the current sample together with the prior three samples) to a single section CIC filter. Below that is shown the implementation for $$CIC^2$$, and more generally $$CIC^N$$.

Resampling will result in frequency aliasing from all higher Nyquist zones, however understanding this can lead to reasonable approximations for practical use in the multi-rate transfer function that can be used.

Below is a simple example showing the frequency response with reference to the higher rate for a 4 sample moving average (which would be that for a single stage CIC for a decimate by 4 or interpolate by 4 operation). I show the input and output Nyquist boundaries ($$f_s/2$$) for a decimate by 4, and the resulting coherent frequency response with the shared blue box for any input signals at the input that are within the first Nyquist zone of the output rate. From this we also see that the delay (which is the negative derivative of phase with respect to frequency) is 1.5 samples as predicted by $$(N-1)/2$$ at the input rate, and that same phase slope is then $$1.5/4$$ samples at the output sample rate.

This plot was created in MATLAB using freqz([1 1 1 1]). Extending this to the more commonly used higher order CIC's is just a matter of convolving the coefficients. For example the coefficients for a CIC^2 would be coeff = conv([1 1 1 1],[1 1 1 1]) and the frequency response would then be determined using freqz(coeff).

If we are concerned about noise and SNR, we would then consider the effects of the aliasing in our analysis, where knowing the input noise, we can predict the output noise due to aliasing very accurately from the resampling. The input signal and noise would be processed by the frequency response shown, and then any energy above the output $$f_s/2$$ rate would fold into our first Nyquist zone as a non-coherent noise signal.

With regards to control system modeling for stability (such as Nyquist or Bode plots of open loop gain and phase), we are concerned with the coherent response specifically which is predicted (and not changed) by the transfer function prior to decimation. So specifically if a CIC decimation is inside the closed loop system (meaning it will be part of the open loop gain and its effects must be considered for stability); to assess these effects (and to properly design the loop filter with these additional delays considered), we can determine the transfer function using the equivalent moving average filter responses and include the resulting magnitude and phase over the portion of spectrum that is in the update rate of our loop as part of our evaluation of phase and gain margin for stability.

• "Resampling is non-linear it that there will be frequency aliasing from all higher Nyquist zones" -- nope. Resampling is time- (or shift-) varying. But it as it's typically modeled, it is linear (a it's implemented in hardware it requires nonlinear elements -- but a good hardware multiplier or mixer is quite linear). Sep 26 at 20:32
• @TimWescott thank you — I might be mixing up linear and time-invariant: I thought a linear system (within signal processing) is any system that has the same output frequencies as input frequencies (scaled and shifted) but no new frequencies created. Am I mistaken? As we can have linear time-variant systems which I could see a mixer, switch, decimator etc falling into if I neglect my restriction on input output frequencies. Sep 26 at 21:18
• It does appear that we violate the basic additive propery of linearity due to the new frequencies produced as I described via aliasing? I edited the contentious language until resolved Sep 26 at 21:47
• I think I am starting to see your point: if an f1 which is above Nyquist aliases in, it’s alias will be unchanged when we apply f2 which is in the first Nyquist zone (for example)- so this would not violate the addition property of linearity, in contrast to new frequencies created when both f1 and f2 are applied that would not be there when either one is. So linear- time variant. Thank you! (And sorry for my confusing earlier comment: scaled and shifted meaning phase shifted) Sep 26 at 22:17
• Linear just means the system obeys superposition. So $x(t) = y(t) \cos(\omega t)$ is linear -- but clearly not time invariant. It gets complicated with complicated time variance, but I'm pretty sure that a time-varying system can only munge frequencies in a finite way -- i.e., multiplying by a sine takes one spectral component and moves it to two new places, but it doesn't make a bazzilion, and it puts those components in very predictable spots. Sep 26 at 22:53