FPGA Central - World's 1st FPGA / CPLD Portal

FPGA Central

World's 1st FPGA Portal

 

Go Back   FPGA Groups > NewsGroup > DSP

DSP comp.dsp newsgroup, mailing list

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-02-2005, 08:33 PM
jaac
Guest
 
Posts: n/a
Default Sample rate conversion doubt

Hello guys,

I've been struggling with algorithms for sample rate conversion, namely
decimation by a factor of 40, to convert from 8kHz sample rate to 200
Hz.

I've started with the block diagrams from P.P. Vaidyanathan's book
"Multirate Systems and Filter Banks" implementing them in Simulink, and
then writting my own C code. From the Simulink model everything was OK.
But my C code (running on a SHARC, BTW) gave me some sort of modulation
on the decimated signal.

I asked for support, people here guided me to the code available at
DSPGuru. I understood it, implemented it, and gave me exactly the same
results as my original C code.

Moreover, I did the decimation by brute force, which means a long
lowpass filter, then discarding 39 out of 40 samples, and again the
same results.

I've been wondering why does it work perfectly in Cimulink, and not in
my code. In my test, the signal to be downsampled is a carrier at 60Hz,
with the "information" modulating this carrier, AM. The strange thing
is that even if I use a pure 60Hz tone as input, I get a modulated
output with my code, not with Simulink.

Someone suggested slightly changing the carrier frequency to say 60.37
Hz, and voilà: even in Simulink it appears that the decimated signal
seems to be modulated.

The conclusion is: I can't do the sample rate conversion for my
application, because MY information is on the envelope of the carrier,
because it's AM modulation.

But my BIG question is: is it TRUE that sampling rate conversion CAN
change the envelope of the output signal? Isn't there a way to do
sample rate conversion which preservers the signal shape, regardless of
the relations between original sample rate, final sample rate and
upsampling/downsampling factors?

Thank you very much,

JaaC

Reply With Quote
  #2 (permalink)  
Old 01-02-2005, 09:33 PM
Tim Wescott
Guest
 
Posts: n/a
Default Re: Sample rate conversion doubt

jaac wrote:

> Hello guys,
>
> I've been struggling with algorithms for sample rate conversion, namely
> decimation by a factor of 40, to convert from 8kHz sample rate to 200
> Hz.
>
> I've started with the block diagrams from P.P. Vaidyanathan's book
> "Multirate Systems and Filter Banks" implementing them in Simulink, and
> then writting my own C code. From the Simulink model everything was OK.
> But my C code (running on a SHARC, BTW) gave me some sort of modulation
> on the decimated signal.
>
> I asked for support, people here guided me to the code available at
> DSPGuru. I understood it, implemented it, and gave me exactly the same
> results as my original C code.
>
> Moreover, I did the decimation by brute force, which means a long
> lowpass filter, then discarding 39 out of 40 samples, and again the
> same results.
>
> I've been wondering why does it work perfectly in Cimulink, and not in
> my code. In my test, the signal to be downsampled is a carrier at 60Hz,
> with the "information" modulating this carrier, AM. The strange thing
> is that even if I use a pure 60Hz tone as input, I get a modulated
> output with my code, not with Simulink.
>
> Someone suggested slightly changing the carrier frequency to say 60.37
> Hz, and voilà: even in Simulink it appears that the decimated signal
> seems to be modulated.
>
> The conclusion is: I can't do the sample rate conversion for my
> application, because MY information is on the envelope of the carrier,
> because it's AM modulation.
>
> But my BIG question is: is it TRUE that sampling rate conversion CAN
> change the envelope of the output signal? Isn't there a way to do
> sample rate conversion which preservers the signal shape, regardless of
> the relations between original sample rate, final sample rate and
> upsampling/downsampling factors?
>
> Thank you very much,
>
> JaaC
>

Yes it is true. Using envelopes for demodulation is a very iffy
business with sampled data.

In fact, are you sure that your envelope is "perfect" with the 200Hz
sampling? I'm seeing a variation with a period of 10 samples -- perhaps
that is just short enough that you didn't notice?

You can't really preserve the signal shape in this case, without up
sampling again before demodulating. If it were me I'd either do exactly
that, or I'd do synchronous AM demodulation, which should retrieve your
original data just fine -- assuming that it's band limited enough.

--

Tim Wescott
Wescott Design Services
http://www.wescottdesign.com
Reply With Quote
  #3 (permalink)  
Old 01-02-2005, 10:18 PM
Jerry Avins
Guest
 
Posts: n/a
Default Re: Sample rate conversion doubt

jaac wrote:

> Hello guys,
>
> I've been struggling with algorithms for sample rate conversion, namely
> decimation by a factor of 40, to convert from 8kHz sample rate to 200
> Hz.
>
> I've started with the block diagrams from P.P. Vaidyanathan's book
> "Multirate Systems and Filter Banks" implementing them in Simulink, and
> then writting my own C code. From the Simulink model everything was OK.
> But my C code (running on a SHARC, BTW) gave me some sort of modulation
> on the decimated signal.
>
> I asked for support, people here guided me to the code available at
> DSPGuru. I understood it, implemented it, and gave me exactly the same
> results as my original C code.
>
> Moreover, I did the decimation by brute force, which means a long
> lowpass filter, then discarding 39 out of 40 samples, and again the
> same results.
>
> I've been wondering why does it work perfectly in Cimulink, and not in
> my code. In my test, the signal to be downsampled is a carrier at 60Hz,
> with the "information" modulating this carrier, AM. The strange thing
> is that even if I use a pure 60Hz tone as input, I get a modulated
> output with my code, not with Simulink.
>
> Someone suggested slightly changing the carrier frequency to say 60.37
> Hz, and voilà: even in Simulink it appears that the decimated signal
> seems to be modulated.
>
> The conclusion is: I can't do the sample rate conversion for my
> application, because MY information is on the envelope of the carrier,
> because it's AM modulation.
>
> But my BIG question is: is it TRUE that sampling rate conversion CAN
> change the envelope of the output signal? Isn't there a way to do
> sample rate conversion which preservers the signal shape, regardless of
> the relations between original sample rate, final sample rate and
> upsampling/downsampling factors?
>
> Thank you very much,
>
> JaaC


Envelope demodulation works with continuous signals because the peak of
the carrier is present in each carrier cycle. It can be faked if the
sample rate is high enough because a sample falls near enough to the
carrier peak in most carrier samples. (Using absolute value essentially
doubles the sample rate.) Even for continuous signals, envelope
detection works well only for modulating frequencies much lower than the
carrier frequency.

Jerry
--
Engineering is the art of making what you want from things you can get.
ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
Reply With Quote
  #4 (permalink)  
Old 01-03-2005, 01:20 AM
jaac
Guest
 
Posts: n/a
Default Re: Sample rate conversion doubt

Hi Tim,

Thanks for prompt reply.

To be precise, my project is related to the measurement of the
phenomena named "flicker", which consists of amplitude variations on
the AC line, 50/60 Hz, 220 / 110 Vrms. That's why my information is
precisely in the envelope of the carrier, which here is 60 Hz (possibly
with fluctuations, of course).

As stated on the IEC standard, the demodulation is done by squaring,
then some filtering is performed, to eliminate DC component and
components higher than Fs/2. And then further filtering and analysis of
the data, and storage.

Your idea of upsampling before demodulation, excuse me, is not a good
one. For my case, it would be better to do all of the downsampling
after the demodulation. I know that it is the almost the same as you
suggested, it is just locating the sample rate conversion to the place
where it is more benefical. I bet that's what you had in your mind.

The idea of synchronous AM demodulation seems interesting. Could you
please elaborate on the subject, or point me to information about it?
Kindest regards,

JaaC

Reply With Quote
  #5 (permalink)  
Old 01-03-2005, 01:20 AM
jaac
Guest
 
Posts: n/a
Default Re: Sample rate conversion doubt

Hi Tim,

Thanks for prompt reply.

To be precise, my project is related to the measurement of the
phenomena named "flicker", which consists of amplitude variations on
the AC line, 50/60 Hz, 220 / 110 Vrms. That's why my information is
precisely in the envelope of the carrier, which here is 60 Hz (possibly
with fluctuations, of course).

As stated on the IEC standard, the demodulation is done by squaring,
then some filtering is performed, to eliminate DC component and
components higher than Fs/2. And then further filtering and analysis of
the data, and storage.

Your idea of upsampling before demodulation, excuse me, is not a good
one. For my case, it would be better to do all of the downsampling
after the demodulation. I know that it is the almost the same as you
suggested, it is just locating the sample rate conversion to the place
where it is more benefical. I bet that's what you had in your mind.

The idea of synchronous AM demodulation seems interesting. Could you
please elaborate on the subject, or point me to information about it?
Kindest regards,

JaaC

Reply With Quote
  #6 (permalink)  
Old 01-03-2005, 01:21 AM
jaac
Guest
 
Posts: n/a
Default Re: Sample rate conversion doubt

Hi Tim,

Thanks for prompt reply.

To be precise, my project is related to the measurement of the
phenomena named "flicker", which consists of amplitude variations on
the AC line, 50/60 Hz, 220 / 110 Vrms. That's why my information is
precisely in the envelope of the carrier, which here is 60 Hz (possibly
with fluctuations, of course).

As stated on the IEC standard, the demodulation is done by squaring,
then some filtering is performed, to eliminate DC component and
components higher than Fs/2. And then further filtering and analysis of
the data, and storage.

Your idea of upsampling before demodulation, excuse me, is not a good
one. For my case, it would be better to do all of the downsampling
after the demodulation. I know that it is the almost the same as you
suggested, it is just locating the sample rate conversion to the place
where it is more benefical. I bet that's what you had in your mind.

The idea of synchronous AM demodulation seems interesting. Could you
please elaborate on the subject, or point me to information about it?
Kindest regards,

JaaC

Reply With Quote
  #7 (permalink)  
Old 01-03-2005, 01:21 AM
jaac
Guest
 
Posts: n/a
Default Re: Sample rate conversion doubt

Hi Tim,

Thanks for prompt reply.

To be precise, my project is related to the measurement of the
phenomena named "flicker", which consists of amplitude variations on
the AC line, 50/60 Hz, 220 / 110 Vrms. That's why my information is
precisely in the envelope of the carrier, which here is 60 Hz (possibly
with fluctuations, of course).

As stated on the IEC standard, the demodulation is done by squaring,
then some filtering is performed, to eliminate DC component and
components higher than Fs/2. And then further filtering and analysis of
the data, and storage.

Your idea of upsampling before demodulation, excuse me, is not a good
one. For my case, it would be better to do all of the downsampling
after the demodulation. I know that it is the almost the same as you
suggested, it is just locating the sample rate conversion to the place
where it is more benefical. I bet that's what you had in your mind.

The idea of synchronous AM demodulation seems interesting. Could you
please elaborate on the subject, or point me to information about it?
Kindest regards,

JaaC

Reply With Quote
  #8 (permalink)  
Old 01-03-2005, 01:29 AM
Tim Wescott
Guest
 
Posts: n/a
Default Re: Sample rate conversion doubt

jaac wrote:

> Hi Tim,
>
> Thanks for prompt reply.
>
> To be precise, my project is related to the measurement of the
> phenomena named "flicker", which consists of amplitude variations on
> the AC line, 50/60 Hz, 220 / 110 Vrms. That's why my information is
> precisely in the envelope of the carrier, which here is 60 Hz (possibly
> with fluctuations, of course).
>
> As stated on the IEC standard, the demodulation is done by squaring,
> then some filtering is performed, to eliminate DC component and
> components higher than Fs/2. And then further filtering and analysis of
> the data, and storage.
>
> Your idea of upsampling before demodulation, excuse me, is not a good
> one. For my case, it would be better to do all of the downsampling
> after the demodulation. I know that it is the almost the same as you
> suggested, it is just locating the sample rate conversion to the place
> where it is more benefical. I bet that's what you had in your mind.
>
> The idea of synchronous AM demodulation seems interesting. Could you
> please elaborate on the subject, or point me to information about it?
> Kindest regards,
>
> JaaC
>

Sorry, I was assuming that you were forced into downsampling first -- if
you can, doing your demodulation first would be best, of course.

Google on "synchronous AM" to get appropriate information -- it's a
well-known method for high quality AM demodulation.

Given that you're working off of a specification it would probably be
easiest to do just that, unless you're prepared to justify how your
method is exactly equivalent.

--

Tim Wescott
Wescott Design Services
http://www.wescottdesign.com
Reply With Quote
  #9 (permalink)  
Old 01-03-2005, 05:22 PM
Philip Martel
Guest
 
Posts: n/a
Default Re: Sample rate conversion doubt


"jaac" <[email protected]> wrote in message
news:[email protected] oups.com...
> Hi Tim,
>
> Thanks for prompt reply.
>
> To be precise, my project is related to the measurement of the
> phenomena named "flicker", which consists of amplitude variations on
> the AC line, 50/60 Hz, 220 / 110 Vrms. That's why my information is
> precisely in the envelope of the carrier, which here is 60 Hz (possibly
> with fluctuations, of course).
>
> As stated on the IEC standard, the demodulation is done by squaring,
> then some filtering is performed, to eliminate DC component and
> components higher than Fs/2. And then further filtering and analysis of
> the data, and storage.

If I understand this, you are digitizing some data at 8KHz, then squaring
it. The data is a 60Hz signal with some modulation on it.
When you square the signal, you will get:
a DC term (level depends on carrier strength)
a low frequency term due to modulation (I think this is what you are
interested in)
the original 60 Hz signal with it's modulation
a signal at 120 Hz with various modulation signals

If the Fs you mention above is the original 8 KHz, then you will have the 60
Hz and 120 Hz signals. If the Fs you mention is the 200 Hz, then the
signals around 120 Hz will be aliased to around 20Hz and may fall into the
passband of your filter

Best wishes,
--Phil Martel
>
> Your idea of upsampling before demodulation, excuse me, is not a good
> one. For my case, it would be better to do all of the downsampling
> after the demodulation. I know that it is the almost the same as you
> suggested, it is just locating the sample rate conversion to the place
> where it is more benefical. I bet that's what you had in your mind.
>
> The idea of synchronous AM demodulation seems interesting. Could you
> please elaborate on the subject, or point me to information about it?
> Kindest regards,
>
> JaaC
>



Reply With Quote
  #10 (permalink)  
Old 01-03-2005, 06:29 PM
jaac
Guest
 
Posts: n/a
Default Re: Sample rate conversion doubt

Hi Phil,

Thanks for the reply.

You are right. I would get aliasing. Thank you for pointing this out.

To be honest the 200Hz Fs comes from originally having the carrier at
50 Hz in the IEC document, but this won't be my case. If I stay without
the sample rate conversion, and sampling directly at low frequency, I'd
better change it to 240Hz, and I'll have to redesign my filters (I'm
lazy to do that).

More interesting, I'll go for the decimation after squaring at 8kHz.
So, my bandpass filter, from 0.05Hz to 35Hz @ 200Hz will effectively
reject the aliased signals, I won't modify the original signal's shape
(important because my information is there), and more important, I'll
only need one ADC per channel, instead of two (one sampling at 8kHz for
spectral analysis, the other one sampling at 200Hz for waveshape
fluctuation analysis).

Thank you very much!

JaaC

Reply With Quote
  #11 (permalink)  
Old 01-03-2005, 07:03 PM
Philip Martel
Guest
 
Posts: n/a
Default Re: Sample rate conversion doubt


"jaac" <[email protected]> wrote in message
news:[email protected] oups.com...
> Hi Phil,
>
> Thanks for the reply.
>
> You are right. I would get aliasing. Thank you for pointing this out.
>
> To be honest the 200Hz Fs comes from originally having the carrier at
> 50 Hz in the IEC document, but this won't be my case. If I stay without
> the sample rate conversion, and sampling directly at low frequency, I'd
> better change it to 240Hz, and I'll have to redesign my filters (I'm
> lazy to do that).
>
> More interesting, I'll go for the decimation after squaring at 8kHz.
> So, my bandpass filter, from 0.05Hz to 35Hz @ 200Hz will effectively
> reject the aliased signals, I won't modify the original signal's shape
> (important because my information is there), and more important, I'll
> only need one ADC per channel, instead of two (one sampling at 8kHz for
> spectral analysis, the other one sampling at 200Hz for waveshape
> fluctuation analysis).
>
> Thank you very much!
>
> JaaC
>

Glad to have been of help. Won't you have to re-design your filter (0.05Hz
to 35Hz @ 200 Hz) to work at 8KHz? If you just feed the 8KHz samples in, I
suspect it will filter from 0.4Hz to 280Hz

Best wishes,
--Phil


Reply With Quote
  #12 (permalink)  
Old 01-06-2005, 06:32 PM
jaac
Guest
 
Posts: n/a
Default Re: Sample rate conversion doubt

Philip Martel wrote:

> Glad to have been of help. Won't you have to re-design your filter

(0.05Hz
> to 35Hz @ 200 Hz) to work at 8KHz? If you just feed the 8KHz samples

in, I
> suspect it will filter from 0.4Hz to 280Hz
>
> Best wishes,
> --Phil


Hi Phil,

No. The signal flow would be like this:

Samples @ 8kHz -> Squaring (AM demodulation) @ 8kHz -> Decimation by 40
(New Fs: 200 Hz) -> Bandpass filtering (0.05Hz - 35 Hz) @ 200Hz ->
Other processing @ 200 Hz. What's wrong here?

Regards,

JaaC

Reply With Quote
  #13 (permalink)  
Old 01-06-2005, 06:35 PM
jaac
Guest
 
Posts: n/a
Default Re: Sample rate conversion doubt

Philip Martel wrote:

> Glad to have been of help. Won't you have to re-design your filter

(0.05Hz
> to 35Hz @ 200 Hz) to work at 8KHz?


The idea is to have them working at 200 Hz, not at 8kHz. Specifically,
to ease the design of the filters.

JaaC

Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sample Rate Conversion (Downsampling) Jaime Andrés Aranguren Cardona DSP 26 12-18-2004 05:14 AM
Asynchronous/Synchronous Sample Rate Conversion Morgan P?lsson DSP 3 08-25-2004 07:20 PM
Clock Rate = Sample Rate?? Curious DSP 4 08-19-2004 03:07 AM
Sample Rate Conversion by non integer factor David Reid DSP 15 07-02-2004 06:03 PM
Sample Rate Conversion Confusion Morgan P?lsson DSP 7 06-29-2004 08:47 PM


All times are GMT +1. The time now is 02:21 AM.


Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
Copyright 2008 @ FPGA Central. All rights reserved