UXR module

Created on Mon Dec 1 20:17:32 2024

@author: Maxim Weizel

class Instruments_Libraries.UXR.UXR(resource_str='TCPIP0::KEYSIGH-Q75EBO9.local::hislip0::INSTR', num_channel=2, visa_library='@ivi')[source]

Bases: object

This class is using pyvisa to connect to Instruments. Please install PyVisa before using it.

Close()[source]
IDN()[source]

The *IDN? query returns the company name, oscilloscope model number, serial number, and software version by returning this string: Keysight Technologies,<Model #>,<USXXXXXXXX>,<Rev #>[,<Options>]

Returns:

Keysight Technologies,DSO9404A,USXXXXXXXX,XX.XX.XXXX

Return type:

str

OPC()[source]

Places a “1” into the output queue when all device operations have been completed

Returns:

1 or 0

Return type:

TYPE str

aquisition_done()[source]

The :ADER? query reads the Acquisition Done Event Register and returns 1 or 0. After the Acquisition Done Event Register is read, the register is cleared. The returned value 1 indicates an acquisition completed event has occurred and 0 indicates an acquisition completed event has not occurred.

Returns:

{1 | 0}

Return type:

int

aquisition_state()[source]

The :ASTate? query returns the acquisition state.

Returns:

{ARM | TRIG | ATRIG | ADONE}

Return type:

str

autoscale()[source]

The :AUToscale command causes the oscilloscope to evaluate all input waveforms and find the optimum conditions for displaying the waveform.

Return type:

None

autoscale_channels(value=None)[source]

The :AUToscale:CHANnels command selects whether to apply autoscale to all of the input channels or just the input channels that are currently displayed.

Parameters:

value (str, optional) – {ALL | DISPlayed}, if None then query

Returns:

{ALL | DISP}

Return type:

str

Raises:

ValueError – Expected one of: {ALL | DISP | DISPlayed }

channel_display(channel, state=None)[source]

The :CHANnel<N>:DISPlay command turns the display of the specified channel on or off.

Parameters:
  • channel (int) – An integer, analog input channel 1 or 2

  • state (int, str, optional) – ON, 1, OFF, 0

Returns:

The :CHANnel<N>:DISPlay? query returns the current display condition for the specified channel

Return type:

int

channel_range(channel, range_value=None)[source]

The :CHANnel<N>:RANGe command defines the full-scale vertical axis of the selected channel. The values represent the full-scale deflection factor of the vertical axis in volts. These values change as the probe attenuation factor is changed.

Parameters:
  • channel (int) – An integer, analog input channel 1 or 2

  • range_value (float, optional) – A real number for the full-scale voltage of the specified channel number, by default None

Returns:

full-scale vertical axis of the selected channel

Return type:

float

Raises:
  • ValueError – For Channel expected one of: num_channels

  • ValueError – For range_value expected to be < 2V

channel_scale(channel, scale_value=None)[source]

The :CHANnel<N>:SCALe command sets the vertical scale, or units per division, of the selected channel. This command is the same as the front-panel channel scale.

Parameters:
  • channel (int) – An integer, analog input channel 1 or 2

  • scale_value (float, optional) – A real number for the vertical scale of the channel in units per division, by default None

Returns:

A real number for the vertical scale of the channel in units per division

Return type:

float

Raises:
  • ValueError – For Channel expected one of: num_channels

  • ValueError – For range_value expected to be < 500mV/div

clear_status()[source]

The *CLS command clears all status and error registers.

Return type:

None

digitize(channel_num=None)[source]

This command initializes the selected channels or functions, then acquires them according to the current oscilloscope settings. When all waveforms are completely acquired, the oscilloscope is stopped. To Do: input can be: [CHANnel<N> | DIFF<D> | COMMonmode<C>]

Parameters:

channel_num (int) – Number of the Channel

Raises:

channel_numError – Expected one of: channel number

Return type:

None

function_display(function_num, state=None)[source]

The :FUNCtion<N>:DISPlay command turns the display of the specified function_num on or off.

Parameters:
  • function_num (int) – Function Number

  • state (int, str, optional) – ON, 1, OFF, 0

Returns:

The :FUNCtion<N>:DISPlay? query returns the current display condition for the specified function_num

Return type:

int

Raises:

ValueError – For function_num expected one of: 1-16

query(message)[source]
query_binary_values(message, datatype='h', container=<built-in function array>, data_points=0, **kwargs)[source]
reset()[source]

The *RST command performs a default setup which is the same as pressing the oscilloscope front panel [Default Setup] key.

Return type:

None

run()[source]

Set the scope in run mode.

Return type:

None

run_state()[source]

The :RSTate? query returns the run state:

Returns:

{RUN | STOP | SING}

Return type:

str

screenshot(path='./screenshot.png', with_time=True, time_fmt='%Y-%m-%d_%H-%M-%S', divider='_', timeout=5000)[source]

Save screen to {path} with {image_type}: bmp, jpg, gif, tif, png Adapted from: https://github.com/microsoft/Qcodes/blob/main/src/qcodes/instrument_drivers/Keysight/Infiniium.py

Parameters:
  • path (str)

  • with_time (bool)

  • time_fmt (str)

  • divider (str)

  • timeout (float)

single()[source]

Take a single acquisition

Return type:

None

status(key=None, value=None)[source]

The :STATus? query shows whether the specified channel, function, wmemory, histogram, measurement trend, measurement spectrum, or equalized waveform is on or off. TODO: Each type has a different range of values that is excepted. No Checking is implemented.

Parameters:
  • key (str, optional) – if None return status of Channel1

  • value (int, optional) – For Channel [1,2], for Function <=16

Returns:

A return value of 1 means on and a return value of 0 means off

Return type:

int

Raises:

ValueError – Expected one of: CHANNEL, FUNCTION, HIST, … etc.

stop()[source]

Set the scope in stop mode.

Return type:

None

system_header(state=None)[source]

!!!! SHOULD BE OFF !!!! The :SYSTem:HEADer command specifies whether the instrument will output a header for query responses. When :SYSTem:HEADer is set to ON, the query responses include the command header.

Parameters:

state (int | str | None, optional) – {{ON | 1} | {OFF | 0}}, by default None

Returns:

{1 | 0}

Return type:

int

Raises:

ValueError – Expected one of: {{ON | 1} | {OFF | 0}}

waveform_byteorder(value='LSBFIRST')[source]

The :WAVeform:BYTeorder command selects the order in which bytes are transferred from (or to) the oscilloscope using WORD and LONG formats

Parameters:

value (str, optional) – byteorder {MSBF, LSBF}, by default LSBFIRST

Returns:

byteorder {MSBF, LSBF}

Return type:

str

Raises:

ValueError – Expected one of: MSBFIRST, LSBFIRST

waveform_data(start=None, size=None, datatype='h', container=<built-in function array>, data_points=0, **kwargs)[source]

The :WAVeform:DATA? query outputs waveform data to the computer over the remote interface. The data is copied from a waveform memory, function, or channel previously specified with the :WAVeform:SOURce command.

Parameters:
  • start (int, optional) – Starting point in the source memory for the first waveform point to transfer, by default None.

  • size (int, optional) – Number of points in the source memory to transfer. If larger than available data, size is adjusted to the maximum available, by default None.

  • datatype (str, optional) – Data type for binary values as defined in Python struct, by default “h” (short).

  • container (type, optional) – Type of container to hold the data, by default np.array.

  • data_points (int, optional) – Expected number of data points, by default 0.

  • kwargs (dict, optional) – Additional arguments passed to the query_binary_values method.

Returns:

Acquired data.

Return type:

np.ndarray

Raises:
  • ValueError – If start or size are invalid (non-integers or negative).

  • NotImplementedError – If the waveform format is not “WORD”.

waveform_format(value=None)[source]

The :WAVeform:FORMat command sets the data transmission mode for waveform data output. This command controls how the data is formatted when it is sent from the oscilloscope, and pertains to all waveforms. To Do: Only WORD is tested. There is a FLOAT type?

Parameters:

value (str, optional) – One of {ASCii | BINary | BYTE | WORD }, by default None

Returns:

{ASC | BIN | BYTE | WORD }

Return type:

str

Raises:

ValueError – Expected one of: {ASCii | BINary | BYTE | WORD}

waveform_points()[source]

The :WAVeform:POINts? query returns the points value in the current waveform preamble.

Returns:

Number of points in the current waveform

Return type:

int

waveform_source(key=None, value=None)[source]

The :WAVeform:SOURce command selects a channel, function, waveform memory, or histogram as the waveform source TODO: No checks implemented

Parameters:
  • key (str | None, optional) – One of: {CHANnel<N> | DIFF<D> | COMMonmode<C> | FUNCtion<F> | HISTogram | WMEMory<R> | CLOCk | MTRend | MSPectrum | EQUalized | XT<X> | PNOise | INPut | CORRected | ERRor | LFPR | NREDuced}, by default None

  • value (int | None, optional) – Number e.g. 1 for Channel1, by default None

Returns:

The :WAVeform:SOURce? query returns the currently selected waveform source.

Return type:

str

waveform_streaming(state=None)[source]

When enabled, :WAVeform:STReaming allows more than 999,999,999 bytes of data to be transferred from the Infiniium oscilloscope to a PC when using the :WAVeform:DATA? query.

Parameters:

state (int | str | None, optional) – {{ON | 1} | {OFF | 0}}, by default None

Returns:

{1 | 0}

Return type:

int

waveform_x_increment()[source]

The :WAVeform:XINCrement? query returns the duration between consecutive data points for the currently specified waveform source.

Returns:

A real number representing the duration between data points on the X axis.

Return type:

float

waveform_x_origin()[source]

The :WAVeform:XORigin? query returns the X-axis value of the first data point in the data record.

Returns:

A real number representing the X-axis value of the first data point in the data record.

Return type:

float

waveform_y_increment()[source]

The :WAVeform:YINCrement? query returns the y-increment voltage value for the currently specified source.

Returns:

A real number in exponential format.

Return type:

float

waveform_y_origin()[source]

The :WAVeform:YORigin? query returns the y-origin voltage value for the currently specified source. The voltage value returned is the voltage value represented by the waveform data digital code 00000.

Returns:

A real number in exponential format.

Return type:

float

write(message)[source]