Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

FIR with minimal delay

Status
Not open for further replies.

bubulescu

Member level 3
Joined
Sep 10, 2009
Messages
65
Helped
12
Reputation
24
Reaction score
12
Trophy points
1,288
Activity points
1,897
Being fairly new to digital filtering I'm trying to make a filter that would have the lowest delay possible while having good filtering characteristics. Call me an idealist, but that is the desired effect.
What I want is a response similar to a Bessel filter, that is for the ugly-spikey signal thet's fed to the input, the output should filter it (as) clean (as possible) while fillowing the DC level of it. Now, I understand IIR filters have lower delays compared to high order FIRs while FIRs are better in terms of stability, but I tried analog so far and a high-order Bessel gave the best response, but the delay is... well not satisfactory, so digital filters were suggested and, trying a few free programs found on the internet I realized that IIR behave -- in terms of my needs -- just like their analog counterparts. FIR, on the other hand, if made so that N and sampling were sufficiently low/high, gave better results.
My question: is there a way to achieve the desired effect?


(Read the following only if you think you have time)

So, at this point, I found that Dolph-Chebyshev would be the best suited since it gives the lowest N for the better filtering capabilities, closely followed by Kaiser (not to mention the possibility of calculating with fc/Att in mind from the beginning). But, still, after implementing a FIR in LTspice, the delay could benefit from more improving...
In practise it would serve an active power filter and the input would have twice the frequency of the mains + a DC level, but with a low level mains humm overlapped. So, the FIR I made was done with fc=0.1Hz (I found out it gives a slightly better response compared to 1Hz, while maintaining the large transit bandwidth for minimizing the N), fs=40Hz (the minimum frequency allowed, imposed as a worse case, being 45Hz), sample=1024 and Att=50dB. For the Kaiser window (easier to calculate) I got M=75 and the delay -- calculated from start to 90% of the DC value -- is ~50ms, which would mean 2,5 periods of the standard 50Hz mains, during which time the DC link capacitor would have to sustain everything => a higher value for it. As a comparison, a 3rd order Bessel with fc=10Hz would give very similar results in terms of reaching the 90% DC level, even if the rising time is less steep as with the FIR.
If, however, I would ignore the humm, so that the input would have 2*f_mains as the lowest frequency in the spectre, then I could make the FIR with fs=80, giving a step response of ~22ms, at the cost of a maximum +3% slight overshoot -- acceptable. That would mean just a bit more than a period, ~40% of the initial delay. This result would be something to try to achieve!
In an ideal case of a fixed, non-drifting mains frequency, say 50Hz, then I could have done a simple moving average filter with sampling over half a period, which would have resulted in a steep 10ms response and a "tight-string" DC level at the output. However, real-life forces me to accept the drifts which would distort the results, making it a non-choice. Still, I could consider this a goal to follow and, while I may never achieve it, a result as close as possible is what I would like to get and the reason I mentioned this example was simply for a better viewing of the reasons.

PS: The thought occured to me that a self-adjusting moving average filter could be done, that is measuring the zero-crossing both ways and trying to adapt the sampling period accordingly, resulting in T/2 measure + T/2 adjusting/response = one T delay, but with a poor performance in case of constant/large drifts.

Vlad
 

I'm under the impression, that you are still missing a clear specification of the intended filter properties, and in turn there's no clear question.

In usual FIR filter theory, delay is simply group delay, or in other words fs*N/2 for any popular FIR design. Because your filter requirements are primarly referring to time domain properties, you seem to be more interested in settling time.

My general comment in this relation is, that standard FIR filter designs pay an extra delay fee for their pefect time-domain symmetry respectively constant group delay. You come off better with an IIR, if you don't rely on this feature.

The moving average solution seems more or less unrelated to the previous considerations in terms of filter properties. It's neither smooth in frequency nor time domain.
 

that is only the case for linear-phase FIR filters. FIR filters that are not symmetric/antisymettric will not have a constant group delay (and thus not a linear phase).

Adaptive filters are generally based on updating the taps of an FIR filter, and tend to be unsymmetric.

For a filter to have low-delay, it should be minimum-phase. Again, that would not be symmetric. As a result, the windowed-sinc filters will all be sub-optimal in terms of group-delay. methods for "nonlinear phase FIR filters" might be applicable. Also, optimization methods that include time-domain requirements can be used.
 
  • Like
Reactions: FvM

    FvM

    Points: 2
    Helpful Answer Positive Rating
In fact, FIR filter can implement arbitray impulse responses, not restricted to time symmetrical, constant group delay ones. The mentioned FIR prototypes, Kaiser and Dolph-Chebyshev are however classical symmerical designs.
 

You were right, FvM, "settling time" was the wanted term, I mentioned the 90% response sensing that "delay" may be a poor choice of words. My apologies. As for the specifications, they need to be fast settling time and minimal group delay for time domain and good filtering for frequency domain, as impossible to achieve as they may be. At least, that is the goal to follow.

Now, three replies and all three "blame" FIR for not being a good choice. Then IIR would be the one? I am fiddling with LTspice and AnaDigFilt (a small useful program) at the moment and the results I get, both in time and frequency domain, for the desired bandwidth, seem to be exact replicas of their analog counterparts (minus the ripple given by the sampling). I even tested Chebyshev I and II and elliptic filters, just for the sake of comparison, even if a higher order Bessel seems to be the best choice in terms of response and settling time. Or would an anti-symmetric, minimal-phase FIR be a good choice? The Park-McClellan and Remez algorithms seem complicated enough, but not impossible.
Among the multitude of search results about FIRs, I stumbled upon a so-called IFIR (Interpolated FIR), which is supposed to minimize N by upsampling a normal FIR, thus minimizing the group delay. But the description seemd fuzzy, is the reduction applied for the previously calculated N or for the upsampled, higher-N one?

I have to admit that these two days I did nothing but go from Google result #1 to Google result #2 and so on, leaving me with a brownian movement of ideas, which is why I opened this topic, in the hope of giving me a point for the lever. I'll be searching for more explanations, but any help is welcome.


Vlad
 

Just a quick intermezzo to actually show what I want and to show you a few results.

Screenshot01, which shows the kind of signal that may be at the input and the responses from an analog filter with fc=10Hz, N=4 and four different types (from first to last): Bessel, Chebyshev II, Butterworth, Chebyshev I. Butterworth and Chebyshev II are similar and both have settling time at ~110ms, Chebyshev I still oscillates until ~140ms, Bessel only at ~60ms.



Screenshot02 shows an FIR at work with, as seen, fc=1Hz, fs(top)=45Hz, Att=-40dB, sample=1024Hz (M=62 [edit]M=60, sorry, I looked at Maxima instead[/edit] ). You can see it setles at ~40ms, a winner so far but it still takes more than 2 periods of the input (f=45Hz, worse case). Also notice the extracted DC level...



And lastly, Screenshot03 which shows three fillters, side-by-side (up to down):
1) FIR with fc=1Hz, fs(top)=40Hz, Att=-35dB (a minimum), sample=1024Hz [edit2]M=50, forgot this[/edit2]
2) Analog Butterworth with fc=10Hz, N=2
3) IIR Bessel, same settings as the 2nd (chosing Butterworth would have resulted in a same, more aliased result as the analog one)

 

The shown examples as well as your comments are partly clarifying the specification.

I think, some confusion is caused by the unrealistic FIR specification of fc=1, fs=40. If you check the actual frequency response, you'll notice a (-3 dB) cut-off frequency of about 15 Hz, which is set by the limited number of FIR taps. I also understand, that something similar to the Kaiser window, N=40 FIR is a good choice in your eyes.

If you prefer an (almost) monotonic time domain response, Bessel (or even a lower Q Gauss type) are the ownly analog filter prototypes of interest. With a moderate order like 3 to 5, you get a time and frequency domain response that's nearer to your FIR. The FIR however creates additional comb filter zeros under the given conditions, that can't be provided by an IIR.

P.S.: My conclusion is, that the FIR is most likely better, if the interfering signal is 50 Hz fixed frequency and you can utilize the comb filter effect. If you however expect a range of e.g. 40 to 60 Hz, it's not necessarily better. So the problem once more refers to fixing the specification.
 
Last edited:
It's true that fc and fs are quite off from one another, but the reason behind it is to have a large transition width, therefore the rising slope will have a slow roll-off but lower N and minimized ripples. For example, making fc=20 would have given pre- and post-ringing, resulting in a settling time further away from what can be obtained with fc=1, not to mention much higher N. Also, I have noticed the fc being at ~15Hz, but I thought that has to do with the weighing sinc factor's argument, ft, the average between fc and fs. I forgot to mention that the FIRs in the previous examples are Kaiser, simply because I could specify fc, fs and Att. I am still trying to implement Dolph-Chebyshev in LTspice but the lack of an iterative sum makes this really cumbersome; I would have really liked to compare it to Kaiser with the given signal.

As for the humm induced by the mains, I thought of a notch filter, but it would have been useless extra computation, since I would have had to choose a large band, 45Hz - 55Hz, due to the maximum imposed drift. So, I thought I'll just go for one low-pass that does the job; a higher N than, say, an fs=80Hz, sure, but less than that one plus a Notch.

The FIR with N=40 would sure have a fast response, but I have doubts that it would have the proper frequency domain characteristics; so far N=50 seems to a minimum acceptable for a +/- ~2% ripple -- but this for the given signal. In the end, the main problem is that the input may have an even uglier waveform than the one chosen as an example. In practise, it will be a quadrature signal decomposed from the sensed mains current, multiplied with unit sin/cos and then added. So, similar to the example, but only Lord knows what harmonics it may carry. One may guess based on the existant apparatus, but still... And, as if this weren't enough, the DC level, representing the total active power, may vary from zero to ...whatever maximum can be imposed, and that DC level has to be followed as quickly as possible to avloid the "strain" on the DC link capacitor/inductor or a large, impractical value. Imposing conditions can be a good detective job :)

Well, as a conclusion, IIRs are bad except Bessel (ringing), analogs -- the same, FIRs only for low N, otherwise they're not good either because of the extra delay. Minimum-phase seem to promise but, from what I've read so far, the price to pay for the reduced delay is ringing, which is unacceptable. Adaptive filters are yet to be discovered, but it seems that they require quite some computation power. So, for now, a thank you for the guide lines, you did help me despite my fuzzy explanaions.


Thank you,
Vlad
 

can you help me with algo. of fir filters for vhdl platform
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top