diff options
-rw-r--r-- | qolab/hardware/power_supply/gpp3610h.py | 133 | ||||
-rw-r--r-- | run.py | 26 |
2 files changed, 154 insertions, 5 deletions
diff --git a/qolab/hardware/power_supply/gpp3610h.py b/qolab/hardware/power_supply/gpp3610h.py new file mode 100644 index 0000000..7ea2fbc --- /dev/null +++ b/qolab/hardware/power_supply/gpp3610h.py @@ -0,0 +1,133 @@ +""" +Module: GW INSTEK GPP-250-4.5 power supply unit control +Description: This module provides a class to interface with the GW INSTEK GPP250-4.5 power + supply unit (PSU) using pyvisa for setting current and voltage on the PSU + +Author: Mykhailo Vorobiov +Email: mvorobiov@wm.edu +Date: 2024-11-05 +Update: 2024-11-05 +""" + +from qolab.hardware.power_supply._basic import PowerSupplySCPI +import pyvisa + +class GPP3610H(PowerSupplySCPI): + """ + A class for interfacing with GW INSTEK GPP-3610H + signle channel power supply unit. + """ + def __init__(self, resource, *args, **kwds): + """ + Initialize the PSU class. + """ + super().__init__(resource, *args, **kwds) + self.resource = resource + + self.config["Device model"] = "GWInstek GPP-3610H" + self.numberOfChannels = 2 + self.deviceProperties.update({"OpMode"}) + self.resource.read_termination = "\n" + + self.resource.timeout = 1000 + + self.MAX_CURRENT = 10.0 # Amp + self.MAX_VOLTAGE = 36.0 # Volt + + @property + def idn(self): + return self.get_idn() + + def get_idn(self): + """ + Query the identification of the instrument. + + :return: Identifier string if query is successful or None otherwise. + """ + try: + self.write('*IDN?') + response = self.read_bytes(count=39).decode().strip() + return response + except pyvisa.VisaIOError as e: + print(f'[ERROR!] Error retrieving identification: {e}') + + def get_out_current(self): + """ + Query the current reading of the instrument. + + :return: Current reading in amps as float number and None if error occurs. + """ + try: + self.write('IOUT1?') + response = float(self.read_bytes(count=8).decode()[:-2]) + return response + except pyvisa.VisaIOError as e: + print(f"[ERROR!] Error querying the current reading: {e}") + + + def get_out_voltage(self): + """ + Query the voltage reading of the instrument. + + :return: Voltage reading in volts as float number and None if error occurs. + """ + + try: + self.write('VOUT1?') + response = float(self.read_bytes(count=8).decode()[:-2]) + return response + except pyvisa.VisaIOError as e: + print(f"[ERROR!] Error querying the voltage reading: {e}") + + + def set_current(self, current): + """ + Set the target current output of the instrument. + """ + + if current <= self.MAX_CURRENT and current >= 0.0: + try: + self.write(f'SOUR:CURR {current}') + print(f"Current is set to {current} V") + except pyvisa.VisaIOError as e: + print(f"[ERROR!] Error setting the current target output: {e}") + else: + print(f"[WARNING] Target current must be between 0 and {self.MAX_CURRENT} Amps." + f"\n\tThe traget current left unchanged.") + + + def set_voltage(self, voltage): + """ + Set the target voltage output of the instrument. + """ + if voltage <= self.MAX_VOLTAGE and voltage >= 0.0: + try: + self.write(f'SOUR:VOLT {voltage}') + print(f"[INFO] Voltage is set to {voltage} V") + except pyvisa.VisaIOError as e: + print(f"[ERROR!] Error setting the voltage target output: {e}") + else: + print(f"[WARNING] Target voltage must be between 0 and {self.MAX_VOLTAGE} Volts." + f"\n\tThe traget voltage left unchanged.") + + def enable_output(self, output_state=False): + """ + Set the output state of the instrument ON or OFF. + + :param output_state: Boolean flag. Sets the output ON if 'True' or OFF if 'False'. + """ + self.output_state = output_state # This is here to define out state (need some work on it) + try: + if self.output_state: + self.write(f'OUTP:STAT 1') + self.output_state = output_state + print(f"[INFO] Output is ON") + else: + self.write(f'OUTP:STAT 0') + self.output_state = not(output_state) + print(f"[INFO] Output is OFF") + except pyvisa.VisaIOError as e: + print(f"[ERROR!] Error toggle the output: {e}") + + + @@ -3,6 +3,7 @@ from qolab.hardware.multimeter.bk_5491 import BK_5491 from qolab.hardware.multimeter.hp_34401 import HP_34401 from qolab.hardware.vacuum_gauge.mks390 import MKS390 from qolab.hardware.power_supply.psw25045 import PSW25045 +from qolab.hardware.power_supply.gpp3610h import GPP3610H from qolab.hardware.scope.sds800xhd import SDS800XHD @@ -15,7 +16,7 @@ if __name__ == "__main__": import matplotlib.pyplot as plt import time - #mpl.style.use('custom-style') + mpl.style.use('custom-style') rm = pyvisa.ResourceManager() address_dict = { @@ -24,7 +25,8 @@ if __name__ == "__main__": 'dmm_hp': 'visa://192.168.194.15/ASRL9::INSTR', 'dmm_bk': 'visa://192.168.194.15/ASRL12::INSTR', 'vacgauge': 'visa://192.168.194.15/ASRL13::INSTR', - 'psu_anode': 'visa://192.168.194.15/ASRL10::INSTR' + 'psu_anode': 'visa://192.168.194.15/ASRL10::INSTR', + 'psu_disp': 'TCPIP0::192.168.2.213::1026::SOCKET' } #---------------------------------------------- # Open visa resources and initialize intruments @@ -50,6 +52,11 @@ if __name__ == "__main__": psu_anode = PSW25045( rm.open_resource(address_dict['psu_anode']) ) + + psu_disp = GPP3610H( + rm.open_resource(address_dict['psu_disp']) + ) + #----------------------------------------------- # Get DMM readings @@ -62,9 +69,18 @@ if __name__ == "__main__": print(psu_anode.get_idn()) psu_anode.set_voltage(5) psu_anode.enable_output(True) - time.sleep(20) + time.sleep(2) psu_anode.enable_output(False) - trace = scope.getTrace(4) - trace.plot() + print(psu_disp.get_idn()) + psu_disp.set_voltage(0.2) + psu_disp.enable_output(True) + time.sleep(3) + print(psu_disp.get_out_current()) + print(psu_disp.get_out_voltage()) + time.sleep(2) + psu_disp.enable_output(False) + + #trace = scope.getTrace(4) + #trace.plot() plt.show()
\ No newline at end of file |