Created
March 12, 2021 16:34
-
-
Save asafpm/2ccd0cf652952dbd1230fc7ae112606e to your computer and use it in GitHub Desktop.
Gamma Vacuum Digitel SPCe controller
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Gamma Vacuum Digitel SPCe controller for ion pump | |
import serial | |
class IonPump: | |
def __init__(self, address=1, port='/dev/ttyUSB0', baudrate=9600): | |
self.serial = serial.Serial(port=port, baudrate=baudrate) | |
self.address = address | |
def send_command(self, cmd): | |
msg = b'~ %02X %02X ' % (self.address, cmd) | |
chk = sum(msg[1:]) % 256 | |
out = msg + b'%02X\r' % chk | |
self.serial.write(out) | |
ret = self.serial.read_until(b'\r') | |
if ret[3:5] == b'OK': | |
return ret | |
else: | |
raise Exception(ret) | |
def read_current(self): | |
resp = str(self.send_command(0x0A)) | |
parts = resp.split(' ') | |
return parts[3]+" "+parts[4] | |
def read_pressure(self): | |
resp = str(self.send_command(0x0B)) | |
parts = resp.split(' ') | |
return parts[3]+" "+parts[4] | |
def read_voltage(self): | |
resp = str(self.send_command(0x0C)) | |
parts = resp.split(' ') | |
return parts[3]+" V" | |
def is_high_voltage_on(self): | |
return str(self.send_command(0x61)) | |
def disable_high_voltage(self): | |
self.send_command(0x38) | |
def enable_high_voltage(self): | |
self.send_command(0x37) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment