How do I find the best CIC FIR compensation filter?
I was reading through this article that was recently posted here. Near the end, the author mentions compensation FIR filters to "sharpen the CIC filter's frequency roll-off and flatten the CIC filter's passband gain". He provided an example in figure 13 with the coefficients in the text below. How do I find the coefficients for such a filter? In the section after that example, he only provides coefficients for a 3-tap FIR filter that is just useful to compensate for the DC gain but not to sharpen the roll-off or flatten the passband (at least as far as I understood). I'm not very proficient in designing such FIR filters as I assume I need to design them in the frequency domain (sampling in the frequency domain maybe?).
Posted Apr 7, 2020, 2:58 PM UTC
Hi there,
CIC-filters need to be compensated in most applications since they have a large frequency roll-off in the desired passband. Compensation is done in this case by knowing the magnitude response equation of the filter to be compensated, and taking the inverse. For a CIC filter, the magnitude response is sinc in nature (look up the exact equation), so CIC compensation filters are know as inverse-sinc filters. Using the equation from taking the inverse of the CIC magnitude response, filter coefficients can be generated.
A quick google of "how to design a CIC compensation filter", and an Intel PDF talks about how this is done, and some other considerations. A matlab example is given to generate FIR coefficients.
Link to PDF: https://www.intel.com/content/dam/www/programmable/us/en/pdfs/literature/an/an455.pdf&ved=2ahUKEwic_d244NboAhWVG80KHeKvAnYQFjAAegQIAxAB&usg=AOvVaw3uDZ9sqPcRFc7C2PlMBMwp
Edit: I think that link is broken, but the title is "AN455: Understanding CIC Compensation Filters"
Thanks, I found the document. So the length of the compensation FIR filter is basically up to choice? Longer filters will result in less ripple and sharper cutoff, I assume. I don't have Matlab so I might as well do the frequency sampling myself.
Length is application dependent, so in a sense it is up to choice. You're spot on in that longer filters will have a sharper cutoff and less ripple.
Typically, a DSP engineer has to also consider hardware limitations in the design, not just ideal filter responses. If you only have a certain amount of memory to store the compensation filter coefficients, or there's only a certain amount of computation allowed (for example, on an FPGA), smaller filters may be required, if less ideal.
Have you heard of GNU Octave? It is an open-source MatLab alternative. Although it does not support near as many things as MatLab, it is still a powerful SW tool, and has the same general language format as MatLab. It has some decent filter tools built in, and is fairly well documented.
Got it. So for real-time applications something less than 15 would probably be reasonable. I'm just trying to suppress aliasing coming from non-linear processing.
Thanks for the tip, I hadn't heard of that program!
If you don't have a deterministic need and have the processing power, you could go for a 32-tap or 64-tap lengthened filter. Really depends on how much/little latency is needed and available resources.
Is this an academic project?
Get Matlab.
No, seriously. Get Matlab. It costs like $50 now. Then you can run Tom Chatt's nifty CIC analysis script to generate the CFIR coefficients.