<!-- HILSTER htf 4.3.1 -->
**htf 4.3.1** · [HTML](../power_supplies.html) · [Complete PDF manual](../_downloads/htf-4.3.1.pdf)

# Power Supplies

htf support some programmable power supplies.

<a id="r-s-hmp"></a>

## 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:

```python
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.

```python
h = HMP4040("socket://hmp4040-ip-address:5025")  # change to your ip address or hostname
```

<a id="module-htf.powersupply.rs_hmpseries"></a>

### *class* htf.powersupply.rs_hmpseries.HMP2020(port: [str](https://docs.python.org/3/builtins/stdtypes.html#str), baudrate: [int](https://docs.python.org/3/builtins/functions.html#int) = 9600, parity: [str](https://docs.python.org/3/builtins/stdtypes.html#str) = 'N', stopbits: [int](https://docs.python.org/3/builtins/functions.html#int) | [float](https://docs.python.org/3/builtins/functions.html#float) = 1, timeout: [int](https://docs.python.org/3/builtins/functions.html#int) | [float](https://docs.python.org/3/builtins/functions.html#float) = 1.0, command_delay: [int](https://docs.python.org/3/builtins/functions.html#int) | [float](https://docs.python.org/3/builtins/functions.html#float) = 0.05, wait_after_set_voltage: [bool](https://docs.python.org/3/builtins/functions.html#bool) = False, wait_time: [int](https://docs.python.org/3/builtins/functions.html#int) | [float](https://docs.python.org/3/builtins/functions.html#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](https://docs.python.org/3/builtins/stdtypes.html#str), baudrate: [int](https://docs.python.org/3/builtins/functions.html#int) = 9600, parity: [str](https://docs.python.org/3/builtins/stdtypes.html#str) = 'N', stopbits: [int](https://docs.python.org/3/builtins/functions.html#int) | [float](https://docs.python.org/3/builtins/functions.html#float) = 1, timeout: [int](https://docs.python.org/3/builtins/functions.html#int) | [float](https://docs.python.org/3/builtins/functions.html#float) = 1.0, command_delay: [int](https://docs.python.org/3/builtins/functions.html#int) | [float](https://docs.python.org/3/builtins/functions.html#float) = 0.05, wait_after_set_voltage: [bool](https://docs.python.org/3/builtins/functions.html#bool) = False, wait_time: [int](https://docs.python.org/3/builtins/functions.html#int) | [float](https://docs.python.org/3/builtins/functions.html#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](https://docs.python.org/3/builtins/stdtypes.html#str), baudrate: [int](https://docs.python.org/3/builtins/functions.html#int) = 9600, parity: [str](https://docs.python.org/3/builtins/stdtypes.html#str) = 'N', stopbits: [int](https://docs.python.org/3/builtins/functions.html#int) | [float](https://docs.python.org/3/builtins/functions.html#float) = 1, timeout: [int](https://docs.python.org/3/builtins/functions.html#int) | [float](https://docs.python.org/3/builtins/functions.html#float) = 1.0, command_delay: [int](https://docs.python.org/3/builtins/functions.html#int) | [float](https://docs.python.org/3/builtins/functions.html#float) = 0.05, wait_after_set_voltage: [bool](https://docs.python.org/3/builtins/functions.html#bool) = False, wait_time: [int](https://docs.python.org/3/builtins/functions.html#int) | [float](https://docs.python.org/3/builtins/functions.html#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](https://docs.python.org/3/builtins/stdtypes.html#str), baudrate: [int](https://docs.python.org/3/builtins/functions.html#int) = 9600, parity: [str](https://docs.python.org/3/builtins/stdtypes.html#str) = 'N', stopbits: [int](https://docs.python.org/3/builtins/functions.html#int) | [float](https://docs.python.org/3/builtins/functions.html#float) = 1, timeout: [int](https://docs.python.org/3/builtins/functions.html#int) | [float](https://docs.python.org/3/builtins/functions.html#float) = 1.0, command_delay: [int](https://docs.python.org/3/builtins/functions.html#int) | [float](https://docs.python.org/3/builtins/functions.html#float) = 0.05, wait_after_set_voltage: [bool](https://docs.python.org/3/builtins/functions.html#bool) = False, wait_time: [int](https://docs.python.org/3/builtins/functions.html#int) | [float](https://docs.python.org/3/builtins/functions.html#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.

```python
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.

```python
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)
```

<a id="module-htf.powersupply.manson_hcs_3xxx"></a>

### *class* htf.powersupply.manson_hcs_3xxx.MansonHCS3xxx(port: [str](https://docs.python.org/3/builtins/stdtypes.html#str), baudrate: [int](https://docs.python.org/3/builtins/functions.html#int) = 9600, parity: [str](https://docs.python.org/3/builtins/stdtypes.html#str) = 'N', stopbits: [int](https://docs.python.org/3/builtins/functions.html#int) | [float](https://docs.python.org/3/builtins/functions.html#float) = 1, timeout: [int](https://docs.python.org/3/builtins/functions.html#int) | [float](https://docs.python.org/3/builtins/functions.html#float) = 1.0, decimal_places_for_current: [int](https://docs.python.org/3/builtins/functions.html#int) = 1, debug: [bool](https://docs.python.org/3/builtins/functions.html#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](https://docs.python.org/3/builtins/constants.html#None)

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

#### disable_output() → [None](https://docs.python.org/3/builtins/constants.html#None)

Disable output.

#### enable_output() → [None](https://docs.python.org/3/builtins/constants.html#None)

Enable output.

#### get_current() → [float](https://docs.python.org/3/builtins/functions.html#float)

Read the current current from device and return the result.

* **Returns:**
  the current current.
* **Return type:**
  [float](https://docs.python.org/3/builtins/functions.html#float)

#### get_display_voltage_current_and_status() → [Dict](https://docs.python.org/3/library/typing.html#typing.Dict)[[str](https://docs.python.org/3/builtins/stdtypes.html#str), [Any](https://docs.python.org/3/library/typing.html#typing.Any)]

Get the display voltage, current and status.

* **Returns:**
  a dictionary containing “voltage”, “current” and “status”.
* **Return type:**
  [dict](https://docs.python.org/3/builtins/stdtypes.html#dict)

#### get_preset_maximum_current() → [float](https://docs.python.org/3/builtins/functions.html#float)

Get preset maximum current for current preset.

* **Returns:**
  the preset maximum current.
* **Return type:**
  [float](https://docs.python.org/3/builtins/functions.html#float)

#### get_preset_maximum_voltage() → [float](https://docs.python.org/3/builtins/functions.html#float)

Get preset maximum voltage for current preset.

* **Returns:**
  the preset maximum voltage.
* **Return type:**
  [float](https://docs.python.org/3/builtins/functions.html#float)

#### get_preset_maximum_voltage_and_current() → [Dict](https://docs.python.org/3/library/typing.html#typing.Dict)[[str](https://docs.python.org/3/builtins/stdtypes.html#str), [float](https://docs.python.org/3/builtins/functions.html#float)]

Get the preset maximum voltage and current.

* **Returns:**
  a dictionary containing “voltage” and “current”.
* **Return type:**
  [dict](https://docs.python.org/3/builtins/stdtypes.html#dict)

#### get_preset_voltage_and_current() → [Dict](https://docs.python.org/3/library/typing.html#typing.Dict)[[str](https://docs.python.org/3/builtins/stdtypes.html#str), [float](https://docs.python.org/3/builtins/functions.html#float)]

Get the preset voltage and current.

* **Returns:**
  a dictionary containing “voltage” and “current”.
* **Return type:**
  [dict](https://docs.python.org/3/builtins/stdtypes.html#dict)

#### get_presets() → [Dict](https://docs.python.org/3/library/typing.html#typing.Dict)[[str](https://docs.python.org/3/builtins/stdtypes.html#str), [Dict](https://docs.python.org/3/library/typing.html#typing.Dict)[[str](https://docs.python.org/3/builtins/stdtypes.html#str), [float](https://docs.python.org/3/builtins/functions.html#float)]]

Get three voltage-current presets.

* **Returns:**
  a dictionary containing “voltage”, “current” and “P<preset>”.
* **Return type:**
  [dict](https://docs.python.org/3/builtins/stdtypes.html#dict)

#### get_voltage() → [float](https://docs.python.org/3/builtins/functions.html#float)

Read current voltage from device and return the result.

* **Returns:**
  the current voltage.
* **Return type:**
  [float](https://docs.python.org/3/builtins/functions.html#float)

#### load_preset(preset: [int](https://docs.python.org/3/builtins/functions.html#int)) → [None](https://docs.python.org/3/builtins/constants.html#None)

Load preset `preset`.

* **Parameters:**
  **preset** – may be 0, 1, or 2.

#### preset_maximum_current(current: [int](https://docs.python.org/3/builtins/functions.html#int) | [float](https://docs.python.org/3/builtins/functions.html#float)) → [None](https://docs.python.org/3/builtins/constants.html#None)

Set maximum voltage for current preset.

#### preset_maximum_voltage(voltage: [int](https://docs.python.org/3/builtins/functions.html#int) | [float](https://docs.python.org/3/builtins/functions.html#float)) → [None](https://docs.python.org/3/builtins/constants.html#None)

Set maximum voltage for current preset.

#### query(query: [bytes](https://docs.python.org/3/builtins/stdtypes.html#bytes), answer_lines: [int](https://docs.python.org/3/builtins/functions.html#int) = 1) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[bytes](https://docs.python.org/3/builtins/stdtypes.html#bytes)] | [None](https://docs.python.org/3/builtins/constants.html#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](https://docs.python.org/3/builtins/stdtypes.html#str)
* **Raises:**
  **manson_hcs_3xxx.TimeoutException** – if a communication time-out occurred.

#### set_current(current: [int](https://docs.python.org/3/builtins/functions.html#int) | [float](https://docs.python.org/3/builtins/functions.html#float)) → [None](https://docs.python.org/3/builtins/constants.html#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](https://docs.python.org/3/builtins/functions.html#int) | [float](https://docs.python.org/3/builtins/functions.html#float)) → [None](https://docs.python.org/3/builtins/constants.html#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](https://docs.python.org/3/library/typing.html#typing.Dict)[[str](https://docs.python.org/3/builtins/stdtypes.html#str), [Dict](https://docs.python.org/3/library/typing.html#typing.Dict)[[str](https://docs.python.org/3/builtins/stdtypes.html#str), [float](https://docs.python.org/3/builtins/functions.html#float)]]) → [None](https://docs.python.org/3/builtins/constants.html#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.

```python
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)
```

<a id="module-htf.powersupply.korad_ka3005p"></a>

### *class* htf.powersupply.korad_ka3005p.KORAD_KA3005P(port: [str](https://docs.python.org/3/builtins/stdtypes.html#str), baudrate: [int](https://docs.python.org/3/builtins/functions.html#int) = 9600, parity: [str](https://docs.python.org/3/builtins/stdtypes.html#str) = 'N', stopbits: [int](https://docs.python.org/3/builtins/functions.html#int) | [float](https://docs.python.org/3/builtins/functions.html#float) = 1, timeout: [int](https://docs.python.org/3/builtins/functions.html#int) | [float](https://docs.python.org/3/builtins/functions.html#float) = 1.0, debug: [bool](https://docs.python.org/3/builtins/functions.html#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](https://docs.python.org/3/builtins/constants.html#None)

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

#### disable_output() → [None](https://docs.python.org/3/builtins/constants.html#None)

Disable output.

#### enable_output() → [None](https://docs.python.org/3/builtins/constants.html#None)

Enable output.

* **Raises:**
  **SetOutputException** – if output was not set.

#### get_current_current(channel: [int](https://docs.python.org/3/builtins/functions.html#int) = 1) → [float](https://docs.python.org/3/builtins/functions.html#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](https://docs.python.org/3/builtins/functions.html#float)

#### get_current_voltage(channel: [int](https://docs.python.org/3/builtins/functions.html#int) = 1) → [float](https://docs.python.org/3/builtins/functions.html#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](https://docs.python.org/3/builtins/functions.html#float)

#### get_id() → [bytes](https://docs.python.org/3/builtins/stdtypes.html#bytes) | [None](https://docs.python.org/3/builtins/constants.html#None)

Return the KORAD id.

* **Returns:**
  the KORAD id.
* **Return type:**
  [str](https://docs.python.org/3/builtins/stdtypes.html#str)

#### get_status() → [Dict](https://docs.python.org/3/library/typing.html#typing.Dict)[[str](https://docs.python.org/3/builtins/stdtypes.html#str), [str](https://docs.python.org/3/builtins/stdtypes.html#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](https://docs.python.org/3/builtins/stdtypes.html#dict)

#### query(query: [bytes](https://docs.python.org/3/builtins/stdtypes.html#bytes), length_of_answer: [int](https://docs.python.org/3/builtins/functions.html#int) | [None](https://docs.python.org/3/builtins/constants.html#None) = None, retries: [int](https://docs.python.org/3/builtins/functions.html#int) = 3) → [bytes](https://docs.python.org/3/builtins/stdtypes.html#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](https://docs.python.org/3/builtins/stdtypes.html#bytes)
* **Raises:**
  **korad_ka3005p.TimeoutException** – if a communication time-out occurred.

#### send_command(command: [bytes](https://docs.python.org/3/builtins/stdtypes.html#bytes)) → [None](https://docs.python.org/3/builtins/constants.html#None)

Directly send a command to the power supply unit.

* **Parameters:**
  **command** – the command to be sent.

#### set_current(current: [int](https://docs.python.org/3/builtins/functions.html#int) | [float](https://docs.python.org/3/builtins/functions.html#float), channel: [int](https://docs.python.org/3/builtins/functions.html#int) = 1) → [None](https://docs.python.org/3/builtins/constants.html#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](https://docs.python.org/3/builtins/functions.html#int) | [float](https://docs.python.org/3/builtins/functions.html#float), channel: [int](https://docs.python.org/3/builtins/functions.html#int) = 1) → [None](https://docs.python.org/3/builtins/constants.html#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.1.0

> - ship `cp312-abi3` wheels that are compatible with Python 3.12 and newer versions

### htf-powersupply-4.0.6

> - implement Cyber Resilience Act Conformity (CRA)
> - update dependencies

### htf-powersupply-4.0.5

> - add support for Python 3.13

### 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`
