DSPRelated.com
Forums

Frequency shifting for software defined radio

Started by overgaard February 17, 2010
Hi all,

Too tired and it's all too late in the evening so pardon any 
stupidness/BS from me. :-)

I've been playing around with software defined radio now for a while.
I've mostly been doing the magic in the time domain and using FFT
mostly for power spectrum of the band of frequencies currently tuned to.

Now I want to see (after reading an article from an amateur radio 
newspaper QEX about just "moving the bins" in the FFT output) what/how
can be done in the frequency domain.
I've tried FFT fast convolution filtering and got it working.
Realtime filtering works with overlap-add, etc.

Now... Just moving the bins in the FFT output... Tried that few years back
when I knew nothing about DSP (now, I few years later, I realize I know
even less! Haha!) and I did not work well...
Clearly just moving the bins around causes phase discontinuity problems,
etc. right? 

Tried tonight, and even though I can demodulate for example AM, SSB using
the moved/shifted FFT, I clearly can see it does not look/sound right.
Even though I use overlap-add there is some "disturbance" every 
matching up to the lenght of the FFT.

Just letting the samples pass though my code FFT->IFFT (including some
filter, overlap-add) works fine... As soon as I just move/copy some bins
the spectrum gets uggly.

So.. Please, how is frequency shifting in the frequency domain implemented
the simplest way for use in my software defined radio.

Thanks and best regards
// Jörgen Overgaard / SM4WWG
On Feb 17, 6:11&#4294967295;pm, "overgaard" <jor...@antistaten.se> wrote:
> Hi all, > > Too tired and it's all too late in the evening so pardon any > stupidness/BS from me. :-) > > I've been playing around with software defined radio now for a while. > I've mostly been doing the magic in the time domain and using FFT > mostly for power spectrum of the band of frequencies currently tuned to. > > Now I want to see (after reading an article from an amateur radio > newspaper QEX about just "moving the bins" in the FFT output) what/how > can be done in the frequency domain. > I've tried FFT fast convolution filtering and got it working. > Realtime filtering works with overlap-add, etc. > > Now... Just moving the bins in the FFT output... Tried that few years back > when I knew nothing about DSP (now, I few years later, I realize I know > even less! Haha!) and I did not work well... > Clearly just moving the bins around causes phase discontinuity problems, > etc. right? > > Tried tonight, and even though I can demodulate for example AM, SSB using > the moved/shifted FFT, I clearly can see it does not look/sound right. > Even though I use overlap-add there is some "disturbance" every > matching up to the lenght of the FFT. > > Just letting the samples pass though my code FFT->IFFT (including some > filter, overlap-add) works fine... As soon as I just move/copy some bins > the spectrum gets uggly. > > So.. Please, how is frequency shifting in the frequency domain implemented > the simplest way for use in my software defined radio. > > Thanks and best regards > // J&#4294967295;rgen Overgaard / SM4WWG
In the time domain, tuning doesn't cost much and the shift frequencies are not quantized to the bin width. It seems to me that quantization would be a deal breaker for SSB. To shift in the frequency domain, you rotate the bins. John John
Hi John,

Thanks for replying!

Yes, just shifting the interesting frequencies in the time domain
to for example 0 Hz is easily done with mixing and lowpass filtering, etc.

But I wanted to try the frequency domain since I am learning and also
since I read in the article that he just copied the bins of interest down
to 0 Hz. Doing just that sounds TOO simple and for me it does not work. 
I get strange results. Please check some of the pictures of the
spectrogram of the results. You can clearly see the horizonal lines
stretching out from signals. http://www.antistaten.se/dsp/

I tried rotating the whole spectrum and it causes the same problem, 
except when I rotate the spectrum 256, 512 or 1024 steps.
And too make sure my rotating routine does this (for each step)
(shifting left)
1 2 3 4 5 6 7 8 9
2 3 4 5 6 7 8 9 1

Anyone know what causes the horizontal lines. They seem to
match up with the length of the FFT. 
I use overlap-add so why are they occuring each FFT length? 

Thanks!

Regards // J&ouml;rgen
>In the time domain, tuning doesn't cost much and the shift frequencies >are not quantized to the bin width. It seems to me that quantization >would be a deal breaker for SSB. To shift in the frequency domain, you >rotate the bins. > >John > > > >John >
I have placed some pictures of the spectrogram of what comes out
after rotating the FFT result.

Anyone can explain why the "disturbance" happens.
They happen about the lenght of the FFT.

As I mentioned before, I do use overlap-add and the "disturbance" only
happens when rotating the FFT some number of steps not 256, 512 or 1024,
etc.
Also, just doing a convoluting FFT filter (Lowpass, Highpass, Bandpass,
etc) works just fine in the same routine...

I just cant figure out why rotating the FFT does this...
I do something that disturbs phase, etc?

Please look at: http://www.antistaten.se/dsp/ for screenshots of the
spectrum

Best regards // J&ouml;rgen
On Feb 18, 5:58&#4294967295;am, "overgaard" <jor...@antistaten.se> wrote:
> I have placed some pictures of the spectrogram of what comes out > after rotating the FFT result. > > Anyone can explain why the "disturbance" happens. > They happen about the lenght of the FFT. > > As I mentioned before, I do use overlap-add and the "disturbance" only > happens when rotating the FFT some number of steps not 256, 512 or 1024, > etc. > Also, just doing a convoluting FFT filter (Lowpass, Highpass, Bandpass, > etc) works just fine in the same routine... > > I just cant figure out why rotating the FFT does this... > I do something that disturbs phase, etc? > > Please look at:http://www.antistaten.se/dsp/for screenshots of the > spectrum > > Best regards // J&#4294967295;rgen
If the FFT of the input block is X and the FFT of the filter response is H, then you can do a point-by-point multiply Y(k) = X(k)*H(k+n) where n is the shift in units of bins (positive or negative). When k+n goes out of bounds then wrap it to the other end. Take IFFT of Y(k), then do OLA. John
On Feb 17, 6:11&#4294967295;pm, "overgaard" <jor...@antistaten.se> wrote:
> Hi all, > > Too tired and it's all too late in the evening so pardon any > stupidness/BS from me. :-) > > I've been playing around with software defined radio now for a while. > I've mostly been doing the magic in the time domain and using FFT > mostly for power spectrum of the band of frequencies currently tuned to. > > Now I want to see (after reading an article from an amateur radio > newspaper QEX about just "moving the bins" in the FFT output) what/how > can be done in the frequency domain. > I've tried FFT fast convolution filtering and got it working. > Realtime filtering works with overlap-add, etc. > > Now... Just moving the bins in the FFT output... Tried that few years back > when I knew nothing about DSP (now, I few years later, I realize I know > even less! Haha!) and I did not work well... > Clearly just moving the bins around causes phase discontinuity problems, > etc. right? > > Tried tonight, and even though I can demodulate for example AM, SSB using > the moved/shifted FFT, I clearly can see it does not look/sound right. > Even though I use overlap-add there is some "disturbance" every > matching up to the lenght of the FFT. > > Just letting the samples pass though my code FFT->IFFT (including some > filter, overlap-add) works fine... As soon as I just move/copy some bins > the spectrum gets uggly. > > So.. Please, how is frequency shifting in the frequency domain implemented > the simplest way for use in my software defined radio. > > Thanks and best regards > // J&#4294967295;rgen Overgaard / SM4WWG
I would do this in the time domain. Extend your signal to be analytic (just takes a pair of phase orthogonal filters!) and then multiply the result by the output of a quadrature oscillator. The oscillator's frequecy is the shift frequency. Clay
Clay wrote:
> On Feb 17, 6:11 pm, "overgaard" <jor...@antistaten.se> wrote: >> Hi all, >> >> Too tired and it's all too late in the evening so pardon any >> stupidness/BS from me. :-) >> >> I've been playing around with software defined radio now for a while. >> I've mostly been doing the magic in the time domain and using FFT >> mostly for power spectrum of the band of frequencies currently tuned to. >> >> Now I want to see (after reading an article from an amateur radio >> newspaper QEX about just "moving the bins" in the FFT output) what/how >> can be done in the frequency domain. >> I've tried FFT fast convolution filtering and got it working. >> Realtime filtering works with overlap-add, etc. >> >> Now... Just moving the bins in the FFT output... Tried that few years back >> when I knew nothing about DSP (now, I few years later, I realize I know >> even less! Haha!) and I did not work well... >> Clearly just moving the bins around causes phase discontinuity problems, >> etc. right? >> >> Tried tonight, and even though I can demodulate for example AM, SSB using >> the moved/shifted FFT, I clearly can see it does not look/sound right. >> Even though I use overlap-add there is some "disturbance" every >> matching up to the lenght of the FFT. >> >> Just letting the samples pass though my code FFT->IFFT (including some >> filter, overlap-add) works fine... As soon as I just move/copy some bins >> the spectrum gets uggly. >> >> So.. Please, how is frequency shifting in the frequency domain implemented >> the simplest way for use in my software defined radio. >> >> Thanks and best regards >> // J&#4294967295;rgen Overgaard / SM4WWG > > I would do this in the time domain. Extend your signal to be analytic > (just takes a pair of phase orthogonal filters!) and then multiply the > result by the output of a quadrature oscillator. The oscillator's > frequecy is the shift frequency. > > Clay
Traditionally, this has been called the 'phasing method' of SSB handling. -- Tauno Voipio (OH2UG) tauno voipio (at) iki fi
On Feb 18, 10:25&#4294967295;am, Tauno Voipio <tauno.voi...@notused.fi.invalid>
wrote:
> Clay wrote: > > On Feb 17, 6:11 pm, "overgaard" <jor...@antistaten.se> wrote: > >> Hi all, > > >> Too tired and it's all too late in the evening so pardon any > >> stupidness/BS from me. :-) > > >> I've been playing around with software defined radio now for a while. > >> I've mostly been doing the magic in the time domain and using FFT > >> mostly for power spectrum of the band of frequencies currently tuned to. > > >> Now I want to see (after reading an article from an amateur radio > >> newspaper QEX about just "moving the bins" in the FFT output) what/how > >> can be done in the frequency domain. > >> I've tried FFT fast convolution filtering and got it working. > >> Realtime filtering works with overlap-add, etc. > > >> Now... Just moving the bins in the FFT output... Tried that few years back > >> when I knew nothing about DSP (now, I few years later, I realize I know > >> even less! Haha!) and I did not work well... > >> Clearly just moving the bins around causes phase discontinuity problems, > >> etc. right? > > >> Tried tonight, and even though I can demodulate for example AM, SSB using > >> the moved/shifted FFT, I clearly can see it does not look/sound right. > >> Even though I use overlap-add there is some "disturbance" every > >> matching up to the lenght of the FFT. > > >> Just letting the samples pass though my code FFT->IFFT (including some > >> filter, overlap-add) works fine... As soon as I just move/copy some bins > >> the spectrum gets uggly. > > >> So.. Please, how is frequency shifting in the frequency domain implemented > >> the simplest way for use in my software defined radio. > > >> Thanks and best regards > >> // J&#4294967295;rgen Overgaard / SM4WWG > > > I would do this in the time domain. Extend your signal to be analytic > > (just takes a pair of phase orthogonal filters!) and then multiply the > > result by the output of a quadrature oscillator. The oscillator's > > frequecy is the shift frequency. > > > Clay > > Traditionally, this has been called the 'phasing method' of SSB handling. > > -- > > Tauno Voipio (OH2UG) > tauno voipio (at) iki fi- Hide quoted text - > > - Show quoted text -
True, but in terms of software radio, this has become computationally inexpensive. I've written articles on how to do both the phase orthogonal filtering and the quadrature oscillators. Sometimes one may look at a method so one classically done in hardware and not realize that it may be simpler in software. Especially in this case it is easy to guarantee the quality of the filters and/or oscillator. Clay
Hi John,

I tried what you suggested, but I must be doing someting wrong.
Doing Y(k) = X(k)*H(k+n) only seem to move the filter about
in the spectrum, not the signal.

For experimenting I have a few files containing I/Q data.

What I want to do is this: (taking an AM signal as an example)
Shift frequencies of AM signal with carrier at 10640 Hz down to
0 Hz. That way I will have upper and lower sideband next to 0 Hz
for easy demodulation. :D

Now... In time domain I could just mix the I and Q signals with the
output of an oscillator and then do lowpass filtering and voila!
But is it really that complicated shifting it down in the
frequency domain.
I have no reason to why I want to do this other than to learn. :D


Some info (maybe should have told you all this before)
Samplerate: 48000 Hz
Size of FFT: 4096
Size of filter: 400
Samples per frame: 4096-400 = 3696
Zero padding input samples and filter: Yes
Output from IFFT is overlap-add'ed
Carrier freq of AM signal: 10640 Hz
Bandwidth of AM signal: 9 kHz * 2 = 18 kHz (both sidebands)


Regards // J&ouml;rgen

PS. If I am being stupid or just anoying, please slap me! *lol* DS
> >If the FFT of the input block is X and the FFT of the filter response >is H, then you can do a point-by-point multiply Y(k) =3D X(k)*H(k+n) >where n is the shift in units of bins (positive or negative). When k+n >goes out of bounds then wrap it to the other end. Take IFFT of Y(k), >then do OLA. > >John >
Clay wrote:
> On Feb 18, 10:25 am, Tauno Voipio <tauno.voi...@notused.fi.invalid> > wrote: >> Clay wrote: >>> On Feb 17, 6:11 pm, "overgaard" <jor...@antistaten.se> wrote: >>>> Hi all, >>>> Too tired and it's all too late in the evening so pardon any >>>> stupidness/BS from me. :-) >>>> I've been playing around with software defined radio now for a while. >>>> I've mostly been doing the magic in the time domain and using FFT >>>> mostly for power spectrum of the band of frequencies currently tuned to. >>>> Now I want to see (after reading an article from an amateur radio >>>> newspaper QEX about just "moving the bins" in the FFT output) what/how >>>> can be done in the frequency domain. >>>> I've tried FFT fast convolution filtering and got it working. >>>> Realtime filtering works with overlap-add, etc. >>>> Now... Just moving the bins in the FFT output... Tried that few years back >>>> when I knew nothing about DSP (now, I few years later, I realize I know >>>> even less! Haha!) and I did not work well... >>>> Clearly just moving the bins around causes phase discontinuity problems, >>>> etc. right? >>>> Tried tonight, and even though I can demodulate for example AM, SSB using >>>> the moved/shifted FFT, I clearly can see it does not look/sound right. >>>> Even though I use overlap-add there is some "disturbance" every >>>> matching up to the lenght of the FFT. >>>> Just letting the samples pass though my code FFT->IFFT (including some >>>> filter, overlap-add) works fine... As soon as I just move/copy some bins >>>> the spectrum gets uggly. >>>> So.. Please, how is frequency shifting in the frequency domain implemented >>>> the simplest way for use in my software defined radio. >>>> Thanks and best regards >>>> // J&#4294967295;rgen Overgaard / SM4WWG >>> I would do this in the time domain. Extend your signal to be analytic >>> (just takes a pair of phase orthogonal filters!) and then multiply the >>> result by the output of a quadrature oscillator. The oscillator's >>> frequecy is the shift frequency. >>> Clay >> Traditionally, this has been called the 'phasing method' of SSB handling. >> >> -- >> >> Tauno Voipio (OH2UG) >> tauno voipio (at) iki fi- Hide quoted text - >> >> - Show quoted text - > > True, but in terms of software radio, this has become computationally > inexpensive. I've written articles on how to do both the phase > orthogonal filtering and the quadrature oscillators. Sometimes one may > look at a method so one classically done in hardware and not realize > that it may be simpler in software. Especially in this case it is easy > to guarantee the quality of the filters and/or oscillator. > > Clay
That's true - you can get two exactly balanced channels and ideal balanced modulators/mixers with digital technology. Also, AM demodulation goes easily with the Pythagorean sqrt(I*I + Q*Q) -- Tauno Voipio