Memory / Buffer Management

Bases: PicoScopeBase, Sharedps5000aPs6000a

PicoScope 5000 (A) API specific functions

Methods:

Name Description
get_maximum_available_memory

Return the maximum sample depth of the device.

memory_segments

Configure the number of memory segments that the PicoScope will use.

set_data_buffer

Allocate and assign NumPy-backed data buffers

set_data_buffer_for_enabled_channels

Sets data buffers for enabled channels set by picosdk.set_channel()

set_data_buffer_rapid_capture

Allocates and assigns multiple data buffers for rapid block capture on a specified channel.

set_data_buffers

Allocate and assign max and min NumPy-backed data buffers

set_unscaled_data_buffer

Allocate and assign a NumPy-backed int8 data buffer using the driver's

set_unscaled_data_buffers

Allocate and assign max and min NumPy-backed int8 data buffers using

get_maximum_available_memory()

Return the maximum sample depth of the device.

The ps5000a API has no GetMaximumAvailableMemory call; this queries MemorySegments with a single segment, which reports the full capture memory at the current resolution. Unlike the ps6000a/psospa query, this is a settings change: it (re)configures the device to 1 memory segment and discards any previously captured data. Do not call it while a capture or stream is in progress.

Returns:
  • int( int ) –

    Maximum number of samples supported.

Raises:
  • PicoSDKException

    If the driver did not report a sample count (e.g. the device was busy capturing).

memory_segments(n_segments)

Configure the number of memory segments that the PicoScope will use.

Parameters:
  • n_segments (int) –

    Desired number of memory segments.

Returns:
  • int( int ) –

    Number of samples available in each segment.

set_data_buffer(channel, samples, segment=0, datatype=None, ratio_mode=cst.RATIO_MODE.NONE, action=None, buffer=None)

Allocate and assign NumPy-backed data buffers

Parameters:
  • channel (CHANNEL) –

    Channel to associate the buffers with.

  • samples (int) –

    Number of samples to allocate.

  • segment (int, default: 0 ) –

    Memory segment to use. Defaults to 0.

  • ratio_mode (RATIO_MODE, default: NONE ) –

    Downsampling mode. Defaults to AGGREGATE.

  • buffer (ndarray | None, default: None ) –

    Send a preallocated data buffer to be populated. Min buffer first. If left as none, this function creates and returns its own buffer.

Returns:
  • ndarray | None

    np.ndarray: Created buffer as a numpy array.

Note

samples=0 clears the registration, but only for this channel/segment/ratio_mode — unlike ACTION.CLEAR_ALL on other drivers, which clears every registered buffer.

set_data_buffer_for_enabled_channels(samples, segment=0, datatype=cst.DATA_TYPE.INT16_T, ratio_mode=cst.RATIO_MODE.RAW, clear_buffer=False, captures=0)

Sets data buffers for enabled channels set by picosdk.set_channel()

Parameters:
  • samples (int) –

    The sample buffer or size to allocate.

  • segment (int, default: 0 ) –

    The memory segment index.

  • datatype (DATA_TYPE, default: INT16_T ) –

    The data type used for the buffer.

  • ratio_mode (RATIO_MODE, default: RAW ) –

    The ratio mode (e.g., RAW, AVERAGE).

  • clear_buffer (bool, default: True ) –

    If True, clear the buffer first

  • captures (int, default: 0 ) –

    If larger than 0, it will create multiple buffers for RAPID mode.

Returns:
  • dict( dict ) –

    A dictionary mapping each channel to its associated data buffer.

set_data_buffer_rapid_capture(channel, samples, captures, segment=0, datatype=DATA_TYPE.INT16_T, ratio_mode=RATIO_MODE.RAW, action=ACTION.CLEAR_ALL | ACTION.ADD)

Allocates and assigns multiple data buffers for rapid block capture on a specified channel.

Parameters:
  • channel (int) –

    The channel to associate the buffer with (e.g., CHANNEL.A).

  • samples (int) –

    Number of samples to allocate in the buffer.

  • captures (int) –

    Number of rapid block captures

  • segment (int, default: 0 ) –

    Memory segment to start at.

  • datatype (DATA_TYPE, default: INT16_T ) –

    C data type for the buffer (e.g., INT16_T).

  • ratio_mode (RATIO_MODE, default: RAW ) –

    Downsampling mode.

  • action (ACTION, default: CLEAR_ALL | ADD ) –

    Action to apply to the data buffer (e.g., CLEAR_ALL | ADD).

Returns:
  • ndarray | None

    np.array | None: The allocated buffer or None when clearing existing buffers.

Raises:
  • PicoSDKException

    If an unsupported data type is provided.

set_data_buffers(channel, samples, segment=0, datatype=None, ratio_mode=cst.RATIO_MODE.AGGREGATE, action=None, buffers=None)

Allocate and assign max and min NumPy-backed data buffers

Parameters:
  • channel (CHANNEL) –

    Channel to associate the buffers with.

  • samples (int) –

    Number of samples to allocate.

  • segment (int, default: 0 ) –

    Memory segment to use. Defaults to 0.

  • ratio_mode (RATIO_MODE, default: AGGREGATE ) –

    Downsampling mode. Defaults to AGGREGATE.

  • buffers (list[ndarray, ndarray] | ndarray | None, default: None ) –

    Send preallocated data buffers to be populared. Min buffer first, followed by max buffer. If left as none, this function creates its own buffers.

Returns:
  • tuple[ndarray, ndarray]

    tuple[np.ndarray,np.ndarray]: Tuple of (buffer_min, buffer_max) numpy arrays.

Note

samples=0 clears the registration, but only for this channel/segment/ratio_mode — unlike ACTION.CLEAR_ALL on other drivers, which clears every registered buffer.

set_unscaled_data_buffer(channel, samples, segment=0, ratio_mode=cst.RATIO_MODE.NONE, buffer=None)

Allocate and assign a NumPy-backed int8 data buffer using the driver's native unscaled 8-bit transfer path (ps5000aSetUnscaledDataBuffers).

At 8-bit resolution this halves the USB bandwidth and host memory per sample compared with the standard int16 path. The driver delivers raw 8-bit ADC codes with no scaling applied.

Parameters:
  • channel (CHANNEL) –

    Channel to associate the buffer with.

  • samples (int) –

    Number of samples to allocate. 0 clears the registration for this channel/segment/mode.

  • segment (int, default: 0 ) –

    Memory segment to use. Defaults to 0.

  • ratio_mode (RATIO_MODE, default: NONE ) –

    Downsampling mode. Defaults to NONE. For AGGREGATE use :meth:set_unscaled_data_buffers.

  • buffer (ndarray | None, default: None ) –

    Preallocated int8 buffer to be populated. If None, this function creates its own.

Returns:
  • ndarray | None

    np.ndarray | None: The registered int8 buffer, or None when clearing.

set_unscaled_data_buffers(channel, samples, segment=0, ratio_mode=cst.RATIO_MODE.AGGREGATE, buffers=None)

Allocate and assign max and min NumPy-backed int8 data buffers using the driver's native unscaled 8-bit transfer path (ps5000aSetUnscaledDataBuffers).

Parameters:
  • channel (CHANNEL) –

    Channel to associate the buffers with.

  • samples (int) –

    Number of samples to allocate. 0 clears the registration for this channel/segment/mode.

  • segment (int, default: 0 ) –

    Memory segment to use. Defaults to 0.

  • ratio_mode (RATIO_MODE, default: AGGREGATE ) –

    Downsampling mode. Defaults to AGGREGATE.

  • buffers (list[ndarray, ndarray] | ndarray | None, default: None ) –

    Preallocated int8 buffers to be populated. Min buffer first, followed by max buffer. If None, this function creates its own.

Returns:
  • ndarray

    tuple[np.ndarray, np.ndarray]: Tuple of (buffer_min, buffer_max)

  • ndarray

    int8 numpy arrays, or (None, None) when clearing.