lab_driver.mxo4x#

Module Contents#

Classes#

API#

class lab_driver.mxo4x.DriverMXO4X[source]#

Initialization

Class for handling the Rohde and Schwarz Mixed-Signal Oscilloscope MXO44 in Python

SerialDevice: pyvisa.Resource | RsInstrument.RsInstrument#

None

SerialActive#

False

src_analogue#

‘tuple(…)’

src_digital#

‘tuple(…)’

src_math#

‘tuple(…)’

src_reference#

‘tuple(…)’

src_specmax#

‘tuple(…)’

src_specmin#

‘tuple(…)’

src_specnorm#

‘tuple(…)’

src_specaver#

‘tuple(…)’

src_spectrum#

None

src_all#

None

src_groups#

()

view_cmd_stack(entries: int = 0)[source]#
sync_device_time() None[source]#

Synchronise the device’s time with this computer’s. This is done automatically on every connection Returns: None

sync(timeout=86400000) None[source]#

Wait until all queued commands have been processed Args: timeout: timeout in milliseconds, VISA exception thrown on timeout, default 1 day Returns: None

serial_open_known_target(resource_name: str, do_reset=False) None[source]#

Open the serial connection to device Args: resource_name: name of the device do_reset: reset device during initialisation Returns: None

serial_start(do_reset=False) None[source]#

Open the serial connection to device if it is found Args: do_reset: reset device during initialisation Returns: None

serial_close() None[source]#

Close the serial connection Returns: None

get_id(do_print=True) str[source]#

Getting the device ID Args: do_print: optionally print the device ID to stdout Returns: Device ID as a string

do_reset() None[source]#

Reset the device, then wait two seconds Returns: None

set_display_activation(show_display: bool) None[source]#

Decide whether display is shown during remote control Args: show_display: True to show display, False to show static image (may improve performance) Returns: None

set_static_display_text(text: str) None[source]#

Display an additional text in remote control Args: text: text to display Returns: None

gen_set_default_index(gen_index: int) bool[source]#

Set which generator is affected by any of the gen_* functions by default Args: gen_index: index of new default generator: 1 or 2 Returns: True if generator index is not 1 or 2

gen_get_default_index() int[source]#

Get which generator is currently set as the default Returns: Default generator’s index: 1 or 2

gen_enable(gen_index: int = None) None[source]#

Enable waveform generator Args: gen_index: index of the target generator to affect (None for default) Returns: None

gen_disable(gen_index: int = None) None[source]#

Disable waveform generator Args: gen_index: index of the target generator to affect (None for default) Returns: None

gen_function(waveform: str, gen_index: int = None) bool[source]#

Select type of waveform function to be generated (case-insensitive) Args: waveform: SINE/SIN for sine function; SQUARE/SQU for square function; RAMP for ramp function; DC for DC function; PULSE/PULS for pulse function; CARDINAL/SINC for cardinal sine function; CARDIAC/CARD for cardiac function; GAUSS/GAUS for gaussian function; LORENTZ/LORN for lorentz function; EXP RISE/EXPR for exponential rise function; EXP FALL/EXPF for exponential fall function; ARBITRARY/ARB for arbitrary function gen_index: index of the target generator to affect (None for default) Returns: True if waveform function is invalid

gen_frequency(frequency: float, gen_index: int = None) None[source]#

Set frequency of waveform Args: frequency: frequency in Hz from [0.001,10^8], 0.001 increment gen_index: index of the target generator to affect (None for default) Returns: None

gen_amplitude(amplitude: float, gen_index: int = None) bool[source]#

Set amplitude of waveform Args: amplitude: amplitude in volt from [0.01,12], 0.01 increment gen_index: index of the target generator to affect (None for default) Returns: True if amplitude out of range

gen_offset(offset: float, gen_index: int = None) bool[source]#

Set vertical offset of generated waveform Args: offset: vertical offset in volt from [-5.995,+5.995], 0.01 increment gen_index: index of the target generator to affect (None for default) Returns: True if offset out of range

gen_preset(gen_index: int = None) None[source]#

Preset the generator to a default setup including following settings: Sine wavefunction, 1 MHz frequency and 1 Vpp amplitude Args: gen_index: index of the target generator to affect (None for default) Returns: None

dig_set_default_logic_group(logic_group: int) bool[source]#

Set the default logic group that shall be configured by dig_* functions Args: logic_group: default logic group (1-4) Returns: True if given group does not exist

dig_get_default_logic_group() int[source]#

Get the currently set default logic group Returns: Logic group from 1 to 4

dig_technology(tech, logic_group: int = None) bool[source]#

Select threshold voltage for various types of circuits and apply to all digital channels Args: tech: 15: TTL 25: CMOS 5.0 V 165: CMOS 3.3 V 125: CMOS 2.5 V 9: CMOS 1.85 V -13: ECL, -1.3 V 38: PECL 20: LVPECL 0: Ground logic_group: index of logic group to configure Returns: True if selected technology is unsupported

dig_threshold(threshold: float, channel_group: int = 1, logic_group: int = None) bool[source]#

Manually set a logical threshold voltage for some channel group Args: threshold: threshold voltage in volt in range [-8,+8] channel_group: 1 = digital channels 0…3 2 = digital channels 4…7 3 = digital channels 8…11 4 = digital channels 12…15 No channel group needed when coupling is enabled logic_group: index of logic group to configure Returns: True if channel group is invalid or threshold out of range

dig_enable(bits, logic_group: int = None) bool[source]#

Enable logic channels Args: bits: Either an int or an iterable of integers denoting the bits to enable logic_group: index of logic group to configure Returns: True if any bit indices are invalid (valid bits are applied)

dig_disable(bits, logic_group: int = None) bool[source]#

Disable logic channels Args: bits: Either an int or an iterable of integers denoting the bits to disable logic_group: index of logic group to configure Returns: True if any bit indices are invalid (valid bits are applied)

dig_show_dig_signals(logic_group: int = None) None[source]#

Show the digital signals on the GUI Returns: None

dig_hide_dig_signals(logic_group: int = None) None[source]#

Hide the digital signals on the GUI Returns: None

dig_hysteresis(level, channel_group: int = 1, logic_group: int = None) bool[source]#

Set hysteresis size for channels Args: level: level of hysteresis “NORMAL”, “ROBUST”, “MAXIMUM” or “SMALL”, “MEDIUM”, “LARGE” or 0, 1, 2; strings are case-insensitive channel_group: 1 = digital channels 0…3 2 = digital channels 4…7 3 = digital channels 8…11 4 = digital channels 12…15 No channel group needed when coupling is enabled Returns: True if channel group or hysteresis is invalid

dig_hysteresis_coupling(state: bool, logic_group: int = None) None[source]#

Set the threshold and hysteresis for all digital channels and all buses to the same value Args: state: True to couple all levels Returns: None

dig_show_bus(logic_group: int = None) None[source]#

Show the bus signal and values in the diagram Returns: None

dig_hide_bus(logic_group: int = None) None[source]#

Hide the bus signal and values in the diagram Returns: None

dig_bus_data_format(format: str, logic_group: int = None) bool[source]#

Set the data format for bus values, which are displayed in the decode table and the comb bus display Args: format: “HEX”, “OCT”, “BIN”, “ASCII”, “SIGNED” or “UNSIGNED” (case-insensitive) Returns: True if data format is invalid

dig_bus_header(logic_group: int = None) str[source]#

Get the header data of the indicated bus Returns: In order - XStart, acquisition time before trigger, in s; XStop, acquisition time after trigger, in s; Record length of the waveform in Samples; Number of values per sample interval, which is 1 for digital data.

sshot_get_default_config()[source]#

Get the number of the default screenshot output configuration Returns: Output configuration number

sshot_set_default_config(output_config: int) bool[source]#

Set which screenshot output configuration is used per default Args: output_config: 1 or 2 Returns: True if output config is invalid

sshot_get_filename() str[source]#

A string of the path and filename of screenshots Returns: Path string

sshot_set_filename(filename: str) None[source]#

Set filename and path of screenshots Args: filename: Path string Returns: None

sshot_destination(dest: str, output_config: int = None) bool[source]#

Select whether to save screenshot in a file or clipboard Args: dest: “FILE” or “CLIPBOARD” (case-insensitive) Returns: True if destination is invalid

sshot_file_format(format: str, output_config: int = None) bool[source]#

Screenshot file format when saving to a file Args: format: “JPG” or “PNG” (case-insensitive) Returns: True if format is invalid

sshot_invert_colours(state: bool, output_config: int = None) None[source]#

Invert all colours of the screenshot Args: state: True to invert colours, False to leave it unchanged Returns: None

sshot_white_background(state: bool, output_config: int = None) None[source]#

Invert only the background colour so it appears white in a screenshot Args: state: True for white background, False for black Returns: None

sshot_include_signal_bar(state: bool, output_config: int = None) None[source]#

Include the signal bar below the diagram area in a screenshot Args: state: True to include signal bar, False to hide it Returns: None

sshot_include_dialog_box(state: bool, output_config: int = None) None[source]#

Include any open dialog box in a screenshot Args: state: True to include dialog boxes on screenshots, False to hide them Returns: None

sshot_capture_now(output_config: int = None) None[source]#

Start immediate output of the display image to a screenshot, the display is automatically enabled if it’s currently showing a static image Returns: None

sshot_capture_next(output_config: int = None) None[source]#

Start output of the next display image to a screenshot, the display is automatically enabled if it’s currently showing a static image Returns: None

trig_event_mode(sequence: bool) None[source]#

Select whether to trigger on a single event or a sequence of events Args: sequence: True to enable trigger on a sequence of events, False for a single event

trig_source(source: str, event: int = 1) bool[source]#

Select the source of the trigger signal. Sequence trigger mode only allows analog sources. Args: source: C1, C2, C3, C4 for single or sequence event mode EXT, LINE, Dx for x in [0…15], SBUS1, SBUS2, SBUS3, SBUS4 only for single event mode event: 1 = A-trigger, 2 = B-trigger, 3 = reset event (for sequence trigger) Returns: True if source or event invalid

trig_delay(delay: float) None[source]#

Sets the time that the instrument waits after an A-trigger until it recognises B-triggers Args: delay: delay in seconds Returns: None

trig_b_trigger_count(count: int) None[source]#

Number of B-trigger conditions that need to happen before the B-trigger is actually triggered. Args: count: number of times B-trigger must occur in sequence from 1 to 2147483647 Returns: None

trig_toggle_reset_event(state: bool) None[source]#

Enable or disable the reset event in sequence event mode Args: state: True to enable, False to disable Returns: None

trig_toggle_reset_event_timeout(state: bool) None[source]#

Toggle whether event sequence shall time out when not receiving enough B-triggers in time Args: state: True to enable reset event by timeout, False to disable Returns: None

trig_reset_event_timeout_time(timeout: float) None[source]#

Set the time to elapse before reset event by timeout is triggered Args: timeout: Time in seconds from 0 to 50 Returns: None

trig_sequence_type(type: str) bool[source]#

Select the type of the trigger sequence Args: type: “A” for single event mode, “ABR” for sequence A → B → R, “AZ” for sequence A → Zone trigger, “ASB” for sequence A → Serial bus Returns: True if sequence type is invalid

trig_level(level: float, channel: int = 1, event: int = 1) bool[source]#

Sets the trigger level for the specified event and source (channel). If the trigger source is serial bus, the trigger level is set by the thresholds in the protocol configuration. Args: level: -10 to 10 volts, value is clamped channel: 1 to 4, index of analogue channel event: 1 = A-trigger, 2 = B-trigger, 3 = reset event (for sequence trigger) Returns: True if channel or event is invalid

trig_find_level() None[source]#

Automatically sets trigger level to 0.5 * (MaxPeak - MinPeak). In a trigger sequence, all events (A, B and R) are affected. This function does not work for trigger sources Extern and Line. Returns: None

trig_edge_direction(direction: lab_driver.units.Threeway, event: int = 1) bool[source]#

Set edge direction for trigger Args: direction: NEGATIVE for falling edge, POSITIVE for rising edge, NEUTRAL for either. event: 1 = A-trigger, 2 = B-trigger, 3 = reset event (for sequence trigger) Returns: True if direction or event is invalid

trig_edge_level(level: float) None[source]#

Set external trigger source trigger level Args: level: -5 to 5 volts, value is clamped Returns: None

trig_edge_coupling(coupling: str) bool[source]#

Sets the connection of the external trigger signal, i.e. the input impedance and a termination. The coupling determines what part of the signal is used for triggering. Args: coupling: “DC” - Connection with 50 Ω termination, passes both DC and AC components of the signal. “DCLimit” - Connection with 1 MΩ termination, passes both DC and AC components of the signal. “AC” - Connection with 1 MΩ termination through DC capacitor, removes DC and very low-frequency components. The waveform is centered on zero volts. Returns: True if coupling mode is invalid

trig_edge_filter(filter: lab_driver.units.Threeway) bool[source]#

Select filter mode for external signal Args: filter: LOW for lowpass filter, HIGH for highpass filter, OFF to disable filter Returns: True if filter mode is invalid

trig_edge_highpass(cutoff: int) bool[source]#

Frequencies below the cutoff frequency are rejected, higher frequencies pass the filter Args: cutoff: 5 or 50 (unit: KHz) Returns: True if cutoff frequency is invalid

trig_edge_lowpass(cutoff: int) bool[source]#

Frequencies higher than the cutoff frequency are rejected, lower frequencies pass the filter Args: cutoff: 50 or 50000 (unit: KHz) Returns: True if cutoff frequency is invalid

trig_edge_noisereject(state: bool) None[source]#

Enable an automatic hysteresis on the trigger level to avoid unwanted trigger events caused by noise.
Args: state: True for noise rejection, False to disable Returns: None

trig_export_on_trigger(state: bool) None[source]#

Decide whether the waveform is saved to a file on a trigger event Args: state: True to export waveform data on trigger, False to do nothing Returns: None

is_source_active(source: str) bool[source]#
export_scope(scope: str) bool[source]#

Defines the part of the waveform record that will be stored Args: scope: (case-insensitive) “DISPLAY” - waveform data that is displayed in the diagram. “ALL” - entire waveform, usually larger than what is displayed. “CURSOR” - data between the cursor lines if a cursor measurement is defined for the source waveform. “GATE” - data included in the measurement gate if a gated measurement is defined for the source waveform. “MANUAL” - data between user-defined start and stop values. Returns: True if scope is invalid

export_manual_start(time: float) None[source]#

Set the start time value for waveform export in MANUAL mode Args: time: start time from -1e26 to +1e26 in seconds with 2 decimal precision (value is clamped to fit range) Returns: None

export_manual_stop(time: float) None[source]#

Set the end time value for waveform export in MANUAL mode Args: time: end time from -1e26 to +1e26 in seconds with 2 decimal precision (value is clamped to fit range) Returns: None

export_save() None[source]#

Save the waveform to the specified file Returns: None

export_abort() None[source]#

Abort a running export started by export_save() Returns: None

export_cursor_set(set: int) bool[source]#

If export scope was set to CURSOR, set the cursor set to be used Args: set: 1 or 2 for CURSOR1 or CURSOR2 Returns: True if cursor set is not 1 or 2

export_sources(*src: str) bool[source]#

Select all waveforms to be exported to the file. At least firmware (2.3.2.2) needed for multiple waveforms, else only the first source is selected.
Args: *src: One or more of the following waveforms Analogue - “C1”,“C2”,“C3”,“C4”. Digital - “D0”,“D1”,“D2”,“D3”,“D4”,“D5”,“D6”,“D7”,“D8”,“D9”,“D10”,“D11”,“D12”,“D13”,“D14”,“D15”. Math - “M1”,“M2”,“M3”,“M4”,“M5”. Reference - “R1”,“R2”,“R3”,“R4”. Spectrum - “SPECMAXH1”,“SPECMAXH2”,“SPECMAXH3”,“SPECMAXH4”, “SPECMINH1”,“SPECMINH2”,“SPECMINH3”,“SPECMINH4”, “SPECNORM1”,“SPECNORM2”,“SPECNORM3”,“SPECNORM4”, “SPECAVER1”,“SPECAVER2”,“SPECAVER3”,“SPECAVER4”. Returns: True if any of the waveforms are invalid, no changes are applied in that case

export_set_filename(filename: str) bool[source]#

Set the filename for waveform exports. Local storage is in /home/storage/userData Args: filename: Path and filename with extension .csv or .ref for single waveform exports and .ref or .zip for multiple waveform exports Returns: True if filename doesn’t end on .csv, .ref or .zip no other checks are done!

export_get_filename() str[source]#

Get the currently set filename for waveform exports Returns: Path and filename for waveform exports as a string

fra_enter() None[source]#

Enter frequency response analysis mode. This is done automatically whenever an FRA function is called. Returns: None

fra_exit()[source]#

Exit frequency response analysis mode Returns: None

fra_freq_start(freq: float) None[source]#

Set the start frequency of the sweep Args: freq: Frequency in Hz from 10 mHz to 100 MHz (value will be clamped) Returns: None

fra_freq_stop(freq: float) None[source]#

Set the stop frequency of the sweep Args: freq: Frequency in Hz from 10 mHz to 100 MHz (value will be clamped) Returns: None

fra_run() None[source]#

Run the frequency response analysis Returns: None

fra_stop() None[source]#

Stop the frequency response analysis Returns: None

fra_generator(channel: int) bool[source]#

Select built-in generator for a frequency sweep Args: channel: 1 or 2 Returns: True for invalid channel number

fra_generator_amplitude(amplitude: float) None[source]#
fra_input_channel(channel: int) bool[source]#

Set the channel used for the input signal of the device Args: channel: 1 to 4 Returns: True for invalid channel number

fra_output_channel(channel: int) bool[source]#

Set the channel used for the output signal of the device Args: channel: 1 to 4 Returns: True for invalid channel number

fra_repeat(state: bool) None[source]#

Whether to repeat the measurement using the same parameters Args: state: True to repeat Returns: None

fra_reset() None[source]#

Reset the frequency response analysis Returns: None

fra_autoscale(state: bool) None[source]#

Enable or disable the autoscaling function for each measurement Args: state: True to enable autoscaling, False to disable Returns: None

fra_with_offset(offset: float = 0, wait_time: float = 1) None[source]#

Start an FRA using the PCB-Addon board to generate a waveform and add an offset to it. GEN1 is the signal generator and GEN2 is the DC offset. Args: offset: GEN2 DC offset added to the signal generated by GEN1 wait_time: Time to wait after application of settings, before running the FRA Returns: None

fra_export_results(results: bool = None, marker: bool = None, margin: bool = None) None[source]#

Export the results of the FRA measurement to a file Args: results: True to export FRA results; frequency, gain, phase and amplitude of each sample marker: True to export marker results; frequency, gain and phase margin: True to export margin results; frequency and value/gain and phase Returns: None

fra_wait_for_finish() None[source]#

Wait for the FRA analysis to finish. This is a blocking function Returns: None

live_command_mode() None[source]#

DEBUGGING - enter statements during the execution of the program using the Python interpreter. Results and errors are printed. Returns: None

test(cmd: str)[source]#

Test any command with the device Args: cmd: Some command to be sent to the device Returns: Result of the command if it was a query, None if it was a write command