Skip to content

PicoScope¤

PicoScope (SDK) ¤

PicoScope(equipment: Equipment)

              flowchart LR
              msl.equipment_resources.picotech.picoscope.PicoScope[PicoScope]
              msl.equipment.interfaces.sdk.SDK[SDK]
              msl.equipment.schema.Interface[Interface]

                              msl.equipment.interfaces.sdk.SDK --> msl.equipment_resources.picotech.picoscope.PicoScope
                                msl.equipment.schema.Interface --> msl.equipment.interfaces.sdk.SDK
                



              click msl.equipment_resources.picotech.picoscope.PicoScope href "" "msl.equipment_resources.picotech.picoscope.PicoScope"
              click msl.equipment.interfaces.sdk.SDK href "" "msl.equipment.interfaces.sdk.SDK"
              click msl.equipment.schema.Interface href "" "msl.equipment.schema.Interface"
            

A wrapper around the PicoScope API Series SDK.

Regular-expression patterns that are used to select this Resource when connect() is called.

manufacturer=r"Pico\s*Tech"
model=r"[23456]\d{3}[A-Z]"

Warning

This class was written for the ps5000a SDK. Different SDKs (e.g., ps4000a) have similar function signatures and may or may not work with this class. Note that Pico Technology have their own repository to support their products.

Parameters:

Name Type Description Default
equipment Equipment

An Equipment instance.

required

A Connection instance supports the following properties for a PicoScope.

Connection Properties:

Name Type Description
auto_select_power bool

PicoScopes that can be powered by either DC power or by USB power may raise an exception if the DC power supply is not connected. Setting auto_select_power to True will automatically switch to the USB power source. Default: True

resolution str

The device resolution (bit depth). Possible values are 8bit, 12bit, 14bit, 15bit or 16bit. Default: 12bit

Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
def __init__(self, equipment: Equipment) -> None:
    r"""A wrapper around the PicoScope API Series SDK.

    Regular-expression patterns that are used to select this Resource when
    [connect()][msl.equipment.schema.Equipment.connect] is called.
    ```python
    manufacturer=r"Pico\s*Tech"
    model=r"[23456]\d{3}[A-Z]"
    ```

    !!! warning
        This class was written for the ps5000a SDK. Different SDKs (e.g., ps4000a) have
        similar function signatures and may or may not work with this class. Note that Pico
        Technology have their own [repository](https://github.com/picotech){:target="_blank"}
        to support their products.

    Args:
        equipment: An [Equipment][] instance.

    A [Connection][msl.equipment.schema.Connection] instance supports the following _properties_
    for a PicoScope.

    Attributes: Connection Properties:
        auto_select_power (bool): PicoScopes that can be powered by either DC power or by USB power
            may raise an exception if the DC power supply is not connected. Setting `auto_select_power`
            to `True` will automatically switch to the USB power source. _Default: `True`_
        resolution (str): The device resolution (bit depth).
            Possible values are `8bit`, `12bit`, `14bit`, `15bit` or `16bit`. _Default: `12bit`_
    """
    self._handle: int = -1
    super().__init__(equipment, libtype="windll" if IS_WINDOWS else "cdll")
    self._prefix: str = Path(self.path).stem.lower()
    _configure(self._prefix, self.sdk, self._errcheck_api)

    assert equipment.connection is not None  # noqa: S101
    props = equipment.connection.properties
    dr = props.get("resolution", DeviceResolution.DR_12BIT)
    resolution = to_enum(dr, DeviceResolution, to_upper=True, prefix="DR_")

    handle = c_int16()
    serial = create_string_buffer(self.equipment.serial.encode())
    if self._prefix in {"ps5000a", "ps6000a"}:
        power_state = self._f("OpenUnit", byref(handle), serial, resolution)
    else:
        power_state = self._f("OpenUnit", byref(handle), serial)
    self._handle = handle.value

    # Check for PICO_POWER_SUPPLY_NOT_CONNECTED, PICO_USB3_0_DEVICE_NON_USB3_0_PORT
    if power_state in {0x11A, 0x11E}:
        if not props.get("auto_select_power", True):
            raise MSLConnectionError(self, Error[power_state])
        self._f("ChangePowerSource", self._handle, power_state)
    elif power_state != PICO_OK:
        raise MSLConnectionError(self, Error[power_state])

    self._channels: dict[str, ChannelSettings] = {}
    self._num_captures: int = 1
    self._pre_trigger: float = 0.0
    self._buffer_size: int = -1
    self._error_code: int = 0

    # the following are re-defined by calling set_timebase()
    self._sampling_interval: float = -1.0
    self._streaming_sampling_interval: int = -1
    self._num_samples: int = -1
    self._timebase_index: int = -1
    self._streaming_time_units: _TimeUnits = _TimeUnits.S

channel property ¤

The configuration settings of each channel.

dt property ¤

dt: float

The time interval between samples (i.e., Δt).

pre_trigger property ¤

pre_trigger: float

The number of seconds that samples were acquired for before the trigger event.

streaming_done class-attribute instance-attribute ¤

streaming_done: bool = False

Whether streaming mode has finished acquiring the samples.

channel_combinations_stateless ¤

channel_combinations_stateless(
    *,
    dt: float,
    resolution: DeviceResolution | str | int,
    ac_adaptor: bool = False
) -> ChannelFlags

Get the channel and port combination flags for a proposed device configuration.

It does not write the configuration to the device.

Parameters:

Name Type Description Default
dt float

The proposed sampling interval, in seconds.

required
resolution DeviceResolution | str | int

The resolution mode in which you propose to operate the oscilloscope. Can be an enum member name (case insensitive, with or without the "DR_" prefix) or value.

required
ac_adaptor bool

Whether the proposed configuration uses the external AC adaptor or not.

False

Returns:

Type Description
ChannelFlags

The channel and port combination flags.

Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
def channel_combinations_stateless(
    self, *, dt: float, resolution: DeviceResolution | str | int, ac_adaptor: bool = False
) -> ChannelFlags:
    """Get the channel and port combination flags for a proposed device configuration.

    It does not write the configuration to the device.

    Args:
        dt: The proposed sampling interval, in seconds.
        resolution: The resolution mode in which you propose to operate the oscilloscope.
            Can be an enum member name (case insensitive, with or without the "DR_" prefix) or value.
        ac_adaptor: Whether the proposed configuration uses the external AC adaptor or not.

    Returns:
        The channel and port combination flags.
    """
    n_combos = c_uint32()
    resolution = to_enum(resolution, DeviceResolution, prefix="DR_", to_upper=True)
    timebase = round(self._get_timebase_index(float(dt), resolution))
    ac = int(ac_adaptor)

    self._f("ChannelCombinationsStateless", self._handle, None, byref(n_combos), resolution, timebase, ac)

    c_flags = (c_uint32 * n_combos.value)()
    self._f("ChannelCombinationsStateless", self._handle, c_flags, byref(n_combos), resolution, timebase, ac)

    flags = [ChannelFlags(flag) for flag in sorted(c_flags)]
    if not flags:  # ideally, the SDK would return a non-zero PICO_STATUS value before this check
        msg = "No channel combinations for the proposed settings"
        raise MSLConnectionError(self, msg)

    combo = flags[0]
    for f in flags[1:]:
        combo |= f
    return combo

check_for_update ¤

check_for_update() -> tuple[str, str, bool]

Check if the firmware version requires an update.

Returns:

Type Description
tuple[str, str, bool]

The current version, the latest version and whether an update is required, i.e., (current, latest, is_required).

Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
246
247
248
249
250
251
252
253
254
255
256
257
258
259
def check_for_update(self) -> tuple[str, str, bool]:
    """Check if the firmware version requires an update.

    Returns:
        The current version, the latest version and whether an update is required,
            i.e., `(current, latest, is_required)`.
    """
    current = (c_uint16 * 4)()
    latest = (c_uint16 * 4)()
    required = c_uint16()
    self._f("CheckForUpdate", self._handle, byref(current), byref(latest), byref(required))
    current_str = ".".join(str(x) for x in current)
    latest_str = ".".join(str(x) for x in latest)
    return current_str, latest_str, bool(required.value)

disconnect ¤

disconnect() -> None

Disconnect from the PicoScope.

Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
261
262
263
264
265
266
def disconnect(self) -> None:  # pyright: ignore[reportImplicitOverride]
    """Disconnect from the PicoScope."""
    if self._handle >= 0:
        self._f("CloseUnit", self._handle)
        self._handle = -1
        super().disconnect()

enumerate_units staticmethod ¤

enumerate_units(path: PathLike) -> list[str]

Find PicoScopes that are connected to the computer.

Note

You cannot call this function after you have opened a connection to a PicoScope.

Parameters:

Name Type Description Default
path PathLike

The path to the Pico Technology SDK of the scope models to find. You may specify the filename (e.g., ps5000a) if the parent directory is available on the PATH environment variable.

required

Returns:

Type Description
list[str]

A list of serial numbers of the PicoScopes that were found.

Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
@staticmethod
def enumerate_units(path: PathLike) -> list[str]:
    """Find PicoScopes that are connected to the computer.

    !!! note
        You cannot call this function after you have opened a connection to a PicoScope.

    Args:
        path: The path to the Pico Technology SDK of the scope models to find.
            You may specify the filename (e.g., `ps5000a`) if the parent directory
            is available on the PATH environment variable.

    Returns:
        A list of serial numbers of the PicoScopes that were found.
    """
    count = c_int16()
    serials = create_string_buffer(1024)
    size = c_int16(len(serials))
    sdk = LoadLibrary(path, libtype="windll" if IS_WINDOWS else "cdll")
    prefix = Path(sdk.path).stem.lower()
    result = getattr(sdk.lib, prefix + "EnumerateUnits")(byref(count), serials, byref(size))
    if result == PICO_OK:
        return serials.value.decode("utf-8").split(",")

    msg = Error.get(result, f"UnknownPicoTechError: Error code 0x{result:08x}")
    raise OSError(msg)

flash_led ¤

flash_led(start: int) -> None

Flashes the LED on the front of the scope without blocking the calling thread.

Parameters:

Name Type Description Default
start int

The action required:

  • < 0: flash the LED indefinitely
  • = 0: stop the LED flashing
  • > 0: flash the LED start times. If the LED is already flashing, the count will reset to start.
required
Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
295
296
297
298
299
300
301
302
303
304
305
306
307
def flash_led(self, start: int) -> None:
    """Flashes the LED on the front of the scope without blocking the calling thread.

    Args:
        start: The action required:

            * &lt; 0: flash the LED indefinitely
            * = 0: stop the LED flashing
            * &gt; 0: flash the LED `start` times. If the LED is already flashing, the
                count will reset to `start`.

    """
    self._f("FlashLed", self._handle, start)

get_analogue_offset ¤

get_analogue_offset(
    range: Range | str | int, coupling: Coupling | str | int = "dc"
) -> tuple[float, float]

Get the minimum and maximum allowable analogue offset for a specific voltage range.

Parameters:

Name Type Description Default
range Range | str | int

The input voltage range. Can be an enum member name (with or without the "R_" prefix) or value.

required
coupling Coupling | str | int

The impedance and coupling type. Can be an enum member name (case insensitive) or value.

'dc'

Returns:

Type Description
tuple[float, float]

The (minimum, maximum) offset values.

Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
def get_analogue_offset(
    self,
    range: Range | str | int,  # noqa: A002
    coupling: Coupling | str | int = "dc",
) -> tuple[float, float]:
    """Get the minimum and maximum allowable analogue offset for a specific voltage range.

    Args:
        range: The input voltage range. Can be an enum member name (with or without the `"R_"` prefix) or value.
        coupling: The impedance and coupling type. Can be an enum member name (case insensitive) or value.

    Returns:
        The `(minimum, maximum)` offset values.
    """
    _range = to_enum(range, Range, prefix="R_")
    _coupling = to_enum(coupling, Coupling, to_upper=True)
    maximum = c_float()
    minimum = c_float()
    self._f("GetAnalogueOffset", self._handle, _range, _coupling, byref(maximum), byref(minimum))
    return minimum.value, maximum.value

get_channel_information ¤

get_channel_information(
    channel: Channel | str | int, info: ChannelInfo | str | int = "ranges"
) -> list[int]

Get information about a channel.

Parameters:

Name Type Description Default
channel Channel | str | int

The channel to get the ranges of. Can be an enum member name (case insensitive) or value.

required
info ChannelInfo | str | int

The information to get for the channel. Can be an enum member name (case insensitive) or value.

'ranges'

Returns:

Type Description
list[int]

The information that was requested.

Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
def get_channel_information(
    self, channel: Channel | str | int, info: ChannelInfo | str | int = "ranges"
) -> list[int]:
    """Get information about a channel.

    Args:
        channel: The channel to get the ranges of. Can be an enum member name (case insensitive) or value.
        info: The information to get for the `channel`. Can be an enum member name (case insensitive) or value.

    Returns:
        The information that was requested.
    """
    ch = to_enum(channel, Channel, to_upper=True)
    info = to_enum(info, ChannelInfo, to_upper=True)
    c_array = (c_int32 * 50)()
    length = c_int32(len(c_array))
    self._f("GetChannelInformation", self._handle, info, 0, c_array, byref(length), ch)
    return [c_array[i] for i in range(length.value)]

get_device_resolution ¤

get_device_resolution() -> DeviceResolution

Get the device resolution.

Returns:

Type Description
DeviceResolution

The resolution (bit depth).

Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
349
350
351
352
353
354
355
356
357
def get_device_resolution(self) -> DeviceResolution:
    """Get the device resolution.

    Returns:
        The resolution (bit depth).
    """
    resolution = c_uint32()
    self._f("GetDeviceResolution", self._handle, byref(resolution))
    return DeviceResolution(resolution.value)

get_max_down_sample_ratio ¤

get_max_down_sample_ratio(
    n: int, mode: RatioMode | str | int = "none", segment: int = 0
) -> int

Get the maximum down-sampling ratio.

Parameters:

Name Type Description Default
n int

The number of unprocessed samples to be downsampled.

required
mode RatioMode | str | int

The down-sampling mode. Can be an enum member name (case insensitive) or value.

'none'
segment int

The index of the memory segment to use.

0

Returns:

Type Description
int

The maximum down-sampling ratio that can be used for a given number of samples in a given down-sampling mode.

Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
def get_max_down_sample_ratio(self, n: int, mode: RatioMode | str | int = "none", segment: int = 0) -> int:
    """Get the maximum down-sampling ratio.

    Args:
        n: The number of unprocessed samples to be downsampled.
        mode: The down-sampling mode. Can be an enum member name (case insensitive) or value.
        segment: The index of the memory segment to use.

    Returns:
        The maximum down-sampling ratio that can be used for a given number of samples
            in a given down-sampling mode.
    """
    mode = to_enum(mode, RatioMode, to_upper=True)
    ratio = c_uint32()
    self._f("GetMaxDownSampleRatio", self._handle, n, byref(ratio), mode, segment)
    return ratio.value

get_max_segments ¤

get_max_segments() -> int

Get the maximum number of segments allowed for the opened device.

Returns:

Type Description
int

This function returns the maximum number of segments allowed for the opened device. This number is the maximum value of num_segments that can be passed to memory_segments.

Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
376
377
378
379
380
381
382
383
384
385
386
def get_max_segments(self) -> int:
    """Get the maximum number of segments allowed for the opened device.

    Returns:
        This function returns the maximum number of segments allowed for the opened device.
            This number is the maximum value of `num_segments` that can be passed to
            [memory_segments][msl.equipment_resources.picotech.picoscope.PicoScope.memory_segments].
    """
    max_segments = c_uint32()
    self._f("GetMaxSegments", self._handle, byref(max_segments))
    return max_segments.value

get_minimum_timebase_stateless ¤

get_minimum_timebase_stateless(
    *, flags: ChannelFlags, resolution: DeviceResolution | str | int
) -> float

Get the fastest available sample interval for the proposed configuration.

It does not write the configuration to the device.

Parameters:

Name Type Description Default
flags ChannelFlags

The proposed combination of enabled channels and ports. To specify multiple channels and ports, use the bitwise-OR of the relevant ChannelFlags.

required
resolution DeviceResolution | str | int

The resolution mode in which you propose to operate the oscilloscope. Can be an enum member name (case insensitive, with or without the "DR_" prefix) or value.

required

Returns:

Type Description
float

The fastest sampling interval, in seconds, corresponding to the proposed configuration.

Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
def get_minimum_timebase_stateless(self, *, flags: ChannelFlags, resolution: DeviceResolution | str | int) -> float:
    """Get the fastest available sample interval for the proposed configuration.

    It does not write the configuration to the device.

    Args:
        flags: The proposed combination of enabled channels and ports. To specify multiple
            channels and ports, use the bitwise-OR of the relevant
            [ChannelFlags][msl.equipment_resources.picotech.picoscope.ChannelFlags].
        resolution: The resolution mode in which you propose to operate the oscilloscope.
            Can be an enum member name (case insensitive, with or without the "DR_" prefix) or value.

    Returns:
        The fastest sampling interval, in seconds, corresponding to the proposed configuration.
    """
    timebase = c_uint32()
    dt = c_double()
    resolution = to_enum(resolution, DeviceResolution, prefix="DR_", to_upper=True)
    self._f("GetMinimumTimebaseStateless", self._handle, flags, byref(timebase), byref(dt), resolution)
    return dt.value

get_no_of_captures ¤

get_no_of_captures(*, pre_allocate: bool = True) -> int

Get the number of captures available.

Parameters:

Name Type Description Default
pre_allocate bool

Whether to pre-allocate a numpy array to hold the samples for each channel that is enabled. Allocation happens only once per run.

True

Returns:

Type Description
int

The number of captures the device has made in rapid-block mode, since run_block was called.

Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
def get_no_of_captures(self, *, pre_allocate: bool = True) -> int:
    """Get the number of captures available.

    Args:
        pre_allocate: Whether to pre-allocate a numpy array to hold the samples for each channel that is enabled.
            Allocation happens only once per run.

    Returns:
        The number of captures the device has made in rapid-block mode,
            since [run_block][msl.equipment_resources.picotech.picoscope.PicoScope.run_block] was called.
    """
    n_captures = c_uint32()
    self._f("GetNoOfCaptures", self._handle, byref(n_captures))
    n = n_captures.value
    if pre_allocate:
        if not self._channels:
            msg = "Must call set_channel() to configure all channels before get_no_of_captures()"
            raise MSLConnectionError(self, msg)

        if self._num_samples < 0:
            msg = "Must call set_timebase() before get_no_of_captures()"
            raise MSLConnectionError(self, msg)

        for channel in self._channels.values():
            if channel.enabled:
                channel.allocate(num_samples=self._num_samples, num_captures=n)

    return n

get_num_of_processed_captures ¤

get_num_of_processed_captures() -> int

Get the number of captures in rapid block mode that have been processed.

Returns:

Type Description
int

The number of available captures that have been collected after calling run_block.

Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
438
439
440
441
442
443
444
445
446
447
def get_num_of_processed_captures(self) -> int:
    """Get the number of captures in rapid block mode that have been processed.

    Returns:
        The number of available captures that have been collected after calling
            [run_block][msl.equipment_resources.picotech.picoscope.PicoScope.run_block].
    """
    n_processed_captures = c_uint32()
    self._f("GetNoOfProcessedCaptures", self._handle, byref(n_processed_captures))
    return n_processed_captures.value

get_streaming_latest_values ¤

get_streaming_latest_values(
    callback: PicoTechStreamingReadyCallback, *, strict: bool = False
) -> None

Instructs the driver to return the next block of values to your callback function.

You must have previously called run_streaming beforehand to set up streaming.

Parameters:

Name Type Description Default
callback PicoTechStreamingReadyCallback

The callback function to be called when the latest streaming samples have been acquired (see also, wait_until_ready and is_ready).

required
strict bool

Whether to raise an exception if the device is busy so data cannot be acquired yet when this method is called.

False
Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
def get_streaming_latest_values(self, callback: PicoTechStreamingReadyCallback, *, strict: bool = False) -> None:
    """Instructs the driver to return the next block of values to your callback function.

    You must have previously called
    [run_streaming][msl.equipment_resources.picotech.picoscope.PicoScope.run_streaming]
    beforehand to set up streaming.

    Args:
        callback: The callback function to be called when the latest streaming samples
            have been acquired (see also,
            [wait_until_ready][msl.equipment_resources.picotech.picoscope.PicoScope.wait_until_ready] and
            [is_ready][msl.equipment_resources.picotech.picoscope.PicoScope.is_ready]).
        strict: Whether to raise an exception if the device is busy so data cannot be
            acquired yet when this method is called.
    """
    try:
        self._f("GetStreamingLatestValues", self._handle, callback, None)
    except MSLConnectionError:
        if self._error_code == PICO_BUSY and not strict:
            return
        raise

get_timebase2 ¤

get_timebase2(
    timebase: int, num_samples: int = 0, segment: int = 0
) -> tuple[float, int]

Get the timebase.

This function calculates the sampling interval and maximum number of samples for a given timebase under the specified conditions. The result will depend on the number of channels enabled.

Parameters:

Name Type Description Default
timebase int

The timebase.

required
num_samples int

The number of samples required.

0
segment int

The index of the memory segment to use.

0

Returns:

Type Description
tuple[float, int]

The sampling interval, in seconds, and the maximum number of samples available.

Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
def get_timebase2(self, timebase: int, num_samples: int = 0, segment: int = 0) -> tuple[float, int]:
    """Get the timebase.

    This function calculates the sampling interval and maximum number of samples for a given timebase under
    the specified conditions. The result will depend on the number of channels enabled.

    Args:
        timebase: The timebase.
        num_samples: The number of samples required.
        segment: The index of the memory segment to use.

    Returns:
        The sampling interval, in seconds, and the maximum number of samples available.
    """
    dt = c_float()
    max_samples = c_int32()
    self._f("GetTimebase2", self._handle, timebase, num_samples, byref(dt), byref(max_samples), segment)
    return dt.value * 1e-9, max_samples.value

get_trigger_info_bulk ¤

get_trigger_info_bulk(
    from_segment: int = 0, to_segment: int | None = None
) -> TriggerInfo

Get information about the trigger point in one or more segments of captured data.

If from_segment > to_segment, the segment index will wrap from the last segment back to 0.

Parameters:

Name Type Description Default
from_segment int

The zero-based number of the first segment of interest.

0
to_segment int | None

The zero-based number of the last segment of interest. If None, the last segment is determined from the number of captures.

None

Returns:

Type Description
TriggerInfo

The trigger-information struct.

Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
def get_trigger_info_bulk(self, from_segment: int = 0, to_segment: int | None = None) -> TriggerInfo:
    """Get information about the trigger point in one or more segments of captured data.

    If `from_segment` > `to_segment`, the segment index will wrap from the last segment back to 0.

    Args:
        from_segment: The zero-based number of the first segment of interest.
        to_segment: The zero-based number of the last segment of interest. If `None`,
            the last segment is determined from the number of captures.

    Returns:
        The trigger-information struct.
    """
    n = self.get_no_of_captures()
    if to_segment is None:
        to_segment = n - 1

    ti = _TriggerInfo()
    self._f("GetTriggerInfoBulk", self._handle, byref(ti), from_segment, to_segment)
    if ti.status != PICO_OK:
        msg = Error.get(ti.status, f"UnknownPicoTechError: Error code 0x{ti.status:08x}")
        raise MSLConnectionError(self, msg)

    return TriggerInfo(
        segment_index=ti.segmentIndex,
        trigger_time=ti.triggerTime * _TimeUnits.to_float(ti.timeUnits),
        trigger_index=ti.triggerIndex,
        timestamp_counter=ti.timeStampCounter,
    )

get_trigger_time_offset64 ¤

get_trigger_time_offset64(segment: int = 0) -> float

Gets the time at which the trigger occurred.

Call it after block-mode data has been captured or when data has been retrieved from a previous block-mode capture.

Parameters:

Name Type Description Default
segment int

The index of the memory segment for which the information is required.

0

Returns:

Type Description
float

The offset time, in seconds.

Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
def get_trigger_time_offset64(self, segment: int = 0) -> float:
    """Gets the time at which the trigger occurred.

    Call it after block-mode data has been captured or when data has been retrieved from a
    previous block-mode capture.

    Args:
        segment: The index of the memory segment for which the information is required.

    Returns:
        The offset time, in seconds.
    """
    time = c_int64()
    time_units = c_uint32()
    self._f("GetTriggerTimeOffset64", self._handle, byref(time), byref(time_units), segment)
    return time.value * _TimeUnits.to_float(time_units.value)

get_unit_info ¤

get_unit_info(
    info: PicoInfo | str | int | None = None, *, prefix: bool = True
) -> str

Retrieves information about the PicoScope.

Parameters:

Name Type Description Default
info PicoInfo | str | int | None

The info to get. Can be an enum member name (case insensitive) or value. If None, retrieves all available information.

None
prefix bool

If True, includes the enum member name as a prefix. For example, returns "CAL_DATE: 09Aug16" if prefix is True else "09Aug16".

True

Returns:

Type Description
str

The requested information from the PicoScope.

Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
def get_unit_info(self, info: PicoInfo | str | int | None = None, *, prefix: bool = True) -> str:
    """Retrieves information about the PicoScope.

    Args:
        info: The info to get. Can be an enum member name (case insensitive) or value.
            If `None`, retrieves all available information.
        prefix: If `True`, includes the enum member name as a prefix.
            For example, returns `"CAL_DATE: 09Aug16"` if `prefix` is `True` else `"09Aug16"`.

    Returns:
        The requested information from the PicoScope.
    """
    values = [PicoInfo(i) for i in range(11)] if info is None else [to_enum(info, PicoInfo, to_upper=True)]
    if info is None:
        values.append(PicoInfo.IPP_VERSION)

    string = create_string_buffer(32)
    required_size = c_int16()

    out: list[str] = []
    for value in values:
        name = f"{value.name}: " if prefix else ""
        self._f("GetUnitInfo", self._handle, string, len(string), byref(required_size), value)
        out.append(f"{name}{string.value.decode()}")
    return "\n".join(out)

get_values ¤

get_values(
    num_samples: int | None = None,
    start: int = 0,
    factor: int = 1,
    mode: RatioMode | str | int = "none",
    segment: int = 0,
) -> tuple[int, int]

Get the block-mode data, with or without down sampling, starting at the specified sample number.

It is used to get the stored data from the driver after data collection has stopped.

Parameters:

Name Type Description Default
num_samples int | None

The number of samples required. If None, automatically determine the number of samples to retrieve.

None
start int

A zero-based index that indicates the start point for data collection. It is measured in sample intervals from the start of the buffer.

0
factor int

The down-sampling factor that will be applied to the raw data.

1
mode RatioMode | str | int

Which down-sampling mode to use. Can be an enum member name (case insensitive) or value.

'none'
segment int

The index of the memory segment where the data is stored.

0

Returns:

Type Description
tuple[int, int]

The actual number of samples retrieved and a flag that indicate whether an over-voltage has occurred on any of the channels. It is a bit field with bit 0 denoting Channel A (i.e., (num_samples, overflow)).

Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
def get_values(
    self,
    num_samples: int | None = None,
    start: int = 0,
    factor: int = 1,
    mode: RatioMode | str | int = "none",
    segment: int = 0,
) -> tuple[int, int]:
    """Get the block-mode data, with or without down sampling, starting at the specified sample number.

    It is used to get the stored data from the driver after data collection has stopped.

    Args:
        num_samples: The number of samples required. If `None`, automatically determine
            the number of samples to retrieve.
        start: A zero-based index that indicates the start point for data collection.
            It is measured in sample intervals from the start of the buffer.
        factor: The down-sampling factor that will be applied to the raw data.
        mode: Which down-sampling mode to use. Can be an enum member name (case insensitive) or value.
        segment: The index of the memory segment where the data is stored.

    Returns:
        The actual number of samples retrieved and a flag that indicate whether
            an over-voltage has occurred on any of the channels. It is a bit field
            with bit 0 denoting Channel A (i.e., `(num_samples, overflow)`).
    """
    overflow = c_int16()
    if num_samples is None:
        if self._num_samples < 0:
            msg = "Must call set_timebase() before get_values() or explicitly specify `num_samples`"
            raise MSLConnectionError(self, msg)
        num_samples = self._num_samples
    n_samples = c_uint32(num_samples)
    mode = to_enum(mode, RatioMode, to_upper=True)
    self._f("GetValues", self._handle, start, byref(n_samples), factor, mode, segment, byref(overflow))
    return n_samples.value, overflow.value

get_values_async ¤

get_values_async(
    callback: PicoTechDataReadyCallback,
    num_samples: int | None = None,
    start: int = 0,
    factor: int = 1,
    mode: RatioMode | str | int = "none",
    segment: int = 0,
) -> None

Get data either with or without down sampling, starting at the specified sample number.

It is used to get the stored data from the scope after data collection has stopped. It returns the data to the callback.

Parameters:

Name Type Description Default
callback PicoTechDataReadyCallback

A callback function to call when data is ready.

required
num_samples int | None

The number of samples required. If None, automatically determine the number of samples to retrieve.

None
start int

A zero-based index that indicates the start point for data collection. It is measured in sample intervals from the start of the buffer.

0
factor int

The down-sampling factor that will be applied to the raw data.

1
mode RatioMode | str | int

Which down-sampling mode to use. Can be an enum member name (case insensitive) or value.

'none'
segment int

The index of the memory segment where the data is stored.

0
Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
def get_values_async(
    self,
    callback: PicoTechDataReadyCallback,
    num_samples: int | None = None,
    start: int = 0,
    factor: int = 1,
    mode: RatioMode | str | int = "none",
    segment: int = 0,
) -> None:
    """Get data either with or without down sampling, starting at the specified sample number.

    It is used to get the stored data from the scope after data collection has stopped.
    It returns the data to the callback.

    Args:
        callback: A callback function to call when data is ready.
        num_samples: The number of samples required. If `None`, automatically determine the
            number of samples to retrieve.
        start: A zero-based index that indicates the start point for data collection.
            It is measured in sample intervals from the start of the buffer.
        factor: The down-sampling factor that will be applied to the raw data.
        mode: Which down-sampling mode to use. Can be an enum member name (case insensitive) or value.
        segment: The index of the memory segment where the data is stored.
    """
    if num_samples is None:
        if self._num_samples < 0:
            msg = "Must call set_timebase() before get_values_async() or explicitly specify `num_samples`"
            raise MSLConnectionError(self, msg)
        num_samples = self._num_samples
    mode = to_enum(mode, RatioMode, to_upper=True)
    self._f("GetValuesAsync", self._handle, start, num_samples, factor, mode, segment, callback, None)

get_values_bulk ¤

get_values_bulk(
    from_segment: int = 0,
    to_segment: int | None = None,
    factor: int = 1,
    mode: RatioMode | str | int = "none",
    num_samples: int | None = None,
) -> tuple[int, list[int]]

Get waveforms captured using rapid block mode.

The waveforms must have been collected sequentially and in the same run.

Parameters:

Name Type Description Default
from_segment int

The first segment from which the waveform should be retrieved.

0
to_segment int | None

The last segment from which the waveform should be retrieved. If None, the last segment is determined from the number of captures.

None
factor int

The down-sampling factor that will be applied to the raw data.

1
mode RatioMode | str | int

Which down-sampling mode to use. Can be an enum member name (case insensitive) or value.

'none'
num_samples int | None

The number of samples required. If None, automatically determine the number of samples to retrieve.

None

Returns:

Type Description
tuple[int, list[int]]

The actual number samples retrieved per capture and a list of overflow bit-mask flags for each capture.

Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
def get_values_bulk(
    self,
    from_segment: int = 0,
    to_segment: int | None = None,
    factor: int = 1,
    mode: RatioMode | str | int = "none",
    num_samples: int | None = None,
) -> tuple[int, list[int]]:
    """Get waveforms captured using rapid block mode.

    The waveforms must have been collected sequentially and in the same run.

    Args:
        from_segment: The first segment from which the waveform should be retrieved.
        to_segment: The last segment from which the waveform should be retrieved. If `None`,
            the last segment is determined from the number of captures.
        factor: The down-sampling factor that will be applied to the raw data.
        mode: Which down-sampling mode to use. Can be an enum member name (case insensitive) or value.
        num_samples: The number of samples required. If `None`, automatically determine the
            number of samples to retrieve.

    Returns:
        The actual number samples retrieved per capture and a list of overflow bit-mask flags for each capture.
    """
    if num_samples is None:
        if self._num_samples < 0:
            msg = "Must call set_timebase() before get_values_bulk() or explicitly specify `num_samples`"
            raise MSLConnectionError(self, msg)
        num_samples = self._num_samples

    n = self.get_no_of_captures()
    if to_segment is None:
        to_segment = n - 1

    num_segments = to_segment - from_segment + 1
    no_of_samples = c_uint32(num_samples * n)
    overflow = (c_int16 * num_segments)()
    mode = to_enum(mode, RatioMode, to_upper=True)
    self._f("GetValuesBulk", self._handle, byref(no_of_samples), from_segment, to_segment, factor, mode, overflow)
    overflows: list[int] = list(overflow)
    return no_of_samples.value, overflows

get_values_overlapped ¤

get_values_overlapped(
    start: int = 0,
    factor: int = 1,
    mode: RatioMode | str | int = "none",
    segment: int = 0,
) -> tuple[int, int]

Allows you to make a deferred data-collection request in block mode.

The advantage of this function is that the driver makes contact with the scope only once, when you call run_block, compared with the two contacts that occur when you use the conventional run_block, get_values calling sequence. This slightly reduces the dead time between successive captures in block mode.

Parameters:

Name Type Description Default
start int

A zero-based index that indicates the start point for data collection. It is measured in sample intervals from the start of the buffer.

0
factor int

The down-sampling factor that will be applied to the raw data.

1
mode RatioMode | str | int

Which down-sampling mode to use. Can be an enum member name (case insensitive) or value.

'none'
segment int

The index of the memory segment where the data is stored.

0

Returns:

Type Description
tuple[int, int]

The actual number of samples retrieved and a flag that indicate whether an over-voltage has occurred on any of the channels. It is a bit field with bit 0 denoting Channel A (i.e., (num_samples, overflow)).

Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
def get_values_overlapped(
    self, start: int = 0, factor: int = 1, mode: RatioMode | str | int = "none", segment: int = 0
) -> tuple[int, int]:
    """Allows you to make a deferred data-collection request in block mode.

    The advantage of this function is that the driver makes contact with the scope only once,
    when you call [run_block][msl.equipment_resources.picotech.picoscope.PicoScope.run_block], compared
    with the two contacts that occur when you use the conventional
    [run_block][msl.equipment_resources.picotech.picoscope.PicoScope.run_block],
    [get_values][msl.equipment_resources.picotech.picoscope.PicoScope.get_values] calling sequence.
    This slightly reduces the dead time between successive captures in block mode.

    Args:
        start: A zero-based index that indicates the start point for data collection.
            It is measured in sample intervals from the start of the buffer.
        factor: The down-sampling factor that will be applied to the raw data.
        mode: Which down-sampling mode to use. Can be an enum member name (case insensitive) or value.
        segment: The index of the memory segment where the data is stored.

    Returns:
        The actual number of samples retrieved and a flag that indicate whether
            an over-voltage has occurred on any of the channels. It is a bit field
            with bit 0 denoting Channel A (i.e., `(num_samples, overflow)`).
    """
    no_of_samples = c_uint32()
    overflow = c_int16()
    mode = to_enum(mode, RatioMode, to_upper=True)
    self._f(
        "GetValuesOverlapped", self._handle, start, byref(no_of_samples), factor, mode, segment, byref(overflow)
    )
    return no_of_samples.value, overflow.value

get_values_overlapped_bulk ¤

get_values_overlapped_bulk(
    start: int = 0,
    factor: int = 1,
    mode: RatioMode | str | int = "none",
    from_segment: int = 0,
    to_segment: int | None = None,
    num_samples: int | None = None,
) -> tuple[int, list[int]]

Allows you to make a deferred data-collection request in block mode.

The advantage of this function is that the driver makes contact with the scope only once, when you call run_block, compared with the two contacts that occur when you use the conventional run_block, get_values_bulk calling sequence. This slightly reduces the dead time between successive captures in rapid block mode.

Parameters:

Name Type Description Default
start int

A zero-based index that indicates the start point for data collection. It is measured in sample intervals from the start of the buffer.

0
factor int

The down-sampling factor that will be applied to the raw data.

1
mode RatioMode | str | int

Which down-sampling mode to use. Can be an enum member name (case insensitive) or value.

'none'
from_segment int

The first segment from which the waveform should be retrieved.

0
to_segment int | None

The last segment from which the waveform should be retrieved. If None, the last segment is determined from the number of captures.

None
num_samples int | None

The number of samples required. If None, automatically determine the number of samples to retrieve.

None

Returns:

Type Description
tuple[int, list[int]]

The actual number samples retrieved per capture and a list of overflow bit-mask flags for each capture.

Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
def get_values_overlapped_bulk(
    self,
    start: int = 0,
    factor: int = 1,
    mode: RatioMode | str | int = "none",
    from_segment: int = 0,
    to_segment: int | None = None,
    num_samples: int | None = None,
) -> tuple[int, list[int]]:
    """Allows you to make a deferred data-collection request in block mode.

    The advantage of this function is that the driver makes contact with the scope only once,
    when you call [run_block][msl.equipment_resources.picotech.picoscope.PicoScope.run_block], compared
    with the two contacts that occur when you use the conventional
    [run_block][msl.equipment_resources.picotech.picoscope.PicoScope.run_block],
    [get_values_bulk][msl.equipment_resources.picotech.picoscope.PicoScope.get_values_bulk] calling sequence.
    This slightly reduces the dead time between successive captures in rapid block mode.

    Args:
        start: A zero-based index that indicates the start point for data collection.
            It is measured in sample intervals from the start of the buffer.
        factor: The down-sampling factor that will be applied to the raw data.
        mode: Which down-sampling mode to use. Can be an enum member name (case insensitive) or value.
        from_segment: The first segment from which the waveform should be retrieved.
        to_segment: The last segment from which the waveform should be retrieved. If `None`,
            the last segment is determined from the number of captures.
        num_samples: The number of samples required. If `None`, automatically determine the
            number of samples to retrieve.

    Returns:
        The actual number samples retrieved per capture and a list of overflow bit-mask flags for each capture.
    """
    if num_samples is None:
        if self._num_samples < 0:
            msg = "Must call set_timebase() before get_values_overlapped_bulk() or explicitly specify `num_samples`"
            raise MSLConnectionError(self, msg)
        num_samples = self._num_samples

    n = self.get_no_of_captures()
    if to_segment is None:
        to_segment = n - 1

    num_segments = to_segment - from_segment + 1
    no_of_samples = c_uint32(num_samples * n)
    overflow = (c_int16 * num_segments)()
    mode = to_enum(mode, RatioMode, to_upper=True)
    self._f(
        "GetValuesOverlappedBulk",
        self._handle,
        start,
        byref(no_of_samples),
        factor,
        mode,
        from_segment,
        to_segment,
        byref(overflow),
    )

    overflows: list[int] = list(overflow)
    return no_of_samples.value, overflows

get_values_trigger_time_offset_bulk64 ¤

get_values_trigger_time_offset_bulk64(
    from_segment: int = 0, to_segment: int | None = None
) -> list[float]

Get the 64-bit time offsets for waveforms captured in rapid block mode.

If from_segment > to_segment, the segment index will wrap from the last segment back to 0.

Parameters:

Name Type Description Default
from_segment int

The zero-based number of the first segment of interest.

0
to_segment int | None

The zero-based number of the last segment of interest. If None, the last segment is determined from the number of captures.

None

Returns:

Type Description
list[float]

The trigger time offset, in seconds, for each requested segment index.

Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
def get_values_trigger_time_offset_bulk64(
    self, from_segment: int = 0, to_segment: int | None = None
) -> list[float]:
    """Get the 64-bit time offsets for waveforms captured in rapid block mode.

    If `from_segment` > `to_segment`, the segment index will wrap from the last segment back to 0.

    Args:
        from_segment: The zero-based number of the first segment of interest.
        to_segment: The zero-based number of the last segment of interest. If `None`,
            the last segment is determined from the number of captures.

    Returns:
        The trigger time offset, in seconds, for each requested segment index.
    """
    if to_segment is None:
        to_segment = self.get_no_of_captures() - 1
    n = to_segment - from_segment + 1
    times = (c_int64 * n)()
    units = (c_uint32 * n)()
    self._f("GetValuesTriggerTimeOffsetBulk64", self._handle, times, units, from_segment, to_segment)
    tu = [_TimeUnits(u) for u in units]
    return [t * _TimeUnits.to_float(u) for t, u in zip(times, tu)]

is_led_flashing ¤

is_led_flashing() -> int

This function reports whether or not the LED is flashing.

Returns:

Type Description
int

Whether the LED is flashing.

Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
791
792
793
794
795
796
797
798
799
def is_led_flashing(self) -> int:
    """This function reports whether or not the LED is flashing.

    Returns:
        Whether the LED is flashing.
    """
    status = c_int16()
    self._f("IsLedFlashing", self._handle, byref(status))
    return bool(status.value)

is_ready ¤

is_ready() -> bool

Check if the PicoScope has collected the requested number of samples.

This function may be used instead of a callback function to receive data from run_block. To use this method, pass None as the callback parameter in run_block. You must then poll the driver to see if it has finished collecting the requested samples.

Returns:

Type Description
bool

Whether the PicoScope has collected the requested number of samples.

Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
def is_ready(self) -> bool:
    """Check if the PicoScope has collected the requested number of samples.

    This function may be used instead of a callback function to receive data from
    [run_block][msl.equipment_resources.picotech.picoscope.PicoScope.run_block].
    To use this method, pass `None` as the callback parameter in
    [run_block][msl.equipment_resources.picotech.picoscope.PicoScope.run_block].
    You must then poll the driver to see if it has finished collecting the requested samples.

    Returns:
        Whether the PicoScope has collected the requested number of samples.
    """
    ready = c_int16()
    self._f("IsReady", self._handle, byref(ready))
    return bool(ready.value)

is_trigger_or_pulse_width_qualifier_enabled ¤

is_trigger_or_pulse_width_qualifier_enabled() -> tuple[bool, bool]

This function checks whether the trigger or pulse-width qualifier is enabled.

Returns:

Type Description
tuple[bool, bool]

Whether the trigger is enabled and the pulse-width qualifier is enabled, i.e., (trigger, pwq).

Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
def is_trigger_or_pulse_width_qualifier_enabled(self) -> tuple[bool, bool]:
    """This function checks whether the trigger or pulse-width qualifier is enabled.

    Returns:
        Whether the trigger is enabled and the pulse-width qualifier is enabled, i.e., `(trigger, pwq)`.
    """
    trigger_enabled = c_int16()
    pulse_width_qualifier_enabled = c_int16()
    self._f(
        "IsTriggerOrPulseWidthQualifierEnabled",
        self._handle,
        byref(trigger_enabled),
        byref(pulse_width_qualifier_enabled),
    )
    return bool(trigger_enabled.value), bool(pulse_width_qualifier_enabled.value)

maximum_value ¤

maximum_value() -> int

Get the maximum ADC value.

Returns:

Type Description
int

The maximum ADC value.

Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
833
834
835
836
837
838
839
840
841
def maximum_value(self) -> int:
    """Get the maximum ADC value.

    Returns:
        The maximum ADC value.
    """
    value = c_int16()
    self._f("MaximumValue", self._handle, byref(value))
    return value.value

memory_segments ¤

memory_segments(num_segments: int) -> int

Sets the number of memory segments that the scope will use.

When the scope is opened, the number of segments defaults to 1, meaning that each capture fills the scopes available memory. This function allows you to divide the memory into a number of segments so that the scope can store several waveforms sequentially.

Parameters:

Name Type Description Default
num_segments int

The number of memory segments.

required

Returns:

Type Description
int

The number of samples available in each segment. This is the total number over all channels, so if two channels or 8-bit digital ports are in use, the number of samples available to each channel is divided by 2.

Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
def memory_segments(self, num_segments: int) -> int:
    """Sets the number of memory segments that the scope will use.

    When the scope is opened, the number of segments defaults to 1, meaning that each
    capture fills the scopes available memory. This function allows you to divide the
    memory into a number of segments so that the scope can store several waveforms
    sequentially.

    Args:
        num_segments: The number of memory segments.

    Returns:
        The number of samples available in each segment. This is the total number over
            all channels, so if two channels or 8-bit digital ports are in use, the number
            of samples available to each channel is divided by 2.
    """
    num_max_samples = c_int32()
    self._f("MemorySegments", self._handle, num_segments, byref(num_max_samples))
    return num_max_samples.value

minimum_value ¤

minimum_value() -> int

Get the minimum ADC value.

Returns:

Type Description
int

The minimum ADC value.

Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
863
864
865
866
867
868
869
870
871
def minimum_value(self) -> int:
    """Get the minimum ADC value.

    Returns:
        The minimum ADC value.
    """
    value = c_int16()
    self._f("MinimumValue", self._handle, byref(value))
    return value.value

nearest_sample_interval_stateless ¤

nearest_sample_interval_stateless(
    *,
    flags: ChannelFlags,
    dt: float,
    resolution: DeviceResolution | str | int,
    use_ets: bool = False
) -> tuple[int, float]

Get the nearest timebase index and sample interval for the proposed configuration.

It does not write the configuration to the device.

Parameters:

Name Type Description Default
flags ChannelFlags

The proposed combination of enabled channels and ports. To specify multiple channels and ports, use the bitwise-OR of the relevant ChannelFlags.

required
dt float

The proposed sampling interval, in seconds.

required
resolution DeviceResolution | str | int

The resolution mode in which you propose to operate the oscilloscope. Can be an enum member name (case insensitive, with or without the "DR_" prefix) or value.

required
use_ets bool

The proposed state of ETS (disabled or enabled).

False

Returns:

Type Description
tuple[int, float]

The nearest (rounded up) timebase index and sampling interval, in seconds, corresponding to the proposed configuration.

Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
def nearest_sample_interval_stateless(
    self, *, flags: ChannelFlags, dt: float, resolution: DeviceResolution | str | int, use_ets: bool = False
) -> tuple[int, float]:
    """Get the nearest timebase index and sample interval for the proposed configuration.

    It does not write the configuration to the device.

    Args:
        flags: The proposed combination of enabled channels and ports. To specify multiple
            channels and ports, use the bitwise-OR of the relevant
            [ChannelFlags][msl.equipment_resources.picotech.picoscope.ChannelFlags].
        dt: The proposed sampling interval, in seconds.
        resolution: The resolution mode in which you propose to operate the oscilloscope.
            Can be an enum member name (case insensitive, with or without the "DR_" prefix) or value.
        use_ets: The proposed state of ETS (disabled or enabled).

    Returns:
        The nearest (rounded up) timebase index and sampling interval, in seconds,
            corresponding to the proposed configuration.
    """
    timebase = c_uint32()
    t = c_double()
    r = to_enum(resolution, DeviceResolution, prefix="DR_", to_upper=True)
    self._f("NearestSampleIntervalStateless", self._handle, flags, dt, r, int(use_ets), byref(timebase), byref(t))
    return timebase.value, t.value

no_of_streaming_values ¤

no_of_streaming_values() -> int

Gets the number of samples available after data collection in streaming mode.

Call it after calling stop.

Returns:

Type Description
int

The number of samples.

Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
899
900
901
902
903
904
905
906
907
908
909
def no_of_streaming_values(self) -> int:
    """Gets the number of samples available after data collection in streaming mode.

    Call it after calling [stop][msl.equipment_resources.picotech.picoscope.PicoScope.stop].

    Returns:
        The number of samples.
    """
    no_of_values = c_uint32()
    self._f("NoOfStreamingValues", self._handle, byref(no_of_values))
    return no_of_values.value

ping_unit ¤

ping_unit() -> None

Ping the PicoScope.

This function can be used to check that the already opened device is still connected to the USB port and communication is successful.

Raises MSLConnectionError if pinging was not successful.

Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
911
912
913
914
915
916
917
918
919
920
def ping_unit(self) -> None:
    """Ping the PicoScope.

    This function can be used to check that the already opened device is still
    connected to the USB port and communication is successful.

    Raises [MSLConnectionError][msl.equipment.interfaces.message_based.MSLConnectionError]
    if pinging was not successful.
    """
    self._f("PingUnit", self._handle)

query_output_edge_detect ¤

query_output_edge_detect() -> bool

Whether output edge detection mode is currently enabled.

The default state is enabled.

Returns:

Type Description
bool

Whether edge detection is enabled.

Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
922
923
924
925
926
927
928
929
930
931
932
def query_output_edge_detect(self) -> bool:
    """Whether output edge detection mode is currently enabled.

    The default state is enabled.

    Returns:
        Whether edge detection is enabled.
    """
    state = c_int16()
    self._f("QueryOutputEdgeDetect", self._handle, byref(state))
    return bool(state)

run_block ¤

run_block(
    pre_trigger: float = 0.0,
    callback: PicoTechBlockReadyCallback | None = None,
    segment: int = 0,
) -> float

Start acquiring samples in block mode.

Parameters:

Name Type Description Default
pre_trigger float

The number of seconds before the trigger event to start acquiring samples. The value must be ≥ 0.

0.0
callback PicoTechBlockReadyCallback | None

An optional callback function to be called when all samples have been acquired. (see also, wait_until_ready and is_ready).

None
segment int

The index of the memory segment to save the samples to.

0

Returns:

Type Description
float

The approximate time, in seconds, that the scope will spend acquiring samples. This does not include any auto trigger timeout

Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
def run_block(
    self,
    pre_trigger: float = 0.0,
    callback: PicoTechBlockReadyCallback | None = None,
    segment: int = 0,
) -> float:
    """Start acquiring samples in block mode.

    Args:
        pre_trigger: The number of seconds before the trigger event to start acquiring samples.
            The value must be &ge; 0.
        callback: An optional callback function to be called when all samples have been acquired.
            (see also, [wait_until_ready][msl.equipment_resources.picotech.picoscope.PicoScope.wait_until_ready]
            and [is_ready][msl.equipment_resources.picotech.picoscope.PicoScope.is_ready]).
        segment: The index of the memory segment to save the samples to.

    Returns:
        The approximate time, in seconds, that the scope will spend acquiring samples.
            This does not include any auto trigger timeout
    """
    if not self._channels:
        msg = "Must call set_channel() to configure all channels before starting a run block"
        raise MSLConnectionError(self, msg)

    if self._sampling_interval < 0 or self._num_samples < 0:
        msg = "Must call set_timebase() before starting a run block"
        raise MSLConnectionError(self, msg)

    if pre_trigger < 0:
        msg = "The pre-trigger value cannot be negative."
        raise ValueError(msg)

    self._pre_trigger = pre_trigger
    n_pre = round(pre_trigger / self._sampling_interval)
    n_post = self._num_samples - n_pre

    if callback is None:  # a dummy callback
        callback = _BlockReady(0, "", None)

    time_ms = c_int32()
    self._f("RunBlock", self._handle, n_pre, n_post, self._timebase_index, byref(time_ms), segment, callback, None)
    return round(time_ms.value * 1e-3, 3)

run_streaming ¤

run_streaming(
    pre_trigger: float = 0.0,
    factor: int = 1,
    mode: RatioMode | str | int = "none",
    *,
    auto_stop: bool = True,
    strict: bool = True
) -> float

Start collecting samples in streaming mode.

This function tells the oscilloscope to start collecting data in streaming mode. When data has been collected from the device it is down sampled if necessary and then delivered to the application. Call get_streaming_latest_values to retrieve the data.

Parameters:

Name Type Description Default
pre_trigger float

The number of seconds before the trigger event to start acquiring data.

0.0
factor int

The down-sampling factor that will be applied to the raw data.

1
mode RatioMode | str | int

Which down-sampling mode to use. Can be an enum member name (case insensitive) or value.

'none'
auto_stop bool

Whether streaming should stop when all of samples have been captured.

True
strict bool

Whether to force the requested and the actual sampling intervals to be equal.

True

Returns:

Type Description
float

The actual time interval, in seconds, between samples.

Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
def run_streaming(
    self,
    pre_trigger: float = 0.0,
    factor: int = 1,
    mode: RatioMode | str | int = "none",
    *,
    auto_stop: bool = True,
    strict: bool = True,
) -> float:
    """Start collecting samples in streaming mode.

    This function tells the oscilloscope to start collecting data in streaming mode. When
    data has been collected from the device it is down sampled if necessary and then
    delivered to the application. Call
    [get_streaming_latest_values][msl.equipment_resources.picotech.picoscope.PicoScope.get_streaming_latest_values]
    to retrieve the data.

    Args:
        pre_trigger: The number of seconds before the trigger event to start acquiring data.
        factor: The down-sampling factor that will be applied to the raw data.
        mode: Which down-sampling mode to use. Can be an enum member name (case insensitive) or value.
        auto_stop: Whether streaming should stop when all of samples have been captured.
        strict: Whether to force the requested and the actual sampling intervals to be equal.

    Returns:
        The actual time interval, in seconds, between samples.
    """
    self.streaming_done = False

    if not self._channels:
        msg = "Must call set_channel() to configure all channels before starting a run streaming"
        raise MSLConnectionError(self, msg)

    if self._sampling_interval < 0 or self._num_samples < 0:
        msg = "Must call set_timebase() before starting a run streaming"
        raise MSLConnectionError(self, msg)

    if pre_trigger < 0:
        msg = "The pre-trigger value cannot be negative."
        raise ValueError(msg)

    self._pre_trigger = pre_trigger

    n_pre = round(pre_trigger / self._sampling_interval)  # don't use self._streaming_sampling_interval
    n_post = self._num_samples - n_pre

    mode = to_enum(mode, RatioMode, to_upper=True)
    interval = c_uint32(self._streaming_sampling_interval)
    self._f(
        "RunStreaming",
        self._handle,
        byref(interval),
        self._streaming_time_units,
        n_pre,
        n_post,
        auto_stop,
        factor,
        mode,
        self._buffer_size,
    )

    time_factor = _TimeUnits.to_float(self._streaming_time_units)
    dt = interval.value * time_factor
    if strict and (interval.value != self._streaming_sampling_interval):
        msg = (
            f"The actual streaming sampling interval is {dt:.6e} seconds, "
            f"requested {self._streaming_sampling_interval * time_factor:.6e} seconds"
        )
        raise MSLConnectionError(self, msg)

    return dt

set_auto_trigger ¤

set_auto_trigger(wait: float) -> None

Sets up the auto-trigger function.

The auto-trigger function starts a capture if no trigger event occurs within a specified time after a run command has been issued.

Parameters:

Name Type Description Default
wait float

The number of seconds to wait for a trigger before timing out. If this argument is zero, the scope will wait indefinitely for a trigger. Rounds to the nearest microsecond.

required
Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
def set_auto_trigger(self, wait: float) -> None:
    """Sets up the auto-trigger function.

    The auto-trigger function starts a capture if no trigger event occurs within a
    specified time after a run command has been issued.

    Args:
        wait: The number of seconds to wait for a trigger before timing out.
            If this argument is zero, the scope will wait indefinitely for a trigger.
            Rounds to the nearest microsecond.
    """
    self._f("SetAutoTriggerMicroSeconds", self._handle, round(wait * 1e6))

set_channel ¤

set_channel(
    channel: Channel | str | int,
    *,
    bandwidth: BandwidthLimiter | str | int = "full",
    coupling: Coupling | str | int = "dc",
    enabled: bool = True,
    offset: float = 0.0,
    range: Range | str | int = "10V"
) -> None

Configure a channel.

Parameters:

Name Type Description Default
channel Channel | str | int

The channel to configure. Can be an enum member name (case insensitive) or value.

required
bandwidth BandwidthLimiter | str | int

The bandwidth limiter to use. Can be an enum member name (case insensitive, with or without the "BW_" prefix) or value.

'full'
coupling Coupling | str | int

The impedance and coupling type. Can be an enum member name (case insensitive) or value.

'dc'
enabled bool

Whether to enable the channel.

True
offset float

A voltage to add to the input channel before digitization. The allowable range of offsets depends on the input range selected for the channel, as obtained from get_analogue_offset.

0.0
range Range | str | int

The input voltage range. Can be an enum member name (with or without the "R_" prefix) or value.

'10V'
Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
def set_channel(
    self,
    channel: Channel | str | int,
    *,
    bandwidth: BandwidthLimiter | str | int = "full",
    coupling: Coupling | str | int = "dc",
    enabled: bool = True,
    offset: float = 0.0,
    range: Range | str | int = "10V",  # noqa: A002
) -> None:
    """Configure a channel.

    Args:
        channel: The channel to configure. Can be an enum member name (case insensitive) or value.
        bandwidth: The bandwidth limiter to use. Can be an enum member name (case insensitive, with
            or without the `"BW_"` prefix) or value.
        coupling: The impedance and coupling type. Can be an enum member name (case insensitive) or value.
        enabled: Whether to enable the channel.
        offset: A voltage to add to the input channel before digitization. The allowable range of
            offsets depends on the input range selected for the channel, as obtained from
            [get_analogue_offset][msl.equipment_resources.picotech.picoscope.PicoScope.get_analogue_offset].
        range: The input voltage range. Can be an enum member name (with or without the `"R_"` prefix) or value.
    """
    channel = to_enum(channel, Channel, to_upper=True)
    bandwidth = to_enum(bandwidth, BandwidthLimiter, prefix="BW_", to_upper=True)
    coupling = to_enum(coupling, Coupling, to_upper=True)
    _range = to_enum(range, Range, prefix="R_")

    # If range=MAX, the SDK uses the maximum enum value and not the maximum range that
    # the PicoScope supports. Here, we choose the maximum supported range.
    if _range == Range.R_MAX:
        _range = Range(self.get_channel_information(channel, info=ChannelInfo.RANGES)[-1])

    self._f("SetChannel", self._handle, channel, enabled, coupling, _range, offset)
    self._f("SetBandwidthFilter", self._handle, channel, bandwidth)

    # Get the voltage range as a floating-point number
    match = re.search(r"(?P<value>\d+)", _range.name)
    assert match is not None  # noqa: S101
    voltage_range = float(match["value"])
    if _range.name.endswith("mV"):
        voltage_range *= 1e-3

    self._channels[channel.name] = ChannelSettings(
        channel=channel,
        enabled=bool(enabled),
        coupling=coupling,
        voltage_range=_range,
        voltage_offset=offset,
        bandwidth=bandwidth,
        max_adu_value=self.maximum_value(),
    )

set_data_buffer ¤

set_data_buffer(
    channel: Channel | str | int,
    buffer: NDArray[int16] | None = None,
    mode: RatioMode | str | int = "none",
    segment: int = 0,
) -> None

Set the data buffer for the specified channel.

Parameters:

Name Type Description Default
channel Channel | str | int

The channel. Can be an enum member name (case insensitive) or value.

required
buffer NDArray[int16] | None

A numpy array of dtype int16. If None then use a pre-allocated array.

None
mode RatioMode | str | int

The ratio mode. Can be an enum member name (case insensitive) or value.

'none'
segment int

The index of the memory segment where the data is stored.

0
Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
def set_data_buffer(
    self,
    channel: Channel | str | int,
    buffer: NDArray[np.int16] | None = None,
    mode: RatioMode | str | int = "none",
    segment: int = 0,
) -> None:
    """Set the data buffer for the specified channel.

    Args:
        channel: The channel. Can be an enum member name (case insensitive) or value.
        buffer: A numpy array of dtype [int16][numpy.int16]. If `None` then use a pre-allocated array.
        mode: The ratio mode. Can be an enum member name (case insensitive) or value.
        segment: The index of the memory segment where the data is stored.
    """
    ch = to_enum(channel, Channel, to_upper=True)
    mode = to_enum(mode, RatioMode, to_upper=True)
    if buffer is None:
        if ch.name not in self._channels:
            msg = (
                f"Must call set_channel(channel='{ch.name}', ...) before setting the data buffer "
                f"or specify which buffer to use"
            )
            raise MSLConnectionError(self, msg)

        if self._num_samples < 0:
            msg = "Must call set_timebase() before setting the data buffer or specify which buffer to use"
            raise MSLConnectionError(self, msg)

        self.channel[ch.name].allocate(num_samples=self._num_samples, num_captures=self._num_captures)
        buffer = self.channel[ch.name].buffer
        self._buffer_size = buffer.size

    self._f("SetDataBuffer", self._handle, ch, buffer, buffer.size, segment, mode)

set_data_buffers ¤

set_data_buffers(
    channel: Channel | str | int,
    buffer_max: NDArray[int16] | None = None,
    buffer_min: NDArray[int16] | None = None,
    mode: RatioMode | str | int = "none",
    segment: int = 0,
) -> None

Set the location of one or two buffers for receiving data.

Parameters:

Name Type Description Default
channel Channel | str | int

The channel. Can be an enum member name (case insensitive) or value.

required
buffer_max NDArray[int16] | None

A user-allocated buffer to receive the maximum data values in aggregation mode, or the non-aggregated values otherwise. Each value is a 16-bit ADC count scaled according to the selected voltage range for the channel.

None
buffer_min NDArray[int16] | None

A user-allocated buffer to receive the minimum data values in aggregation mode. Not normally used in other modes, but you can direct the driver to write non-aggregated values to this buffer by setting buffer_max to None.

None
mode RatioMode | str | int

The ratio mode. Can be an enum member name (case insensitive) or value.

'none'
segment int

The index of the memory segment where the data is stored.

0
Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
def set_data_buffers(
    self,
    channel: Channel | str | int,
    buffer_max: NDArray[np.int16] | None = None,
    buffer_min: NDArray[np.int16] | None = None,
    mode: RatioMode | str | int = "none",
    segment: int = 0,
) -> None:
    """Set the location of one or two buffers for receiving data.

    Args:
        channel: The channel. Can be an enum member name (case insensitive) or value.
        buffer_max: A user-allocated buffer to receive the maximum data values in aggregation mode,
            or the non-aggregated values otherwise. Each value is a 16-bit ADC count scaled
            according to the selected voltage range for the `channel`.
        buffer_min: A user-allocated buffer to receive the minimum data values in aggregation mode.
            Not normally used in other modes, but you can direct the driver to write non-aggregated
            values to this buffer by setting `buffer_max` to `None`.
        mode: The ratio mode. Can be an enum member name (case insensitive) or value.
        segment: The index of the memory segment where the data is stored.
    """
    ch = to_enum(channel, Channel, to_upper=True)
    mode = to_enum(mode, RatioMode, to_upper=True)
    if buffer_min is None:
        if ch.name not in self._channels:
            msg = f"Must call set_channel(channel='{ch.name}', ...) before setting the data buffers"
            raise MSLConnectionError(self, msg)
        buffer_min = self.channel[ch.name].buffer

    if buffer_max is not None and buffer_max.size != buffer_min.size:
        msg = f"The size of buffer_max, {buffer_max.size}, and buffer_min, {buffer_min.size} are not equal"
        raise ValueError(msg)

    self._buffer_size = buffer_min.size
    self._f("SetDataBuffers", self._handle, ch, buffer_max, buffer_min, buffer_min.size, segment, mode)

set_device_resolution ¤

set_device_resolution(bit_depth: DeviceResolution | str | int) -> None

Set the device resolution.

Parameters:

Name Type Description Default
bit_depth DeviceResolution | str | int

The resolution. Can be an enum member name (case insensitive, with or without the "DR_" prefix) or value.

required
Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
1186
1187
1188
1189
1190
1191
1192
1193
1194
def set_device_resolution(self, bit_depth: DeviceResolution | str | int) -> None:
    """Set the device resolution.

    Args:
        bit_depth: The resolution. Can be an enum member name (case insensitive,
            with or without the `"DR_"` prefix) or value.
    """
    resolution = to_enum(bit_depth, DeviceResolution, prefix="DR_", to_upper=True)
    self._f("SetDeviceResolution", self._handle, resolution)

set_digital_port ¤

set_digital_port(
    port: Channel | str | int, logic_level: int, *, enabled: bool = True
) -> None

Enable the digital port and set the logic level.

Parameters:

Name Type Description Default
port Channel | str | int

A digital channel. Can be an enum member name (case insensitive) or value.

required
logic_level int

The voltage at which the state transitions from 0 to 1.

required
enabled bool

Whether to enable or disable the port.

True
Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
1196
1197
1198
1199
1200
1201
1202
1203
1204
def set_digital_port(self, port: Channel | str | int, logic_level: int, *, enabled: bool = True) -> None:
    """Enable the digital port and set the logic level.

    Args:
        port: A digital channel. Can be an enum member name (case insensitive) or value.
        logic_level: The voltage at which the state transitions from 0 to 1.
        enabled: Whether to enable or disable the `port`.
    """
    self._f("SetDigitalPort", self._handle, port, enabled, logic_level)

set_ets ¤

set_ets(mode: ETSMode | str | int, cycles: int, interleave: int) -> float

Enable or disable ETS (equivalent-time sampling) and set the ETS parameters.

Parameters:

Name Type Description Default
mode ETSMode | str | int

The ETS mode. Can be an enum member name (case insensitive) or value.

required
cycles int

The number of ETS cycles to store.

required
interleave int

The number of waveforms to combine into a single ETS capture.

required

Returns:

Type Description
float

The effective sampling interval, in seconds, of the ETS data.

Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
def set_ets(self, mode: ETSMode | str | int, cycles: int, interleave: int) -> float:
    """Enable or disable ETS (equivalent-time sampling) and set the ETS parameters.

    Args:
        mode: The ETS mode. Can be an enum member name (case insensitive) or value.
        cycles: The number of ETS cycles to store.
        interleave: The number of waveforms to combine into a single ETS capture.

    Returns:
        The effective sampling interval, in seconds, of the ETS data.
    """
    mode = to_enum(mode, ETSMode, to_upper=True)
    sample_time_picoseconds = c_int32()
    self._f("SetEts", self._handle, mode, cycles, interleave, byref(sample_time_picoseconds))
    dt = sample_time_picoseconds.value * 1e-12
    self._sampling_interval = dt
    return dt

set_ets_time_buffer ¤

set_ets_time_buffer(buffer: NDArray[int64]) -> None

Set the ETS time buffers.

This function tells the driver where to find your applications ETS time buffers. These buffers contain the timing information for each ETS sample after you run a block-mode ETS capture.

Parameters:

Name Type Description Default
buffer NDArray[int64]

A numpy array of dtype int64 where each element represents the time, in femtoseconds, at which the samples were captured.

required
Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
def set_ets_time_buffer(self, buffer: NDArray[np.int64]) -> None:
    """Set the ETS time buffers.

    This function tells the driver where to find your applications ETS time buffers. These
    buffers contain the timing information for each ETS sample after you run a block-mode
    ETS capture.

    Args:
        buffer: A numpy array of dtype [int64][numpy.int64] where each element represents the
            time, in femtoseconds, at which the samples were captured.
    """
    self._f("SetEtsTimeBuffer", self._handle, buffer, len(buffer))

set_no_of_captures ¤

set_no_of_captures(n: int) -> None

Sets the number of captures to be collected in one run of rapid block mode.

If you do not call this function before a run, the driver will capture only one waveform. Once a value has been set, the value remains constant unless changed.

Parameters:

Name Type Description Default
n int

The number of captures.

required
Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
def set_no_of_captures(self, n: int) -> None:
    """Sets the number of captures to be collected in one run of rapid block mode.

    If you do not call this function before a run, the driver will capture only one
    waveform. Once a value has been set, the value remains constant unless changed.

    Args:
        n: The number of captures.
    """
    self._num_captures = n
    self._f("SetNoOfCaptures", self._handle, n)

set_output_edge_detect ¤

set_output_edge_detect(*, enable: bool) -> None

Enables or disables output edge detection mode for the logic trigger.

Output edge detection is enabled by default and should be left enabled for normal operation.

Parameters:

Name Type Description Default
enable bool

Whether to enable or disable output edge detection mode.

required
Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
1249
1250
1251
1252
1253
1254
1255
1256
1257
def set_output_edge_detect(self, *, enable: bool) -> None:
    """Enables or disables output edge detection mode for the logic trigger.

    Output edge detection is enabled by default and should be left enabled for normal operation.

    Args:
        enable: Whether to enable or disable output edge detection mode.
    """
    self._f("SetOutputEdgeDetect", self._handle, int(enable))

set_pulse_width_digital_port_properties ¤

set_pulse_width_digital_port_properties(
    directions: Sequence[DigitalChannelDirections],
) -> None

Set the individual digital channels' pulse-width trigger directions.

Parameters:

Name Type Description Default
directions Sequence[DigitalChannelDirections]

The digital-port properties. The sequence can contain a single element describing the properties of one digital channel, or a number of elements describing several digital channels. If empty, digital pulse width triggering is switched off. A digital channel that is not included in the array will be set to DONT_CARE.

required
Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
def set_pulse_width_digital_port_properties(self, directions: Sequence[DigitalChannelDirections]) -> None:
    """Set the individual digital channels' pulse-width trigger directions.

    Args:
        directions: The digital-port properties. The sequence can contain a single element describing
            the properties of one digital channel, or a number of elements describing several digital
            channels. If empty, digital pulse width triggering is switched off. A digital channel that
            is not included in the array will be set to `DONT_CARE`.
    """
    c_array = (DigitalChannelDirections * len(directions))(*directions)
    self._f("SetPulseWidthDigitalPortProperties", self._handle, c_array, len(directions))

set_pulse_width_qualifier_conditions ¤

set_pulse_width_qualifier_conditions(
    conditions: Sequence[Condition], info: ConditionsInfo | str | int
) -> None

Set the condition to the pulse-width qualifier.

It can either add the new condition to the existing qualifier, or clear the existing qualifier and replace it with the new condition.

Parameters:

Name Type Description Default
conditions Sequence[Condition]

A sequence of conditions.

required
info ConditionsInfo | str | int

Whether to add this condition to the existing definition or clear the definition and start a new one. Can be an enum member name (case insensitive) or value.

required
Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
def set_pulse_width_qualifier_conditions(
    self, conditions: Sequence[Condition], info: ConditionsInfo | str | int
) -> None:
    """Set the condition to the pulse-width qualifier.

    It can either add the new condition to the existing qualifier, or clear the
    existing qualifier and replace it with the new condition.

    Args:
        conditions: A sequence of conditions.
        info: Whether to add this condition to the existing definition or clear the definition
            and start a new one. Can be an enum member name (case insensitive) or value.
    """
    c_array = (Condition * len(conditions))(*conditions)
    info = to_enum(info, ConditionsInfo, to_upper=True)
    self._f("SetPulseWidthQualifierConditions", self._handle, c_array, len(conditions), info)

set_pulse_width_qualifier_directions ¤

set_pulse_width_qualifier_directions(directions: Sequence[Direction]) -> None

Set the directions for all the trigger sources used with the pulse-width qualifier.

Parameters:

Name Type Description Default
directions Sequence[Direction]

Specifies which direction to apply to each trigger source.

required
Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
1288
1289
1290
1291
1292
1293
1294
1295
def set_pulse_width_qualifier_directions(self, directions: Sequence[Direction]) -> None:
    """Set the directions for all the trigger sources used with the pulse-width qualifier.

    Args:
        directions: Specifies which direction to apply to each trigger source.
    """
    c_array = (Direction * len(directions))(*directions)
    self._f("SetPulseWidthQualifierDirections", self._handle, c_array, len(directions))

set_pulse_width_qualifier_properties ¤

set_pulse_width_qualifier_properties(
    lower: int, upper: int = 0, type: PulseWidthType | str | int = "none"
) -> None

Set the pulse width timings and logic type of the pulse-width trigger qualifier.

Parameters:

Name Type Description Default
lower int

The lower limit of the pulse-width counter, in samples. This argument is required for all pulse width types.

required
upper int

The upper limit of the pulse-width counter, in samples. This argument is used only when the type is IN_RANGE or OUT_OF_RANGE.

0
type PulseWidthType | str | int

The type of pulse width trigger. Can be an enum member name (case insensitive) or value.

'none'
Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
def set_pulse_width_qualifier_properties(
    self,
    lower: int,
    upper: int = 0,
    type: PulseWidthType | str | int = "none",  # noqa: A002
) -> None:
    """Set the pulse width timings and logic type of the pulse-width trigger qualifier.

    Args:
        lower: The lower limit of the pulse-width counter, in samples. This argument is
            required for all pulse width types.
        upper: The upper limit of the pulse-width counter, in samples. This argument is
            used only when the type is `IN_RANGE` or `OUT_OF_RANGE`.
        type: The type of pulse width trigger. Can be an enum member name (case insensitive) or value.
    """
    typ = to_enum(type, PulseWidthType, to_upper=True)
    self._f("SetPulseWidthQualifierProperties", self._handle, lower, upper, typ)

set_sig_gen_arbitrary ¤

set_sig_gen_arbitrary(
    waveform: NDArray[float64],
    repetition_rate: float | None = None,
    offset_voltage: float = 0.0,
    peak_to_peak: float | None = None,
    start_delta_phase: int | None = None,
    stop_delta_phase: int | None = None,
    delta_phase_increment: int = 0,
    dwell_count: int | None = None,
    sweep_type: SweepType | str | int = "up",
    operation: ExtraOperations | str | int = "off",
    index_mode: IndexMode | str | int = "single",
    shots: int = 0,
    sweeps: int = 0,
    trigger_type: SigGenTrigType | str | int = "rising",
    trigger_source: SigGenTrigSource | str | int = "none",
    ext_in_threshold: int = 0,
) -> NDArray[int16]

Set the signal generator to produce an arbitrary waveform.

Parameters:

Name Type Description Default
waveform NDArray[float64]

The arbitrary waveform, in volts. Must be 1D array.

required
repetition_rate float | None

The requested repetition rate (frequency in Hz) of the entire arbitrary waveform. The actual repetition rate that is used may be different based on the specifications of the AWG. If specified then the sig_gen_frequency_to_phase method is called (with the mode value) to determine the value of start_delta_phase.

None
offset_voltage float

The offset, in volts, to be applied to the waveform.

0.0
peak_to_peak float | None

The peak-to-peak voltage of the waveform signal. If None, uses the maximum value of the waveform to determine the peak-to-peak voltage.

None
start_delta_phase int | None

The initial value added to the phase accumulator as the generator begins to step through the waveform buffer. If None then repetition_rate must be specified.

None
stop_delta_phase int | None

The final value added to the phase accumulator before the generator restarts or reverses the sweep. When frequency sweeping is not required, set equal to start_delta_phase (which is what it is set to if None).

None
delta_phase_increment int

The amount added to the delta phase value every time the dwell_count period expires. This determines the amount by which the generator sweeps the output frequency in each dwell period. When frequency sweeping is not required, set to zero.

0
dwell_count int | None

The time, in 50 ns steps, between successive additions of delta_phase_increment to the delta phase accumulator. This determines the rate at which the generator sweeps the output frequency. If None, the minimum dwell count value is used.

None
sweep_type SweepType | str | int

How the frequency will sweep from start_delta_phase to stop_delta_phase or in the opposite direction. Can be an enum member name (case insensitive) or value.

'up'
operation ExtraOperations | str | int

The type of waveform to be produced. Can be an enum member name (case insensitive) or value.

'off'
index_mode IndexMode | str | int

Specifies how the signal will be formed from the arbitrary waveform data. Can be an enum member name (case insensitive) or value.

'single'
shots int

See the manual.

0
sweeps int

See the manual.

0
trigger_type SigGenTrigType | str | int

The type of trigger that will be applied to the signal generator. Can be an enum member name (case insensitive) or value.

'rising'
trigger_source SigGenTrigSource | str | int

The source that will trigger the signal generator. Can be an enum member name (case insensitive) or value.

'none'
ext_in_threshold int

Used to set trigger level for an external trigger.

0

Returns:

Type Description
NDArray[int16]

The arbitrary waveform in ADU counts.

Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
def set_sig_gen_arbitrary(  # noqa: PLR0913
    self,
    waveform: NDArray[np.float64],
    repetition_rate: float | None = None,
    offset_voltage: float = 0.0,
    peak_to_peak: float | None = None,
    start_delta_phase: int | None = None,
    stop_delta_phase: int | None = None,
    delta_phase_increment: int = 0,
    dwell_count: int | None = None,
    sweep_type: SweepType | str | int = "up",
    operation: ExtraOperations | str | int = "off",
    index_mode: IndexMode | str | int = "single",
    shots: int = 0,
    sweeps: int = 0,
    trigger_type: SigGenTrigType | str | int = "rising",
    trigger_source: SigGenTrigSource | str | int = "none",
    ext_in_threshold: int = 0,
) -> NDArray[np.int16]:
    """Set the signal generator to produce an arbitrary waveform.

    Args:
        waveform: The arbitrary waveform, in volts. Must be 1D array.
        repetition_rate: The requested repetition rate (frequency in Hz) of the entire arbitrary waveform.
            The actual repetition rate that is used may be different based on the specifications of
            the AWG. If specified then the
            [sig_gen_frequency_to_phase][msl.equipment_resources.picotech.picoscope.PicoScope.sig_gen_frequency_to_phase]
            method is called (with the `mode` value) to determine the value of `start_delta_phase`.
        offset_voltage: The offset, in volts, to be applied to the waveform.
        peak_to_peak: The peak-to-peak voltage of the waveform signal. If `None`, uses
            the maximum value of the `waveform` to determine the peak-to-peak voltage.
        start_delta_phase: The initial value added to the phase accumulator as the generator begins
            to step through the waveform buffer. If `None` then `repetition_rate` must be specified.
        stop_delta_phase: The final value added to the phase accumulator before the generator restarts or
            reverses the sweep. When frequency sweeping is not required, set equal to `start_delta_phase`
            (which is what it is set to if `None`).
        delta_phase_increment: The amount added to the delta phase value every time the `dwell_count`
            period expires. This determines the amount by which the generator sweeps the output frequency
            in each dwell period. When frequency sweeping is not required, set to zero.
        dwell_count: The time, in 50 ns steps, between successive additions of `delta_phase_increment` to the
            delta phase accumulator. This determines the rate at which the generator sweeps the output frequency.
            If `None`, the minimum dwell count value is used.
        sweep_type: How the frequency will sweep from `start_delta_phase` to `stop_delta_phase`
            or in the opposite direction. Can be an enum member name (case insensitive) or value.
        operation: The type of waveform to be produced. Can be an enum member name (case insensitive) or value.
        index_mode: Specifies how the signal will be formed from the arbitrary waveform data.
            Can be an enum member name (case insensitive) or value.
        shots: See the manual.
        sweeps: See the manual.
        trigger_type: The type of trigger that will be applied to the signal generator.
            Can be an enum member name (case insensitive) or value.
        trigger_source: The source that will trigger the signal generator.
            Can be an enum member name (case insensitive) or value.
        ext_in_threshold: Used to set trigger level for an external trigger.

    Returns:
        The arbitrary waveform in ADU counts.
    """
    _, max_value, min_size, max_size = self.sig_gen_arbitrary_min_max_values()
    if waveform.size < min_size:
        msg = f"The waveform size is {waveform.size}, must be >= {min_size}"
        raise ValueError(msg)
    if waveform.size > max_size:
        msg = f"The waveform size is {waveform.size}, must be <= {max_size}"
        raise ValueError(msg)

    sweep_typ = to_enum(sweep_type, SweepType, to_upper=True)
    extra_ops = to_enum(operation, ExtraOperations, to_upper=True)
    index_mode = to_enum(index_mode, IndexMode, to_upper=True)
    trig_typ = to_enum(trigger_type, SigGenTrigType, to_upper=True)
    trig_source = to_enum(trigger_source, SigGenTrigSource, to_upper=True)

    if start_delta_phase is None and repetition_rate is None:
        msg = "Must specify either 'start_delta_phase' or 'repetition_rate'"
        raise ValueError(msg)

    if start_delta_phase is None:
        assert repetition_rate is not None  # noqa: S101
        start_delta_phase = self.sig_gen_frequency_to_phase(repetition_rate, index_mode, waveform.size)

    if stop_delta_phase is None:
        stop_delta_phase = start_delta_phase

    if dwell_count is None:
        dwell_count = to_enum("MIN_DWELL_COUNT", _Constants, prefix=f"{self._prefix}_", to_upper=True)

    # convert the waveform from volts to analogue-to-digital units
    _waveform = waveform.copy()
    max_waveform_value: float = np.max(np.absolute(_waveform))
    _waveform /= max_waveform_value  # the waveform must be within the range -1.0 to 1.0
    _waveform *= max_value
    waveform_adu: NDArray[np.int16] = _waveform.round(out=_waveform).astype(np.int16)

    if peak_to_peak is None:
        peak_to_peak = max_waveform_value / 2.0

    offset = round(offset_voltage * 1e6)
    pk2pk = round(peak_to_peak * 1e6)

    self._f(
        "SetSigGenArbitrary",
        self._handle,
        offset,
        pk2pk,
        start_delta_phase,
        stop_delta_phase,
        delta_phase_increment,
        dwell_count,
        waveform_adu,
        waveform_adu.size,
        sweep_typ,
        extra_ops,
        index_mode,
        shots,
        sweeps,
        trig_typ,
        trig_source,
        ext_in_threshold,
    )
    return waveform_adu

set_sig_gen_builtin_v2 ¤

set_sig_gen_builtin_v2(
    offset_voltage: float = 0.0,
    peak_to_peak: float = 1.0,
    wave_type: WaveType | str | int = "sine",
    start_frequency: float = 1.0,
    stop_frequency: float | None = None,
    increment: float = 0.1,
    dwell_time: float = 1.0,
    sweep_type: SweepType | str | int = "up",
    operation: ExtraOperations | str | int = "off",
    shots: int = 0,
    sweeps: int = 0,
    trigger_type: SigGenTrigType | str | int = "rising",
    trigger_source: SigGenTrigSource | str | int = "none",
    ext_in_threshold: int = 0,
) -> None

Set up the signal generator to produce a signal from a list of built-in waveforms.

Parameters:

Name Type Description Default
offset_voltage float

The voltage offset, in volts, to be applied to the waveform.

0.0
peak_to_peak float

The peak-to-peak voltage, in volts, of the waveform signal.

1.0
wave_type WaveType | str | int

The type of waveform to be generated. Can be an enum member name (case insensitive) or value.

'sine'
start_frequency float

The frequency that the signal generator will initially produce.

1.0
stop_frequency float | None

The frequency at which the sweep reverses direction or returns to the initial frequency. If None, it is set equal to start_frequency.

None
increment float

The amount of frequency increase or decrease in sweep mode.

0.1
dwell_time float

The time, in seconds, for which the sweep stays at each frequency.

1.0
sweep_type SweepType | str | int

How the frequency will sweep from start_frequency to stop_frequency or in the opposite direction. Can be an enum member name (case insensitive) or value.

'up'
operation ExtraOperations | str | int

The type of waveform to be produced (not used by 5000A models). Can be an enum member name (case insensitive) or value.

'off'
shots int

See the manual.

0
sweeps int

See the manual.

0
trigger_type SigGenTrigType | str | int

The type of trigger that will be applied to the signal generator. Can be an enum member name (case insensitive) or value.

'rising'
trigger_source SigGenTrigSource | str | int

The source that will trigger the signal generator. Can be an enum member name (case insensitive) or value.

'none'
ext_in_threshold int

Used to set trigger level for an external trigger.

0
Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
def set_sig_gen_builtin_v2(  # noqa: PLR0913
    self,
    offset_voltage: float = 0.0,
    peak_to_peak: float = 1.0,
    wave_type: WaveType | str | int = "sine",
    start_frequency: float = 1.0,
    stop_frequency: float | None = None,
    increment: float = 0.1,
    dwell_time: float = 1.0,
    sweep_type: SweepType | str | int = "up",
    operation: ExtraOperations | str | int = "off",
    shots: int = 0,
    sweeps: int = 0,
    trigger_type: SigGenTrigType | str | int = "rising",
    trigger_source: SigGenTrigSource | str | int = "none",
    ext_in_threshold: int = 0,
) -> None:
    """Set up the signal generator to produce a signal from a list of built-in waveforms.

    Args:
        offset_voltage: The voltage offset, in volts, to be applied to the waveform.
        peak_to_peak: The peak-to-peak voltage, in volts, of the waveform signal.
        wave_type: The type of waveform to be generated.
            Can be an enum member name (case insensitive) or value.
        start_frequency: The frequency that the signal generator will initially produce.
        stop_frequency: The frequency at which the sweep reverses direction or returns
            to the initial frequency. If `None`, it is set equal to `start_frequency`.
        increment: The amount of frequency increase or decrease in sweep mode.
        dwell_time: The time, in seconds, for which the sweep stays at each frequency.
        sweep_type: How the frequency will sweep from `start_frequency` to `stop_frequency`
            or in the opposite direction. Can be an enum member name (case insensitive) or value.
        operation: The type of waveform to be produced (not used by 5000A models).
            Can be an enum member name (case insensitive) or value.
        shots: See the manual.
        sweeps: See the manual.
        trigger_type: The type of trigger that will be applied to the signal generator.
            Can be an enum member name (case insensitive) or value.
        trigger_source: The source that will trigger the signal generator.
            Can be an enum member name (case insensitive) or value.
        ext_in_threshold: Used to set trigger level for an external trigger.
    """
    wave_typ = to_enum(wave_type, WaveType, to_upper=True)
    sweep_typ = to_enum(sweep_type, SweepType, to_upper=True)
    extra_ops = to_enum(operation, ExtraOperations, to_upper=True)
    trig_typ = to_enum(trigger_type, SigGenTrigType, to_upper=True)
    trig_source = to_enum(trigger_source, SigGenTrigSource, to_upper=True)

    if stop_frequency is None:
        stop_frequency = start_frequency

    self._f(
        "SetSigGenBuiltInV2",
        self._handle,
        round(offset_voltage * 1e6),
        round(peak_to_peak * 1e6),
        wave_typ,
        start_frequency,
        stop_frequency,
        increment,
        dwell_time,
        sweep_typ,
        extra_ops,
        shots,
        sweeps,
        trig_typ,
        trig_source,
        ext_in_threshold,
    )

set_timebase ¤

set_timebase(dt: float, duration: float, segment: int = 0) -> tuple[float, int]

Set the timebase information.

This method does not consider ETS (equivalent-time sampling). If using ETS, consider using set_ets. See also, nearest_sample_interval_stateless.

Parameters:

Name Type Description Default
dt float

The requested sampling interval, in seconds.

required
duration float

The number of seconds to acquire samples for.

required
segment int

The index of the memory segment to use.

0

Returns:

Type Description
tuple[float, int]

The actual sampling interval (i.e., actual Δt) and the number of samples that will be acquired.

Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
def set_timebase(self, dt: float, duration: float, segment: int = 0) -> tuple[float, int]:
    """Set the timebase information.

    This method does not consider ETS (equivalent-time sampling). If using ETS, consider using
    [set_ets][msl.equipment_resources.picotech.picoscope.PicoScope.set_ets]. See also,
    [nearest_sample_interval_stateless][msl.equipment_resources.picotech.picoscope.PicoScope.nearest_sample_interval_stateless].

    Args:
        dt: The requested sampling interval, in seconds.
        duration: The number of seconds to acquire samples for.
        segment: The index of the memory segment to use.

    Returns:
        The actual sampling interval (i.e., actual &Delta;t) and the number of samples
            that will be acquired.
    """
    self._timebase_index = round(self._get_timebase_index(float(dt)))
    num_samples_requested = round(duration / dt)
    self._sampling_interval, _ = self.get_timebase2(self._timebase_index, num_samples_requested, segment)

    self._num_samples = round(duration / self._sampling_interval)

    # determine the TimeUnits enum from the sample interval
    for unit in _TimeUnits:
        num_seconds_float = self._sampling_interval / _TimeUnits.to_float(unit)
        if num_seconds_float < 1e9:  # use <9 digits to specify the streaming sampling interval  # noqa: PLR2004
            self._streaming_sampling_interval = round(num_seconds_float)
            self._streaming_time_units = unit
            break

    return self._sampling_interval, self._num_samples

set_trigger ¤

set_trigger(
    channel: Channel | str | int,
    threshold: float,
    *,
    delay: float = 0.0,
    direction: ThresholdDirection | str | int = "RISING",
    timeout: float | None = None,
    enable: bool = True
) -> None

Set up the trigger.

Parameters:

Name Type Description Default
channel Channel | str | int

The trigger channel. Can be an enum member name (case insensitive) or value.

required
threshold float

The threshold voltage to signal a trigger event.

required
delay float

The time, in seconds, between the trigger occurring and the first sample.

0.0
direction ThresholdDirection | str | int

The direction in which the signal must move to cause a trigger. Can be an enum member name (case insensitive) or value.

'RISING'
timeout float | None

The time, in seconds, to wait to automatically create a trigger event if no trigger event occurs. If timeout ≤ 0 or None, then wait indefinitely for a trigger. Only accurate to the nearest millisecond.

None
enable bool

Set to False to disable the trigger for this channel.

True
Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
def set_trigger(
    self,
    channel: Channel | str | int,
    threshold: float,
    *,
    delay: float = 0.0,
    direction: ThresholdDirection | str | int = "RISING",
    timeout: float | None = None,
    enable: bool = True,
) -> None:
    """Set up the trigger.

    Args:
        channel: The trigger channel. Can be an enum member name (case insensitive) or value.
        threshold: The threshold voltage to signal a trigger event.
        delay: The time, in seconds, between the trigger occurring and the first sample.
        direction: The direction in which the signal must move to cause a trigger.
            Can be an enum member name (case insensitive) or value.
        timeout: The time, in seconds, to wait to automatically create a trigger event if no
            trigger event occurs. If `timeout` &le; 0 or `None`, then wait indefinitely for a trigger.
            Only accurate to the nearest millisecond.
        enable: Set to `False` to disable the trigger for this channel.
    """
    ch = to_enum(channel, Channel, to_upper=True)
    if ch.name not in self._channels:
        msg = f"Must call set_channel(channel='{ch.name}', ...) before enabling a trigger with channel {ch.name}"
        raise MSLConnectionError(self, msg)

    if self._sampling_interval < 0:
        msg = "Must call set_timebase() before setting the trigger"
        raise MSLConnectionError(self, msg)

    if delay < 0:
        msg = f"The trigger delay must be >=0 seconds, requested a delay of {delay} seconds"
        raise ValueError(msg)

    delay_ = round(delay / self._sampling_interval)
    max_delay_count = to_enum("MAX_DELAY_COUNT", _Constants, prefix=f"{self._prefix}_", to_upper=True)
    if delay_ > max_delay_count:
        msg = (
            f"The maximum allowed trigger delay is {max_delay_count * self._sampling_interval} seconds, "
            f"requested a delay of {delay} seconds"
        )
        raise ValueError(msg)

    if ch == Channel.EXT:
        max_value = to_enum("EXT_MAX_VALUE", _Constants, prefix=f"{self._prefix}_", to_upper=True)
        max_volts = to_enum("EXT_MAX_VOLTAGE", _Constants, prefix=f"{self._prefix}_", to_upper=True)
        threshold_adu = round(max_value * threshold / float(max_volts))
    else:
        voltage_offset = self._channels[ch.name].voltage_offset
        adu_per_volt = 1.0 / self._channels[ch.name].volts_per_adu
        threshold_adu = round(adu_per_volt * (threshold + voltage_offset))

    trig_dir = to_enum(direction, ThresholdDirection, to_upper=True)
    auto_trigger_ms = round(max(0, timeout * 1e3)) if timeout is not None else 0
    self._f("SetSimpleTrigger", self._handle, enable, ch, threshold_adu, trig_dir, delay_, auto_trigger_ms)

set_trigger_channel_conditions_v2 ¤

set_trigger_channel_conditions_v2(
    conditions: Sequence[Condition], info: ConditionsInfo | str | int
) -> None

Sets up trigger conditions on the scope's inputs.

Parameters:

Name Type Description Default
conditions Sequence[Condition]

The conditions that should be applied to each channel. In the simplest case, the sequence consists of a single element. When there is more than one element, the overall trigger condition is the logical OR of all the elements.

required
info ConditionsInfo | str | int

Specifies whether to clear the existing conditions or add the current condition to them using logical OR. Can be an enum member name (case insensitive) or value.

required
Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
def set_trigger_channel_conditions_v2(
    self, conditions: Sequence[Condition], info: ConditionsInfo | str | int
) -> None:
    """Sets up trigger conditions on the scope's inputs.

    Args:
        conditions: The conditions that should be applied to each channel. In the simplest case,
            the sequence consists of a single element. When there is more than one element, the
            overall trigger condition is the logical OR of all the elements.
        info: Specifies whether to clear the existing conditions or add the current condition to
            them using logical OR. Can be an enum member name (case insensitive) or value.
    """
    c_array = (Condition * len(conditions))(*conditions)
    info = to_enum(info, ConditionsInfo, to_upper=True)
    self._f("SetTriggerChannelConditionsV2", self._handle, c_array, len(conditions), info)

set_trigger_channel_directions_v2 ¤

set_trigger_channel_directions_v2(directions: Sequence[Direction]) -> None

Sets the direction of the trigger for each channel.

Parameters:

Name Type Description Default
directions Sequence[Direction]

A sequence of directions in which the signal must pass through the threshold to activate the trigger.

required
Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
1611
1612
1613
1614
1615
1616
1617
1618
1619
def set_trigger_channel_directions_v2(self, directions: Sequence[Direction]) -> None:
    """Sets the direction of the trigger for each channel.

    Args:
        directions: A sequence of directions in which the signal must pass through
            the threshold to activate the trigger.
    """
    c_array = (Direction * len(directions))(*directions)
    self._f("SetTriggerChannelDirectionsV2", self._handle, c_array, len(directions))

set_trigger_channel_properties_v2 ¤

set_trigger_channel_properties_v2(
    properties: Sequence[TriggerChannelPropertiesV2],
) -> None

Enable or disable triggering and set its parameters.

Parameters:

Name Type Description Default
properties Sequence[TriggerChannelPropertiesV2]

The requested properties. The sequence can contain a single element describing the properties of one channel, or a number of elements describing several channels. If empty, triggering is switched off.

required
Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
def set_trigger_channel_properties_v2(self, properties: Sequence[TriggerChannelPropertiesV2]) -> None:
    """Enable or disable triggering and set its parameters.

    Args:
        properties: The requested properties. The sequence can contain a single element describing the
            properties of one channel, or a number of elements describing several channels. If empty,
            triggering is switched off.
    """
    c_array = (TriggerChannelPropertiesV2 * len(properties))(*properties)
    self._f("SetTriggerChannelPropertiesV2", self._handle, c_array, len(properties), 0)

set_trigger_delay ¤

set_trigger_delay(delay: float) -> None

Sets the post-trigger delay, which causes capture to start a defined time after the trigger event.

Parameters:

Name Type Description Default
delay float

The time, in seconds, between the trigger occurring and the first sample

required
Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
def set_trigger_delay(self, delay: float) -> None:
    """Sets the post-trigger delay, which causes capture to start a defined time after the trigger event.

    Args:
        delay: The time, in seconds, between the trigger occurring and the first sample
    """
    if self._sampling_interval < 0:
        msg = "Must call set_timebase() before setting the trigger delay"
        raise MSLConnectionError(self, msg)

    delay_ = round(delay / self._sampling_interval)
    max_delay_count = to_enum("MAX_DELAY_COUNT", _Constants, prefix=f"{self._prefix}_", to_upper=True)
    if delay_ > max_delay_count:
        msg = (
            f"The maximum allowed trigger delay is {max_delay_count * self._sampling_interval} seconds, "
            f"requested a delay of {delay} seconds"
        )
        raise ValueError(msg)

    self._f("SetTriggerDelay", self._handle, delay_)

set_trigger_digital_port_properties ¤

set_trigger_digital_port_properties(
    directions: Sequence[DigitalChannelDirections],
) -> None

Set the individual digital channel's trigger directions.

Parameters:

Name Type Description Default
directions Sequence[DigitalChannelDirections]

The digital-port properties. The sequence can contain a single element describing the properties of one digital channel, or a number of elements describing several digital channels. If empty, digital pulse width triggering is switched off. A digital channel that is not included in the array will be set to DONT_CARE. The outcomes of all the directions in the sequence are bitwise-OR'ed together to produce the final trigger signal.

required
Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
def set_trigger_digital_port_properties(self, directions: Sequence[DigitalChannelDirections]) -> None:
    """Set the individual digital channel's trigger directions.

    Args:
        directions: The digital-port properties. The sequence can contain a single element describing
            the properties of one digital channel, or a number of elements describing several digital
            channels. If empty, digital pulse width triggering is switched off. A digital channel that
            is not included in the array will be set to `DONT_CARE`. The outcomes of all the `directions`
            in the sequence are bitwise-OR'ed together to produce the final trigger signal.
    """
    c_array = (DigitalChannelDirections * len(directions))(*directions)
    self._f("SetTriggerDigitalPortProperties", self._handle, c_array, len(directions))

sig_gen_arbitrary_min_max_values ¤

sig_gen_arbitrary_min_max_values() -> tuple[int, int, int, int]

Get the range of possible sample values and waveform buffer sizes.

Returns:

Type Description
tuple[int, int, int, int]

The range of possible sample values and waveform buffer sizes that can be supplied to set_sig_gen_arbitrary for setting up the arbitrary waveform generator (i.e., (min_value, max_value, min_size, max_size)).

Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
def sig_gen_arbitrary_min_max_values(self) -> tuple[int, int, int, int]:
    """Get the range of possible sample values and waveform buffer sizes.

    Returns:
        The range of possible sample values and waveform buffer sizes that can be supplied to
            [set_sig_gen_arbitrary][msl.equipment_resources.picotech.picoscope.PicoScope.set_sig_gen_arbitrary]
            for setting up the arbitrary waveform generator (i.e., `(min_value, max_value, min_size, max_size)`).
    """
    min_value = c_int16()
    max_value = c_int16()
    min_size = c_uint32()
    max_size = c_uint32()
    self._f(
        "SigGenArbitraryMinMaxValues",
        self._handle,
        byref(min_value),
        byref(max_value),
        byref(min_size),
        byref(max_size),
    )
    return min_value.value, max_value.value, min_size.value, max_size.value

sig_gen_frequency_to_phase ¤

sig_gen_frequency_to_phase(
    repetition_rate: float, index_mode: IndexMode | str | int, size: int
) -> int

Converts a frequency to a phase count for use with the arbitrary waveform generator (AWG).

Parameters:

Name Type Description Default
repetition_rate float

The requested repetition rate (frequency in Hz) of the entire arbitrary waveform.

required
index_mode IndexMode | str | int

Specifies how the signal will be formed from the arbitrary waveform data. Can be an enum member name (case insensitive) or value.

required
size int

The size (number of samples) of the waveform.

required

Returns:

Type Description
int

The phase count. The phase count can then be sent to the driver through set_sig_gen_arbitrary.

Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
def sig_gen_frequency_to_phase(self, repetition_rate: float, index_mode: IndexMode | str | int, size: int) -> int:
    """Converts a frequency to a phase count for use with the arbitrary waveform generator (AWG).

    Args:
        repetition_rate: The requested repetition rate (frequency in Hz) of the entire arbitrary waveform.
        index_mode: Specifies how the signal will be formed from the arbitrary waveform data.
            Can be an enum member name (case insensitive) or value.
        size: The size (number of samples) of the waveform.

    Returns:
        The phase count. The phase count can then be sent to the driver through
            [set_sig_gen_arbitrary][msl.equipment_resources.picotech.picoscope.PicoScope.set_sig_gen_arbitrary].
    """
    mode = to_enum(index_mode, IndexMode, to_upper=True)

    phase = c_uint32()
    self._f("SigGenFrequencyToPhase", self._handle, repetition_rate, mode, size, byref(phase))
    if phase.value < 1:
        msg = "The delta phase value is < 1, increase the repetition rate value"
        raise ValueError(msg)
    return phase.value

sig_gen_software_control ¤

sig_gen_software_control(*, state: bool) -> None

Send a software trigger event, or starts and stops gating.

Parameters:

Name Type Description Default
state bool

Specifies the new state of the gate signal.

required
Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
1710
1711
1712
1713
1714
1715
1716
def sig_gen_software_control(self, *, state: bool) -> None:
    """Send a software trigger event, or starts and stops gating.

    Args:
        state: Specifies the new state of the gate signal.
    """
    self._f("SigGenSoftwareControl", self._handle, int(state))

stop ¤

stop() -> None

Stop the oscilloscope from sampling data.

If this function is called before a trigger event occurs, then the oscilloscope may not contain valid data.

Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
1718
1719
1720
1721
1722
1723
1724
def stop(self) -> None:
    """Stop the oscilloscope from sampling data.

    If this function is called before a trigger event occurs, then the
    oscilloscope may not contain valid data.
    """
    self._f("Stop", self._handle)

trigger_within_pre_trigger_samples ¤

trigger_within_pre_trigger_samples(
    state: TriggerWithinPreTrigger | str | int,
) -> None

Allow a trigger anywhere within the pre-trigger samples.

This function selects a mode in which the scope can be triggered anywhere within the pre-trigger samples, as opposed to the normal operation of only arming the trigger after all the pre-trigger samples have been collected.

Parameters:

Name Type Description Default
state TriggerWithinPreTrigger | str | int

Can be an enum member name (case insensitive) or value.

required
Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
def trigger_within_pre_trigger_samples(self, state: TriggerWithinPreTrigger | str | int) -> None:
    """Allow a trigger anywhere within the pre-trigger samples.

    This function selects a mode in which the scope can be triggered anywhere within the pre-trigger
    samples, as opposed to the normal operation of only arming the trigger after all the pre-trigger
    samples have been collected.

    Args:
        state: Can be an enum member name (case insensitive) or value.
    """
    state = to_enum(state, TriggerWithinPreTrigger, to_upper=True)
    self._f("TriggerWithinPreTriggerSamples", self._handle, state)

wait_until_ready ¤

wait_until_ready() -> None

Blocking function to wait for the scope to finish acquiring samples.

Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
1739
1740
1741
1742
def wait_until_ready(self) -> None:
    """Blocking function to wait for the scope to finish acquiring samples."""
    while not self.is_ready():
        time.sleep(0.01)

A wrapper around the PicoScope SDK.

The main class is PicoScope. The other classes are enumerations and structs from the SDK. Version 11.1.0.418 of the SDK was used as a reference.

Warning

This class was written for the ps5000a SDK. Different SDKs (e.g., ps4000a) have similar function signatures and may or may not work with this class. Note that Pico Technology have their own repository to support their products.

BandwidthLimiter (IntEnum) ¤

The hardware bandwidth limiter fitted to each analogue input channel.

Attributes:

Name Type Description
BW_FULL int

Use the scope's full specified bandwidth. 0

BW_20MHZ int

Enable the hardware 20 MHz bandwidth limiter. 1

Channel (IntEnum) ¤

An analogue input channel, 8-bit digital port or other input.

Attributes:

Name Type Description
A int

Analogue channel A. 0

B int

Analogue channel B. 1

C int

Analogue channel C. 2

D int

Analogue channel D. 3

EXT int

External trigger input; not on MSOs. 4

MAX_CHANNELS int

4

TRIGGER_AUX int

Reserved. 5

MAX_TRIGGER_SOURCES int

6

PORT0 int

Digital port 0, inputs D0-D7, MSO models only. 0x80

PORT1 int

Digital port 1, inputs D8-D15, MSO models only. 0x81

PORT2 int

Reserved. 0x82

PORT3 int

Reserved. 0x83

PULSE_WIDTH_SOURCE int

Pulse width qualifier. 0x10000000

ChannelFlags (IntFlag) ¤

Channel flags enum.

Attributes:

Name Type Description
A int

Analogue channel A. 1

B int

Analogue channel B. 2

C int

Analogue channel C. 4

D int

Analogue channel D. 8

PORT0 int

Digital port 0, inputs D0-D7, MSO models only. 0x10000

PORT1 int

Digital port 1, inputs D8-D15, MSO models only. 0x20000

PORT2 int

Reserved. 0x40000

PORT3 int

Reserved. 0x80000

ChannelInfo (IntEnum) ¤

Channel info enum.

Attributes:

Name Type Description
RANGES int

Supported channel ranges. 0

ChannelSettings ¤

ChannelSettings(
    *,
    bandwidth: BandwidthLimiter,
    channel: Channel,
    enabled: bool,
    coupling: Coupling,
    voltage_range: float,
    voltage_offset: float,
    max_adu_value: int
)

The settings for a channel.

Do not instantiate this class directly. Created when set_channel is called.

Parameters:

Name Type Description Default
channel Channel

The channel.

required
bandwidth BandwidthLimiter

The bandwidth limiter that is used.

required
enabled bool

Whether the channel is enabled.

required
coupling Coupling

The impedance and coupling type.

required
voltage_range float

The voltage range, in Volts.

required
voltage_offset float

The voltage offset, in Volts.

required
max_adu_value int

The maximum analogue-to-digital value.

required
Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
def __init__(
    self,
    *,
    bandwidth: BandwidthLimiter,
    channel: Channel,
    enabled: bool,
    coupling: Coupling,
    voltage_range: float,
    voltage_offset: float,
    max_adu_value: int,
) -> None:
    """Information about a PicoScope channel.

    Do not instantiate this class directly. Created when
    [set_channel][msl.equipment_resources.picotech.picoscope.PicoScope.set_channel]
    is called.

    Args:
        channel: The channel.
        bandwidth: The bandwidth limiter that is used.
        enabled: Whether the channel is enabled.
        coupling: The impedance and coupling type.
        voltage_range: The voltage range, in Volts.
        voltage_offset: The voltage offset, in Volts.
        max_adu_value: The maximum analogue-to-digital value.
    """
    self.channel: Channel = channel
    """The channel."""

    self.enabled: bool = enabled
    """Whether the channel is enabled."""

    self.bandwidth: BandwidthLimiter = bandwidth
    """The bandwidth limiter that is used."""

    self.coupling: Coupling = coupling
    """The impedance and coupling type."""

    self.voltage_range: float = voltage_range
    """The voltage range, in Volts."""

    self.voltage_offset: float = voltage_offset
    """The voltage offset, in Volts."""

    self.volts_per_adu: float = voltage_range / float(max_adu_value)
    """The voltage/ADU factor."""

    # the raw data in analogue-to-digital units
    self._adu_values: NDArray[np.int16] = np.empty((0, 0), dtype=np.int16)

adu property ¤

adu: NDArray[int16]

The samples in ADU counts.

bandwidth instance-attribute ¤

bandwidth: BandwidthLimiter = bandwidth

The bandwidth limiter that is used.

buffer property ¤

buffer: NDArray[int16]

An alias for the samples in ADU counts.

channel instance-attribute ¤

channel: Channel = channel

The channel.

coupling instance-attribute ¤

coupling: Coupling = coupling

The impedance and coupling type.

enabled instance-attribute ¤

enabled: bool = enabled

Whether the channel is enabled.

num_samples property ¤

num_samples: int

The number of samples to acquire for this channel.

voltage_offset instance-attribute ¤

voltage_offset: float = voltage_offset

The voltage offset, in Volts.

voltage_range instance-attribute ¤

voltage_range: float = voltage_range

The voltage range, in Volts.

volts property ¤

volts: NDArray[floating]

The samples in volts.

volts_per_adu instance-attribute ¤

volts_per_adu: float = voltage_range / float(max_adu_value)

The voltage/ADU factor.

allocate ¤

allocate(num_samples: int, num_captures: int = 1) -> None

Maybe allocate memory to save the samples (if the array needs to be resized).

Parameters:

Name Type Description Default
num_samples int

The number of samples.

required
num_captures int

The number of captures.

1
Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
def allocate(self, num_samples: int, num_captures: int = 1) -> None:
    """Maybe allocate memory to save the samples (if the array needs to be resized).

    Args:
        num_samples: The number of samples.
        num_captures: The number of captures.
    """
    if self._adu_values.size != num_captures * num_samples:
        if num_captures == 1:
            self._adu_values = np.empty(num_samples, dtype=np.int16)
        else:
            self._adu_values = np.empty((num_captures, num_samples), dtype=np.int16)

Condition (Structure) ¤

Condition(
    source: Channel | str | int,
    condition: TriggerState | str | int = "DONT_CARE",
)

Trigger condition.

Parameters:

Name Type Description Default
source Channel | str | int

The channel to use for the condition. Can be an enum member name (case insensitive) or value.

required
condition TriggerState | str | int

The trigger state of the source. Can be an enum member name (case insensitive) or value.

'DONT_CARE'
Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
def __init__(self, source: Channel | str | int, condition: TriggerState | str | int = "DONT_CARE") -> None:
    """Trigger condition.

    Args:
        source: The channel to use for the condition. Can be an enum member name (case insensitive) or value.
        condition: The trigger state of the `source`. Can be an enum member name (case insensitive) or value.
    """
    self.source: int = to_enum(source, Channel, to_upper=True)
    self.condition: int = to_enum(condition, TriggerState, to_upper=True)
    super().__init__(source=self.source, condition=self.condition)

ConditionsInfo (IntEnum) ¤

Specify what to do with any existing trigger conditions that you have previously set up.

Attributes:

Name Type Description
CLEAR int

Clear existing trigger logic and replace with the new condition. 1

ADD int

Add the new condition, using Boolean OR, to the existing trigger logic. 2

Coupling (IntEnum) ¤

Input coupling modes for each analogue channel.

Attributes:

Name Type Description
AC int

AC coupling. 0

DC int

DC coupling. 1

DeviceResolution (IntEnum) ¤

Resolution of the sampling hardware in the oscilloscope.

Attributes:

Name Type Description
DR_8BIT int

0

DR_12BIT int

1

DR_14BIT int

2

DR_15BIT int

3

DR_16BIT int

4

DigitalChannelDirections (Structure) ¤

DigitalChannelDirections(channel: int, direction: DigitalDirection | str | int)

The trigger direction for the specified digital channel.

Parameters:

Name Type Description Default
channel int

The digital channel number.

required
direction DigitalDirection | str | int

The direction in which the digital input must cross the threshold(s) to cause a trigger event. Can be an enum member name (case insensitive) or value.

required
Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
def __init__(
    self,
    channel: int,
    direction: DigitalDirection | str | int,
) -> None:
    """The trigger direction for the specified digital channel.

    Args:
        channel: The digital channel number.
        direction: The direction in which the digital input must cross the threshold(s) to cause a trigger event.
            Can be an enum member name (case insensitive) or value.
    """
    self.channel: int = channel
    self.direction: int = to_enum(direction, DigitalDirection, to_upper=True)
    super().__init__(channel=channel, direction=self.direction)

DigitalDirection (IntEnum) ¤

The polarity of a digital channel used as a trigger source.

Attributes:

Name Type Description
DONT_CARE int

Ignore input. 0

LOW int

Input must be low. 1

HIGH int

Input must be high. 2

RISING int

Input must have a rising edge. 3

FALLING int

Input must have a falling edge. 4

RISING_OR_FALLING int

Input must have an edge of either polarity. 5

Direction (Structure) ¤

Direction(
    source: Channel | str | int,
    direction: ThresholdDirection | str | int = "rising",
    mode: ThresholdMode | str | int = "level",
)

The direction in which the specified source signal must cross the threshold(s) to produce a trigger event.

Parameters:

Name Type Description Default
source Channel | str | int

The channel to use for the trigger source. Can be an enum member name (case insensitive) or value.

required
direction ThresholdDirection | str | int

The direction in which the signal must cross the threshold. Can be an enum member name (case insensitive) or value.

'rising'
mode ThresholdMode | str | int

Whether to use a level trigger (a single threshold) or a window trigger (two thresholds defining a range).

'level'
Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
def __init__(
    self,
    source: Channel | str | int,
    direction: ThresholdDirection | str | int = "rising",
    mode: ThresholdMode | str | int = "level",
) -> None:
    """The direction in which the specified source signal must cross the threshold(s) to produce a trigger event.

    Args:
        source: The channel to use for the trigger source. Can be an enum member name (case insensitive) or value.
        direction: The direction in which the signal must cross the threshold. Can be an enum member name
            (case insensitive) or value.
        mode: Whether to use a level trigger (a single threshold) or a window trigger
            (two thresholds defining a range).
    """
    self.source: int = to_enum(source, Channel, to_upper=True)
    self.direction: int = to_enum(direction, ThresholdDirection, to_upper=True)
    self.mode: int = to_enum(mode, ThresholdMode, to_upper=True)
    super().__init__(source=self.source, direction=self.direction, mode=self.mode)

ETSMode (IntEnum) ¤

ETS (equivalent-time sampling) mode.

Attributes:

Name Type Description
OFF int

ETS disabled. 0

FAST int

Return ready as soon as requested number of interleaves is available. 1

SLOW int

Return ready every time a new set of no_of_cycles is collected. 2

ExtraOperations (IntEnum) ¤

Additional signal types for the signal generator.

Attributes:

Name Type Description
OFF int

Normal signal generator operation. 0

WHITENOISE int

Produces white noise. 1

PRBS int

Produces a pseudo-random binary sequence. 2

IndexMode (IntEnum) ¤

Index mode used by the arbitrary waveform generator.

Attributes:

Name Type Description
SINGLE int

The generator outputs the raw contents of the buffer repeatedly. This mode is the only one that can generate asymmetrical waveforms. You can also use this mode for symmetrical waveforms, but the DUAL mode makes more efficient use of the buffer memory. 0

DUAL int

The generator outputs the contents of the buffer from beginning to end, and then does a second pass in the reverse direction through the buffer. This allows you to specify only the first half of a waveform with twofold symmetry, such as a Gaussian function, and let the generator fill in the other half. 1

QUAD int

Not used. 2

PulseWidthType (IntEnum) ¤

The type of pulse-width trigger.

Attributes:

Name Type Description
NONE int

Do not use the pulse width qualifier. 0

LESS_THAN int

Pulse width less than lower. 1

GREATER_THAN int

Pulse width greater than lower. 2

IN_RANGE int

Pulse width between lower and upper. 3

OUT_OF_RANGE int

Pulse width not between lower and upper. 4

Range (IntEnum) ¤

The possible voltage ranges to which an analogue input channel can be set.

Each range is bipolar, so the R_10mV range spans from -10 mV to +10 mV.

Attributes:

Name Type Description
R_10mV int

0

R_20mV int

1

R_50mV int

2

R_100mV int

3

R_200mV int

4

R_500mV int

5

R_1V int

6

R_2V int

7

R_5V int

8

R_10V int

9

R_20V int

10

R_50V int

11

R_MAX int

12

RatioMode (IntEnum) ¤

Various methods of data reduction (down sampling).

Attributes:

Name Type Description
NONE int

No down sampling. 0

AGGREGATE int

Reduces every block of n values to just two values: a minimum and a maximum. 1

DECIMATE int

Reduces every block of n values to just the first value in the block, discarding all the other values. 2

AVERAGE int

Reduces every block of n values to a single value representing the average (arithmetic mean) of all the values. 4

DISTRIBUTION int

Not used. 8

SigGenTrigSource (IntEnum) ¤

How triggering of the signal generator or arbitrary waveform generator works.

Attributes:

Name Type Description
NONE int

Run without waiting for trigger. 0

SCOPE_TRIG int

Use scope trigger. 1

AUX_IN int

Use AUX input. 2

EXT_IN int

Use EXT input. 3

SOFT_TRIG int

Wait for software trigger from sig_gen_software_control. 4

SigGenTrigType (IntEnum) ¤

Trigger types used by the signal generator or arbitrary waveform generator.

Attributes:

Name Type Description
RISING int

0

FALLING int

1

GATE_HIGH int

2

GATE_LOW int

3

SweepType (IntEnum) ¤

The frequency sweep mode of the signal generator or arbitrary waveform generator.

Attributes:

Name Type Description
UP int

Sweep the frequency from lower limit up to upper limit. 0

DOWN int

Sweep the frequency from upper limit down to lower limit. 1

UPDOWN int

Sweep the frequency up and then down. 2

DOWNUP int

Sweep the frequency down and then up. 3

ThresholdDirection (IntEnum) ¤

The direction(s) in which the trigger source must cross the threshold(s) to cause a trigger event.

Attributes:

Name Type Description
ABOVE int

Using upper threshold. 0

BELOW int

Using upper threshold. 1

RISING int

Using upper threshold. 2

FALLING int

Using upper threshold. 3

RISING_OR_FALLING int

Using both thresholds. 4

ABOVE_LOWER int

Using lower threshold. 5

BELOW_LOWER int

Using lower threshold. 6

RISING_LOWER int

Using lower threshold. 7

FALLING_LOWER int

Using lower threshold. 8

INSIDE int

Windowing using both thresholds. 0

OUTSIDE int

Windowing using both thresholds. 1

ENTER int

Windowing using both thresholds. 2

EXIT int

Windowing using both thresholds. 3

ENTER_OR_EXIT int

Windowing using both thresholds. 4

POSITIVE_RUNT int

Windowing using both thresholds. 9

NEGATIVE_RUNT int

Windowing using both thresholds. 10

NONE int

No trigger set. 2

ThresholdMode (IntEnum) ¤

The type of threshold used by a trigger condition.

Attributes:

Name Type Description
LEVEL int

An edge or level trigger with a single threshold. 0

WINDOW int

Two thresholds defining a range. 1

TriggerChannelPropertiesV2 (Structure) ¤

TriggerChannelPropertiesV2(
    threshold_upper: int,
    threshold_upper_hysteresis: int,
    threshold_lower: int,
    threshold_lower_hysteresis: int,
    channel: Channel | str | int,
)

The trigger thresholds for a given channel (version 2).

Parameters:

Name Type Description Default
threshold_upper int

The upper threshold at which the trigger must fire. This is scaled in 16-bit ADC counts at the currently selected range for that channel.

required
threshold_upper_hysteresis int

The hysteresis by which the trigger must exceed the upper threshold before it will fire. It is scaled in 16-bit counts.

required
threshold_lower int

The lower threshold at which the trigger must fire. This is scaled in 16-bit ADC counts at the currently selected range for that channel.

required
threshold_lower_hysteresis int

The hysteresis by which the trigger must exceed the lower threshold before it will fire. It is scaled in 16-bit counts.

required
channel Channel | str | int

The channel to which the properties apply. Can be an enum member name (case insensitive) or value.

required
Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
def __init__(
    self,
    threshold_upper: int,
    threshold_upper_hysteresis: int,
    threshold_lower: int,
    threshold_lower_hysteresis: int,
    channel: Channel | str | int,
) -> None:
    """The trigger thresholds for a given channel (version 2).

    Args:
        threshold_upper: The upper threshold at which the trigger must fire. This is scaled
            in 16-bit ADC counts at the currently selected range for that channel.
        threshold_upper_hysteresis: The hysteresis by which the trigger must exceed
            the upper threshold before it will fire. It is scaled in 16-bit counts.
        threshold_lower: The lower threshold at which the trigger must fire. This
            is scaled in 16-bit ADC counts at the currently selected range for that channel.
        threshold_lower_hysteresis: The hysteresis by which the trigger must exceed
            the lower threshold before it will fire. It is scaled in 16-bit counts.
        channel: The channel to which the properties apply. Can be an enum member name
            (case insensitive) or value.
    """
    self.threshold_upper: int = threshold_upper
    self.threshold_upper_hysteresis: int = threshold_upper_hysteresis
    self.threshold_lower: int = threshold_lower
    self.threshold_lower_hysteresis: int = threshold_lower_hysteresis
    self.channel: int = to_enum(channel, Channel, to_upper=True)
    super().__init__(
        threshold_upper=threshold_upper,
        threshold_upper_hysteresis=threshold_upper_hysteresis,
        threshold_lower=threshold_lower,
        threshold_lower_hysteresis=threshold_lower_hysteresis,
        channel=self.channel,
    )

TriggerInfo dataclass ¤

TriggerInfo(
    segment_index: int,
    trigger_index: int,
    trigger_time: float,
    timestamp_counter: int,
)

The trigger timestamp information for the specified buffer segment.

Attributes:

Name Type Description
segment_index int

A zero-based index identifying the segment.

trigger_index int

The index of the trigger point measured in samples within the captured data, with the first sample being index 0.

trigger_time float

The trigger offset time, in seconds.

timestamp_counter int

The number of sample intervals between the trigger point of this segment and the previous segment. This allows you to determine the time interval between the trigger points of captures within a single rapid block run.

TriggerState (IntEnum) ¤

How each trigger condition is combined with the overall trigger logic.

Attributes:

Name Type Description
DONT_CARE int

The source condition has no effect on the logic. 0

TRUE int

The source condition must be true. 1

FALSE int

The source condition must be false. 2

TriggerWithinPreTrigger (IntEnum) ¤

Enable or disable the trigger during the pre-trigger period.

Attributes:

Name Type Description
DISABLE int

Uses triggering in the normal way. 0

ARM int

Enables triggering anywhere within the pre-trigger samples. 1

WaveType (IntEnum) ¤

Standard waveform produced by the signal generator.

Attributes:

Name Type Description
SINE int

0

SQUARE int

1

TRIANGLE int

2

RAMP_UP int

3

RAMP_DOWN int

4

SINC int

5

GAUSSIAN int

6

HALF_SINE int

7

DC_VOLTAGE int

8

WHITE_NOISE int

9

block_ready ¤

block_ready(f: PicoTechBlockReadyCallback) -> _CFunctionType

Use as a decorator for a callback function when the data block is ready.

See ps5000a_block_ready_callback.py for an example usage.

Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
1755
1756
1757
1758
1759
1760
1761
def block_ready(f: PicoTechBlockReadyCallback) -> _CFunctionType:
    """Use as a decorator for a callback function when the data block is ready.

    See [ps5000a_block_ready_callback.py](https://github.com/MSLNZ/msl-equipment/blob/main/packages/resources/examples/picotech/ps5000a_block_ready_callback.py)
    for an example usage.
    """
    return _BlockReady(f)

data_ready ¤

data_ready(f: PicoTechDataReadyCallback) -> _CFunctionType

Use as a decorator for a callback function when the data is ready.

See ps5000a_data_ready_callback.py for an example usage.

Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
1764
1765
1766
1767
1768
1769
1770
def data_ready(f: PicoTechDataReadyCallback) -> _CFunctionType:
    """Use as a decorator for a callback function when the data is ready.

    See [ps5000a_data_ready_callback.py](https://github.com/MSLNZ/msl-equipment/blob/main/packages/resources/examples/picotech/ps5000a_data_ready_callback.py)
    for an example usage.
    """
    return _DataReady(f)

streaming_ready ¤

streaming_ready(f: PicoTechStreamingReadyCallback) -> _CFunctionType

Use as a decorator for a callback function when the data stream is ready.

See ps5000a_streaming_ready_callback.py for an example usage.

Source code in packages/resources/src/msl/equipment_resources/picotech/picoscope.py
1773
1774
1775
1776
1777
1778
1779
def streaming_ready(f: PicoTechStreamingReadyCallback) -> _CFunctionType:
    """Use as a decorator for a callback function when the data stream is ready.

    See [ps5000a_streaming_ready_callback.py](https://github.com/MSLNZ/msl-equipment/blob/main/packages/resources/examples/picotech/ps5000a_streaming_ready_callback.py)
    for an example usage.
    """
    return _StreamingReady(f)