Memory / Buffer Management

Bases: PicoScopeBase, Sharedps5000aPs6000a

PicoScope 5000 (A) API specific functions

Methods:

Name Description
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

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.

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.