コード例 #1
0
    def set_current(self, level: float):
        """
        Sets current of power supply.

        :param level: Requested Current Level
        :type level: float
        :raises: MalformedParamterException
        """
        if (level > 3) or (level < 0):
            raise exceptions.MalformedParamterException(level,
                    "between 0 - 3 A")
        self.instrument.write(f"CURRent {level}")
コード例 #2
0
    def set_output_state(self, state: str):
        """
        Turns supply output on or off

        :param state: ON or OFF status of power supply
        :type state: str
        :raises: MalformedParameterException
        """
        state = state.upper()
        if state != "OFF" or state != "ON":
            raise exceptions.MalformedParamterException(state, ["ON", "OFF"])
        self.instrument.write(f"OUTput {state}")
コード例 #3
0
    def set_voltage(self, level: float):
        """
        Sets voltage of power supply. This will set the voltage to any level
        regardless of the output level set.

        :param level: Requested Voltage Level
        :type level: float
        :raises: MalformedParamterException
        """
        if (level > 20) or (level < 0):
            raise exceptions.MalformedParamterException(level,
                "between 0 - 20 V")
        self.instrument.write(f"VOLTage {level}")
コード例 #4
0
    def voltage_measurement(self, measurement_type: str) -> float:
        """
        Measures either AC or DC voltage.

        :param measurement_type: AC or DC measurement
        :type measurement_type: str
        :rtype: float
        :raises: MalformedParamterException
        """
        measurement_type = measurement_type.upper()
        if (measurement_type == "AC") or (measurement_type == "DC"):
            return self.instrument.query(
                f"MEASure:VOLTage:{measurement_type}? DEF,DEF")
        raise exceptions.MalformedParamterException(measurement_type,
                                                    ["AC", "DC"])
コード例 #5
0
    def set_output(self, voltage: float, current: float):
        """
        Set output current and voltage

        :param voltage: Output Voltage (between 0 - 20 V)
        :type voltage: float
        :param current: Output Current (between 0 - 3 A)
        :type current: float
        :raises: MalformedParamterException
        """
        if (((current > 3) or (current < 0)) and
                ((voltage > 20) or (voltage < 0))):
            raise exceptions.MalformedParamterException(
                f"{voltage} V, {current} A", "between 0 - 3 A/0 - 20 V")
        self.instrument.write(f"APPLy {voltage}, {current}")
コード例 #6
0
    def set_voltage_range(self, voltage_range: str):
        """
        Sets voltage range to high or low

        :param voltage_range: HIGH (20V) or LOW (8V)
        :type voltage_range: str
        :raises: MalformedParameterException
        """
        voltage_range = voltage_range.upper()
        if voltage_range == "HIGH":
            self.instrument.write("VOLTage:RANGe P20V")
        elif voltage_range == "LOW":
            self.instrument.write("VOLTage:RANGe P8V")
        else:
            raise exceptions.MalformedParamterException(voltage_range,
                                                        ["HIGH", "LOW"])
コード例 #7
0
    def resistance_measurement(self, measurement_type: str) -> float:
        """
        Measures either two or four wire resistance.

        :param measurement_type: TWO or FOUR wire measurement
        :type measurement_type: str
        :rtype: float
        :raises: MalformedParamterException
        """
        if measurement_type == "TWO":
            return self.instrument.query(
                f"MEASure:RESistance? DEF,DEF")
        elif measurement_type == "FOUR":
            return self.instrument.query(
                f"MEASure:FRESistance? DEF,DEF")
        else:
            raise exceptions.MalformedParamterException(
                measurement_type, ["TWO", "FOUR"])