Source code for labtronyx.drivers.TDI.Load

"""
.. codeauthor:: Kevin Kennedy <protonyx@users.noreply.github.com>

Remote Interface
----------------

These loads feature a Ethernet connection that hosts a web-based interface from
which you can control the load much like you would if you were sitting in front
of it.
"""
import labtronyx


[docs]class d_XBL(labtronyx.DriverBase): """ Driver for TDI XBL Series DC Electronic Loads """ author = 'KKENNEDY' version = '1.0' deviceType = 'DC Electronic Load' compatibleInterfaces = ['Serial'] compatibleInstruments = { 'TDI': ['XBL-50-150-800', 'XBL-100-120-800', 'XBL-400-120-800', 'XBL-600-40-800', 'XBL-50-400-2000', 'XBL-100-300-2000', 'XBL-400-300-2000', 'XBL-600-100-2000', 'XBL-50-1000-4000', 'XBL-100-600-4000', 'XBL-400-600-4000', 'XBL-600-200-4000', 'XBL-100-600-6000', 'XBL-400-600-6000', 'XBL-600-200-6000'] } modes = { 'Constant Current': 'CI', 'Constant Voltage': 'CV', 'Constant Power': 'CW', 'Constant Resistance': 'CR'} def open(self): # Turn off text mode (mangles queries) self.instr.write("TEXT OFF") # Turn off keyboard sounds self.instr.write("KEYOFF") self._model = self.query("MDL?") self._serial = self.query("SERNO?") self._fw = self.query("VER?") def close(self): pass def getProperties(self): return { 'deviceVendor': 'TDI', 'deviceModel': self._model, 'deviceSerial': self._serial, 'deviceFirmware': self._fw }
[docs] def powerOn(self): """ Turns the load on """ self.write("LOAD ON")
[docs] def powerOff(self): """ Turns the load off """ self.write("LOAD OFF")
[docs] def setMaster(self): """ Set load into master mode """ self.write("MASTER")
[docs] def setSlave(self): """ Set load into slave mode """ self.write("SLAVE")
[docs] def setMaxCurrent(self, current): """ Sets the maximum current the load will sink :param current: Current in Amps :type current: float """ self.write("IL %s" % str(current))
[docs] def getMaxCurrent(self): """ Returns the maximum current the load will sink :returns: float """ return float(self.query("IL?"))
[docs] def setMaxVoltage(self, voltage): """ Sets the maximum voltage the load will allow :param voltage: Voltage in Volts :type voltage: float """ return self.write("VL %s" % str(voltage))
[docs] def getMaxVoltage(self): """ Gets the maximum voltage the load will allow :returns: float """ return float(self.query("VL?"))
[docs] def setMaxPower(self, power): """ Sets the maximum power the load will allow :param power: Power in Watts :type power: float """ self.write("PL %s" % str(power))
[docs] def getMaxPower(self): """ Gets the maximum power the load will allow :returns: float """ return float(self.query("PL?"))
[docs] def setCurrent(self, current): """ Sets the constant current mode's current level :param current: Current in Amps :type current: float """ self.write("CI %s" % str(current))
[docs] def getCurrent(self): """ Gets the constant current mode's current level :returns: float """ return float(self.query("CI?"))
[docs] def setVoltage(self, voltage): """ Sets the constant voltage mode's voltage level :param voltage: Voltage in Volts :type voltage: float """ self.write("CV %s" % str(voltage))
[docs] def getVoltage(self): """ Gets the constant voltage mode's voltage level :returns: float """ return float(self.query("CV?"))
[docs] def setPower(self, power): """ Sets the constant power mode's power level :param power: Power in Watts :type power: float """ self.write("CP %s" % str(power))
[docs] def getPower(self): """ Gets the constant power mode's power level :returns: float """ return float(self.query("CP?"))
[docs] def setResistance(self, resistance): """ Sets the constant resistance mode's resistance level :param resistance: Resistance in Ohms :type resistance: str """ self.write("CR %s" % str(resistance))
[docs] def getResistance(self): """ Gets the constant resistance mode's resistance level :returns: float """ return float(self.query("CR?"))
[docs] def configureSlewRate(self, rate): """ Set the slew rate for a zero to full-scale transision. :param rate: Rise and Fall time (in microseconds) :type rate: float """ if rate > 10.0 and rate <= 4000.0: self.write("SF") elif rate > 4000.0: self.write("SS") self.write("SR %s" % str(rate))
[docs] def configurePulsing(self, freq, duty, mode, base, peak): """ Mode can be one of: * `cc`: Constant Current * `cv`: Constant Voltage * `cw`: Constant Power * `cr`: Constant Resistance """ if mode.lower() == 'cc': self.write("I1 %s" % base) self.write("I2 %s" % peak) elif mode.lower() == 'cv': self.write("V1 %s" % base) self.write("V2 %s" % peak) elif mode.lower() == 'cw': self.write("P1 %s" % base) self.write("P2 %s" % peak) elif mode.lower() == 'cr': self.write("R1 %s" % base) self.write("R2 %s" % peak) else: raise Exception("Invalid mode") # Frequency self.write("FQ %s" % float(freq)) # Duty self.write("DU %s" % float(duty)) # Enable pulsing self.write("SW ON")
[docs] def enableLocalControl(self): """ Enable local control of the load """ self.write("LOCK OFF")
[docs] def disableLocalControl(self): """ Disable local control of the load. User will be unable to control load functions using the front panel. """ self.write("LOCK ON")
[docs] def getTerminalVoltage(self): """ Returns the terminal voltage in Volts :returns: float """ return float(self.query("V?"))
[docs] def getTerminalCurrent(self): """ Returns the terminal current in Amps :returns: float """ return float(self.query("I?"))
[docs] def getTerminalPower(self): """ Returns the terminal power in Watts :returns: float """ return float(self.query("P?"))