コード例 #1
0
 def get_xlim(self):
     _signal_hound.initiate(self._device, _signal_hound.sweeping, 0)
     nop, start_freq, bin_size = _signal_hound.query_sweep_info(
         self._device)
     start = start_freq
     stop = start_freq + (nop - 1) * bin_size
     return start, stop
コード例 #2
0
    def do_set_video_bw(self, video_bw):
        vbw_max = 250e3
        vbw_min = 0.1

        _signal_hound.initiate(self._device, _signal_hound.sweeping, 0)
        nop, start_freq, bin_size = _signal_hound.query_sweep_info(
            self._device)
        span = (nop - 1) * bin_size

        res_bw = self.get_res_bw()
        reject_if = self.get_reject_if()
        if not res_bw:
            res_bw = 250e3
        if video_bw > res_bw:
            video_bw = res_bw

        vbw_6MHz_allowed = False

        if span > 100e6:
            vbw_min = 6.5e3
        if span > 200e3 and start_freq < 16e6:
            vbw_min = 6.5e3
        if start_freq > 200e6 and span > 200e6:
            vbw_6MHz_allowed = True

        if video_bw > vbw_max:
            if vbw_6MHz_allowed and video_bw > 3e6:
                video_wb = 6e6
            else:
                video_bw = vbw_max

        if video_bw < vbw_min:
            video_bw = vbw_min
        _signal_hound.config_sweep_coupling(self._device, res_bw, video_bw,
                                            reject_if)
コード例 #3
0
 def set_xlim(self, start, stop):
     logging.debug(__name__ +
                   ' : setting start freq to %s Hz and stop freq to %s Hz' %
                   (start, stop))
     _signal_hound.initiate(self._device, _signal_hound.sweeping, 0)
     _signal_hound.config_center_span(self._device, (start + stop) * 0.5,
                                      stop - start)
コード例 #4
0
    def get_tracedata(self):
        '''
		Get the data of the current trace in mW
		'''
        _signal_hound.initiate(self._device, _signal_hound.sweeping, 0)
        nop, start_freq, bin_size = _signal_hound.query_sweep_info(
            self._device)

        min = (ctypes.c_float * nop)()
        max = (ctypes.c_float * nop)()
        datamin = np.zeros(nop)
        datamax = np.zeros(nop)

        for _ in range(self.averages):
            end = 0
            while end < nop:
                begin, end = _signal_hound.get_partial_sweep_32f(
                    self._device, min, max)
                plt.pause(0.05)
            datamin += 10.**(np.asarray(max, dtype=np.float) / 10.)
            datamax += 10.**(np.asarray(min, dtype=np.float) / 10.)

        datax = np.linspace(start_freq, start_freq + bin_size * (nop - 1), nop)
        datamin = datamin / self.averages
        datamax = datamax / self.averages

        return [datax, datamin, datamax]
コード例 #5
0
    def do_get_nop(self):
        '''
		Get Number of Points (nop) for sweep

		Input:
			None
		Output:
			nop (int)
		'''
        logging.debug(__name__ + ' : getting Number of Points')
        _signal_hound.initiate(self._device, _signal_hound.sweeping, 0)
        nop, start_freq, bin_size = _signal_hound.query_sweep_info(
            self._device)
        return nop
コード例 #6
0
    def do_get_startfreq(self):
        '''
		Get Start frequency
		
		Input:
			None

		Output:
			span (float) : Start Frequency in Hz
		'''
        logging.debug(__name__ + ' : getting start frequency')
        _signal_hound.initiate(self._device, _signal_hound.sweeping, 0)
        nop, start_freq, bin_size = _signal_hound.query_sweep_info(
            self._device)
        return start_freq
コード例 #7
0
    def do_get_centerfreq(self):
        '''
		Get the center frequency

		Input:
			None

		Output:
			cf (float) :Center Frequency in Hz
		'''
        logging.debug(__name__ + ' : getting center frequency')
        _signal_hound.initiate(self._device, _signal_hound.sweeping, 0)
        nop, start_freq, bin_size = _signal_hound.query_sweep_info(
            self._device)
        return start_freq + (nop - 1) * bin_size / 2.
コード例 #8
0
    def do_get_span(self):
        '''
		Get Span
		
		Input:
			None

		Output:
			span (float) : Span in Hz
		'''
        #logging.debug(__name__ + ' : getting center frequency')
        _signal_hound.initiate(self._device, _signal_hound.sweeping, 0)
        nop, start_freq, bin_size = _signal_hound.query_sweep_info(
            self._device)
        span = (nop - 1) * bin_size  #float( self.ask('SENS1:FREQ:SPAN?'))
        return span
コード例 #9
0
    def do_set_stopfreq(self, val):
        '''
		Set STop frequency

		Input:
			val (float) : Stop Frequency in Hz

		Output:
			None
		'''
        logging.debug(__name__ + ' : setting start freq to %s Hz' % val)
        _signal_hound.initiate(self._device, _signal_hound.sweeping, 0)
        nop, start_freq, bin_size = _signal_hound.query_sweep_info(
            self._device)
        if nop < 2: nop = 1
        #stop = start_freq + (nop-1)*bin_size
        new_center = (val + start_freq) * 0.5
        new_span = val - start_freq

        _signal_hound.config_center_span(self._device, new_center, new_span)

        self.get_centerfreq()
        self.get_stopfreq()
        self.get_span()
コード例 #10
0
    def do_set_span(self, span):
        '''
		Set Span

		Input:
			span (float) : Span in KHz

		Output:
			None
		'''
        logging.debug(__name__ + ' : setting span to %s Hz' % span)
        _signal_hound.initiate(self._device, _signal_hound.sweeping, 0)
        nop, start_freq, bin_size = _signal_hound.query_sweep_info(
            self._device)
        start = start_freq
        if nop < 2: nop = 2
        stop = start_freq + (nop - 1) * bin_size

        _signal_hound.config_center_span(self._device, (start + stop) * 0.5,
                                         span)

        self.get_startfreq()
        self.get_stopfreq()
        self.get_centerfreq()
コード例 #11
0
    def do_set_centerfreq(self, cf):
        '''
		Set the center frequency

		Input:
			cf (float) :Center Frequency in Hz

		Output:
			None
		'''
        logging.debug(__name__ + ' : setting center frequency to %s' % cf)
        _signal_hound.initiate(self._device, _signal_hound.sweeping, 0)
        nop, start_freq, bin_size = _signal_hound.query_sweep_info(
            self._device)
        if nop < 2: nop = 2
        start = start_freq
        stop = start_freq + (nop - 1) * bin_size
        span = stop - start

        _signal_hound.config_center_span(self._device, cf, span)

        self.get_startfreq()
        self.get_stopfreq()
        self.get_span()
コード例 #12
0
    def __init__(self, name, serial):
        '''
		Initializes 

		Input:
			name (string)    : name of the instrument
			serial (int) : serial number
		'''
        logging.info(__name__ + ' : Initializing instrument')
        Instrument.__init__(self, name, tags=['physical'])
        self._device = _signal_hound.open_device_by_serial_number(
            serial_number=serial)
        #self._device = f(serial_number=serial)

        self._serial = serial

        # Implement parameters

        self.add_parameter('ref',
                           type=float,
                           flags=Instrument.FLAG_SET | Instrument.FLAG_SOFTGET,
                           minval=-80,
                           maxval=_signal_hound.max_ref,
                           units='dBm',
                           tags=['sweep'])

        self.add_parameter('reject_if',
                           type=bool,
                           flags=Instrument.FLAG_SET | Instrument.FLAG_SOFTGET,
                           tags=['sweep'])

        self.add_parameter('nop',
                           type=int,
                           flags=Instrument.FLAG_GET,
                           tags=['sweep'])

        self.add_parameter('video_bw',
                           type=float,
                           flags=Instrument.FLAG_SET | Instrument.FLAG_SOFTGET,
                           minval=_signal_hound.min_rbw,
                           maxval=_signal_hound.max_rbw,
                           units='Hz',
                           tags=['sweep'])

        self.add_parameter('res_bw',
                           type=float,
                           flags=Instrument.FLAG_SET | Instrument.FLAG_SOFTGET,
                           minval=_signal_hound.min_rbw,
                           maxval=_signal_hound.max_rbw,
                           units='Hz',
                           tags=['sweep'])

        self.add_parameter('centerfreq',
                           type=float,
                           flags=Instrument.FLAG_GETSET,
                           minval=_signal_hound.sa124_min_freq,
                           maxval=_signal_hound.sa124_max_freq,
                           units='Hz',
                           tags=['sweep'])

        self.add_parameter('startfreq',
                           type=float,
                           flags=Instrument.FLAG_GETSET,
                           minval=_signal_hound.sa124_min_freq,
                           maxval=_signal_hound.sa124_max_freq,
                           units='Hz',
                           tags=['sweep'])

        self.add_parameter('stopfreq',
                           type=float,
                           flags=Instrument.FLAG_GETSET,
                           minval=_signal_hound.sa124_min_freq,
                           maxval=_signal_hound.sa124_max_freq,
                           units='Hz',
                           tags=['sweep'])

        self.add_parameter('span',
                           type=float,
                           flags=Instrument.FLAG_GETSET,
                           minval=_signal_hound.min_span,
                           maxval=_signal_hound.sa124_max_freq,
                           units='Hz',
                           tags=['sweep'])

        self.add_parameter('averages',
                           type=int,
                           flags=Instrument.FLAG_SET | Instrument.FLAG_SOFTGET,
                           minval=1,
                           maxval=1024,
                           tags=['sweep'])

        #		self.add_parameter('zerospan', type=bool,
        #			flags=Instrument.FLAG_GETSET)

        #Triggering Stuff
        #		self.add_parameter('trigger_source', type=str,
        #			flags=Instrument.FLAG_GETSET)

        # Implement functions
        self.add_function('get_freqpoints')
        self.add_function('get_tracedata')
        self.add_function('set_xlim')
        self.add_function('get_xlim')
        #self.add_function('avg_clear')
        #self.add_function('avg_status')

        #self._oldspan = self.get_span()
        #self._oldnop = self.get_nop()
        #if self._oldspan==0.002:
        #  self.set_zerospan(True)

        self.set_xlim(_signal_hound.sa124_min_freq,
                      _signal_hound.sa124_max_freq)
        self.set_res_bw(_signal_hound.max_rbw)
        self.set_video_bw(_signal_hound.max_rbw)
        self.set_reject_if(True)
        self.set_averages(1)
        _signal_hound.initiate(self._device, _signal_hound.sweeping, 0)

        self.get_all()
コード例 #13
0
 def get_freqpoints(self, query=False):
     _signal_hound.initiate(self._device, _signal_hound.sweeping, 0)
     nop, start_freq, bin_size = _signal_hound.query_sweep_info(
         self._device)
     return np.linspace(start_freq, start_freq + bin_size * (nop - 1), nop)