From: analog_fever on
I designed a CIC filter and am trying to plot its response.

fclk (sampling frequency) = 1.4MHz
D (Decimation factor) = 100
Order = 3
Input bits = 3
Output bits = 13

I sent in 102400 samples in, with 1500 samples set to "1" and got 1024
(filtOutData) samples out. Now I am trying to plot the magnitude response
in Matlab. I do the following in Matlab:

fft_pts = 2^(fix(log2(data_length)))

fft_filtOutData = fft(filtOutData, fft_pts)
half = fix(fft_pts/2);
fft_filtOutData_dB = 20*log10(abs(fft_filtOutData(1:half,:)))

fft_pts_by2 = round(fft_pts/2);
freq = (fclk/fft_pts)*(1:1:fft_pts_by2);

figure(1)
semilogx(freq,fft_filtOutData_dB(1:half,:))

I am not seeing the proper magnitude response, of a sinc filter, i.e., I am
not seeing zeros at multiples of fclk/D. What am I doing wrong?



From: Tim Wescott on
On 06/18/2010 10:47 AM, analog_fever wrote:
> I designed a CIC filter and am trying to plot its response.
>
> fclk (sampling frequency) = 1.4MHz
> D (Decimation factor) = 100
> Order = 3
> Input bits = 3
> Output bits = 13
>
> I sent in 102400 samples in, with 1500 samples set to "1" and got 1024
> (filtOutData) samples out. Now I am trying to plot the magnitude response
> in Matlab. I do the following in Matlab:
>
> fft_pts = 2^(fix(log2(data_length)))
>
> fft_filtOutData = fft(filtOutData, fft_pts)
> half = fix(fft_pts/2);
> fft_filtOutData_dB = 20*log10(abs(fft_filtOutData(1:half,:)))
>
> fft_pts_by2 = round(fft_pts/2);
> freq = (fclk/fft_pts)*(1:1:fft_pts_by2);
>
> figure(1)
> semilogx(freq,fft_filtOutData_dB(1:half,:))
>
> I am not seeing the proper magnitude response, of a sinc filter, i.e., I am
> not seeing zeros at multiples of fclk/D. What am I doing wrong?

You are looking at the output without thinking what aliasing is doing to
your ability to see zeros at multiples of fclk/D in a signal that is
sampled at fclk/D.

You either need to do this on paper, or by experimentation -- try
putting in sine waves, swept through the frequency range of your choice
but including harmonics of fclk/D, and see what you see.

--
Tim Wescott
Control system and signal processing consulting
www.wescottdesign.com
From: analog_fever on

>
>You are looking at the output without thinking what aliasing is doing to
>your ability to see zeros at multiples of fclk/D in a signal that is
>sampled at fclk/D.
>
>You either need to do this on paper, or by experimentation -- try
>putting in sine waves, swept through the frequency range of your choice
>but including harmonics of fclk/D, and see what you see.
>
>--
>Tim Wescott
>Control system and signal processing consulting
>www.wescottdesign.com
>

THanks a bunch. One more question, I use this filter at the output of an
incremental Delta Sigma modulato. I need to reset the filter (its
integrators, and comb sections) once every D clock cycles, where D is the
decimation factor. Will this filter work even in this case, i.e., if it is
reset every D clock cycles?
From: Rick Lyons on
On Fri, 18 Jun 2010 12:47:58 -0500, "analog_fever"
<usu_vlsi(a)n_o_s_p_a_m.yahoo.com> wrote:

>I designed a CIC filter and am trying to plot its response.
>
>fclk (sampling frequency) = 1.4MHz
>D (Decimation factor) = 100
>Order = 3
>Input bits = 3
>Output bits = 13
>
>I sent in 102400 samples in, with 1500 samples set to "1" and got 1024
>(filtOutData) samples out. Now I am trying to plot the magnitude response
>in Matlab. I do the following in Matlab:
>
>fft_pts = 2^(fix(log2(data_length)))
>
>fft_filtOutData = fft(filtOutData, fft_pts)
>half = fix(fft_pts/2);
>fft_filtOutData_dB = 20*log10(abs(fft_filtOutData(1:half,:)))
>
>fft_pts_by2 = round(fft_pts/2);
>freq = (fclk/fft_pts)*(1:1:fft_pts_by2);
>
>figure(1)
>semilogx(freq,fft_filtOutData_dB(1:half,:))
>
>I am not seeing the proper magnitude response, of a sinc filter, i.e., I am
>not seeing zeros at multiples of fclk/D. What am I doing wrong?

Hello analog_fever,
You believe your above words sufficiently describe
your CIC filter input sequence, but they don't. I'm
too ignorant in the field of probability theory to know
how many different input sequences that could be
described by your above words, but I'd guess that
it's greater than a billion.

In any case, regardless of whatever you mean by:

"...102400 samples in, with 1500 samples set to 1..."

performing the FFT of your CIC filter's output will
*NOT* tell you anything useful about the frequency
magnitude response of a CIC filter.

Have a look at Figure 4 at:

http://www.embedded.com/columns/showArticle.jhtml?articleID=160400592

Good Luck,
[-Rick-]