Hello, I work with standards that specify first and second order PLL transfer-function (e.g. filtering) using s-domain (Laplace) equations. I know that Matlab has a function firpm that accepts a frequency characteristic to create FIR coefficients.
While I can to use the s-domain equation to compute a magnitude plot that I can then extract the required frequency characteristic to input into firpm. But that s-domain equation has a specific phase response that needs to be matched as well.
Really what I need is an FIR filter that matches the magnitude, peaking, roll-off, and phase characteristics of the Laplace equation.
Would firpm ensure all of this, or, are all bets off? Is there a better way to tackle this?
Are you going to be simulating the PLL? If so think you'll find that a FIR filter that accurately duplicates the characteristics of your Laplace-domain specification is going to be very long. If you're simulating it anyway, why not use a simulation in the time domain?
If you're trying to duplicate the PLL, then please stop and think. Getting a FIR filter that duplicates the characteristics of some PLL is just going to be a distraction -- you should be thinking of how to make your PLL controller work in digital-land such that you get the performance that you need.
Hello, there are different ways to transform an analog filter (s domain equation) to a digital filter. They correspond to different ways to map the s-plane into the z-plane. You could try the bilinear transformation: https://ch.mathworks.com/help/signal/ref/bilinear....
Best regards, Sara
Sorry, I just realise that you wanted an FIR filter, whereas bilinear will give you an IIR. But (as far as I remember) this IIR would match both the phase and magnitude response of your original s-domain filter for frequencies that are smaller than the Nyquist frequency.
Thanks Sara, Besides computation time and the possibility of not converging, is there any technical downside to IIR vs FIR as far as the filtered result is concerned? For example, the IIR phase response can vary erratically, etc.
The link posted by JOS give a good comparison.
I would mainly choose FIR if I want a linear phase, but seems not to be your case, as you want the same phase as your s-domain function. I do not see any particular downsize in using IIR (you could post the s-domain function as Michael says). The magnitude and phase of the resulting function cannot match those of your s-domain function at all frequencies (due to frequency warping). It will be the case only far from fs/2 (or around a matching frequency fp that you specify). You should check the phase and magnitude of the resulting transfer function to see if it is what you need. and also the poles to see if there is risk of instability (poles too close to the unit circle) and pay attention of the structure you use if implementing in fixed point arithmetic.
I posted the function below. I don't like the sound of: "The magnitude and phase of the resulting function cannot match those of your s-domain function at all frequencies..." Won't this cause a problem? What if I set fp=fs/2 (is that a solution)?
A low pass filter should be accurate from low frequencies up to about an order of magnitude higher in frequency than the corner frequency (after things have started rolling off). If it's not accurate near Fs/2, seems like it should be a big issue. In this not the case in all applications? Sorry for the rookie question.
The bi-linear transform maps (compress, warps) the whole frequency range of your s-domain function, 0 to inf, to the available frequency range in the z-domain, 0 to fs/2 (or 0 to pi if you use normalised frequency). The mapping has the shape of an arctan, which is highly nonlinear. From https://en.wikipedia.org/wiki/Bilinear_transform: "The transform preserves stability and maps every point of the frequency response of the continuous-time filter, to a corresponding point in the frequency response of the discrete-time filter, although to a somewhat different frequency, as shown in the Frequency warping section below. This means that for every feature that one sees in the frequency response of the analog filter, there is a corresponding feature, with identical gain and phase shift, in the frequency response of the digital filter but, perhaps, at a somewhat different frequency. This is barely noticeable at low frequencies but is quite evident at frequencies close to the Nyquist frequency."
Frequency warping is unavoidable because you cannot otherwise fit an infinite frequency into a finite one. But a low-pass will still be a low-pass and a resonator will still be a resonator (however the cut-off and the resonance may be in a different place). But you can play with the sampling frequency and prewarping (optional parameter Fp that indicates in hertz a "match" frequency, that is, a frequency for which the frequency responses before and after mapping match exactly) so that the response is what you want for certain frequencies. Choose a sampling frequency that is much higher than the resonance and/or try prewarping using as match frequency fp the resonance frequency of the s-function. Finally you should plot both responses of the s-function and the z-function to verify.
Can you post the s-domain transfer function(s)?
Something of the form:
(b1*s + b0)/(s*s + a1*s + a0), where s=2*pi*f