# Teledyne Oscilloscope base classes

## Teledyne Oscilloscope

class pymeasure.instruments.teledyne.TeledyneOscilloscope(adapter, name='Teledyne Oscilloscope', **kwargs)

  Bases: `SCPIUnknownMixin`, `Instrument`

  A base abstract class for any Teledyne Lecroy oscilloscope.

  All Teledyne oscilloscopes have a very similar interface, hence this base class to combine them. Note that specific models will likely have conflicts in their interface.

  Attributes:

    WRITE_INTERVAL_S: minimum time between two commands. If a command is received less than WRITE_INTERVAL_S after the previous one, the code blocks until at least WRITE_INTERVAL_S seconds have passed. Because the oscilloscope takes a non neglibile time to perform some operations, it might be needed for the user to tweak the sleep time between commands. The WRITE_INTERVAL_S is set to 10ms as default however its optimal value heavily depends on the actual commands and on the connection type, so it is impossible to give a unique value to fit all cases. An interval between 10ms and 500ms second proved to be good, depending on the commands and connection latency.

  ch_1
    Channel:

      `TeledyneOscilloscopeChannel`

  ch_2
    Channel:

      `TeledyneOscilloscopeChannel`

  ch_3
    Channel:

      `TeledyneOscilloscopeChannel`

  ch_4
    Channel:

      `TeledyneOscilloscopeChannel`

  autoscale()

    Autoscale displayed channels.

  property bwlimit

    Set the internal low-pass filter for all channels.(dynamic)

  center_trigger()

    Set the trigger levels to center of the trigger source waveform.

  ch(source)

    Get channel object from its index or its name. Or if source is “math”, just return the scope object.

    Parameters:

      source – can be 1, 2, 3, 4 or C1, C2, C3, C4, MATH

    Returns:

      handle to the selected source.

  default_setup()

    Set up the oscilloscope for remote operation.

    The COMM_HEADER command controls the way the oscilloscope formats response to queries. This command does not affect the interpretation of messages sent to the oscilloscope. Headers can be sent in their long or short form regardless of the CHDR setting. By setting the COMM_HEADER to OFF, the instrument is going to reply with minimal information, and this makes the response message much easier to parse. The user should not be fiddling with the COMM_HEADER during operation, because if the communication header is anything other than OFF, the whole driver breaks down.

  display_parameter(parameter, channel)

    Same as the display_parameter method in the Channel subclass.

  download_image()

    Get a BMP image of oscilloscope screen in bytearray of specified file format.

  download_waveform(source, requested_points=None, sparsing=None)

    Get data points from the specified source of the oscilloscope.

    The returned objects are two np.ndarray of data and time points and a dict with the waveform preamble, that contains metadata about the waveform.

    Parameters:

      - source – measurement source. It can be “C1”, “C2”, “C3”, “C4”, “MATH”.

      - requested_points – number of points to acquire. If None the number of points requested in the previous call will be assumed, i.e. the value of the number of points stored in the oscilloscope memory. If 0 the maximum number of points will be returned.

      - sparsing – interval between data points. For example if sparsing = 4, only one point every 4 points is read. If 0 or None the sparsing of the previous call is assumed, i.e. the value of the sparsing stored in the oscilloscope memory.

    Returns:

      data_ndarray, time_ndarray, waveform_preamble_dict: see waveform_preamble property for dict format.

  property intensity

    Set the intensity level of the grid or the trace in percent

  measure_parameter(parameter, channel)

    Same as the measure_parameter method in the Channel subclass

  property memory_size

    Control the maximum depth of memory (float or string). Assign for example 500, 100e6, “100K”, “25MA”.

    The reply will always be a float.

  run()

    Starts repetitive acquisitions.

    This is the same as pressing the Run key on the front panel.

  single()

    Causes the instrument to acquire a single trigger of data.

    This is the same as pressing the Single key on the front panel.

  stop()

    Stops the acquisition. This is the same as pressing the Stop key on the front panel.

  property timebase

    Get timebase setup as a dict containing the following keys:

    - “timebase_scale”: horizontal scale in seconds/div (float)

    - “timebase_offset”: interval in seconds between the trigger and the reference position (float)

  property timebase_offset

    Control the time interval in seconds between the trigger event and the reference position (at center of screen by default).

  property timebase_scale

    Control the horizontal scale (units per division) in seconds for the main window (float).

  timebase_setup(scale=None, offset=None)

    Set up timebase. Unspecified parameters are not modified. Modifying a single parameter might impact other parameters. Refer to oscilloscope documentation and make multiple consecutive calls to timebase_setup if needed.

    Parameters:

      - scale – interval in seconds between the trigger event and the reference position.

      - offset – horizontal scale per division in seconds/div.

  property trigger

    Get trigger setup as a dict containing the following keys:

    - “mode”: trigger sweep mode [auto, normal, single, stop]

    - “trigger_type”: condition that will trigger the acquisition of waveforms [edge, slew,glit,intv,runt,drop]

    - “source”: trigger source [c1,c2,c3,c4]

    - “hold_type”: hold type (refer to page 172 of programing guide)

    - “hold_value1”: hold value1 (refer to page 172 of programing guide)

    - “hold_value2”: hold value2 (refer to page 172 of programing guide)

    - “coupling”: input coupling for the selected trigger sources

    - “level”: trigger level voltage for the active trigger source

    - “level2”: trigger lower level voltage for the active trigger source (only slew/runt trigger)

    - “slope”: trigger slope of the specified trigger source

  property trigger_mode

    Control the trigger sweep mode (string).

    <mode>:= {AUTO,NORM,SINGLE,STOP}

    - auto : When AUTO sweep mode is selected, the oscilloscope begins to search for the trigger signal that meets the conditions. If the trigger signal is satisfied, the running state on the top left corner of the user interface shows Trig’d, and the interface shows stable waveform. Otherwise, the running state always shows Auto, and the interface shows unstable waveform.

    - normal : When NORMAL sweep mode is selected, the oscilloscope enters the wait trigger state and begins to search for trigger signals that meet the conditions. If the trigger signal is satisfied, the running state shows Trig’d, and the interface shows stable waveform. Otherwise, the running state shows Ready, and the interface displays the last triggered waveform (previous trigger) or does not display the waveform (no previous trigger).

    - single : When SINGLE sweep mode is selected, the backlight of SINGLE key lights up, the oscilloscope enters the waiting trigger state and begins to search for the trigger signal that meets the conditions. If the trigger signal is satisfied, the running state shows Trig’d, and the interface shows stable waveform. Then, the oscilloscope stops scanning, the RUN/STOP key is red light, and the running status shows Stop. Otherwise, the running state shows Ready, and the interface does not display the waveform.

    - stopped : STOP is a part of the option of this command, but not a trigger mode of the oscilloscope.

  property trigger_select

    Control the condition that will trigger the acquisition of waveforms (string).

    Depending on the trigger type, additional parameters must be specified. These additional parameters are grouped in pairs. The first in the pair names the variable to be modified, while the second gives the new value to be assigned. Pairs may be given in any order and restricted to those variables to be changed.

    There are five parameters that can be specified. Parameters 1. 2. 3. are always mandatory. Parameters 4. 5. are required only for certain combinations of the previous parameters.

    1. <trig_type>:={edge, slew, glit, intv, runt, drop}

    2. <source>:={c1, c2, c3, c4, line}

    3. <hold_type>:=

       - {ti, off} for edge trigger.

       - {ti} for drop trigger.

       - {ps, pl, p2, p1} for glit/runt trigger.

       - {is, il, i2, i1} for slew/intv trigger.

    4. <hold_value1>:= a time value with unit.

    5. <hold_value2>:= a time value with unit.

    Note:

    - “line” can only be selected when the trigger type is “edge”.

    - All time arguments should be given in multiples of seconds. Use the scientific notation if necessary.

    - The range of hold_values varies from trigger types. [80nS, 1.5S] for “edge” trigger, and [2nS, 4.2S] for others.

    - The trigger_select command is switched automatically between the short, normal and extended version depending on the number of expected parameters.

  trigger_setup(mode=None, source=None, trigger_type=None, hold_type=None, hold_value1=None, hold_value2=None, coupling=None, level=None, level2=None, slope=None)

    Set up trigger.

    Unspecified parameters are not modified. Modifying a single parameter might impact other parameters. Refer to oscilloscope documentation and make multiple consecutive calls to trigger_setup and channel_setup if needed.

    Parameters:

      - mode – trigger sweep mode [auto, normal, single, stop]

      - source – trigger source [c1, c2, c3, c4, line]

      - trigger_type – condition that will trigger the acquisition of waveforms [edge,slew,glit,intv,runt,drop]

      - hold_type – hold type (refer to page 172 of programing guide)

      - hold_value1 – hold value1 (refer to page 172 of programing guide)

      - hold_value2 – hold value2 (refer to page 172 of programing guide)

      - coupling – input coupling for the selected trigger sources

      - level – trigger level voltage for the active trigger source

      - level2 – trigger lower level voltage for the active trigger source (only slew/runt trigger)

      - slope – trigger slope of the specified trigger source

  property waveform_first_point

    Control the address of the first data point to be sent (int). For waveforms acquired in sequence mode, this refers to the relative address in the given segment. The first data point starts at zero and is strictly positive.

  property waveform_points

    Control the number of waveform points to be transferred with the digitize method (int). NP = 0 sends all data points.

    Note that the oscilloscope may provide less than the specified nb of points.

  property waveform_preamble

    Get preamble information for the selected waveform source as a dict with the following keys:

    - “requested_points”: number of data points requested by the user (int)

    - “sampled_points”: number of data points sampled by the oscilloscope (int)

    - “transmitted_points”: number of data points actually transmitted (optional) (int)

    - “memory_size”: size of the oscilloscope internal memory in bytes (int)

    - “sparsing”: sparse point. It defines the interval between data points. (int)

    - “first_point”: address of the first data point to be sent (int)

    - “source”: source of the data : “C1”, “C2”, “C3”, “C4”, “MATH”.

    - “grid_number”: number of horizontal grids (it is a read-only property)

    - “xdiv”: horizontal scale (units per division) in seconds

    - “xoffset”: time interval in seconds between the trigger event and the reference position

    - “ydiv”: vertical scale (units per division) in Volts

    - “yoffset”: value that is represented at center of screen in Volts

  property waveform_sparsing

    Control the interval between data points (integer). For example:

    SP = 0 sends all data points. SP = 4 sends 1 point every 4 data points.

  write(command, **kwargs)

    Write the command to the instrument through the adapter.

    Note: if the last command was sent less than WRITE_INTERVAL_S before, this method blocks for the remaining time so that commands are never sent with rate more than 1/WRITE_INTERVAL_S Hz.

    Parameters:

      command – command string to be sent to the instrument

## Teledyne Channel

class pymeasure.instruments.teledyne.teledyne_oscilloscope.TeledyneOscilloscopeChannel(parent, id)

  Bases: `Channel`

  A base abstract class for channel on a `TeledyneOscilloscope` device.

  property bwlimit

    Control the internal low-pass filter for this channel.

    The current bandwidths can only be read back for all channels at once! (dynamic)

  property coupling

    Control the coupling with a string parameter (“ac 1M”, “dc 1M”, “ground”).

  property current_configuration

    Get channel configuration as a dict containing the following keys:

    - “channel”: channel number (int)

    - “attenuation”: probe attenuation (float)

    - “bandwidth_limit”: bandwidth limiting enabled (bool)

    - “coupling”: “ac 1M”, “dc 1M”, “ground” coupling (str)

    - “offset”: vertical offset (float)

    - “skew_factor”: channel-tochannel skew factor (float)

    - “display”: currently displayed (bool)

    - “unit”: “A” or “V” units (str)

    - “volts_div”: vertical divisions (float)

    - “inverted”: inverted (bool)

    - “trigger_coupling”: trigger coupling can be “dc” “ac” “highpass” “lowpass” (str)

    - “trigger_level”: trigger level (float)

    - “trigger_level2”: trigger lower level for SLEW or RUNT trigger (float)

    - “trigger_slope”: trigger slope can be “negative” “positive” “window” (str)

  property display

    Control the display enabled state. (strict bool)

  property display_parameter

    Set the waveform processing of this channel with the specified algorithm and the result is displayed on the front panel.

    The command accepts the following parameters:

    Parameter | Description
    --- | ---
    PKPK | vertical peak-to-peak
    MAX | maximum vertical value
    MIN | minimum vertical value
    AMPL | vertical amplitude
    TOP | waveform top value
    BASE | waveform base value
    CMEAN | average value in the first cycle
    MEAN | average value
    RMS | RMS value
    CRMS | RMS value in the first cycle
    OVSN | overshoot of a falling edge
    FPRE | preshoot of a falling edge
    OVSP | overshoot of a rising edge
    RPRE | preshoot of a rising edge
    PER | period
    FREQ | frequency
    PWID | positive pulse width
    NWID | negative pulse width
    RISE | rise-time
    FALL | fall-time
    WID | Burst width
    DUTY | positive duty cycle
    NDUTY | negative duty cycle
    ALL | All measurement

  insert_id(command)

    Insert the channel id in a command replacing placeholder.

    Subclass this method if you want to do something else, like always prepending the channel id.

  measure_parameter(parameter: str)

    Process a waveform with the selected algorithm and returns the specified measurement.

    Parameters:

      parameter – same as the display_parameter property

  property offset

    Control the center of the screen in Volts by a a float parameter. The range of legal values varies depending on range and scale. If the specified value is outside of the legal range, the offset value is automatically set to the nearest legal value.

  property probe_attenuation

    Control the probe attenuation. The probe attenuation may be from 0.1 to 10000.

  property scale

    Control the vertical scale (units per division) in Volts.

  setup(**kwargs)

    Setup channel. Unspecified settings are not modified.

    Modifying values such as probe attenuation will modify offset, range, etc. Refer to oscilloscope documentation and make multiple consecutive calls to setup() if needed. See property descriptions for more information.

    Parameters:

      - bwlimit

      - coupling

      - display

      - invert

      - offset

      - skew_factor

      - probe_attenuation

      - scale

      - unit

      - trigger_coupling

      - trigger_level

      - trigger_level2

      - trigger_slope

  property trigger_coupling

    Control the input coupling for the selected trigger sources (string).

    - ac: AC coupling block DC component in the trigger path, removing dc offset voltage from the trigger waveform. Use AC coupling to get a stable edge trigger when your waveform has a large dc offset.

    - dc: DC coupling allows dc and ac signals into the trigger path.

    - lowpass: HFREJ coupling places a lowpass filter in the trigger path.

    - highpass: LFREJ coupling places a highpass filter in the trigger path.

  property trigger_level

    Control the trigger level voltage for the active trigger source (float).

    When there are two trigger levels to set, this command is used to set the higher trigger level voltage for the specified source. `trigger_level2` is used to set the lower trigger level voltage.

    When setting the trigger level it must be divided by the probe attenuation. This is not documented in the datasheet and it is probably a bug of the scope firmware. An out-of-range value will be adjusted to the closest legal value.

  property trigger_slope

    Control the trigger slope of the specified trigger source (string).

    <trig_slope>:={NEG,POS,WINDOW} for edge trigger <trig_slope>:={NEG,POS} for other trigger

    parameter | trigger slope
    negative | Negative slope for edge trigger or other trigger
    positive | Positive slope for edge trigger or other trigger
    window | Window slope for edge trigger

    (dynamic)

## Teledyne MAUI Oscilloscope

class pymeasure.instruments.teledyne.TeledyneMAUI(adapter, name='Teledyne Oscilloscope', **kwargs)

  Bases: `TeledyneOscilloscope`

  A base class for the MAUI-type of Teledyne oscilloscopes.

  This base class works out of the box. Some properties, especially the number of channels, might have to be adjusted to the actual device.

  The manual detailing the API is “MAUI Oscilloscopes Remote Control and Automation Manual” (link).

  ch_1
    Channel:

      `TeledyneMAUIChannel`

  ch_2
    Channel:

      `TeledyneMAUIChannel`

  ch_3
    Channel:

      `TeledyneMAUIChannel`

  ch_4
    Channel:

      `TeledyneMAUIChannel`

  download_image(**kwargs)

    Get a BMP image of oscilloscope screen in bytearray of specified file format.

    The hardcopy destination is set to “REMOTE” by default.

    Parameters:

      **kwargs – Keyword arguments for `hardcopy_setup()`

  force_trigger()

    Make one acquisition if in active trigger mode.

    No action is taken if the device is in ‘Stop trigger mode’.

  hardcopy_setup(**kwargs)

    Specify hardcopy settings.

    Connect a printer or define how to save to file. Set any or all of the following parameters.

    Parameters:

      - device – {BMP, JPEG, PNG, TIFF}

      - format – {PORTRAIT, LANDSCAPE}

      - background – {Std, Print, BW}

      - destination – {PRINTER, CLIPBOARD, EMAIL, FILE, REMOTE}

      - area – {GRIDAREAONLY, DSOWINDOW, FULLSCREEN}

      - directory – Any legal DOS path, for FILE mode only

      - filename – Filename string, no extension, for FILE mode only

      - printername – Valid printer name, for PRINTER mode only

      - portname – {GPIB, NET}

  property hardcopy_setup_current

    Get current hardcopy config.

  property trigger

    Get trigger setup as a dict containing the following keys:

    - “mode”: trigger sweep mode [auto, normal, single, stop]

    - “trigger_type”: condition that will trigger the acquisition of waveforms [edge,slew,glit,intv,runt,drop]

    - “source”: trigger source [c1,c2,c3,c4]

    - “hold_type”: hold type (refer to page 172 of programing guide)

    - “hold_value1”: hold value1 (refer to page 172 of programing guide)

    - “hold_value2”: hold value2 (refer to page 172 of programing guide)

    - “coupling”: input coupling for the selected trigger sources

    - “level”: trigger level voltage for the active trigger source

    - “slope”: trigger slope of the specified trigger source

## Teledyne MAUI Channel

class pymeasure.instruments.teledyne.teledyneMAUI.TeledyneMAUIChannel(parent, id)

  Bases: `TeledyneOscilloscopeChannel`

  Base class for channels on a `TeledyneMAUI` device.

  autoscale()

    Perform auto-setup command for channel.

  property current_configuration

    Get channel configuration as a dict containing the following keys:

    - “channel”: channel number (int)

    - “attenuation”: probe attenuation (float)

    - “bandwidth_limit”: bandwidth limiting, parsed for this channel (str)

    - “coupling”: “ac 1M”, “dc 1M”, “ground” coupling (str)

    - “offset”: vertical offset (float)

    - “display”: currently displayed (bool)

    - “volts_div”: vertical divisions (float)

    - “trigger_coupling”: trigger coupling can be “dc” “ac” “highpass” “lowpass” (str)

    - “trigger_level”: trigger level (float)

    - “trigger_slope”: trigger slope can be “negative” “positive” “window” (str)

  setup(**kwargs)

    Setup channel. Unspecified settings are not modified.

    Modifying values such as probe attenuation will modify offset, range, etc. Refer to oscilloscope documentation and make multiple consecutive calls to setup() if needed. See property descriptions for more information.

    Parameters:

      - bwlimit

      - coupling

      - display

      - offset

      - probe_attenuation

      - scale

      - trigger_coupling

      - trigger_level

      - trigger_slope