asr module

class asr.Asr

Bases: object

This module can control ASR-2100.

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 asr
inst = asr.Asr()
inst.connect('<Instrument Serial Number>')
print(inst.idn())
inst.close()
clear_output_protection() None

Clear output protection alarms.

Description:

This command clears alarms such as Over Current, Over Peak Current, Output Over-Power, Output Short, Output Overvoltage, and Sensing Voltage Error.

close() None

Close the connection.

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

Connect to the ASR.

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

err() str
get_active_power() float

Returns the active power (P) in Watts.

get_apparent_power() float

Returns the apparent power (S) in VA.

get_crest_factor() float

Returns the output current crest factor (CF).

get_frequency() float

Returns the SYNC signal source frequency in Hz. (Only AC+DC-sync or AC-sync Active)

get_iavg() float

Returns the output current average value (Iavg) in amps.

get_imax() float

Returns the output current maximum peak value (Imax) in amps.

get_imin() float

Returns the output current minimum peak value (Imin) in amps.

get_irms() float

Returns the output current RMS (Irms) value in amps.

get_output_mode() str

Queries the output mode of the power supply.

Returns:

The current output mode. Possible return values are:

’ACDC-INT’ (0), ‘AC-INT’ (1), ‘DC-INT’ (2), ‘ACDC-EXT’ (3), ‘AC-EXT’ (4), ‘ACDC-ADD’ (5), ‘AC-ADD’ (6), ‘ACDC-SYNC’ (7), ‘AC-SYNC’ (8).

Return type:

str

get_power_factor() float

Returns the power factor (PF).

get_reactive_power() float

Returns the reactive power (Q) in VAR.

get_seq_condition() int

Queries the current sequence status in Sequence Mode. (Only Sequence Mode Active)

Returns:

Current sequence status. Possible values are:
  • 0: Idle mode

  • 1: Run mode

  • 2: Hold mode

Return type:

int

get_seq_cstep() int

Returns the currently running step number. (Only Sequence Mode Active)

Returns:

The current step number (positive integer).

Return type:

int

get_sim_condition() int

Returns the simulation status. (Only Simulation Mode Active)

Returns:

Current simulation status. Possible values are:
  • 0: Idle mode

  • 1: Run mode

  • 2: Hold mode

Return type:

int

get_vavg() float

Returns the voltage average value (Vavg) in volts.

get_vmax() float

Returns the output voltage maximum peak value (Vmax) in volts.

get_vmin() float

Returns the output voltage minimum peak value (Vmin) in volts.

get_vrms() float

Returns the voltage (Vrms).

idn() str
is_on() bool

Get the output state of power source.

opc() int
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_IPK_limit(high: str = 'MAX', low: str = 'MIN', enable: bool = True) None

Set the Ipk high and low limit parameters and enable/disable the limit for continuous operation mode.

Parameters:
  • high (float, str, optional) – Ipk-High Limit in Arms, or ‘MAX’, ‘MIN’.

  • low (float, str, optional) – Ipk-Low Limit in Arms, or ‘MAX’, ‘MIN’.

  • enable (bool, optional) – If True, enables the Ipk limit. If False, disables it.

set_Irms(Irms: str | None = None, enable: bool | None = None) None

Set the Irms parameter and enable/disable the Irms limit for continuous operation mode.

Parameters:
  • Irms (float, str, optional) – Irms in A., or ‘MAX’, ‘MIN’.

  • enable (bool, optional) – If True, enables the Irms limit. If False, disables it.

set_THD(format: str) None

Sets the THD format.

Parameters:

format (str, bool) – THD format to set. Acceptable values are ‘IEC’ (0), or ‘CSA’ (1).

set_external_control(state: str) None

Sets the external control state (on/off).

Parameters:

state (str or int) – ‘ON’ (1) to enable external control, ‘OFF’ (0) to disable.

set_freeze_hold(state: str) None

Sets the freeze hold state (on/off).

Parameters:

state (str or int) – ‘ON’ (1) to enable freeze hold, ‘OFF’ (0) to disable.

set_frequency(high: str | None = None, low: str | None = None, freq: str | None = None) None

Set the frequency parameters including upper limit, lower limit, and immediate frequency value. (Only AC+DC-INT or AC-INT or AC+DC-ADD or AC-ADD Active)

Parameters:
  • high (float, str, optional) – The upper frequency limit in Hz or ‘MIN’, ‘MAX’.

  • low (float, str, optional) – The lower frequency limit in Hz or ‘MIN’, ‘MAX’.

  • freq (float, str, optional) – The immediate frequency value in Hz or ‘MIN’, ‘MAX’.

set_gain(gain: str) None

Sets the input gain value. (Only AC+DC-EXT or AC-EXT or AC+DC-ADD or AC-ADD Active)

Parameters:

gain (float or str) – Input gain value in volts, or ‘MINimum’ / ‘MAXimum’.

set_ipeak_hold_time(time_ms: int) None

Sets the Ipeak hold time for peak current measurement when output is on.

Parameters:

time_ms (int) – The Ipeak hold time in milliseconds (1 to 60,000).

set_off() None

Turns the output off.

set_on() None

Turns the output on.

set_output_mode(mode: str) None

Sets the output mode of the power supply.

Parameters:

mode (str, optional) – Output mode to set. Acceptable values are: ‘ACDC-INT’ (0), ‘AC-INT’ (1), ‘DC-INT’ (2), ‘ACDC-EXT’ (3), ‘AC-EXT’ (4), ‘ACDC-ADD’ (5), ‘AC-ADD’ (6), ‘ACDC-SYNC’ (7), ‘AC-SYNC’ (8).

set_output_pon(mode: str) None

Set the output state at power-on.

Parameters:

mode (int, str) – The output state to set at power-on. Acceptable values are: 0 or ‘OFF’ - Disabled 1 or ‘ON’ - Enabled 2 or ‘SEQ’ - Sequence function 3 or ‘SIM’ - Simulate function

set_output_relay(state: str) None

Sets the output relay of the power source.

Parameters:

state (str or int) – ‘ON’ (1) to enable the output relay, ‘OFF’ (0) to disable.

set_phase_parameters(start_state: str | None = None, stop_state: str | None = None, start_phase: float | None = None, stop_phase: float | None = None) None

Sets the state and phase values for the start and stop phases. (Not available for DC-INT, AC+DC-EXT and AC-EXT)

Parameters:
  • start_state (str, optional) – State of start phase. Acceptable values are ‘FREE’, ‘FIXED’, or 0 (FREE), 1 (FIXED).

  • stop_state (str, optional) – State of stop phase. Acceptable values are ‘FREE’, ‘FIXED’, or 0 (FREE), 1 (FIXED).

  • start_phase (float, optional) – Start phase value in degrees. Acceptable values are: 0 to 359.9, ‘MIN’, or ‘MAX’.

  • stop_phase (float, optional) – Stop phase value in degrees. Acceptable values are: 0 to 359.9, ‘MIN’, or ‘MAX’.

set_scpi_delay(delay: float) None

Set the SCPI delay

Parameters:

delay (float) – delay time

set_seq_execute(action: str) None

Sets the execution actions in sequence mode. (Only Sequence Mode Active)

Parameters:

action (str) – Action to be executed. Acceptable values are: - ‘STOP’: Stops sequence execution - ‘STARt’: Starts sequence execution - ‘HOLD’: Holds sequence execution - ‘BRAN1’: Jumps to Branch 1 execution - ‘BRAN2’: Jumps to Branch 2 execution

set_seq_parameters(step: int | None = None, cparams: dict | None = None, sparams: dict | None = None) None

Sets the common parameters for the Sequence mode. (Only Sequence Mode Active)

Parameters:
  • step (int, optional) – Current step number (0 to 999).

  • cparams (dict, optional) – Dictionary containing the parameters. Acceptable keys are: - ‘step_time’ (float): Step time. - ‘on_phase’ (float): On phase value. - ‘on_phase_st’ (str or int): On phase state, can be ‘FIXED’ (‘ON’) (1), or ‘FREE’ (‘OFF’) (0). - ‘off_phase’ (float): Off phase value. - ‘off_phase_st’ (str or int): Off phase state, can be ‘FIXED’ (‘ON’) (1), or ‘FREE’ (‘OFF’) (0). - ‘term’ (str): Termination settings, can be ‘CONTinue’, ‘END’, or ‘HOLD’. - ‘jump_to’ (int): Jump step number (0 to 999). - ‘jump_st’ (str or int): Jump state, can be ‘ON’ (1), or ‘OFF’ (0). - ‘jump_cnt’ (int): Jump count (0 to 9999). - ‘sync’ (int): Synchronous code for each step, can be 0, 1 , 2 , or 3. (0: LL, 1: LH, 2: HL, 3: HH). - ‘br1’ (int): Branch 1 number (0 to 999). - ‘br1_st’ (str or int): Branch 1 state, can be ‘ON’ (1), or ‘OFF’ (0). - ‘br2’ (int): Branch 2 number (0 to 999). - ‘br2_st’ (str or int): Branch 2 state, can be ‘ON’ (1), or ‘OFF’ (0).

  • sparams (dict, optional) – Dictionary containing the step-specific parameters. Acceptable keys are: - ‘acv’ (float): AC voltage setting. - ‘acv_mode’ (str or int): ACV mode, can be ‘CONSt’ (0), ‘KEEP’ (1), or ‘SWEep’ (2). - ‘dcv’ (float): DC voltage setting (not applicable, will be ignored). - ‘dcv_mode’ (str or int): DCV mode, can be ‘CONSt’ (0), ‘KEEP’ (1), or ‘SWEep’ (2). - ‘freq’ (float): Frequency setting. - ‘freq_mode’ (str or int): Frequency mode, can be ‘CONSt’ (0), ‘KEEP’ (1), or ‘SWEep’ (2). - ‘waveform’ (str): Waveform type, can be ‘SIN’, ‘SQU’, ‘TRI’, or ‘ARB1’ to ‘ARB16’. - ‘phase’ (int): Phase angle (fixed to 0).

set_sim_abnormal(code: str | None = None, freq: str | None = None, ph_start_st: str | None = None, ph_start: str | None = None, ph_stop_st: str | None = None, ph_stop: str | None = None, time: str | None = None, volt: str | None = None) None

Sets the abnormal step parameters in Simulation mode. (Only Simulation Mode Active)

Parameters:
  • code (int or str, optional) – External trigger output code, can be 0, 1, 2, 3, ‘MINimum’, or ‘MAXimum’. (0: LL, 1: LH, 2: HL, 3: HH).

  • freq (float or str, optional) – Frequency of the abnormal step, can be a frequency value, ‘MINimum’, or ‘MAXimum’.

  • ph_start_st (str or int, optional) – ON phase state, can be ‘FIXED’ (‘ON’) (1), or ‘FREE’ (‘OFF’) (0).

  • ph_start (float or str, optional) – ON phase (start phase) value, can be a value between 0 and 359.9, ‘MINimum’, or ‘MAXimum’.

  • ph_stop_st (str or int, optional) – OFF phase state, can be ‘FIXED’ (‘ON’) (1), or ‘FREE’ (‘OFF’) (0).

  • ph_stop (float or str, optional) – OFF phase (stop phase) value, can be a value between 0 and 359.9, ‘MINimum’, or ‘MAXimum’.

  • time (str, optional) – Time value of the abnormal step, can be a time in seconds, ‘MINimum’, or ‘MAXimum’.

  • volt (str, optional) – Voltage value of the abnormal step, can be a numeric voltage value, ‘MINimum’, or ‘MAXimum’.

set_sim_execute(action: str) None

Sets the execution actions in simulation mode. (Only Simulation Mode Active)

Parameters:

action (str) – Action to be executed. Acceptable values are: - ‘STOP’: Stops simulation execution - ‘STARt’: Starts simulation execution - ‘HOLD’: Holds simulation execution

set_sim_initial(code: str | None = None, freq: str | None = None, ph_start_st: str | None = None, ph_start: str | None = None, ph_stop_st: str | None = None, ph_stop: str | None = None, volt: str | None = None) None

Sets the initial step parameters in Simulation mode. (Only Simulation Mode Active)

Parameters:
  • code (int or str, optional) – External trigger output code, can be 0, 1, 2, 3, ‘MINimum’, or ‘MAXimum’. (0: LL, 1: LH, 2: HL, 3: HH).

  • freq (float or str, optional) – Frequency of the initial step, can be a frequency value, ‘MINimum’, or ‘MAXimum’.

  • ph_start_st (str or int, optional) – ON phase state, can be ‘FIXED’ (‘ON’) (1), or ‘FREE’ (‘OFF’) (0).

  • ph_start (float or str, optional) – ON phase (start phase) value, can be a value between 0 and 359.9, ‘MINimum’, or ‘MAXimum’.

  • ph_stop_st (str or int, optional) – OFF phase state, can be ‘FIXED’ (‘ON’) (1), or ‘FREE’ (‘OFF’) (0).

  • ph_stop (float or str, optional) – OFF phase (stop phase) value, can be a value between 0 and 359.9, ‘MINimum’, or ‘MAXimum’.

  • volt (float or str, optional) – Voltage value of the initial step, can be a numeric voltage value, ‘MINimum’, or ‘MAXimum’.

set_sim_normal(norm_idx: int, code: str | None = None, freq: str | None = None, ph_start_st: str | None = None, ph_start: str | None = None, ph_stop_st: str | None = None, ph_stop: str | None = None, time: str | None = None, volt: str | None = None) None

Sets the normal 1 or normal 2 step parameters in simulation mode. (Only Simulation Mode Active)

Parameters:
  • norm_idx (int) – Normal index number, 1 for normal 1, 2 for normal 2.

  • code (int or str, optional) – External trigger output code, can be 0, 1, 2, 3, ‘MINimum’, or ‘MAXimum’. (0: LL, 1: LH, 2: HL, 3: HH).

  • freq (float or str, optional) – Frequency of the normal 1 step, can be a frequency value, ‘MINimum’, or ‘MAXimum’.

  • ph_start_st (str or int, optional) – ON phase state, can be ‘FIXED’ (‘ON’) (1), or ‘FREE’ (‘OFF’) (0).

  • ph_start (float or str, optional) – ON phase (start phase) value, can be a value between 0 and 359.9, ‘MINimum’, or ‘MAXimum’.

  • ph_stop_st (str or int, optional) – OFF phase state, can be ‘FIXED’ (‘ON’) (1), or ‘FREE’ (‘OFF’) (0).

  • ph_stop (float or str, optional) – OFF phase (stop phase) value, can be a value between 0 and 359.9, ‘MINimum’, or ‘MAXimum’.

  • time (float or str, optional) – Time value of the normal step, can be a time in seconds (0.0001 to 999.9999), ‘MINimum’, or ‘MAXimum’.

  • volt (float or str, optional) – Voltage value of the normal 1 step, can be a numeric voltage value, ‘MINimum’, or ‘MAXimum’.

set_sim_repeat(count: str | None = None, enable: str | None = None)

Configures the repeat parameters for the simulation mode. (Only Simulation Mode Active)

Parameters:
  • count (int or str, optional) – Repeat count, can be a value between 0 and 9999 (0 = infinite loop), ‘MINimum’ or ‘MAXimum’.

  • enable (int or str, optional) – Enables or disables the repeat function, can be ‘ON’ (1), or ‘OFF’ (0)..

set_sim_transition(trans_idx: int, time: str | None = None, code: str | None = None) None

Sets the transition step parameters in Simulation mode. (Only Simulation Mode Active)

Parameters:
  • trans_idx (int) – Transition index number, 1 for transition 1, 2 for transition 2.

  • time (float or str, optional) – Time value of the transition step, can be a time in seconds (0 to 999.9999), ‘MINimum’, or ‘MAXimum’.

  • code (int or str, optional) – External trigger output code, can be 0, 1, 2, 3, ‘MINimum’, or ‘MAXimum’. (0: LL, 1: LH, 2: HL, 3: HH).

set_slew_mode(mode: str) None

Sets the slew mode.

Parameters:

mode (str or int) – ‘TIME’ (0) to set the Time mode or ‘SLOPe’ (1) to set the Slope mode.

set_sync_source(source: str) None

Sets the sync source state. (Only AC+DC-sync or AC-sync Active)

Parameters:

source (str) – Sync source, can be ‘LINE’(0) or ‘EXT’(1).

set_test_mode(mode: str) None

Sets the test mode for the power supply.

Parameters:

mode (str) – The test mode to be set. Acceptable values are: - ‘CONTinuous’ or 0: Continuous mode (normal operating mode). - ‘SEQuence’ or 1: Sequence mode (available for AC+DC-INT, AC-INT, DC-INT modes). - ‘SIMulation’ or 2: Simulation mode (available only for AC+DC-INT mode).

set_voltage_parameters(volt_range: str | None = None, limit_vrms: str | None = None, limit_vpp: str | None = None, limit_vpk_h: str | None = None, limit_vpk_l: str | None = None, vrms: str | None = None, offset: str | None = None) None

Sets various voltage parameters for the power supply.

Parameters:
  • volt_range (str, optional) – Voltage range. Acceptable values are: 100, 200, ‘AUTO’. AUTO is only available in AC+DC-INT, AC-INT, DC-INT, AC+DC-SYNC, or AC-SYNC modes.

  • limit_vrms (str, optional) – RMS voltage limit. Acceptable values are: Any valid Vrms value, ‘MIN’, ‘MAX’. Only available in AC-INT, AC-ADD, or AC-SYNC modes.

  • limit_vpp (str, optional) – Vpp limit. Acceptable values are: Any valid Vpp value, ‘MIN’, ‘MAX’. Only available in AC-INT, AC-ADD, or AC-SYNC modes, with specific wave shape(TRI or ARB) and specific voltage Unit(p-p).

  • limit_vpk_h (str, optional) – Voltage high limit. Acceptable values are: Any valid voltage high limit value, ‘MIN’, ‘MAX’. Only available in AC+DC-INT, DC-INT, AC+DC-ADD, or AC+DC-SYNC modes.

  • limit_vpk_l (str, optional) – Voltage low limit. Acceptable values are: Any valid voltage low limit value, ‘MIN’, ‘MAX’. Only available in AC+DC-INT, DC-INT, AC+DC-ADD, or AC+DC-SYNC modes.

  • vrms (str, optional) – RMS voltage value. Acceptable values are: Any valid Vrms value, ‘MIN’, ‘MAX’. Not available in DC-INT, AC+DC-EXT, or AC-EXT modes.

  • offset (str, optional) – Voltage offset value. Acceptable values are: Any valid voltage offset value, ‘MIN’, ‘MAX’. Only available in AC+DC-INT, DC-INT, AC+DC-ADD, or AC+DC-SYNC modes.

set_voltage_unit(unit: str) None

Sets the unit of voltage for specific wave shapes (TRI or ARB).

Parameters:

unit (str or int) – ‘RMS’ (0) to set the voltage unit as RMS, or ‘P-P’ (1) to set it as peak-to-peak (P-P).

set_waveform(waveform: str) None

Sets the waveform of the power supply. (Not available for DC-INT, AC+DC-EXT, and AC-EXT)

Parameters:

waveform (str) – The waveform to set. Can be one of the following: - ‘ARB1’ (0): Arbitrary wave 1 - ‘ARB2’ (1): Arbitrary wave 2 - ‘ARB3’ (2): Arbitrary wave 3 - ‘ARB4’ (3): Arbitrary wave 4 - ‘ARB5’ (4): Arbitrary wave 5 - ‘ARB6’ (5): Arbitrary wave 6 - ‘ARB7’ (6): Arbitrary wave 7 - ‘ARB8’ (7): Arbitrary wave 8 - ‘ARB9’ (8): Arbitrary wave 9 - ‘ARB10’ (9): Arbitrary wave 10 - ‘ARB11’ (10): Arbitrary wave 11 - ‘ARB12’ (11): Arbitrary wave 12 - ‘ARB13’ (12): Arbitrary wave 13 - ‘ARB14’ (13): Arbitrary wave 14 - ‘ARB15’ (14): Arbitrary wave 15 - ‘ARB16’ (15): Arbitrary wave 16 - ‘SIN’ (16): Sin wave - ‘SQU’ (17): Square wave - ‘TRI’ (18): Triangle wave

write(cmd: str) None

Write an SCPI command to the instrument.

Parameters:

cmd (str) – SCPI command to be written.