Silaev/3.5.1 auto/amperemeter.py

31 lines
872 B
Python
Raw Normal View History

import serial
class B7_78():
def __init__(self, folder):
self.folder = folder
self.instr = serial.Serial(
self.folder, timeout=1, inter_byte_timeout=1)
self.instr.write(b'SYST:REM\n')
self.instr.write(b'SYST:REM\n')
def getCurrentDC(self):
self.instr.write(b'MEAS:CURR:DC?\n')
return self.instr.read(100).decode().rstrip()
def getVoltageDC(self):
self.instr.write(b'MEAS:VOLT:DC?\n')
return float(self.instr.read(100).decode().rstrip())
def getCurrentAC(self):
self.instr.write(b'MEAS:CURR:AC?\n')
return float(self.instr.read(100).decode().rstrip())
def getVoltageAC(self):
self.instr.write(b'MEAS:VOLT:AC?\n')
return float(self.instr.read(100).decode().rstrip())
# for i in range(5):
# print(B7_78('/dev/ttyUSB0').getCurrentDC())