Power Supplies

htf support some programmable power supplies.

Rohde + Schwarz HMP Series programmable power supplies

The Rhode + Schwarz HMP Series are programmable power supplies that are supported by the HILSTER Testing Framework.

The user does not need not call any methods. He can use the automatic delegation to easily set current and voltage by assigning values to the members of the same names.

The abstraction supports virtual controls that appear as class members. These are voltage<i>, actual_voltage<i>, current<i> and actual_current<i>. <i> it the port (1..4).

For most usecases using the virtual controls should be appropriate.

To setup a HMP 2020 power supply use:

from htf.power supply import HMP2020

h = HMP2020("COM3")

# set the voltage on port 1
h.voltage1 = 1.23
# print the measured voltage on port 1
print(h.actual_voltage1)

# set the current on port 2
h.current2 = 0.2
# print the measured current on port 2
print(h.actual_current2)

To make use of R&S®HO720 or R&S®HO730 Dual Interface via ethernet you can simply pass a url e.g.

h = HMP4040("socket://hmp4040-ip-address:5025")  # change to your ip address or hostname
class htf.powersupply.rs_hmpseries.HMP2020(port: str, baudrate: int = 9600, parity: str = 'N', stopbits: int | float = 1, timeout: int | float = 1.0, command_delay: int | float = 0.05, wait_after_set_voltage: bool = False, wait_time: int | float = 0.5)

HMP2020: 1 × 0 V to 32 V/0 A to 10 A; 1 × 0 V to 32 V/0 A to 5 A (188 W)

class htf.powersupply.rs_hmpseries.HMP2030(port: str, baudrate: int = 9600, parity: str = 'N', stopbits: int | float = 1, timeout: int | float = 1.0, command_delay: int | float = 0.05, wait_after_set_voltage: bool = False, wait_time: int | float = 0.5)

HMP2030: 3 × 0 V to 32 V/0 A to 5 A (188 W)

class htf.powersupply.rs_hmpseries.HMP4030(port: str, baudrate: int = 9600, parity: str = 'N', stopbits: int | float = 1, timeout: int | float = 1.0, command_delay: int | float = 0.05, wait_after_set_voltage: bool = False, wait_time: int | float = 0.5)

HMP4030: 3 × 0 V to 32 V/0 A to 10 A (384 W)

class htf.powersupply.rs_hmpseries.HMP4040(port: str, baudrate: int = 9600, parity: str = 'N', stopbits: int | float = 1, timeout: int | float = 1.0, command_delay: int | float = 0.05, wait_after_set_voltage: bool = False, wait_time: int | float = 0.5)

HMP4040: 4 × 0 V to 32 V/0 A to 10 A (384 W)

Manson HCS-3XXX

The Manson HCS-3XXX is a programmable power supply unit family.

The user does not need not call any methods. He can use the automatic delegation to easily set current and voltage by assigning values to the members of the same names.

from htf.powersupply import MansonHCS3xxx

m - MansonHCS3xxx("COM3")

# set output to 4 V
m.voltage = 4
print(m.voltage)
# set current (maximum) to 0.5 A
m.current = 0.5
print(m.current)

To store presets for current and voltage levels use the store_presets method. You can store up to three presets.

presets = {
    'P1': {'current': 12.0, 'voltage': 5.0},
    'P2': {'current': 12.0, 'voltage': 13.8},
    'P3': {'current': 12.0, 'voltage': 25.0}}
m.store_presets(presets)
class htf.powersupply.manson_hcs_3xxx.MansonHCS3xxx(port: str, baudrate: int = 9600, parity: str = 'N', stopbits: int | float = 1, timeout: int | float = 1.0, decimal_places_for_current: int = 1, debug: bool = False)

MansonHCS3xxx is a hardware abstraction to the Manson HCS-3xxx power supply family using a UART to control it.

MansonHCS3xxx uses DelegatorMixin to automatically set and read it’s members voltage and current.

Parameters:
  • port – the comport to be used, eg. “COM3”, 3 or “/dev/ttyUSB0”, etc.

  • decimal_places_for_current=1 – the number of decimal places for the current. HCS-3100, 3150, 3200 and 3202 have one decimal place. HCS-3102, 3014 and 3204 have two decimal places.

  • debug=False – if set to True debugging is enabled

close() None

Close the serial member. This method is automatically called when __del__ is called.

disable_output() None

Disable output.

enable_output() None

Enable output.

get_current() float

Read the current current from device and return the result.

Returns:

the current current.

Return type:

float

get_display_voltage_current_and_status() Dict[str, Any]

Get the display voltage, current and status.

Returns:

a dictionary containing “voltage”, “current” and “status”.

Return type:

dict

get_preset_maximum_current() float

Get preset maximum current for current preset.

Returns:

the preset maximum current.

Return type:

float

get_preset_maximum_voltage() float

Get preset maximum voltage for current preset.

Returns:

the preset maximum voltage.

Return type:

float

get_preset_maximum_voltage_and_current() Dict[str, float]

Get the preset maximum voltage and current.

Returns:

a dictionary containing “voltage” and “current”.

Return type:

dict

get_preset_voltage_and_current() Dict[str, float]

Get the preset voltage and current.

Returns:

a dictionary containing “voltage” and “current”.

Return type:

dict

get_presets() Dict[str, Dict[str, float]]

Get three voltage-current presets.

Returns:

a dictionary containing “voltage”, “current” and “P<preset>”.

Return type:

dict

get_voltage() float

Read current voltage from device and return the result.

Returns:

the current voltage.

Return type:

float

load_preset(preset: int) None

Load preset preset.

Parameters:

preset – may be 0, 1, or 2.

preset_maximum_current(current: int | float) None

Set maximum voltage for current preset.

preset_maximum_voltage(voltage: int | float) None

Set maximum voltage for current preset.

query(query: bytes, answer_lines: int = 1) List[bytes] | None

Send a command and wait for the answer.

Parameters:
  • query – the query to be sent.

  • answer_lines=1 – the number of lines to be received.

Returns:

the answer line(s).

Return type:

str

Raises:

manson_hcs_3xxx.TimeoutException – if a communication time-out occurred.

set_current(current: int | float) None

Set the output current to current.

Parameters:

current – the current in units of amperes as int(), float() or string, eg. 0, 0.5, “0.5” or even “0.5 mA” work.

set_voltage(voltage: int | float) None

Set the output voltage to voltage.

Parameters:

voltage – the voltage in units of volts as int(), float() or string, eg. 23, 23.0, “23.0” or even “23.0 V” work. voltage may have on decimal point. If voltage is None the output is disabled.

store_presets(presets: Dict[str, Dict[str, float]]) None

Store three voltage-current presets.

Parameters:

presets – a dictionary containing the key P1, P2 and P3. Each key contains “voltage” and “current” keys.

KORAD KA3005P

The KORAD KA3005P is a programmable power supply unit.

To use the implementation you do not need to call any methods. Simply use the automatic delegation to easily set current and voltages by assigning values to the members of the same name.

from htf.powersupply import KORAD_KA3005P

k = KORAD_KA3005P("COM3")

# set output to 4 V
k.voltage = 4
print(k.voltage)
# set current (maximum) to 0.5 A
k.current = 0.5
print(k.current)
class htf.powersupply.korad_ka3005p.KORAD_KA3005P(port: str, baudrate: int = 9600, parity: str = 'N', stopbits: int | float = 1, timeout: int | float = 1.0, debug: bool = False)

KORAD_KA3005P is a hardware abstraction to the KORAD KA3005P power supply unit using a UART to control it.

KORAD_KA3005P uses DelegatorMixin to automatically set and read it’s members voltage and current.

Parameters:
  • port – the comport to be used, eg. “COM3”, 3 or “/dev/ttyUSB0”, etc.

  • debug=False – if set to True debugging is enabled.

close() None

Close the serial member. This method is automatically called when __del__ is called.

disable_output() None

Disable output.

enable_output() None

Enable output.

Raises:

SetOutputException – if output was not set.

get_current_current(channel: int = 1) float

Read the current current from device and return the result.

Parameters:

channel – the channel to use. Shall always be 1.

Returns:

the current current.

Return type:

float

get_current_voltage(channel: int = 1) float

Read current voltage from device and return the result.

Parameters:

channel=1 – the channel to use. Shall always be 1.

Returns:

the current voltage.

Return type:

float

get_id() bytes | None

Return the KORAD id.

Returns:

the KORAD id.

Return type:

str

get_status() Dict[str, str]

Read device status and return a dictionary.

Returns:

the status dictionary containing the keys “ch1 mode”, “ch2 mode”, “tracking mode”, “beep”,

”lock” and “output”.

Return type:

dict

query(query: bytes, length_of_answer: int | None = None, retries: int = 3) bytes

Send a command and wait for the answer.

Parameters:
  • query – the query to be sent.

  • length_of_answer=None – the maximum number of bytes to be received.

  • retries=3 – the number of retries.

Returns:

the answer.

Return type:

bytes

Raises:

korad_ka3005p.TimeoutException – if a communication time-out occurred.

send_command(command: bytes) None

Directly send a command to the power supply unit.

Parameters:

command – the command to be sent.

set_current(current: int | float, channel: int = 1) None

Set the output current for a given channel.

Parameters:
  • current – the current in units of amperes as int(), float() or string, eg. 0, 0.5, “0.5” or even “0.5 mA” work.

  • channel – the channel to use. Shall always be 1.

Raises:

SetCurrentException – if current was not set.

set_voltage(voltage: int | float, channel: int = 1) None

Set the output voltage for a given channel.

If voltage is None the output is disabled. If voltage is not None the output is enabled. If voltage changes the output is first disabled, changed, and then enabled again.

Parameters:
  • voltage – the voltage in units of volts as int(), float() or string, eg. 23, 23.0, “23.0”

  • work. (or even "23.0 V") –

  • channel – the channel to use. Shall always be 1.

Raises:

SetVoltageException – if voltage was not set.

Changelog

htf-powersupply-4.0.4

  • add requirements for validation purposes

htf-powersupply-4.0.3

  • add build environment data for validation purposes

htf-powersupply-4.0.2

  • htf-powersupply can now be used standalone

htf-powersupply-4.0.1

  • add support for Python 3.12

htf-powersupply-4.0.0

  • remove all camel-case methods

  • add type-hints

  • use hlm-3.1

  • rename comport to port for all HMP power supplies

htf-powersupply-3.0.1

  • add support for Python 3.11

htf-powersupply-3.0.0

  • extract htf-powersupply from htf