Forums

Resampling for multirate system help

Started by billysdomain May 8, 2007
Hi

I need to resample a 32Khz signal into a 8Khz signal, and then back again
to 32Khz after it has been processed and am looking for some guidance.

I am using a dsPIC and have the following two library functions available
to me, FIRDecimate and FIRInterpolate, I am also using the dsPICfd
software to create my filters.

After reading many tutorials on doing this, I am still a bit disorientated
as to how to best create the filter

To downsample I am looking at decimation at a factor of 2/8 = 0.25, and
the application is for voice, but relatively good quality voice.

So, when I create my FIR filter, I have to input the following, I have
included what I think should be set for these values:

Sampling Frequency: 32000
Passband Frequency: 4100 (Maybe too high?)
Stopband Frequency: 4800
Passband Ripple (dB): 0.1
Stopband Ripple (dB): 50

Can anybody tell me if im on the right tracks here?

And when I interpolate, do I use the same filter but with 8000 as the
sampling frequency? Will this break the nyquist frequency rule? If so
would I need to drop my passband and stopband to below 4000Khz?

Many thanks for any help

Billy





_____________________________________
Do you know a company who employs DSP engineers?  
Is it already listed at http://dsprelated.com/employers.php ?
billysdomain wrote:
> Hi > > I need to resample a 32Khz signal into a 8Khz signal, and then back again > to 32Khz after it has been processed and am looking for some guidance. > > I am using a dsPIC and have the following two library functions available > to me, FIRDecimate and FIRInterpolate, I am also using the dsPICfd > software to create my filters. > > After reading many tutorials on doing this, I am still a bit disorientated > as to how to best create the filter > > To downsample I am looking at decimation at a factor of 2/8 = 0.25, and > the application is for voice, but relatively good quality voice. > > So, when I create my FIR filter, I have to input the following, I have > included what I think should be set for these values: > > Sampling Frequency: 32000 > Passband Frequency: 4100 (Maybe too high?) > Stopband Frequency: 4800 > Passband Ripple (dB): 0.1 > Stopband Ripple (dB): 50 > > Can anybody tell me if im on the right tracks here? > > And when I interpolate, do I use the same filter but with 8000 as the > sampling frequency? Will this break the nyquist frequency rule? If so > would I need to drop my passband and stopband to below 4000Khz?
Yes, your stopband is too high. It needs to be LESS THAN 4000 Hz in order to satisfy Nyquist when fs = 8000Hz. I'd go with 3600. You can use the same filter coefs for the interpolator. There's a nice tutorial here: http://www.dspguru.com/info/faqs/mrfaq.htm -- Jim Thomas Principal Applications Engineer Bittware, Inc jthomas@bittware.com http://www.bittware.com (603) 226-0404 x536 Roses are #FF0000, violets are #0000FF, all my base are belong to you.
billysdomain wrote:
> Hi > > I need to resample a 32Khz signal into a 8Khz signal, and then back again > to 32Khz after it has been processed and am looking for some guidance.
Why? If for some purpose, there may be a better way. If as an assignment, all bets are off.
> I am using a dsPIC and have the following two library functions available > to me, FIRDecimate and FIRInterpolate, I am also using the dsPICfd > software to create my filters. > > After reading many tutorials on doing this, I am still a bit disorientated > as to how to best create the filter > > To downsample I am looking at decimation at a factor of 2/8 = 0.25, and > the application is for voice, but relatively good quality voice. > > So, when I create my FIR filter, I have to input the following, I have > included what I think should be set for these values: > > Sampling Frequency: 32000 > Passband Frequency: 4100 (Maybe too high?)
Of course too high. The stopband has to be less than half the new sample rate. Did you sleep through that lecture?
> Stopband Frequency: 4800 > Passband Ripple (dB): 0.1 > Stopband Ripple (dB): 50
Stopband Ripple? Are you sure? how about minimum stopband attenuation?
> Can anybody tell me if im on the right tracks here? > > And when I interpolate, do I use the same filter but with 8000 as the > sampling frequency?
No. You filter again after interpolating. What is the sample rate then?
> Will this break the nyquist frequency rule? If so > would I need to drop my passband and stopband to below 4000Khz?
Yes and yes. Jerry -- Engineering is the art of making what you want from things you can get. ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
>billysdomain wrote:
>Why? If for some purpose, there may be a better way. If as an >assignment, all bets are off.
its for a purpose, its a intercom path and the data samples get piped through a echo cancellor library which only operates at 8Khz. Is there a better way? i dont have the processing power to takle echo cancellation, vad, howling control and data transmission at higher rates i dont think.
>Of course too high. The stopband has to be less than half the new sample
>rate. Did you sleep through that lecture? > > >Stopband Ripple? Are you sure? how about minimum stopband attenuation? >
Stopband Frequency: 3600 Passband Ripple (dB): 0.1 Stopband Ripple (dB): 30
> >No. You filter again after interpolating. What is the sample rate then? >
fair point Billy _____________________________________ Do you know a company who employs DSP engineers? Is it already listed at http://dsprelated.com/employers.php ?
Sampling Frequency: 32000
Passband Frequency: 3600
Stopband Frequency: 3800
Passband Ripple (dB): 0.01
Stopband Ripple (dB): 60

billy

_____________________________________
Do you know a company who employs DSP engineers?  
Is it already listed at http://dsprelated.com/employers.php ?
billysdomain wrote:
>> billysdomain wrote: > >> Why? If for some purpose, there may be a better way. If as an >> assignment, all bets are off. > > its for a purpose, its a intercom path and the data samples get piped > through a echo cancellor library which only operates at 8Khz. Is there a > better way? i dont have the processing power to takle echo cancellation, > vad, howling control and data transmission at higher rates i dont think. > > >> Of course too high. The stopband has to be less than half the new sample > >> rate. Did you sleep through that lecture? >> >> >> Stopband Ripple? Are you sure? how about minimum stopband attenuation? >> > > Stopband Frequency: 3600 > Passband Ripple (dB): 0.1 > Stopband Ripple (dB): 30
The maximum stopband attenuation doesn't matter; it's the minimum signal that counts (30 dB down isn't really enough). Suppose the minimum attenuation is an adequate 50 dB* and there's a spec that the ripple may not exceed 30 dB. If at some frequency the attenuation exceeds 80 dB, does that mean that the filter is out of spec? Look again at the parameters you enter. I think you're reading them wrong. BTW: look up http://www.google.com/search?q=multirate+filter ... Jerry _______________________________ * I can see that you might need to cut corners. Try for 40, anyway. 30 dB is about 3% voltage passthrough. 40 is 1%. -- Engineering is the art of making what you want from things you can get. ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
On May 9, 2:58 am, "billysdomain" <b...@lismore.uk.com> wrote:
> >billysdomain wrote: > >Why? If for some purpose, there may be a better way. If as an > >assignment, all bets are off. > > its for a purpose, its a intercom path and the data samples get piped > through a echo cancellor library which only operates at 8Khz. Is there a > better way?
do your echo canceller at 32 kHz. what is it? a normalized LMS adaptive filter? r b-j