Sign in

username or email:

password:



Not a member?
Forgot your password?

Search compdsp



Search tips

Ads

Discussion Groups

Free Online Books

See Also

Embedded SystemsFPGA

Discussion Groups | Comp.DSP | Sample Rate Conversion (Downsampling)

There are 25 messages in this thread.

You are currently looking at messages 1 to .


Is this discussion worth a thumbs up?

0

Sample Rate Conversion (Downsampling) - Jaime Andrés Aranguren Cardona - 2004-12-14 12:40:00

Hello,

For a project which I'm working on, I have a 60Hz sinewave modulated with a
square wave at 0.5Hz, modulation is 2.72%

The signal comes sampled at 8kHz, I should downsample it to 200Hz, so M 40. I do that in two
stages, first with M1 = 10, then with M2 = 4. I
implemented polyphase structure in Simulink, and runs great. By "great" I
mean that the output signal, sampled at 200Hz, preserves the squarewave
shape perfectly.

Ths structure used in Simulink is the one in P.P. Vaidyanathan's book
"Multirate Systems and Filter Banks", figure 4.3-4 (a), page 124.

However, In my C implementation (on SHARC, BTW), the downsampled signal
looks weird. By "weird" I mean that the envelope of the output signal,
instead of being flat (square) as it is expected to be, seems more like a
low frequency sinusoid, still it is noticeable when the amplitude rises and
falls at the same frequency of the original modulating square wave.

Given this information, and the fact that Simulink implementation maps
directly to the figure in Vaidyanathan's book, I am pretty sure that I have
some mistakes in my C implementation, but I can't find them.

Could someone here please give me advice on what mistakes in implementing
the polyphase M-fold decimation filters lead to the sort of "weirdness" that
I got from my C implementation? That would be of much support in finding
what I did wrong.

If someone who desires to help me wants to have a look at the Simulink Model
that I implemented, to the output of my C (for SHARC) implementation, and/or
to my C implementation itself, please let me know, and I will be more than
pleased in sending it to you.

Kindest regards,

--
Jaime Andrés Aranguren Cardona
j...@nospam.sanjaac.com
SanJaaC Electronics
Soluciones en DSP
www.sanjaac.com

(Remove "nospam" from e-mail address)


______________________________
New DSP Code Snippets Section now Live.   Learn more about the reward program for contributors here.

Re: Sample Rate Conversion (Downsampling) - Jon Harris - 2004-12-14 13:13:00



Just a quick thought, one difference could be that in the Simulink case, your
8kHz sample rate is probably an _exact_ multiple of the 60Hz waveform, but in
the real-world case, it may not be.  Try modifying your Simulink example to use
a slightly different frequency such as 60.37 Hz or something and see what
happens.

You could also try simplifying the problem by downsampling just the 60Hz
waveform without the modulation.

"Jaime Andrés Aranguren Cardona" <j...@nospam.sanjaac.com> wrote in message
news:1103046565.72fb8397a7036cd0ab33545d0fe7c860@teranews...
> Hello,
>
> For a project which I'm working on, I have a 60Hz sinewave modulated with a
> square wave at 0.5Hz, modulation is 2.72%
>
> The signal comes sampled at 8kHz, I should downsample it to 200Hz, so M > 40. I do that
in two stages, first with M1 = 10, then with M2 = 4. I
> implemented polyphase structure in Simulink, and runs great. By "great" I
> mean that the output signal, sampled at 200Hz, preserves the squarewave
> shape perfectly.
>
> Ths structure used in Simulink is the one in P.P. Vaidyanathan's book
> "Multirate Systems and Filter Banks", figure 4.3-4 (a), page 124.
>
> However, In my C implementation (on SHARC, BTW), the downsampled signal
> looks weird. By "weird" I mean that the envelope of the output signal,
> instead of being flat (square) as it is expected to be, seems more like a
> low frequency sinusoid, still it is noticeable when the amplitude rises and
> falls at the same frequency of the original modulating square wave.
>
> Given this information, and the fact that Simulink implementation maps
> directly to the figure in Vaidyanathan's book, I am pretty sure that I have
> some mistakes in my C implementation, but I can't find them.
>
> Could someone here please give me advice on what mistakes in implementing
> the polyphase M-fold decimation filters lead to the sort of "weirdness" that
> I got from my C implementation? That would be of much support in finding
> what I did wrong.


______________________________
New DSP Code Snippets Section now Live.   Learn more about the reward program for contributors here.

Re: Sample Rate Conversion (Downsampling) - David Kirkland - 2004-12-14 13:22:00

Jaime Andrés Aranguren Cardona wrote:
> Hello,
> 
> For a project which I'm working on, I have a 60Hz sinewave modulated with a
> square wave at 0.5Hz, modulation is 2.72%
> 
> The signal comes sampled at 8kHz, I should downsample it to 200Hz, so M > 40. I do that
in two stages, first with M1 = 10, then with M2 = 4. I
> implemented polyphase structure in Simulink, and runs great. By "great" I
> mean that the output signal, sampled at 200Hz, preserves the squarewave
> shape perfectly.
> 
> Ths structure used in Simulink is the one in P.P. Vaidyanathan's book
> "Multirate Systems and Filter Banks", figure 4.3-4 (a), page 124.
> 
> However, In my C implementation (on SHARC, BTW), the downsampled signal
> looks weird. By "weird" I mean that the envelope of the output signal,
> instead of being flat (square) as it is expected to be, seems more like a
> low frequency sinusoid, still it is noticeable when the amplitude rises and
> falls at the same frequency of the original modulating square wave.
> 
> Given this information, and the fact that Simulink implementation maps
> directly to the figure in Vaidyanathan's book, I am pretty sure that I have
> some mistakes in my C implementation, but I can't find them.
> 
> Could someone here please give me advice on what mistakes in implementing
> the polyphase M-fold decimation filters lead to the sort of "weirdness" that
> I got from my C implementation? That would be of much support in finding
> what I did wrong.
> 
> If someone who desires to help me wants to have a look at the Simulink Model
> that I implemented, to the output of my C (for SHARC) implementation, and/or
> to my C implementation itself, please let me know, and I will be more than
> pleased in sending it to you.
> 
> Kindest regards,
> 
> --
> Jaime Andrés Aranguren Cardona
> j...@nospam.sanjaac.com
> SanJaaC Electronics
> Soluciones en DSP
> www.sanjaac.com
> 
> (Remove "nospam" from e-mail address)
> 
> 

You could also try a regular decimation implementation (instead of 
polyphase) to see whether of not it's your polyphase filtering code.

Cheers,
David
______________________________
New DSP Code Snippets Section now Live.   Learn more about the reward program for contributors here.

Re: Sample Rate Conversion (Downsampling) - Att - 2004-12-14 13:27:00

Just another thought.  Did you make sure you cycled through the coeffs in
the right order.
Try reversing the sequence in which you use the coeffs.
Although I am as careful as I can be, I can't tell you how many times I end
up experimenting
till I get the sequencing right.

Regards,
Dave Shaw
>
> Could someone here please give me advice on what mistakes in implementing
> the polyphase M-fold decimation filters lead to the sort of "weirdness"
that
> I got from my C implementation? That would be of much support in finding
> what I did wrong.
>
> If someone who desires to help me wants to have a look at the Simulink
Model
> that I implemented, to the output of my C (for SHARC) implementation,
and/or
> to my C implementation itself, please let me know, and I will be more than
> pleased in sending it to you.
>


______________________________
New DSP Code Snippets Section now Live.   Learn more about the reward program for contributors here.

Re: Sample Rate Conversion (Downsampling) - Jon Harris - 2004-12-14 13:34:00

Good suggestion.  For some reason, I usually find the order is backwards from
what I would intuitively think!  There was an interesting thread on this a while
back:
http://tinyurl.com/3s6dc

"Att" <d...@att.net> wrote in message
news:agGvd.124735$7...@bgtnsc05-news.ops.worldnet.att.net...
> Just another thought.  Did you make sure you cycled through the coeffs in
> the right order.
> Try reversing the sequence in which you use the coeffs.
> Although I am as careful as I can be, I can't tell you how many times I end
> up experimenting
> till I get the sequencing right.
>
> Regards,
> Dave Shaw
> >
> > Could someone here please give me advice on what mistakes in implementing
> > the polyphase M-fold decimation filters lead to the sort of "weirdness"
> that
> > I got from my C implementation? That would be of much support in finding
> > what I did wrong.
> >
> > If someone who desires to help me wants to have a look at the Simulink
> Model
> > that I implemented, to the output of my C (for SHARC) implementation,
> and/or
> > to my C implementation itself, please let me know, and I will be more than
> > pleased in sending it to you.


______________________________
New DSP Code Snippets Section now Live.   Learn more about the reward program for contributors here.

Re: Sample Rate Conversion (Downsampling) - Jaime Andrés Aranguren Cardona - 2004-12-15 11:43:00

"Jim Thomas" <j...@bittware.com> escribió en el mensaje
news:1...@corp.supernews.com...
> Jaime Andrés Aranguren Cardona wrote:
> > What else could I try, guys? I'd really appreciate if you can take a
look at
> > my code, and help me find out where the mistakes can be, or provide me
with
> > some reference C code.
> >
> > Thanks you very much in advance,
>
> Did you see Grant's multirate code on dspguru.com?
>

Hi Jim,

Yes I did. It is not polyphase, right? I'd love it was... Any example in C
with ployphase implementation?

--
Jaime Andrés Aranguren Cardona
j...@nospam.sanjaac.com
SanJaaC Electronics
Soluciones en DSP
www.sanjaac.com

(Remove "nospam" from e-mail address)


______________________________
New DSP Code Snippets Section now Live.   Learn more about the reward program for contributors here.

Re: Sample Rate Conversion (Downsampling) - Bhaskar Thiagarajan - 2004-12-15 13:19:00

"Jaime Andrés Aranguren Cardona" <j...@nospam.sanjaac.com> wrote in
message
news:1103129550.7987b75918af9ea133251f5237596ac2@teranews...
> "Jim Thomas" <j...@bittware.com> escribió en el mensaje
> news:1...@corp.supernews.com...
> > Jaime Andrés Aranguren Cardona wrote:
> > > What else could I try, guys? I'd really appreciate if you can take a
> look at
> > > my code, and help me find out where the mistakes can be, or provide me
> with
> > > some reference C code.
> > >
> > > Thanks you very much in advance,
> >
> > Did you see Grant's multirate code on dspguru.com?
> >
>
> Hi Jim,
>
> Yes I did. It is not polyphase, right? I'd love it was... Any example in C
> with ployphase implementation?

Yes - from what I remember it is a polyphase implementation.
Cheers
Bhaskar

> --
> Jaime Andrés Aranguren Cardona
> j...@nospam.sanjaac.com
> SanJaaC Electronics
> Soluciones en DSP
> www.sanjaac.com
>
> (Remove "nospam" from e-mail address)
>
>


______________________________
New DSP Code Snippets Section now Live.   Learn more about the reward program for contributors here.

Re: Sample Rate Conversion (Downsampling) - Jon Harris - 2004-12-15 13:24:00

Try this:
http://www.mega-nerd.com/SRC/
It includes source.

"Jaime Andrés Aranguren Cardona" <j...@nospam.sanjaac.com> wrote in message
news:1103129550.7987b75918af9ea133251f5237596ac2@teranews...
> "Jim Thomas" <j...@bittware.com> escribió en el mensaje
> news:1...@corp.supernews.com...
> > Jaime Andrés Aranguren Cardona wrote:
> > > What else could I try, guys? I'd really appreciate if you can take a
> look at
> > > my code, and help me find out where the mistakes can be, or provide me
> with
> > > some reference C code.
> > >
> > > Thanks you very much in advance,
> >
> > Did you see Grant's multirate code on dspguru.com?
>
> Hi Jim,
>
> Yes I did. It is not polyphase, right? I'd love it was... Any example in C
> with ployphase implementation?


______________________________
New DSP Code Snippets Section now Live.   Learn more about the reward program for contributors here.

Re: Sample Rate Conversion (Downsampling) - Jim Thomas - 2004-12-16 09:21:00

Jaime Andrés Aranguren Cardona wrote:
> "Jim Thomas" <j...@bittware.com> escribió en el mensaje
> news:1...@corp.supernews.com...
> 
>>Jaime Andrés Aranguren Cardona wrote:
>>
>>>What else could I try, guys? I'd really appreciate if you can take a
> 
> look at
> 
>>>my code, and help me find out where the mistakes can be, or provide me
> 
> with
> 
>>>some reference C code.
>>>
>>>Thanks you very much in advance,
>>
>>Did you see Grant's multirate code on dspguru.com?
>>
> 
> 
> Hi Jim,
> 
> Yes I did. It is not polyphase, right? I'd love it was... Any example in C
> with ployphase implementation?

The interpolation code on dspguru is most definitely polyphase.

My understanding is that polyphase only comes into play during interpolation.
It's only during interpolation that you get the opportunity to skip through the 
coefs - essentially choosing a phase of the impulse response.  In decimation you 
work on contiguous samples, but only calculate the outputs you're going to keep.

Am I wrong?

-- 
Jim Thomas            Principal Applications Engineer  Bittware, Inc
j...@bittware.com  http://www.bittware.com    (603) 226-0404 x536
Hope springs occasionally.
______________________________
New DSP Code Snippets Section now Live.   Learn more about the reward program for contributors here.

Re: Sample Rate Conversion (Downsampling) - 2004-12-16 10:36:00

Jim Thomas <j...@bittware.com> writes:

> Jaime Andrés Aranguren Cardona wrote:
> > "Jim Thomas" <j...@bittware.com> escribió en el mensaje
> > news:1...@corp.supernews.com...
> >
> 
> >>Jaime Andrés Aranguren Cardona wrote:
> >>
> >>>What else could I try, guys? I'd really appreciate if you can take a
> > look at
> 
> >
> 
> >>>my code, and help me find out where the mistakes can be, or provide me
> > with
> 
> >
> 
> >>>some reference C code.
> >>>
> >>>Thanks you very much in advance,
> >>
> >>Did you see Grant's multirate code on dspguru.com?
> >>
> > Hi Jim,
> 
> > Yes I did. It is not polyphase, right? I'd love it was... Any
> > example in C
> 
> > with ployphase implementation?
> 
> The interpolation code on dspguru is most definitely polyphase.
> 
> My understanding is that polyphase only comes into play during interpolation.
> It's only during interpolation that you get the opportunity to skip
> through the coefs - essentially choosing a phase of the impulse
> response.  In decimation you work on contiguous samples, but only
> calculate the outputs you're going to keep.
> 
> 
> Am I wrong?

Well, I hate to say wrong because I see exactly where you're coming
from and I like to view it your way, but according to Mitra [1] the
term "polyphase," and the corresponding partitioning of filter
coefficients, can be applied to both interpolators and decimators.

In a polyphase M-fold interpolator, you have M polyphase filter coefficient sets
E_0 through E_{M-1} that each operate at the incoming sample rate. Each are then
upsampled by M, delayed, and then summed. The end result is that, assuming the total
filter length is M*K (so that each polyphase section is K coefficients long), 
your computations require M*K*Fs multiplications/second instead of M^2*K*Fs,
where Fs is the input sample rate.

In a polyphase M-fold decimator, you have M polyphase filter coefficient sets
E_0 through E_{M-1} that each operate at the outgoing sample rate. Each section
is fed from an M-fold downsampler. M phases of the input signal are obtained 
at the M downsampler outputs by delaying the input of each by a sample. Then
each polyphase section is convolved and the results summed. Again 
your computations require M*K*Fs multiplications/second instead of M^2*K*Fs,
where Fs is the output sample rate. 
-- 
Randy Yates
Sony Ericsson Mobile Communications
Research Triangle Park, NC, USA
r...@sonyericsson.com, 919-472-1124
______________________________
New DSP Code Snippets Section now Live.   Learn more about the reward program for contributors here.

| 1 | | 3 |