psw module

class psw.Psw

Bases: object

This module can control the PSW.

It supports USB interface to use SCPI.

It will scan available instruments on your DSO, then require a Serial Number to specify and connect to it.

Usage:

import psw
inst = psw.Psw()
inst.connect('<Instrument Serial Number>')
print(inst.idn())
inst.close()
clear_prot()

Clears over-voltage, over-current and overtemperature (OVP, OCP, OTP) protection circuits. It also clears the shutdown protection circuit.

close()

Close the connection.

connect(SN: str, baudrate: int = 115200, timeout: int = 3)

Connect to the PSW.

Parameters:
  • SN (str) – Serial Number is necessary.

  • baudrate (int, optional) – baudrate. Defaults to 115200.

  • timeout (int, optional) – timeout. Defaults to 3.

Returns:

0 or -1

Return type:

int

current() float

Queries the current level in amps.

Returns:

output current

Return type:

float

idn()
is_ocp_on()

Returns the OCP (over-current protection) status.

is_on()

Returns output status of the instrument.

is_prot_trip()

Returns the state of the protection circuits (OVP, OCP, OTP).

max_current

MAX Current for this instrument. You will get it after connection.

max_voltage

MAX Voltage for this instrument. You will get it after connection.

meas_current() float

Takes a measurement and returns the average output current

Returns:

output current

Return type:

float

meas_power() float

Takes a measurement and returns the average output power

Returns:

output power

Return type:

float

meas_voltage() float

Takes a measurement and returns the average output voltage

Returns:

output voltage

Return type:

float

min_current

MIN Current for this instrument. You will get it after connection.

min_voltage

MIN Voltage for this instrument. You will get it after connection.

mode() str

Returns the output mode.

Returns:

output mode

Return type:

str

ocp()

Queries the OCP (over-current protection) level in amps.

Returns:

current

Return type:

float

opc()
ovp()

Queries the overvoltage protection level.

Returns:

current

Return type:

float

query(cmd: str) str

Send a query SCPI command to the instrument and return the result.

Parameters:

cmd (str) – SCPI command to be queried.

Returns:

Result of the SCPI command.

Return type:

str

readline() str

Read a line from the instrument’s communication port and return it as a string.

Returns:

The string read from the instrument.

Return type:

str

scpi_delay

SCPI delay.

set_current(value)

Sets the current level in amps.

Parameters:

value – (float) output current level. (str): MAX or MIN

set_mode(mode: int)

Sets the PSW output mode.

Parameters:

mode (int) – 0:’CVHS’, 1:’CCHS’, 2:’CVLS’, 3:’CCLS’,

set_ocp(current: float)

Sets the OCP (over-current protection) level in amps.

set_ocp_off()

Turns OCP (over-current protection) off.

set_ocp_on()

Turns OCP (over-current protection) on.

set_off()

Turns the output off.

set_on()

Turns the output on.

set_ovp(voltage: float)

Sets the overvoltage protection level.

set_scpi_delay(delay: float)

Set the SCPI delay

Parameters:

delay (float) – delay time

set_voltage(value)

Sets the voltage level in volts.

Parameters:

value – (float) output voltage level. (str): MAX or MIN

voltage() float

Queries the voltage level in volts.

Returns:

output voltage

Return type:

float

write(cmd: str)

Write an SCPI command to the instrument.

Parameters:

cmd (str) – SCPI command to be written.