DSPRelated.com
Forums

Real time downsampling with DSP

Started by Xander December 5, 2004
hi 

can somebody help me with these problem.

I am using Texas Instrument 6711 DSP to do downsampling on some input.

The input and output rates are fixed at 8kHz.

Is there a way to do downsampling (by a factor of 2) realtime? 
i.e. process each input and produce a corresponding output.

It seem to me that it is not possible as I need to have 2 input
samples to produce an output.

thanks a lot, any help is greatly appreciated
Real-time signal processing refers to the processor being able to "keep up" 
with the incoming data stream.  Let's take your case as an example.  Your 
data is coming in at a rate of 8 kHz.  This corresponds to a new sample 
arriving every 125 microseconds.  In order for your processing to be 
considered real-time, the DSP must complete all its processing for a sample 
in under 125 microseconds such that it can process the next sample as it 
arrives.

In order to downsample by two all you need to do is apply a 4 kHz lowpass 
filter (i.e. pi/2 in digital domain) and then output alternating samples 
coming out of the filter.  This will be a piece of cake for the DSP.

Brad

"Xander" <koksoon.toh@gmail.com> wrote in message 
news:90674b52.0412042306.7a1e52bf@posting.google.com...
> hi > > can somebody help me with these problem. > > I am using Texas Instrument 6711 DSP to do downsampling on some input. > > The input and output rates are fixed at 8kHz. > > Is there a way to do downsampling (by a factor of 2) realtime? > i.e. process each input and produce a corresponding output. > > It seem to me that it is not possible as I need to have 2 input > samples to produce an output. > > thanks a lot, any help is greatly appreciated
Is it that simple?

Suppose the after filtering we get ->   y(1),  y(2),  y(3),  y(4),  y(5)
...

what you are suggesting is that (by output alternating samples) ->  y(1),
0,  y(3),  0,  y(5),  0, ... which is not the case.

it should be   y(1),  y(3),  y(5), ...

I think the problem lies  here

at t = 1 output = y(1)
at t = 2 output = y(3)  which is not available until t = 3



"Brad Griffis" <bradgriffis@hotmail.com> wrote in message
news:C3Hsd.39527$Qv5.13096@newssvr33.news.prodigy.com...
> Real-time signal processing refers to the processor being able to "keep
up"
> with the incoming data stream. Let's take your case as an example. Your > data is coming in at a rate of 8 kHz. This corresponds to a new sample > arriving every 125 microseconds. In order for your processing to be > considered real-time, the DSP must complete all its processing for a
sample
> in under 125 microseconds such that it can process the next sample as it > arrives. > > In order to downsample by two all you need to do is apply a 4 kHz lowpass > filter (i.e. pi/2 in digital domain) and then output alternating samples > coming out of the filter. This will be a piece of cake for the DSP. > > Brad > > "Xander" <koksoon.toh@gmail.com> wrote in message > news:90674b52.0412042306.7a1e52bf@posting.google.com... > > hi > > > > can somebody help me with these problem. > > > > I am using Texas Instrument 6711 DSP to do downsampling on some input. > > > > The input and output rates are fixed at 8kHz. > > > > Is there a way to do downsampling (by a factor of 2) realtime? > > i.e. process each input and produce a corresponding output. > > > > It seem to me that it is not possible as I need to have 2 input > > samples to produce an output. > > > > thanks a lot, any help is greatly appreciated > >
in article covh5g$31c$1@mawar.singnet.com.sg, above_ware at
above_ware@yahoo.com wrote on 12/05/2004 13:08:

> Is it that simple? > > Suppose the after filtering we get -> y(1), y(2), y(3), y(4), y(5) > ... > > what you are suggesting is that (by output alternating samples) -> y(1), > 0, y(3), 0, y(5), 0, ... which is not the case. > > it should be y(1), y(3), y(5), ... > > I think the problem lies here > > at t = 1 output = y(1) > at t = 2 output = y(3) which is not available until t = 3 >
you need to somehow program your D/A hardware to have a different (lower) sampling rate than the A/D. that is an issue of getting the data sheets and setting the correct bits in some control register. if you can't do that, try (after LPF filtering) y[0] y[0] y[2] y[2] y[4] y[4] y[6] y[6] ... (real DSPers count from zero except when they have to deal with @$%%^$@#^&* MATLAB!) -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
y[0] y[0] y[2] y[2] y[4] y[4] y[6] y[6] ...   <= This doesn't work !!!

Now I got 2 alternatives 

1: buffer the inputs for a period ot time
2: use polyphase filter, which i suspect, also suffers the same problem

anymore solutions? 



robert bristow-johnson <rbj@audioimagination.com> wrote in message news:<BDD8C3D2.2C5E%rbj@audioimagination.com>...
> in article covh5g$31c$1@mawar.singnet.com.sg, above_ware at > above_ware@yahoo.com wrote on 12/05/2004 13:08: > > > Is it that simple? > > > > Suppose the after filtering we get -> y(1), y(2), y(3), y(4), y(5) > > ... > > > > what you are suggesting is that (by output alternating samples) -> y(1), > > 0, y(3), 0, y(5), 0, ... which is not the case. > > > > it should be y(1), y(3), y(5), ... > > > > I think the problem lies here > > > > at t = 1 output = y(1) > > at t = 2 output = y(3) which is not available until t = 3 > > > > you need to somehow program your D/A hardware to have a different (lower) > sampling rate than the A/D. that is an issue of getting the data sheets and > setting the correct bits in some control register. if you can't do that, > try (after LPF filtering) > > y[0] y[0] y[2] y[2] y[4] y[4] y[6] y[6] ... > > (real DSPers count from zero except when they have to deal with @$%%^$@#^&* > MATLAB!)
Xander,

I think I misunderstood you when you asked initially.  You are correct that 
if you downsample by 2 that you will have twice as many samples at the 
output as you will at the input.  Isn't that what you wanted?  This implies 
that you will need to cut the sampling rate in half for the output in order 
for it to work properly.

Alternatively if you want to have the same number of samples on the input 
side and output side and have it "sound" like you downsampled you could 
simply apply the lowpass filter and then keep all the samples.

x[n] -> |_lowpass_filter_| -> y[n]

That is output the full y[0], y[1], y[2], y[3], etc.

Brad

"Xander" <koksoon.toh@gmail.com> wrote in message 
news:90674b52.0412052212.20cd7de4@posting.google.com...
> y[0] y[0] y[2] y[2] y[4] y[4] y[6] y[6] ... <= This doesn't work !!! > > Now I got 2 alternatives > > 1: buffer the inputs for a period ot time > 2: use polyphase filter, which i suspect, also suffers the same problem > > anymore solutions? > > > > robert bristow-johnson <rbj@audioimagination.com> wrote in message > news:<BDD8C3D2.2C5E%rbj@audioimagination.com>... >> in article covh5g$31c$1@mawar.singnet.com.sg, above_ware at >> above_ware@yahoo.com wrote on 12/05/2004 13:08: >> >> > Is it that simple? >> > >> > Suppose the after filtering we get -> y(1), y(2), y(3), y(4), >> > y(5) >> > ... >> > >> > what you are suggesting is that (by output alternating samples) -> >> > y(1), >> > 0, y(3), 0, y(5), 0, ... which is not the case. >> > >> > it should be y(1), y(3), y(5), ... >> > >> > I think the problem lies here >> > >> > at t = 1 output = y(1) >> > at t = 2 output = y(3) which is not available until t = 3 >> > >> >> you need to somehow program your D/A hardware to have a different (lower) >> sampling rate than the A/D. that is an issue of getting the data sheets >> and >> setting the correct bits in some control register. if you can't do that, >> try (after LPF filtering) >> >> y[0] y[0] y[2] y[2] y[4] y[4] y[6] y[6] ... >> >> (real DSPers count from zero except when they have to deal with >> @$%%^$@#^&* >> MATLAB!)
Xander wrote:

> y[0] y[0] y[2] y[2] y[4] y[4] y[6] y[6] ... <= This doesn't work !!!
Why not?
> Now I got 2 alternatives > > 1: buffer the inputs for a period ot time > 2: use polyphase filter, which i suspect, also suffers the same problem > > anymore solutions?
I probably don't understand what you want to do. What do you think "downsampling" means? Here's what I think you said you want to do: You have a signal with no components higher than 4 KHz, sampled 8,000 times per second. You want to reduce the sample rate to 4,000 per second. That rate supports frequencies up to 2 KHz, so you must remove the top octave before decimating, err .. downsampling. Now you have an output stream that has half as many samples in a given time as the input stream. Clearly, each output sample has to last twice as long as an input sample if a minute of input is to translate to a minute of output. Any time ratio other than 1:1 can't be long-term real time. So, what's the problem? Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
"Xander" <koksoon.toh@gmail.com> wrote in message
news:90674b52.0412042306.7a1e52bf@posting.google.com...
> hi > > can somebody help me with these problem. > > I am using Texas Instrument 6711 DSP to do downsampling on some input. > > The input and output rates are fixed at 8kHz.
There is a problem here in your problem description... You said that you want to do downsampling on the input but your input and output rates are the same (8kHz). So why do you need to do downsampling? Downsampling is going to change your sample rate of the output.
> > Is there a way to do downsampling (by a factor of 2) realtime? > i.e. process each input and produce a corresponding output. > > It seem to me that it is not possible as I need to have 2 input > samples to produce an output. > > thanks a lot, any help is greatly appreciated
in article dBZsd.40743$Qv5.4821@newssvr33.news.prodigy.com, Brad Griffis at
bradgriffis@hotmail.com wrote on 12/06/2004 08:59:

> I think I misunderstood you when you asked initially. You are correct that > if you downsample by 2 that you will have twice as many samples at the > output as you will at the input.
i think it's the other way around, no?
> Isn't that what you wanted? This implies > that you will need to cut the sampling rate in half for the output in order > for it to work properly. > > Alternatively if you want to have the same number of samples on the input > side and output side and have it "sound" like you downsampled you could > simply apply the lowpass filter and then keep all the samples. > > x[n] -> |_lowpass_filter_| -> y[n] > > That is output the full y[0], y[1], y[2], y[3], etc. > > Brad > > "Xander" <koksoon.toh@gmail.com> wrote in message > news:90674b52.0412052212.20cd7de4@posting.google.com... >> y[0] y[0] y[2] y[2] y[4] y[4] y[6] y[6] ... <= This doesn't work !!!
can you be more specific? *what* doesn't work? are those LPF filter output samples available? if so, i can't, for the life in me, see why you cannot code it so that the odd indexed samples, y[2n+1], are replaced by their even counterparts, y[2n]. this is not really downsampling (until you can actually change the sample rate of the output D/A) but it is a demonstration of downsampling by 2 in a case where the D/A is hard synced to the A/D. or is it a digital-in, digital-out situation? -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
>> >> Now I got 2 alternatives >> >> 1: buffer the inputs for a period ot time >> 2: use polyphase filter, which i suspect, also suffers the same problem >> >> anymore solutions? >> >> >> >> robert bristow-johnson <rbj@audioimagination.com> wrote in message >> news:<BDD8C3D2.2C5E%rbj@audioimagination.com>... >>> in article covh5g$31c$1@mawar.singnet.com.sg, above_ware at >>> above_ware@yahoo.com wrote on 12/05/2004 13:08: >>> >>>> Is it that simple? >>>> >>>> Suppose the after filtering we get -> y(1), y(2), y(3), y(4), >>>> y(5) >>>> ... >>>> >>>> what you are suggesting is that (by output alternating samples) -> >>>> y(1), >>>> 0, y(3), 0, y(5), 0, ... which is not the case. >>>> >>>> it should be y(1), y(3), y(5), ... >>>> >>>> I think the problem lies here >>>> >>>> at t = 1 output = y(1) >>>> at t = 2 output = y(3) which is not available until t = 3 >>>> >>> >>> you need to somehow program your D/A hardware to have a different (lower) >>> sampling rate than the A/D. that is an issue of getting the data sheets >>> and >>> setting the correct bits in some control register. if you can't do that, >>> try (after LPF filtering) >>> >>> y[0] y[0] y[2] y[2] y[4] y[4] y[6] y[6] ... >>> >>> (real DSPers count from zero except when they have to deal with >>> @$%%^$@#^&* >>> MATLAB!) > >
y[0] y[0] y[2] y[2] y[4] y[4] y[6] y[6] ...   <= This doesn't work !!!
if you output these samples at 8kHz  (thinking that you can use the
8kHhz as a 4 kHz one )

Of course I can code it so that the odd indexed samples, y[2n+1], are
replaced by their even
counterparts, y[2n]. But the problem is

at t = 1 output = y(1)
at t = 2 output = y(3)  which is not available until t = 3   [as
mentioned in my eariler thread]


To eleborate more, ...  I am actually implementing a  channelizer,
using Quadrature Mirror Filtering (1 stage only). to do QMF, I need to
do downsampling