Skip to content

tenma_ps

python package for controlling tenma power supply

source manual


TenmaPs(port)

Interface for a Tenma power supply device.

This class manages connection to a Tenma power supply, allowing users to retrieve device status and control voltage/current settings.

Attributes:

Name Type Description
VOLTAGE_MULTIPLIER float

Multiplier to convert volts to millivolts.

CURRENT_MULTIPLIER float

Multiplier to convert amps to milliamps.

Example
from tenma_ps.power_supply import TenmaPs

with TenmaPs("COM4") as tenma_ps:
    print("Device version:", tenma_ps.get_version())
    print("Device status:", tenma_ps.get_status())

    # Set voltage and current on channel 1
    tenma_ps.set_voltage(channel=1, voltage=5.0)
    tenma_ps.set_current(channel=1, current=1.0)

    # Read voltage and current from channel 1
    voltage = tenma_ps.read_voltage(channel=1)
    current = tenma_ps.read_current(channel=1)
    print(f"Channel 1 Voltage: {voltage} V")
    print(f"Channel 1 Current: {current} A")

    # Turn on and off the power supply
    tenma_ps.turn_on()
    print("Power supply turned ON.")
    tenma_ps.turn_off()
    print("Power supply turned OFF.")

Initialize the Tenma power supply interface.

Parameters:

Name Type Description Default
port str

The COM port (e.g., "COM4") to which the device is connected.

required

Raises:

Type Description
Exception

If the connection to the device fails.

__enter__()

Enter the runtime context for the TenmaPs object.

Returns:

Name Type Description
TenmaPs TenmaPs

The TenmaPs instance.

__exit__(exc_type, exc_value, traceback)

Exit the runtime context and clean up resources.

Parameters:

Name Type Description Default
exc_type Optional[Type[BaseException]]

Exception type, if any.

required
exc_value Optional[BaseException]

Exception value, if any.

required
traceback Optional[object]

Traceback object, if any.

required

close()

Close the connection to the Tenma power supply.

get_status()

Get the current status of the Tenma power supply.

Returns:

Name Type Description
str str

The status string reported by the device.

get_version()

Get the version information of the Tenma power supply.

Returns:

Name Type Description
str str

The version string reported by the device.

read_current(channel)

Read the current from a specified channel.

Parameters:

Name Type Description Default
channel int

The channel number to read from.

required

Returns:

Name Type Description
float float

The current value in amps.

read_voltage(channel)

Read the voltage from a specified channel.

Parameters:

Name Type Description Default
channel int

The channel number to read from.

required

Returns:

Name Type Description
float float

The voltage value in volts.

set_current(channel, current)

Set the current for a specified channel.

Parameters:

Name Type Description Default
channel int

The channel number to set.

required
current float

The current value in amps.

required

set_voltage(channel, voltage)

Set the voltage for a specified channel.

Parameters:

Name Type Description Default
channel int

The channel number to set.

required
voltage float

The voltage value in volts.

required

turn_off()

Power off the Tenma power supply.

turn_on()

Power on the Tenma power supply.