78 lines
2.8 KiB
Python
78 lines
2.8 KiB
Python
import socket
|
|
import time
|
|
|
|
TCP_PORT = 10000
|
|
Buffer = 80
|
|
|
|
class TaborLS6081B:
|
|
|
|
def __init__(self, ip):
|
|
#establishes connection via ethernet to ip "ip"
|
|
try:
|
|
self.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
time.sleep(0.1)
|
|
self.s.settimeout(5)
|
|
time.sleep(0.1)
|
|
self.s.connect((ip, TCP_PORT))
|
|
time.sleep(0.2)
|
|
except:
|
|
print(f'could not connect to device with IP: {ip}')
|
|
|
|
def __del__(self):
|
|
#closes connection
|
|
time.sleep(0.1)
|
|
command = 'OUTP OFF\n'
|
|
self.s.send(command.encode('utf-8'))
|
|
self.s.close()
|
|
|
|
def CW(self,P,freq,ON):
|
|
# enables CW mode, and can turn power on or off
|
|
#P (Power): sets power value in dBm. Values:-100-20
|
|
#freq: sets frequency. Values: 9e3-12e9
|
|
#ON: turn RF on or off. Values: 'OFF','On',0,1
|
|
command = 'INIT:CONT ON\n'
|
|
self.s.send(command.encode('utf-8'))
|
|
time.sleep(0.1)
|
|
command = 'SOUR:PULS OFF\n'
|
|
time.sleep(0.1)
|
|
self.s.send(command.encode('utf-8'))
|
|
command = f'SOUR:FREQ {freq}\n'
|
|
self.s.send(command.encode('utf-8'))
|
|
time.sleep(0.1)
|
|
command = f'SOUR:POW {P}\n'
|
|
self.s.send(command.encode('utf-8'))
|
|
time.sleep(0.1)
|
|
command = f'OUTP {ON}\n'
|
|
self.s.send(command.encode('utf-8'))
|
|
|
|
def Pulse(self,P,freq,width,duty,ON):
|
|
# enables pulse mode, and can turn power on or off. Uses internal source for timing.
|
|
#P (Power): sets power value in dBm. Values:-100-20
|
|
#freq: sets frequency. Values: 9e3-12e9
|
|
#width: length of pulse (including off time) Values: (1-1e-6)s
|
|
#duty(dutycycle): sets the duty cycle of the puls. Values:0-1 Setting it to 0 or 1 might not be the best thing (haven't tried it)
|
|
#ON: turn RF on or off. Values: 'OFF','On',0,1
|
|
command = 'INIT:CONT ON\n'
|
|
self.s.send(command.encode('utf-8'))
|
|
time.sleep(0.1)
|
|
command = f'SOUR:FREQ {freq}\n'
|
|
self.s.send(command.encode('utf-8'))
|
|
time.sleep(0.1)
|
|
command = f'SOUR:POW {P}\n'
|
|
self.s.send(command.encode('utf-8'))
|
|
command = 'SOUR:PULS 1\n'
|
|
time.sleep(0.1)
|
|
self.s.send(command.encode('utf-8'))
|
|
time.sleep(0.1)
|
|
command = ':PULS:SOUR INT\n'
|
|
self.s.send(command.encode('utf-8'))
|
|
time.sleep(0.1)
|
|
command = f':PULS:FREQ {1/width}\n'
|
|
self.s.send(command.encode('utf-8'))
|
|
time.sleep(0.1)
|
|
command = f':PULS:WIDT {duty*width}\n'
|
|
self.s.send(command.encode('utf-8'))
|
|
time.sleep(0.1)
|
|
command = f'OUTP {ON}\n'
|
|
self.s.send(command.encode('utf-8'))
|
|
|