#!/usr/bin/env python3 __all__ = ["DP800"] class DP800(object): """ Rigol DP800 command wrapper. """ def __init__(self, inst): """ Initialize the DP800 wrapper with a specific PyVISA resource. This class does NOT open the resource, you have to open it for yourself! """ self.inst = inst def enable(self): """ Enable the electronic source Equivalent to pressing "ON/OFF" when the source is ON """ return self.inst.write(":OUTP CH1,ON") def disable(self): """ Disable the electronic source Equivalent to pressing "ON/OFF" when the source is ON """ return self.inst.write(":OUTP CH1,OFF") def voltage(self): # My DL3021 returns a string like '0.000067\n0' return float(self.inst.query(":MEAS:VOLT?").partition("\n")[0]) def current(self): # My DL3021 returns a string like '0.000067\n0' return float(self.inst.query(":MEAS:CURR?").partition("\n")[0]) def set_cc_current(self, maxV, sourceCurrent): """ Set CC current limit """ return self.inst.write(":APPLy CH1,{},{}".format(maxV, sourceCurrent)) def setCC(self): return self.inst.write("STAT:QUES:ENAB 1") def cc(self, maxV, sourceCurrent, activate=True): """ One-line constant-current configuration. if activate == True, also turns on the power supply """ self.set_cc_current(maxV, sourceCurrent) self.setCC() self.enable() def reset(self): return self.inst.write("*RST")