Changeset 6720
- Timestamp:
- 10/28/07 16:08:40
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
gnuradio/trunk/gr-utils/src/python/usrp_oscope.py
r6466 r6720 31 31 import wx 32 32 import sys 33 try: 34 import usrp_dbid 35 except: 36 from usrpm import usrp_dbid 33 37 34 38 … … 65 69 parser.add_option("-8", "--width-8", action="store_true", default=False, 66 70 help="Enable 8-bit samples across USB") 71 parser.add_option("-C", "--basic-complex", action="store_true", default=False, 72 help="Use both inputs of a basicRX or LFRX as a single Complex input channel") 73 parser.add_option("-D", "--basic-dualchan", action="store_true", default=False, 74 help="Use both inputs of a basicRX or LFRX as seperate Real input channels") 67 75 parser.add_option("-n", "--frame-decim", type="int", default=1, 68 76 help="set oscope frame decimation factor to n [default=1]") … … 79 87 80 88 # build the graph 81 82 self.u = usrp.source_c(decim_rate=options.decim) 89 if options.basic_dualchan: 90 self.num_inputs=2 91 else: 92 self.num_inputs=1 93 self.u = usrp.source_c(nchan=self.num_inputs,decim_rate=options.decim) 83 94 if options.rx_subdev_spec is None: 84 95 options.rx_subdev_spec = pick_subdevice(self.u) 85 self.u.set_mux(usrp.determine_rx_mux_value(self.u, options.rx_subdev_spec))86 96 87 97 if options.width_8: … … 95 105 # determine the daughterboard subdevice we're using 96 106 self.subdev = usrp.selected_subdev(self.u, options.rx_subdev_spec) 107 if (options.basic_complex or options.basic_dualchan ): 108 if ((self.subdev.dbid()==usrp_dbid.BASIC_RX) or (self.subdev.dbid()==usrp_dbid.LF_RX)): 109 side = options.rx_subdev_spec[0] # side A = 0, side B = 1 110 if options.basic_complex: 111 #force Basic_RX and LF_RX in complex mode (use both I and Q channel) 112 print "Receiver daughterboard forced in complex mode. Both inputs will combined to form a single complex channel." 113 self.dualchan=False 114 if side==0: 115 self.u.set_mux(0x00000010) #enable adc 0 and 1 to form a single complex input on side A 116 else: #side ==1 117 self.u.set_mux(0x00000032) #enable adc 3 and 2 to form a single complex input on side B 118 elif options.basic_dualchan: 119 #force Basic_RX and LF_RX in dualchan mode (use input A for channel 0 and input B for channel 1) 120 print "Receiver daughterboard forced in dualchannel mode. Each input will be used to form a seperate channel." 121 self.dualchan=True 122 if side==0: 123 self.u.set_mux(gru.hexint(0xf0f0f1f0)) #enable adc 0, side A to form a real input on channel 0 and adc1,side A to form a real input on channel 1 124 else: #side ==1 125 self.u.set_mux(0xf0f0f3f2) #enable adc 2, side B to form a real input on channel 0 and adc3,side B to form a real input on channel 1 126 else: 127 sys.stderr.write('options basic_dualchan or basic_complex is only supported for Basic Rx or LFRX at the moment\n') 128 sys.exit(1) 129 else: 130 self.dualchan=False 131 self.u.set_mux(usrp.determine_rx_mux_value(self.u, options.rx_subdev_spec)) 97 132 98 133 input_rate = self.u.adc_freq() / self.u.decim_rate() … … 101 136 frame_decim=options.frame_decim, 102 137 v_scale=options.v_scale, 103 t_scale=options.t_scale) 104 self.connect(self.u, self.scope) 138 t_scale=options.t_scale, 139 num_inputs=self.num_inputs) 140 if self.dualchan: 141 # deinterleave two channels from FPGA 142 self.di = gr.deinterleave(gr.sizeof_gr_complex) 143 self.connect(self.u,self.di) 144 self.connect((self.di,0),(self.scope,0)) 145 self.connect((self.di,1),(self.scope,1)) 146 else: 147 self.connect(self.u, self.scope) 105 148 106 149 self._build_gui(vbox) … … 114 157 115 158 if options.freq is None: 116 # if no freq was specified, use the mid-point 117 r = self.subdev.freq_range() 118 options.freq = float(r[0]+r[1])/2 159 if ((self.subdev.dbid()==usrp_dbid.BASIC_RX) or (self.subdev.dbid()==usrp_dbid.LF_RX)): 160 #for Basic RX and LFRX if no freq is specified you probably want 0.0 Hz and not 45 GHz 161 options.freq=0.0 162 else: 163 # if no freq was specified, use the mid-point 164 r = self.subdev.freq_range() 165 options.freq = float(r[0]+r[1])/2 119 166 120 167 self.set_gain(options.gain) … … 126 173 self.myform['baseband'].set_value(0) 127 174 self.myform['ddc'].set_value(0) 175 if self.num_inputs==2: 176 self.myform['baseband2'].set_value(0) 177 self.myform['ddc2'].set_value(0) 128 178 129 179 if not(self.set_freq(options.freq)): 130 180 self._set_status_msg("Failed to set initial frequency") 181 if self.num_inputs==2: 182 if not(self.set_freq2(options.freq)): 183 self._set_status_msg("Failed to set initial frequency for channel 2") 131 184 132 185 … … 138 191 def _form_set_freq(kv): 139 192 return self.set_freq(kv['freq']) 140 193 194 def _form_set_freq2(kv): 195 return self.set_freq2(kv['freq2']) 141 196 vbox.Add(self.scope.win, 10, wx.EXPAND) 142 197 … … 148 203 parent=self.panel, sizer=hbox, label="Center freq", weight=1, 149 204 callback=myform.check_input_and_call(_form_set_freq, self._set_status_msg)) 150 151 hbox.Add((5,0), 0, 0) 205 if self.num_inputs==2: 206 myform['freq2'] = form.float_field( 207 parent=self.panel, sizer=hbox, label="Center freq2", weight=1, 208 callback=myform.check_input_and_call(_form_set_freq2, self._set_status_msg)) 209 hbox.Add((5,0), 0, 0) 152 210 g = self.subdev.gain_range() 153 211 myform['gain'] = form.slider_field(parent=self.panel, sizer=hbox, label="Gain", … … 202 260 myform['ddc'] = form.static_float_field( 203 261 parent=panel, sizer=hbox, label="DDC") 262 if self.num_inputs==2: 263 hbox.Add((1,0), 1) 264 myform['baseband2'] = form.static_float_field( 265 parent=panel, sizer=hbox, label="BB2") 266 hbox.Add((1,0), 1) 267 myform['ddc2'] = form.static_float_field( 268 parent=panel, sizer=hbox, label="DDC2") 204 269 205 270 hbox.Add((5,0), 0) … … 226 291 self.myform['baseband'].set_value(r.baseband_freq) 227 292 self.myform['ddc'].set_value(r.dxc_freq) 293 return True 294 295 return False 296 297 def set_freq2(self, target_freq): 298 """ 299 Set the center frequency of we're interested in for the second channel. 300 301 @param target_freq: frequency in Hz 302 @rypte: bool 303 304 Tuning is a two step process. First we ask the front-end to 305 tune as close to the desired frequency as it can. Then we use 306 the result of that operation and our target_frequency to 307 determine the value for the digital down converter. 308 """ 309 r = usrp.tune(self.u, 1, self.subdev, target_freq) 310 311 if r: 312 self.myform['freq2'].set_value(target_freq) # update displayed value 313 if self.show_debug_info: 314 self.myform['baseband2'].set_value(r.baseband_freq) 315 self.myform['ddc2'].set_value(r.dxc_freq) 228 316 return True 229 317
