qmi.instruments.picotech.picoscope3403

Instrument driver for the PicoTech PicoScope 3000A series oscilloscopes.

This driver depends on the PicoSDK libraries from PicoTech and on the PicoSDK Python wrappers from https://github.com/picotech/picosdk-python-wrappers.

Classes

PicoTech_PicoScope3403(context, name, ...)

Instrument driver for the PicoTech PicoScope 3403 USB oscilloscope.

class qmi.instruments.picotech.picoscope3403.PicoTech_PicoScope3403(context: QMI_Context, name: str, serial_number: str)

Instrument driver for the PicoTech PicoScope 3403 USB oscilloscope.

NUM_CHANNELS

Number of oscilloscope channels.

NUM_INPUT_RANGES

Number of supported input ranges. Range ‘0’ is not supported.

run_block(num_pretrig_samples: int, num_posttrig_samples: int, time_base: int) None

Start acquisition in block mode.

If the trigger is enabled (see set_trigger()), the oscilloscope will until the trigger condition occurs, then acquire a single block of data. If the trigger is disabled, the oscilloscope will immediately acquire a single block of data.

This function returns immediately while the acquisition is in progress. Call is_block_ready() or wait_block_ready() to check whether the acquisition has finished. Optionally call stop() to end the acquisition before it completes.

Parameters:
  • num_pretrig_samples – Number of pre-trigger samples.

  • num_posttrig_samples – Number of post-trigger samples.

  • time_base – Time base selector (range 0 … 2**32-1). The effective time base is (timebase - 2) * 8 ns for timebase > 2, else 2^timebase. For one enabled channel, values from 0 are allowed (time-base >= 1 ns). For two enabled channels, values from 1 are allowed (time-base >= 2 ns). From three enabled channels, values from 2 are allowed (time-base >= 4 ns).

acquire_by_trigger_and_get_data(channels: list[int], max_val: list[float], couplings: list[ChannelCoupling], trigger_channel: int | None, trigger_level: float, sampling_interval: int, time_span: int) object

Acquires data from a specific channel, which is triggered, and returns the data.

It is assumed that the trigger level is set to (almost) the highest point of the measured waveform. This is used to select the appropriate input range. The scope waits 1 second to get triggered. Default measurement values are: DC coupling and triggering on the rising edge. The number of samples is determined from the sampling interval and time span and set relative to the trigger point. If no trigger channel number is given, trigger is disabled and sampling is done from the number of samples before the current moment of run_block call. The data is then sent back as real voltages.

Parameters:
  • channels – List of used channels [0…NUM_CHANNELS-1] for readout.

  • max_val – Maximum expected values for ALL channels [0, 1, … NUM_CHANNELS-1] to set an appropriate input range.

  • couplings – Coupling of channels for readout for ALL channels [0, 1, … NUM_CHANNELS-1]. ChannelCoupling.DC or ChannelCoupling.AC.

  • trigger_channel – Channel to set the trigger on. If it is ‘None’, triggers will be disabled on all channels.

  • trigger_level – Threshold in Volts for the trigger.

  • sampling_interval – Sampling interval in nanoseconds. Must be 1, 2, 4 or a multiple of 8 ns.

  • time_span – Time span of data acquiring in nanoseconds.

Returns:

A 1D Numpy array containing the sampling times in ns. voltages: A 1D Numpy array containing the measured voltages in V.

Return type:

times

close() None

Close the connection to the instrument hardware and release associated resources.

When this method returns, the instrument must not be used again unless it is first re-opened by calling the open() method.

Subclasses can extend this method if they have specific resources to close. If they do, they should call super().close() as a last statement.

disable_trigger()

Disables all triggers in all channels

force_unlock() None

Forcefully unlock the remote object.

This unlocks the object, regardless of who owns the lock. This allows you to unlock an object if the locking proxy has been destroyed without unlocking.

Use this with care.

Do not override this stub method in subclasses. It has already been implemented in QMI_RpcProxy.

get_block_data(channels: list[int]) tuple[ndarray, float, list[bool]]

Retrieve a block of data, previously acquired via run_block().

Samples are returned as 16-bit signed integers, where the value (2**16-1) corresponds to the maximum positive voltage and -(2**16-1) corresponds to the most negative voltage in the input range.

The number of retrieved samples corresponds to the sum of pre-trigger and post-trigger samples as specified in the call to run_block().

Parameters:

channels – List of channels for which to retrieve samples and overrange indications.

Returns:

A 2D Numpy array with shape (num_channels, num_samples) containing signed 16-bit samples. time_base_interval_ns: The time interval between samples as a floating point number in nanoseconds. overrange: A list of booleans indicating whether overvoltage occurred on the selected channels.

Return type:

samples

Raises:
  • ValueError – If a channel number in ‘channels’ is invalid.

  • QMI_InstrumentException – If unexpected number of samples were obtained.

classmethod get_category() str | None

Return the optional name of the category this object belongs to.

A category name is a free-form string that has no special significance. Its purpose is to distinguish between groups of RPC objects that fulfill similar roles.

get_device_variant() str

Get the type of PicoScope (for example “4824”).

get_input_ranges() dict[int, float]

Return a dictionary mapping supported input range indexes to the corresponding input range in Volt.

get_name() str

Return the name of this object.

Returns:

name attribute.

get_sampling_interval(time_base: int) float

Returns the scope’s time resolution in nanoseconds depending on the time_base selector.

Parameters:

time_base – Timebase selector (range 0 … 2^32-1). The effective time resolution is 2^time_base ns for timebase <= 2. The effective time resolution is (timebase-2)/(125000000) for timebase > 2.

Returns:

Scope’s time resolution in nanoseconds. 0 is returned for invalid time_base.

Return type:

resolution

get_serial_number() str

Get the batch and serial number of the device.

get_signals() list[SignalDescription]

Return a list of signals that can be published by this object.

Returns:

List consisting of qmi_signals attributes.

is_block_ready() bool

Return True if a block acquisition has completed, or False if the acquisition is still in progress. Only call this function after starting an acquisition via run_block().

is_locked() bool

Query if the remote object is locked.

Do not override this stub method in subclasses. It has already been implemented in QMI_RpcProxy.

is_open() bool

Return True if the instrument is open (ready for interaction).

static list_instruments(library: str) list[str]

Return a list of serial numbers of detected PicoScope instruments of a specific library type.

Parameters:

library – The library type to list, e.g. “3000a”

Returns:

A list of serial numbers of devices found which use input library type.

Return type:

serials

lock(timeout: float = 0.0, lock_token: str | None = None) bool

Lock the remote object. If timeout is given, try every 0.1s within the given timeout value. The remote object can be locked with an optional custom lock token by giving a string into lock_token keyword argument.

If successful, this proxy is the only proxy that can invoke RPC methods on the remote object; other proxies will receive an “object is locked” response. The return value indicates if the lock was granted; a denied lock means the object was already locked by another proxy.

Do not override this stub method in subclasses. It has already been implemented in QMI_RpcProxy.

open() None

Connect to the instrument hardware.

When this method returns, the instrument must be ready for interaction via calls to instrument-specific methods.

Subclasses can extend this method to implement instrument-specific initialization. If they do, they should call super().open() as a last statement.

release_rpc_object() None

Give a warning if the instrument is removed while still open.

set_channel(channel: int, enable: bool, coupling: ChannelCoupling, range_sel: int, offset: float) None

Configure an oscilloscope input channel.

Parameters:
  • channel – Input channel (range 0 .. 3).

  • enable – True to enable the channel, False to disable it.

  • coupling – Input coupling (ChannelCoupling.AC or ChannelCoupling.DC).

  • range_sel – Input range selector (range 0 .. 9). See get_input_ranges().

  • offset – Analog input offset in Volt. This offset is added to the analog input signal before digitizing the signal.

set_trigger(enable: bool, channel: int, threshold: int, edge: TriggerEdge) None

Configure the trigger mode of the oscilloscope.

Parameters:
  • enable – True to enable triggering, False to disable the trigger.

  • channel – Source channel to trigger on (range 0 .. 7).

  • threshold – Trigger level as an ADC code (range -32767 .. +32767).

  • edge – Trigger edge (TriggerEdge.RISING or TriggerEdge.FALLING or TriggerEdge.RISING_OR_FALLING).

stop() None

Stop any ongoing acquisition.

unlock(lock_token: str | None = None) bool

Unlock the remote object.

Without optional parameters, this is only allowed by the proxy that initially locked the object. By giving the lock token as an input parameter, the specific object locked by this token can be unlocked. The return value indicates if the unlocking was successful.

Do not override this stub method in subclasses. It has already been implemented in QMI_RpcProxy.

wait_block_ready(timeout: float) None

Wait until the running block acquisition has completed. Uses the “is_block_ready” above.

Parameters:

timeout – Maximum time to wait in seconds.

Raises:
  • ValueError – If the timeout input value is negative.

  • QMI_TimeoutException – If the timeout expires before a block is ready.