Streaming

Streaming in a PicoScope is a great tool for monitoring a waveform for a long period of time without the delay between block captures. Though this method of capture is fairly limited in sample rate and usability in comparison to a block capture and especially rapid block capture.

Using Streaming in pyPicoSDK

Streaming is implemented in this package as a class to take advantage of the benefits offered by an object-oriented approach. For a quick start-up use the example code and alter it to your application.

Methods & Functions

Below are the included public methods for streaming:

Methods:

Name Description
add_channel

!NOT YET IMPLEMETED!

config_streaming

Configures the streaming settings for data acquisition. This method sets up the channel,

main_streaming_loop

Main loop for handling streaming data acquisition.

run_streaming

Initiates the data streaming process.

run_streaming_for

Runs the streaming acquisition loop for a fixed number of iterations.

run_streaming_for_samples

Runs streaming acquisition until a specified number of samples are collected.

run_streaming_while

Starts and continuously runs the streaming acquisition loop until

stop

Signals the streaming loop to stop.

add_channel(channel, ratio_mode=RATIO_MODE.RAW, data_type=DATA_TYPE.INT16_T)

!NOT YET IMPLEMETED! Adds a channel configuration for data acquisition.

This method appends a new channel configuration to the internal list, specifying the channel, ratio mode, and data type to be used for streaming.

Parameters:
  • channel (CHANNEL) –

    The channel to add for streaming.

  • ratio_mode (RATIO_MODE, default: RAW ) –

    The downsampling ratio mode for this channel. Defaults to RATIO_MODE.RAW.

  • data_type (DATA_TYPE, default: INT16_T ) –

    The data type to use for samples from this channel. Defaults to DATA_TYPE.INT16_T.

Returns:
  • None

    None

config_streaming(channel, samples, interval, time_units, max_buffer_size, pre_trig_samples=0, post_trig_samples=250, ratio=0, ratio_mode=RATIO_MODE.RAW, data_type=DATA_TYPE.INT16_T)

Configures the streaming settings for data acquisition. This method sets up the channel, sample counts, timing intervals, and buffer management for streaming data from the device.

Parameters:
  • channel (CHANNEL) –

    The channel to stream data from.

  • samples (int) –

    The number of samples to acquire in each streaming segment.

  • interval (int) –

    The time interval between samples.

  • time_units (PICO_TIME_UNIT) –

    Units for the sample interval (e.g., microseconds).

  • max_buffer_size (int | None) –

    Maximum number of samples the python buffer can hold. If None, the buffer will not constrain.

  • pre_trig_samples (int, default: 0 ) –

    Number of samples to capture before a trigger event. Defaults to 0.

  • post_trig_samples (int, default: 250 ) –

    Number of samples to capture after a trigger event. Defaults to 250.

  • ratio (int, default: 0 ) –

    Downsampling ratio to apply to the captured data. Defaults to 0 (no downsampling).

  • ratio_mode (RATIO_MODE, default: RAW ) –

    Mode used for applying the downsampling ratio. Defaults to RATIO_MODE.RAW.

  • data_type (DATA_TYPE, default: INT16_T ) –

    Data type for the samples in the buffer. Defaults to DATA_TYPE.INT16_T.

Returns:
  • None

    None

main_streaming_loop()

Main loop for handling streaming data acquisition.

This method retrieves the latest streaming data from the device, appends new samples to the internal buffer array, and manages buffer rollover when the hardware buffer becomes full.

The method ensures that the internal buffer (self.buffer_array) always contains the most recent samples up to max_buffer_size. It also handles alternating between buffer segments when a buffer overflow condition is detected.

run_streaming()

Initiates the data streaming process.

This method prepares the device for streaming by clearing existing data buffers, setting up a new data buffer for the selected channel, and starting the streaming process with the configured parameters such as sample interval, trigger settings, and downsampling options.

The method resets internal buffer indices and flags to prepare for incoming data.

run_streaming_for(n_times)

Runs the streaming acquisition loop for a fixed number of iterations.

Parameters:
  • n_times (int) –

    Number of iterations to run the streaming loop.

run_streaming_for_samples(no_of_samples)

Runs streaming acquisition until a specified number of samples are collected. The loop will terminate early if StreamingScope.stop() is called.

Parameters:
  • no_of_samples (int) –

    The total number of samples to acquire before stopping.

Returns:
  • ndarray

    numpy.ndarray: The buffer array containing the collected samples.

run_streaming_while()

Starts and continuously runs the streaming acquisition loop until StreamingScope.stop() is called.

stop()

Signals the streaming loop to stop.