discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

phase align and passive radar (was Re: Fwd: Re: [Discuss-gnuradio] math


From: Martin Dvh
Subject: phase align and passive radar (was Re: Fwd: Re: [Discuss-gnuradio] math range error?)
Date: Thu, 23 Feb 2006 00:10:58 +0100
User-agent: Debian Thunderbird 1.0.2 (X11/20051002)

joe j wrote:
> 
I'm trying to take the phase difference between two signals and combining it 
back with one signal's magnitude - using this for a radar project
and I'm using 2 signals.  The first signal is the signal I get back from 
reflection and the second is my reference signal (I subtract the phase
from my reference signal to the signal collected then put it back with the 
original magnitude, I get the actual signal) - main goal is to get
doppler spectrum.

I attached two examples of how I align two signals with a phase difference.
For this to work you need gr.agc_cc and/or gr.phase_modulator_fc which are not 
in cvs yet.
(But probably will be very soon)

I extracted these from the code I am using to try to do passive radar with fm, 
TV and gsm signals.
My current work on this can be donwloaded from
http://www.olifantasia.com/pub/projects/gnuradio/mdvh/passive_radar/

The files on my website are not nicely formatted examples but just my current 
hacking code.

There are also an fft based correlators in there.
And a fake usrp signal generator which models and fm transmitter including a 
single echo received on two antenna's.

I hope it is of use,

Greetings,

Martin





def build_phase_align_cc( fg, input0, input1,phase_avg_alpha=1e-5, 
ph_corr_type=1):
    #input two similar signals with a phase difference
    #returns two blocks outputting the signals phase aligned, 
    # also returns the block which outputs the average phase difference
    mult=gr.multiply_cc()
    conj=gr.conjugate_cc()
    c2arg=gr.complex_to_arg() #fft_size)
    mult2=gr.multiply_cc()
    conj2=gr.conjugate_cc()
    #degrees=180.0
    #ps=2.0*3.1415926535384626*degrees/360.0
    #phase_sh=gr.multiply_const_cc(complex(cos(ps),sin(ps))) #add this 
phase_shift block in between for testing
    phase_average=gr.single_pole_iir_filter_cc(phase_avg_alpha)
    fg.connect(input0,(mult,0))
    fg.connect(input1,conj,(mult,1))
    if ph_corr_type==0: #this version does not work very well
      mag=gr.complex_to_mag()
      div=gr.divide_cc() #output of this contains only phase information, 
magnitude is eliminated (mag==1.0)
      float_to_complex=gr.float_to_complex()
      fg.connect(mult,(div,0))
      fg.connect(mult,mag,float_to_complex,(div,1))
      fg.connect(div,phase_average,(mult2,0))
    elif ph_corr_type==1: #this version works OK, especially when both sources 
have amplitude 1.0 (use agc_cc for both before inputing)
      agc=gr.agc_cc(1e-5,1.0,1.0) #1e-3 #rate,reference,gain
      fg.connect(mult,phase_average,agc,(mult2,0)) #phase_average,
    elif ph_corr_type==2: #another way of doing this, this one is a bit noisy
      phasemod=gr.phase_modulator_fc(1.0)
      fg.connect(mult,c2arg,phasemod,phase_average,(mult2,0))
    fg.connect(input1,(mult2,1))
    #interleaver= gr.interleave(gr.sizeof_gr_complex)
    #fg.connect(dummy0,(interleaver,0))
    #fg.connect(mult2,(interleaver,1))
    #gr.hier_block.__init__(self, fg, di, interleaver)
    return input0,mult2,phase_average

class phase_align_cc(gr.hier_block):
    def __init__(self, fg, phase_avg_alpha=1e-5, phase_agc_avg_alpha=1e-5, 
ph_corr_type=1):
        # input two similar signals with a phase difference.
        # returns two blocks outputting the signals phase aligned, 
        # also returns the block which outputs the average phase difference.

        # Works best when the signals have the same amplitude.
        # This can be accomplished when you add agc_cc before both inputs.

        di = gr.deinterleave(gr.sizeof_gr_complex)
        mult=gr.multiply_cc()
        conj=gr.conjugate_cc()
        c2arg=gr.complex_to_arg() #fft_size)
        mult2=gr.multiply_cc()
        conj2=gr.conjugate_cc()
        phase_average=gr.single_pole_iir_filter_cc(phase_avg_alpha)
        fg.connect((di,0),(mult,0))
        fg.connect((di,1),conj,(mult,1))
        if ph_corr_type==0: #this version does not work very well
          mag=gr.complex_to_mag()
          div=gr.divide_cc() #output of this contains only phase information, 
magnitude is eliminated (mag==1.0)
          float_to_complex=gr.float_to_complex()
          fg.connect(mult,(div,0))
          fg.connect(mult,mag,float_to_complex,(div,1))
          fg.connect(div,phase_average,(mult2,0))
        elif ph_corr_type==1: #this version works OK, especially when both 
sources have amplitude 1.0 (use agc_cc for both before inputing)
          phase_agc=gr.agc_cc(phase_agc_avg_alpha,1.0,1.0) #rate,reference,gain
          fg.connect(mult,phase_average,phase_agc,(mult2,0)) #phase_average,
        elif ph_corr_type==2: #another way of doing this, this one is a bit 
noisy
          phasemod=gr.phase_modulator_fc(1.0)
          fg.connect(mult,c2arg,phasemod,phase_average,(mult2,0))
        fg.connect((di,1),(mult2,1))
        interleaver= gr.interleave(gr.sizeof_gr_complex)
        fg.connect((di,0),(interleaver,0))
        fg.connect(mult2,(interleaver,1))
        gr.hier_block.__init__(self, fg, di, interleaver)
        return (di,0),mult2,phase_average


reply via email to

[Prev in Thread] Current Thread [Next in Thread]