DSPRelated.com
Forums

Fir Interpolation question for dummy

Started by Jack1962 November 30, 2010
Hi everyone.

I have a signal sampled at 100Hz for example: [1 2 3 4 3 2 1]

I have to interpolate to 200Hz to send a DAC, so I adding zero between
the samples in this way: [1 0 2 0 3 0 4 0 5 0 4 0 3 0 2 0 1].

Now I want to filter with a low pass Fir filter to have a passband
frequency of 20Hz. I am using Scopefir, my question is, I have to use 100Hz
or 200Hz as sampling frequency in the design options?

Thank you very much.
Jack











"Jack1962" <domenicoc@n_o_s_p_a_m.tiscali.it> writes:

> Hi everyone. > > I have a signal sampled at 100Hz for example: [1 2 3 4 3 2 1] > > I have to interpolate to 200Hz to send a DAC, so I adding zero between > the samples in this way: [1 0 2 0 3 0 4 0 5 0 4 0 3 0 2 0 1]. > > Now I want to filter with a low pass Fir filter to have a passband > frequency of 20Hz. I am using Scopefir, my question is, I have to use 100Hz > or 200Hz as sampling frequency in the design options?
200 Hz. -- Randy Yates % "How's life on earth? Digital Signal Labs % ... What is it worth?" mailto://yates@ieee.org % 'Mission (A World Record)', http://www.digitalsignallabs.com % *A New World Record*, ELO
On 11/30/2010 07:04 AM, Jack1962 wrote:
> Hi everyone. > > I have a signal sampled at 100Hz for example: [1 2 3 4 3 2 1] > > I have to interpolate to 200Hz to send a DAC, so I adding zero between > the samples in this way: [1 0 2 0 3 0 4 0 5 0 4 0 3 0 2 0 1]. > > Now I want to filter with a low pass Fir filter to have a passband > frequency of 20Hz. I am using Scopefir, my question is, I have to use 100Hz > or 200Hz as sampling frequency in the design options?
200Hz. At the cost of two different FIR filter kernels, you can do polyphase filtering and save on MAC costs. It sounds like you just want to proceed on the road you're on, but if you start running out of clock ticks, Google "polyphase filtering" and "sample rate conversion". -- Tim Wescott Wescott Design Services http://www.wescottdesign.com Do you need to implement control loops in software? "Applied Control Theory for Embedded Systems" was written for you. See details at http://www.wescottdesign.com/actfes/actfes.html
On Nov 30, 12:05=A0pm, Tim Wescott <t...@seemywebsite.com> wrote:
> On 11/30/2010 07:04 AM, Jack1962 wrote: > > > I have a signal sampled at 100Hz for example: [1 2 3 4 3 2 1] > > > I have to interpolate to 200Hz to send a DAC, so I adding zero between > > the samples in this way: [1 0 2 0 3 0 4 0 5 0 4 0 3 0 2 0 1]. > > > Now I want to filter with a low pass Fir filter to have a passband > > frequency of 20Hz. I am using Scopefir, my question is, I have to use 1=
00Hz
> > or 200Hz as sampling frequency in the design options? > > 200Hz. =A0At the cost of two different FIR filter kernels, you can do > polyphase filtering and save on MAC costs. >
in fact, if his LPF is a simple windowed sinc() function, he need not calculate the points with 1, 2, 3, etc, but just copy those samples. he would only need to calculate the values in between. y[n] =3D SUM{ h[i] * x[n-i] } where h[n] =3D sinc(n/2) * w(n/N) r b-j
Thank you everyone for the answer,

I am trying to understand the polyphase filtering, but for now I have
another question. After filtering the data [1 0 2 0 3 0 4 0 5 0 4 0 3 0 2 0
1] I have half magnitude of the signal. I have to multiply the output of
the filter * 2 before sendig the data to DAC?
Thank you everyone.

>On Nov 30, 12:05=A0pm, Tim Wescott <t...@seemywebsite.com> wrote: >> On 11/30/2010 07:04 AM, Jack1962 wrote: >> >> > I have a signal sampled at 100Hz for example: [1 2 3 4 3 2 1] >> >> > I have to interpolate to 200Hz to send a DAC, so I adding zero
between
>> > the samples in this way: [1 0 2 0 3 0 4 0 5 0 4 0 3 0 2 0 1]. >> >> > Now I want to filter with a low pass Fir filter to have a passband >> > frequency of 20Hz. I am using Scopefir, my question is, I have to use
1=
>00Hz >> > or 200Hz as sampling frequency in the design options? >> >> 200Hz. =A0At the cost of two different FIR filter kernels, you can do >> polyphase filtering and save on MAC costs. >> > >in fact, if his LPF is a simple windowed sinc() function, he need not >calculate the points with 1, 2, 3, etc, but just copy those samples. >he would only need to calculate the values in between. > > > y[n] =3D SUM{ h[i] * x[n-i] } > > >where h[n] =3D sinc(n/2) * w(n/N) > > >r b-j >
On 12/10/2010 07:21 AM, Jack1962 wrote:
(top posting fixed)
> >> On Nov 30, 12:05=A0pm, Tim Wescott<t...@seemywebsite.com> wrote: >>> On 11/30/2010 07:04 AM, Jack1962 wrote: >>> >>>> I have a signal sampled at 100Hz for example: [1 2 3 4 3 2 1] >>> >>>> I have to interpolate to 200Hz to send a DAC, so I adding zero > between >>>> the samples in this way: [1 0 2 0 3 0 4 0 5 0 4 0 3 0 2 0 1]. >>> >>>> Now I want to filter with a low pass Fir filter to have a passband >>>> frequency of 20Hz. I am using Scopefir, my question is, I have to use > 1= >> 00Hz >>>> or 200Hz as sampling frequency in the design options? >>> >>> 200Hz. =A0At the cost of two different FIR filter kernels, you can do >>> polyphase filtering and save on MAC costs. >>> >> >> in fact, if his LPF is a simple windowed sinc() function, he need not >> calculate the points with 1, 2, 3, etc, but just copy those samples. >> he would only need to calculate the values in between. >> >> >> y[n] =3D SUM{ h[i] * x[n-i] } >> >> >> where h[n] =3D sinc(n/2) * w(n/N) >> >> >> r b-j > > Thank you everyone for the answer, > > I am trying to understand the polyphase filtering, but for now I have > another question. After filtering the data [1 0 2 0 3 0 4 0 5 0 4 0 3 0 2 0 > 1] I have half magnitude of the signal. I have to multiply the output of > the filter * 2 before sendig the data to DAC? > Thank you everyone. >
The need to multiply by 2 certainly follows -- whenever you're sampling, reconstructing, or changing sampling rates, scaling correctly can be a bit of an issue -- as you just found out. Fortunately in this case it's obvious. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com Do you need to implement control loops in software? "Applied Control Theory for Embedded Systems" was written for you. See details at http://www.wescottdesign.com/actfes/actfes.html
On 12/10/2010 10:21 AM, Jack1962 wrote:
> Thank you everyone for the answer, > > I am trying to understand the polyphase filtering, but for now I have > another question. After filtering the data [1 0 2 0 3 0 4 0 5 0 4 0 3 0 2 0 > 1] I have half magnitude of the signal. I have to multiply the output of > the filter * 2 before sendig the data to DAC? > Thank you everyone.
You need to somehow ensure the gain of the filter "block" is double what it is now. Of course doing another multiply on each sample would be inefficient; the better way would be to shift your MAC results right one less than you are now. --Randy
> >> On Nov 30, 12:05=A0pm, Tim Wescott<t...@seemywebsite.com> wrote: >>> On 11/30/2010 07:04 AM, Jack1962 wrote: >>> >>>> I have a signal sampled at 100Hz for example: [1 2 3 4 3 2 1] >>> >>>> I have to interpolate to 200Hz to send a DAC, so I adding zero > between >>>> the samples in this way: [1 0 2 0 3 0 4 0 5 0 4 0 3 0 2 0 1]. >>> >>>> Now I want to filter with a low pass Fir filter to have a passband >>>> frequency of 20Hz. I am using Scopefir, my question is, I have to use > 1= >> 00Hz >>>> or 200Hz as sampling frequency in the design options? >>> >>> 200Hz. =A0At the cost of two different FIR filter kernels, you can do >>> polyphase filtering and save on MAC costs. >>> >> >> in fact, if his LPF is a simple windowed sinc() function, he need not >> calculate the points with 1, 2, 3, etc, but just copy those samples. >> he would only need to calculate the values in between. >> >> >> y[n] =3D SUM{ h[i] * x[n-i] } >> >> >> where h[n] =3D sinc(n/2) * w(n/N) >> >> >> r b-j >>
-- Randy Yates % "My Shangri-la has gone away, fading like Digital Signal Labs % the Beatles on 'Hey Jude'" mailto://yates@ieee.org % http://www.digitalsignallabs.com % 'Shangri-La', *A New World Record*, ELO
On 12/10/2010 12:54 PM, Randy Yates wrote:
> On 12/10/2010 10:21 AM, Jack1962 wrote: >> Thank you everyone for the answer, >> >> I am trying to understand the polyphase filtering, but for now I have >> another question. After filtering the data [1 0 2 0 3 0 4 0 5 0 4 0 3 0 2 0 >> 1] I have half magnitude of the signal. I have to multiply the output of >> the filter * 2 before sendig the data to DAC? >> Thank you everyone. > > You need to somehow ensure the gain of the filter "block" is double what it > is now. Of course doing another multiply on each sample would be > inefficient; the better way would be to shift your MAC results > right one less than you are now.
OH, this is Matlab? Never mind - throw efficiency to the wind! (Still you might just multiply the filter taps by two...) --Randy
> > --Randy > >> >>> On Nov 30, 12:05=A0pm, Tim Wescott<t...@seemywebsite.com> wrote: >>>> On 11/30/2010 07:04 AM, Jack1962 wrote: >>>> >>>>> I have a signal sampled at 100Hz for example: [1 2 3 4 3 2 1] >>>> >>>>> I have to interpolate to 200Hz to send a DAC, so I adding zero >> between >>>>> the samples in this way: [1 0 2 0 3 0 4 0 5 0 4 0 3 0 2 0 1]. >>>> >>>>> Now I want to filter with a low pass Fir filter to have a passband >>>>> frequency of 20Hz. I am using Scopefir, my question is, I have to use >> 1= >>> 00Hz >>>>> or 200Hz as sampling frequency in the design options? >>>> >>>> 200Hz. =A0At the cost of two different FIR filter kernels, you can do >>>> polyphase filtering and save on MAC costs. >>>> >>> >>> in fact, if his LPF is a simple windowed sinc() function, he need not >>> calculate the points with 1, 2, 3, etc, but just copy those samples. >>> he would only need to calculate the values in between. >>> >>> >>> y[n] =3D SUM{ h[i] * x[n-i] } >>> >>> >>> where h[n] =3D sinc(n/2) * w(n/N) >>> >>> >>> r b-j >>> > >
-- Randy Yates % "My Shangri-la has gone away, fading like Digital Signal Labs % the Beatles on 'Hey Jude'" mailto://yates@ieee.org % http://www.digitalsignallabs.com % 'Shangri-La', *A New World Record*, ELO
>On 12/10/2010 12:54 PM, Randy Yates wrote: >> On 12/10/2010 10:21 AM, Jack1962 wrote: >>> Thank you everyone for the answer, >>> >>> I am trying to understand the polyphase filtering, but for now I have >>> another question. After filtering the data [1 0 2 0 3 0 4 0 5 0 4 0 3 0
2 0
>>> 1] I have half magnitude of the signal. I have to multiply the output
of
>>> the filter * 2 before sendig the data to DAC? >>> Thank you everyone. >> >> You need to somehow ensure the gain of the filter "block" is double what
it
>> is now. Of course doing another multiply on each sample would be >> inefficient; the better way would be to shift your MAC results >> right one less than you are now.
>OH, this is Matlab? Never mind - throw efficiency to the wind! (Still >you might just multiply the filter taps by two...)
I am using a DSPIC microcontroller fot that. I want make sure, that it is correct, multiply the signal for a gain. Great idea to multiply the flter tap to correct the gain. Thank you everyone.