Source code for instruments.WT68145B

#import serial
#import visa

import numpy as np

[docs]class WT68145B(object): def __init__(self,res_manager, address='GPIB0::5::INSTR'): ''' Constructor method :param res_manager: PyVisa resource manager :type res_manager: PyVisa resourceManager object :param address: SCPI address of instrument :type address: String ''' self.active = False self.gpib = res_manager.open_resource(address) # select power channel L0 and put it to minimal pwoer self.set_power(-120) # keep rf ouput on when switching freqs self.gpib.write('RC1')
[docs] def whoAmI(self): ''':returns: reference to device''' return 'RFSource'
[docs] def change_state(self): if self.active == True: self.active = False else: self.active = True
[docs] def out_on(self): '''Turns output ON''' self.gpib.write('RF1')
[docs] def out_off(self): '''Turns output OFF''' self.gpib.write('RF0')
[docs] def set_freq1(self, freq = 10): ''' Sets the first frequency to specified value. :param freq: Frequency to spcify; defaults to 10. :type freq: Integer ''' self.gpib.write('F1 '+str(freq)+' GH')
[docs] def set_freq2(self, freq = 10): ''' Sets the second frequency to specified value. :param freq: Frequency to spcify; defaults to 10. :type freq: Integer ''' self.gpib.write('F2 '+str(freq)+' GH')
[docs] def sweep_f1f2(self): '''Execute a sweep of the two frequencies''' self.gpib.write('SF1')
[docs] def single_trigger_mode(self): '''Enter single trigger mode.''' self.gpib.write('EXT')
[docs] def auto_trigger_mode(self): '''Enter auto trigger mode''' self.gpib.write('AUT')
[docs] def set_CW_mode(self): '''Enter CW mode''' self.gpib.write('CF1')
[docs] def set_deltasweep_mode(self): '''Enter delta sweep mode''' self.gpib.write('DF1')
[docs] def set_sweep_delta(self,delta = 5): ''' Set delta sweep value :param delta: Specified delta value; defaults to 5 :type delta: Integer ''' self.gpib.write('DLF '+str(delta)+' GH')
[docs] def decrement(self): '''Execute decrement''' self.gpib.write('DN')
[docs] def increment(self): '''Execute increment''' self.gpib.write('UP')
[docs] def full_range_sweep(self): '''Execute full range sweep''' self.gpib.write('FUL')
[docs] def set_power(self,power = 0): ''' Set the power to specified value. :param power: Specified power value; defaults to 0 :type power: Integer ''' self.gpib.write('XL0 '+str(power)+' DM') self.gpib.write('L0')
[docs] def set_stepsweep_time(self,time = 100): ''' Sets the step sweep time :param time: Specified time value; defaults to 100 :type time: Integer ''' self.gpib.write('SDT '+str(time)+' MS')
[docs] def set_stepsweep_steps(self, steps = 1000): ''' Set the number of steps :param steps: Specified step value; defaults to 1000 :type steps: Integer ''' self.gpib.write('SNS '+str(steps)+' SPS')
[docs] def set_stepsweep_mode(self): '''Enter step-sweep mode''' self.gpib.write('SSP')
[docs] def set_analogsweep_mode(self): '''Enter analog-sweep mode''' self.gpib.write('SWP')
[docs] def set_analogsweep_time(self, time = 1000): ''' Set analog-sweep time :param time: Specify time value; defaults to 1000 :type time: Integer ''' self.gpib.write('SWT '+str(time)+' MS')
[docs] def set_stepsweep_stepsize(self, step = 500): ''' Set the stepsize of step-sweep mode :param step: Specify the step size; defaults to 500. :type step: Integer ''' self.gpib.write('SYZ '+str(step)+' MH')
[docs] def trigger_sweep(self): '''Execute trigger sweep''' self.gpib.write('TRG')
[docs] def fill_freq_buffer(self, start, stop,steps): ''' Writes to frequency buffer. :param start: Specify starting point. :type start: Float :param stop: Specify ending point :type stop: Float :param steps: Specify steps :type steps: Float ''' self.gpib.write('ZL000') for x in np.arange(float(start),float(stop),(float(stop)-float(start))/float(steps)): self.gpib.write(str(x)+' GH,') self.gpib.write('ZEL GTF ZS000')
[docs] def freq_step(self): '''Set step frequency.''' self.gpib.write('Y')
''' Copyright (C) 2017 Robert Polster This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. '''