diff options
author | jcorgan | 2007-07-18 20:20:30 +0000 |
---|---|---|
committer | jcorgan | 2007-07-18 20:20:30 +0000 |
commit | 0c30f34bf0afa14e8f2ee128dd4168c7c372b862 (patch) | |
tree | 080a5617dced0b5c60e2b0a3a3423e9d4eabd875 /gr-radar-mono/src/python | |
parent | 21a86c72fb9059cd975603dbae7d06665cfab373 (diff) | |
download | gnuradio-0c30f34bf0afa14e8f2ee128dd4168c7c372b862.tar.gz gnuradio-0c30f34bf0afa14e8f2ee128dd4168c7c372b862.tar.bz2 gnuradio-0c30f34bf0afa14e8f2ee128dd4168c7c372b862.zip |
Merged r5945:6012 from jcorgan/radar into trunk. Updates gr-radar-mono component. Trunk passes distcheck.
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@6013 221aa14e-8319-0410-a670-987f0aec2ac5
Diffstat (limited to 'gr-radar-mono/src/python')
-rw-r--r-- | gr-radar-mono/src/python/radar_mono.py | 174 | ||||
-rwxr-xr-x | gr-radar-mono/src/python/usrp_radar_mono.py | 20 |
2 files changed, 109 insertions, 85 deletions
diff --git a/gr-radar-mono/src/python/radar_mono.py b/gr-radar-mono/src/python/radar_mono.py index 5077b3d92..5a5be9c8d 100644 --- a/gr-radar-mono/src/python/radar_mono.py +++ b/gr-radar-mono/src/python/radar_mono.py @@ -30,37 +30,32 @@ n2s = eng_notation.num_to_str #----------------------------------------------------------------------- FR_RADAR_MODE = usrp.FR_USER_0 # Operational mode bmFR_RADAR_MODE_RESET = 1 << 0 # bit 0: active high reset -bmFR_RADAR_MODE_TX = 1 << 1 # bit 1: enable transmitter -#bmFR_RADAR_MODE_RX = 1 << 2 # bit 2: enable receiver -#bmFR_RADAR_MODE_LP = 1 << 3 # bit 3: enable digital loopback -#bmFR_RADAR_MODE_DR = 1 << 4 # bit 4: enable on-board deramping -#bmFR_RADAR_MODE_MD = 1 << 5 # bit 5: enable echo metadata -#bmFR_RADAR_MODE_CHIRPS = 3 << 6 # bit 6,7: number of chirp center frequencies +#bmFR_RADAR_MODE_LP = 1 << 1 # bit 1: enable digital loopback +#bmFR_RADAR_MODE_DR = 1 << 2 # bit 2: enable on-board deramping +#bmFR_RADAR_MODE_MD = 1 << 3 # bit 3: enable echo metadata +#bmFR_RADAR_MODE_CHIRPS = 3 << 4 # bit 4,5: number of chirp center frequencies -#FR_RADAR_TON = usrp.FR_USER_1 # 16-bit transmitter on time in clocks -#FR_RADAR_TSW = usrp.FR_USER_2 # 16-bit transmitter switch time in clocks -#FR_RADAR_TLOOK = usrp.FR_USER_3 # 16-bit receiver look time in clocks -#FR_RADAR_TIDLE = usrp.FR_USER_4 # 32-bit inter-pulse idle time +FR_RADAR_TON = usrp.FR_USER_1 # 16-bit transmitter on time in clocks +FR_RADAR_TSW = usrp.FR_USER_2 # 16-bit transmitter switch time in clocks +FR_RADAR_TLOOK = usrp.FR_USER_3 # 16-bit receiver look time in clocks +FR_RADAR_TIDLE = usrp.FR_USER_4 # 32-bit inter-pulse idle time FR_RADAR_AMPL = usrp.FR_USER_5 # 16-bit pulse amplitude (2s complement) into CORDIC -#FR_RADAR_FSTART = usrp.FR_USER_6 # 32-bit FTW for chirp start frequency -#FR_RADAR_FINCR = usrp.FR_USER_7 # 32-bit FTW increment per transmit clock +FR_RADAR_FSTART = usrp.FR_USER_6 # 32-bit FTW for chirp start frequency +FR_RADAR_FINCR = usrp.FR_USER_7 # 32-bit FTW increment per transmit clock # These are for phase II development - -# Temporarily use this for transmitter frequency calibration -FR_RADAR_FREQ1N = usrp.FR_USER_8 # 24-bit N register for chirp #1 - -FR_RADAR_FREQ1R = usrp.FR_USER_9 # 24-bit R register for chirp #1 -FR_RADAR_FREQ1C = usrp.FR_USER_10 # 24-bit control register for chirp #1 -FR_RADAR_FREQ2N = usrp.FR_USER_11 # 24-bit N register for chirp #2 -FR_RADAR_FREQ2R = usrp.FR_USER_12 # 24-bit R register for chirp #2 -FR_RADAR_FREQ2C = usrp.FR_USER_13 # 24-bit control register for chirp #2 -FR_RADAR_FREQ3N = usrp.FR_USER_14 # 24-bit N register for chirp #3 -FR_RADAR_FREQ3R = usrp.FR_USER_15 # 24-bit R register for chirp #3 -FR_RADAR_FREQ3C = usrp.FR_USER_16 # 24-bit control register for chirp #3 -FR_RADAR_FREQ4N = usrp.FR_USER_17 # 24-bit N register for chirp #4 -FR_RADAR_FREQ4R = usrp.FR_USER_18 # 24-bit R register for chirp #4 -FR_RADAR_FREQ4C = usrp.FR_USER_19 # 24-bit control register for chirp #4 +#FR_RADAR_FREQ1N = usrp.FR_USER_8 # 24-bit N register for chirp #1 +#FR_RADAR_FREQ1R = usrp.FR_USER_9 # 24-bit R register for chirp #1 +#FR_RADAR_FREQ1C = usrp.FR_USER_10 # 24-bit control register for chirp #1 +#FR_RADAR_FREQ2N = usrp.FR_USER_11 # 24-bit N register for chirp #2 +#FR_RADAR_FREQ2R = usrp.FR_USER_12 # 24-bit R register for chirp #2 +#FR_RADAR_FREQ2C = usrp.FR_USER_13 # 24-bit control register for chirp #2 +#FR_RADAR_FREQ3N = usrp.FR_USER_14 # 24-bit N register for chirp #3 +#FR_RADAR_FREQ3R = usrp.FR_USER_15 # 24-bit R register for chirp #3 +#FR_RADAR_FREQ3C = usrp.FR_USER_16 # 24-bit control register for chirp #3 +#FR_RADAR_FREQ4N = usrp.FR_USER_17 # 24-bit N register for chirp #4 +#FR_RADAR_FREQ4R = usrp.FR_USER_18 # 24-bit R register for chirp #4 +#FR_RADAR_FREQ4C = usrp.FR_USER_19 # 24-bit control register for chirp #4 #----------------------------------------------------------------------- # Transmitter object. Uses usrp_sink, but only for a handle to the @@ -74,20 +69,38 @@ class radar_tx: self._u = usrp.sink_s(fpga_filename='usrp_radar_mono.rbf') self._subdev_spec = (0,0); # FPGA code only implements side A self._subdev = usrp.selected_subdev(self._u, self._subdev_spec) + self._ton_ticks = 0 + self._tsw_ticks = 0 + self._tlook_ticks = 0 + self._tidle_ticks = 0 + if self._verbose: print "Using", self._subdev.name(), "for radar transmitter." - def tune(self, center_freq, waveform_freq): - self._center_freq = center_freq - self._waveform_freq = waveform_freq - self._ftw = int(waveform_freq*(2**32)/32e6) - if self._verbose: - print "Setting transmitter center frequency to", n2s(center_freq) - print "Setting waveform frequency offset to", n2s(waveform_freq), "with ftw of", self._ftw - result = self._u.tune(0, self._subdev, center_freq) - if result == False: - raise RuntimeError("Failed to set transmitter frequency.") - self._u._write_fpga_reg(FR_RADAR_FREQ1N, self._ftw) + def set_ton(self, ton): + self._ton_ticks = 2*(int(ton*64e6)/2)-1 # Even number, then subtract 1 + if self._verbose: + print "Setting pulse on time to", ton, " sec ("+`self._ton_ticks+1`+" ticks)" + self._u._write_fpga_reg(FR_RADAR_TON, self._ton_ticks) + + def set_tsw(self, tsw): + self._tsw_ticks = 2*(int(tsw*64e6)/2)-1 # Even number, then subtract 1 + if self._verbose: + print "Setting pulse switching time to", tsw, " sec ("+`self._tsw_ticks+1`+" ticks)" + self._u._write_fpga_reg(FR_RADAR_TSW, self._tsw_ticks) + + def set_tlook(self, tlook): + self._tlook_ticks = 2*(int(tlook*64e6)/2)-1 # Even number, then subtract 1 + if self._verbose: + print "Setting receiver look time to", tlook, " sec ("+`self._tlook_ticks+1`+" ticks)" + self._u._write_fpga_reg(FR_RADAR_TLOOK, self._tlook_ticks) + + def set_prf(self, prf): + period = 2*int(32e6/prf) + self._tidle_ticks = period-(self._ton_ticks+self._tsw_ticks+self._tlook_ticks+3)-1 + if self._verbose: + print "Setting PRF to", prf, "Hz ("+`self._tidle_ticks+1`+" ticks idle time)" + self._u._write_fpga_reg(FR_RADAR_TIDLE, self._tidle_ticks) def set_amplitude(self, ampl): self._amplitude = int(ampl*9946/100.0) # CORDIC gain correction @@ -95,6 +108,22 @@ class radar_tx: print "Writing amplitude register with:", hex(self._amplitude) self._u._write_fpga_reg(FR_RADAR_AMPL, self._amplitude) + def set_freq(self, center_freq, chirp_width): + self._center_freq = center_freq + self._chirp_width = chirp_width + self._fstart = -int((chirp_width/2)*(2**32)/32e6) + self._fincr = int((chirp_width/16e6)*(2**32)/(self._ton_ticks+1)) + + if self._verbose: + print "Setting transmitter center frequency to", n2s(center_freq) + print "Setting chirp width to", n2s(chirp_width), "Hz "+"("+hex(self._fstart)+", "+hex(self._fincr)+")" + + result = self._u.tune(0, self._subdev, center_freq) + if result == False: + raise RuntimeError("Failed to set transmitter frequency.") + self._u._write_fpga_reg(FR_RADAR_FSTART, self._fstart) + self._u._write_fpga_reg(FR_RADAR_FINCR, self._fincr) + def start(self): self._u.start() @@ -181,47 +210,25 @@ class radar: self._debug = debug self._mode = 0 - self._transmitting = False self._trans = radar_tx(verbose=self._verbose, debug=self._debug) self.set_reset(True) - def set_amplitude(self, ampl): - self._trans.set_amplitude(ampl) - - def tune(self, center_freq, waveform_freq): - self._trans.tune(center_freq, waveform_freq) - def _write_mode(self): if self._debug: print "Writing mode register with:", hex(self._mode) self._trans._u._write_fpga_reg(FR_RADAR_MODE, self._mode) - def enable_tx(self, value): + def set_reset(self, value): if value: - if self._verbose: - print "Enabling transmitter." - self._mode |= bmFR_RADAR_MODE_TX - self._transmitting = True + if self._debug: + print "Asserting reset." + self._mode |= bmFR_RADAR_MODE_RESET else: - if self._verbose: - print "Disabling transmitter." - self._mode &= ~bmFR_RADAR_MODE_TX - self._transmitting = False + if self._debug: + print "De-asserting reset." + self._mode &= ~bmFR_RADAR_MODE_RESET self._write_mode() - - """ - def enable_rx(self, value): - if value: - self._mode |= bmFR_RADAR_MODE_RX - self._write_mode() - self._rcvr.start() - self._receiving = True - else: - self._rcvr.stop() - self._mode &= ~bmFR_RADAR_MODE_RX - self._write_mode() - self._receiving = False - """ + """ def set_loopback(self, value): if value: @@ -235,27 +242,32 @@ class radar: self._write_mode() """ - def set_reset(self, value): - if value: - if self._debug: - print "Asserting reset." - self._mode |= bmFR_RADAR_MODE_RESET - else: - if self._debug: - print "De-asserting reset." - self._mode &= ~bmFR_RADAR_MODE_RESET - self._write_mode() + def set_ton(self, ton): + self._trans.set_ton(ton) + + def set_tsw(self, tsw): + self._trans.set_tsw(tsw) + + def set_tlook(self, tlook): + self._trans.set_tlook(tlook) + + def set_prf(self, prf): + self._trans.set_prf(prf) + + def set_amplitude(self, ampl): + self._trans.set_amplitude(ampl) + def set_freq(self, center_freq, chirp_width): + self._trans.set_freq(center_freq, chirp_width) + # set receiver center frequency + def start(self): self._trans.start() - self.enable_tx(True) self.set_reset(False) def stop(self): self.set_reset(True) self._trans.stop() - if self._transmitting: - self.enable_tx(False) def __del__(self): self.stop() diff --git a/gr-radar-mono/src/python/usrp_radar_mono.py b/gr-radar-mono/src/python/usrp_radar_mono.py index 61dd1163f..47db53c26 100755 --- a/gr-radar-mono/src/python/usrp_radar_mono.py +++ b/gr-radar-mono/src/python/usrp_radar_mono.py @@ -33,11 +33,18 @@ def main(): parser = OptionParser(option_class=eng_option) parser.add_option("-f", "--frequency", type="eng_float", default=0.0, help="set transmitter center frequency to FREQ in Hz, default is %default", metavar="FREQ") - # Temporary for debugging transmitter frequency response - parser.add_option("-w", "--waveform-frequency", type="eng_float", default=1e3, - help="set waveform offset frequency to FREQ in Hz, default is %default", metavar="FREQ") + parser.add_option("-w", "--chirp-width", type="eng_float", default=32e6, + help="set LFM chirp bandwidth in Hz, default is %default", metavar="FREQ") parser.add_option("-a", "--amplitude", type="eng_float", default=100, help="set waveform amplitude in % full scale, default is %default,") + parser.add_option("", "--ton", type="eng_float", default=5e-6, + help="set pulse on period in seconds, default is %default,") + parser.add_option("", "--tsw", type="eng_float", default=406.25e-9, + help="set transmitter switching period in seconds, default is %default,") + parser.add_option("", "--tlook", type="eng_float", default=5e-6, + help="set receiver look time in seconds, default is %default,") + parser.add_option("", "--prf", type="eng_float", default=10e3, + help="set pulse repetition frequency in Hz, default is %default,") parser.add_option("-v", "--verbose", action="store_true", default=False, help="enable verbose output, default is disabled") parser.add_option("-D", "--debug", action="store_true", default=False, @@ -69,8 +76,13 @@ def main(): msgq = gr.msg_queue() s = radar(msgq=msgq,verbose=options.verbose,debug=options.debug) + s.set_ton(options.ton) + s.set_tsw(options.tsw) + s.set_tlook(options.tlook) + s.set_prf(options.prf) s.set_amplitude(options.amplitude) - s.tune(options.frequency, options.waveform_frequency) + s.set_freq(options.frequency, options.chirp_width) + s.start() """ |