pyecsca.sca.scope.picoscope_sdk module

Provides an oscilloscope class for PicoScope branded oscilloscopes using the official picosdk-python-wrappers.

class pyecsca.sca.scope.picoscope_sdk.PicoScopeSdk(variant=None)[source]

Bases: Scope

PicoScope based scope.

MODULE: Library
PREFIX: str
CHANNELS: Mapping
RANGES: Mapping
MAX_ADC_VALUE: int
MIN_ADC_VALUE: int
COUPLING: Mapping
TIME_UNITS: Mapping
TRIGGERS: Mapping = {'above': 0, 'below': 1, 'falling': 3, 'rising': 2}
open()[source]

Open the connection to the scope.

Return type:

None

property channels

A list of channels available on this scope.

get_variant()[source]
setup_frequency(frequency, pretrig, posttrig)[source]

Setup the frequency and sample count for the measurement.

The scope might not support the requested values and will adjust them to get the next best frequency and the largest supported number of samples (or the number of samples requested).

Parameters:
  • frequency (int) – The requested frequency in Hz.

  • pretrig (int) – The requested number of samples to measure before the trigger.

  • posttrig (int) – The requested number of samples to measure after the trigger.

Return type:

Tuple[int, int]

Returns:

A tuple of the actual set frequency and the actual number of samples.

set_channel(channel, enabled, coupling, range, offset)[source]
setup_channel(channel, coupling, range, offset, enable)[source]

Setup a channel to use the coupling method and measure the given voltage range.

Parameters:
  • channel (str) – The channel to measure.

  • coupling (str) – The coupling method (“AC” or “DC).

  • range (float) – The voltage range to measure.

  • offset (float) – The analog voltage offset added to the input. Not supported on many scopes.

  • enable (bool) – Whether to enable or disable the channel.

set_frequency(frequency, pretrig, posttrig)[source]
Return type:

Tuple[int, int]

setup_trigger(channel, threshold, direction, delay, timeout, enable)[source]

Setup a trigger on a particular channel, the channel has to be set up and enabled.

The trigger will fire based on the threshold and direction, if enabled, the trigger will capture after delay ticks pass. If trigger conditions do not hold it will fire automatically after timeout milliseconds.

Parameters:
  • channel (str) – The channel to trigger on.

  • threshold (float) – The value to trigger on.

  • direction (str) – The direction to trigger on (“above”, “below”, “rising”, “falling”).

  • delay (int) – The delay for capture after trigger (clock ticks).

  • timeout (int) – The timeout in milliseconds.

  • enable (bool) – Whether to enable or disable this trigger.

set_trigger(type, enabled, value, channel, delay, timeout)[source]
setup_capture(channel, enable)[source]

Setup the capture for a channel.

Parameters:
  • channel (str) – The channel to capture.

  • enable (bool) – Whether to enable or disable capture.

set_buffer(channel, enable)[source]
arm()[source]

Arm the scope, it will listen for the trigger after this point.

capture(timeout=None)[source]

Wait for the trace to capture, this will block until the scope has a trace.

Parameters:

timeout (Optional[int]) – A time in milliseconds to wait for the trace, returns None if it runs out.

Return type:

bool

Returns:

Whether capture was successful (or it timed out).

retrieve(channel, type, dtype=<class 'numpy.float32'>)[source]

Retrieve a captured trace of a channel.

Parameters:
  • channel (str) – The channel to retrieve the trace from.

  • type (SampleType) – The type of returned samples.

  • dtype – The data type of the returned samples, should be numpy dtype-like.

Return type:

Optional[Trace]

Returns:

The captured trace (if any).

stop()[source]

Stop the capture, if any.

close()[source]

Close the connection to the scope.

class pyecsca.sca.scope.picoscope_sdk.PS3000Scope(variant=None)[source]

Bases: PicoScopeSdk

PicoScope 3000 series oscilloscope.

MODULE: Library = <picosdk.ps3000.Ps3000lib object>
PREFIX: str = 'ps3000'
CHANNELS: Mapping = {'A': 0, 'B': 1, 'C': 2, 'D': 3}
RANGES: Mapping = {0.02: 1, 0.05: 2, 0.1: 3, 0.2: 4, 0.5: 5, 1.0: 6, 2.0: 7, 5.0: 8, 10.0: 9, 20.0: 10, 50.0: 11, 100.0: 12, 200.0: 13, 400.0: 14}
MAX_ADC_VALUE: int = 32767
MIN_ADC_VALUE: int = -32767
COUPLING: Mapping = {'AC': 0, 'DC': 1}
open()[source]

Open the connection to the scope.

Return type:

None

stop()[source]

Stop the capture, if any.

close()[source]

Close the connection to the scope.

get_variant()[source]
set_frequency(frequency, pretrig, posttrig)[source]
TRIGGERS: Mapping = {'above': 0, 'below': 1, 'falling': 3, 'rising': 2}
arm()

Arm the scope, it will listen for the trigger after this point.

capture(timeout=None)

Wait for the trace to capture, this will block until the scope has a trace.

Parameters:

timeout (Optional[int]) – A time in milliseconds to wait for the trace, returns None if it runs out.

Return type:

bool

Returns:

Whether capture was successful (or it timed out).

property channels

A list of channels available on this scope.

retrieve(channel, type, dtype=<class 'numpy.float32'>)

Retrieve a captured trace of a channel.

Parameters:
  • channel (str) – The channel to retrieve the trace from.

  • type (SampleType) – The type of returned samples.

  • dtype – The data type of the returned samples, should be numpy dtype-like.

Return type:

Optional[Trace]

Returns:

The captured trace (if any).

set_buffer(channel, enable)
set_channel(channel, enabled, coupling, range, offset)
set_trigger(type, enabled, value, channel, delay, timeout)
setup_capture(channel, enable)

Setup the capture for a channel.

Parameters:
  • channel (str) – The channel to capture.

  • enable (bool) – Whether to enable or disable capture.

setup_channel(channel, coupling, range, offset, enable)

Setup a channel to use the coupling method and measure the given voltage range.

Parameters:
  • channel (str) – The channel to measure.

  • coupling (str) – The coupling method (“AC” or “DC).

  • range (float) – The voltage range to measure.

  • offset (float) – The analog voltage offset added to the input. Not supported on many scopes.

  • enable (bool) – Whether to enable or disable the channel.

setup_frequency(frequency, pretrig, posttrig)

Setup the frequency and sample count for the measurement.

The scope might not support the requested values and will adjust them to get the next best frequency and the largest supported number of samples (or the number of samples requested).

Parameters:
  • frequency (int) – The requested frequency in Hz.

  • pretrig (int) – The requested number of samples to measure before the trigger.

  • posttrig (int) – The requested number of samples to measure after the trigger.

Return type:

Tuple[int, int]

Returns:

A tuple of the actual set frequency and the actual number of samples.

setup_trigger(channel, threshold, direction, delay, timeout, enable)

Setup a trigger on a particular channel, the channel has to be set up and enabled.

The trigger will fire based on the threshold and direction, if enabled, the trigger will capture after delay ticks pass. If trigger conditions do not hold it will fire automatically after timeout milliseconds.

Parameters:
  • channel (str) – The channel to trigger on.

  • threshold (float) – The value to trigger on.

  • direction (str) – The direction to trigger on (“above”, “below”, “rising”, “falling”).

  • delay (int) – The delay for capture after trigger (clock ticks).

  • timeout (int) – The timeout in milliseconds.

  • enable (bool) – Whether to enable or disable this trigger.

TIME_UNITS: Mapping
handle: c_short
frequency: Optional[int]
pretrig: Optional[int]
posttrig: Optional[int]
samples: Optional[int]
timebase: Optional[int]
buffers: MutableMapping
ranges: MutableMapping
class pyecsca.sca.scope.picoscope_sdk.PS3000aScope(variant=None)[source]

Bases: PicoScopeSdk

PicoScope 3000 series oscilloscope (A API).

MODULE: Library = <picosdk.ps3000a.Ps3000alib object>
PREFIX: str = 'ps3000a'
CHANNELS: Mapping = {'A': 0, 'B': 1, 'C': 2, 'D': 3}
RANGES: Mapping = {0.01: 0, 0.02: 1, 0.05: 2, 0.1: 3, 0.2: 4, 0.5: 5, 1.0: 6, 2.0: 7, 5.0: 8, 10.0: 9, 20.0: 10, 50.0: 11}
MAX_ADC_VALUE: int = 32767
MIN_ADC_VALUE: int = -32767
COUPLING: Mapping = {'AC': 0, 'DC': 1}
open()[source]

Open the connection to the scope.

Return type:

None

set_channel(channel, enabled, coupling, range, offset)[source]
set_buffer(channel, enable)[source]
set_frequency(frequency, pretrig, posttrig)[source]
TRIGGERS: Mapping = {'above': 0, 'below': 1, 'falling': 3, 'rising': 2}
arm()

Arm the scope, it will listen for the trigger after this point.

capture(timeout=None)

Wait for the trace to capture, this will block until the scope has a trace.

Parameters:

timeout (Optional[int]) – A time in milliseconds to wait for the trace, returns None if it runs out.

Return type:

bool

Returns:

Whether capture was successful (or it timed out).

property channels

A list of channels available on this scope.

close()

Close the connection to the scope.

get_variant()
retrieve(channel, type, dtype=<class 'numpy.float32'>)

Retrieve a captured trace of a channel.

Parameters:
  • channel (str) – The channel to retrieve the trace from.

  • type (SampleType) – The type of returned samples.

  • dtype – The data type of the returned samples, should be numpy dtype-like.

Return type:

Optional[Trace]

Returns:

The captured trace (if any).

set_trigger(type, enabled, value, channel, delay, timeout)
setup_capture(channel, enable)

Setup the capture for a channel.

Parameters:
  • channel (str) – The channel to capture.

  • enable (bool) – Whether to enable or disable capture.

setup_channel(channel, coupling, range, offset, enable)

Setup a channel to use the coupling method and measure the given voltage range.

Parameters:
  • channel (str) – The channel to measure.

  • coupling (str) – The coupling method (“AC” or “DC).

  • range (float) – The voltage range to measure.

  • offset (float) – The analog voltage offset added to the input. Not supported on many scopes.

  • enable (bool) – Whether to enable or disable the channel.

setup_frequency(frequency, pretrig, posttrig)

Setup the frequency and sample count for the measurement.

The scope might not support the requested values and will adjust them to get the next best frequency and the largest supported number of samples (or the number of samples requested).

Parameters:
  • frequency (int) – The requested frequency in Hz.

  • pretrig (int) – The requested number of samples to measure before the trigger.

  • posttrig (int) – The requested number of samples to measure after the trigger.

Return type:

Tuple[int, int]

Returns:

A tuple of the actual set frequency and the actual number of samples.

setup_trigger(channel, threshold, direction, delay, timeout, enable)

Setup a trigger on a particular channel, the channel has to be set up and enabled.

The trigger will fire based on the threshold and direction, if enabled, the trigger will capture after delay ticks pass. If trigger conditions do not hold it will fire automatically after timeout milliseconds.

Parameters:
  • channel (str) – The channel to trigger on.

  • threshold (float) – The value to trigger on.

  • direction (str) – The direction to trigger on (“above”, “below”, “rising”, “falling”).

  • delay (int) – The delay for capture after trigger (clock ticks).

  • timeout (int) – The timeout in milliseconds.

  • enable (bool) – Whether to enable or disable this trigger.

stop()

Stop the capture, if any.

TIME_UNITS: Mapping
handle: c_short
frequency: Optional[int]
pretrig: Optional[int]
posttrig: Optional[int]
samples: Optional[int]
timebase: Optional[int]
buffers: MutableMapping
ranges: MutableMapping
class pyecsca.sca.scope.picoscope_sdk.PS4000Scope(variant=None)[source]

Bases: PicoScopeSdk

PicoScope 4000 series oscilloscope.

MODULE: Library = <picosdk.ps4000.Ps4000lib object>
PREFIX: str = 'ps4000'
CHANNELS: Mapping = {'A': 0, 'B': 1, 'C': 2, 'D': 3}
RANGES: Mapping = {0.01: 0, 0.02: 1, 0.05: 2, 0.1: 3, 0.2: 4, 0.5: 5, 1.0: 6, 2.0: 7, 5.0: 8, 10.0: 9, 20.0: 10, 50.0: 11, 100.0: 12}
MAX_ADC_VALUE: int = 32764
MIN_ADC_VALUE: int = -32764
COUPLING: Mapping = {'AC': 0, 'DC': 1}
set_frequency(frequency, pretrig, posttrig)[source]
TRIGGERS: Mapping = {'above': 0, 'below': 1, 'falling': 3, 'rising': 2}
arm()

Arm the scope, it will listen for the trigger after this point.

capture(timeout=None)

Wait for the trace to capture, this will block until the scope has a trace.

Parameters:

timeout (Optional[int]) – A time in milliseconds to wait for the trace, returns None if it runs out.

Return type:

bool

Returns:

Whether capture was successful (or it timed out).

property channels

A list of channels available on this scope.

close()

Close the connection to the scope.

get_variant()
open()

Open the connection to the scope.

Return type:

None

retrieve(channel, type, dtype=<class 'numpy.float32'>)

Retrieve a captured trace of a channel.

Parameters:
  • channel (str) – The channel to retrieve the trace from.

  • type (SampleType) – The type of returned samples.

  • dtype – The data type of the returned samples, should be numpy dtype-like.

Return type:

Optional[Trace]

Returns:

The captured trace (if any).

set_buffer(channel, enable)
set_channel(channel, enabled, coupling, range, offset)
set_trigger(type, enabled, value, channel, delay, timeout)
setup_capture(channel, enable)

Setup the capture for a channel.

Parameters:
  • channel (str) – The channel to capture.

  • enable (bool) – Whether to enable or disable capture.

setup_channel(channel, coupling, range, offset, enable)

Setup a channel to use the coupling method and measure the given voltage range.

Parameters:
  • channel (str) – The channel to measure.

  • coupling (str) – The coupling method (“AC” or “DC).

  • range (float) – The voltage range to measure.

  • offset (float) – The analog voltage offset added to the input. Not supported on many scopes.

  • enable (bool) – Whether to enable or disable the channel.

setup_frequency(frequency, pretrig, posttrig)

Setup the frequency and sample count for the measurement.

The scope might not support the requested values and will adjust them to get the next best frequency and the largest supported number of samples (or the number of samples requested).

Parameters:
  • frequency (int) – The requested frequency in Hz.

  • pretrig (int) – The requested number of samples to measure before the trigger.

  • posttrig (int) – The requested number of samples to measure after the trigger.

Return type:

Tuple[int, int]

Returns:

A tuple of the actual set frequency and the actual number of samples.

setup_trigger(channel, threshold, direction, delay, timeout, enable)

Setup a trigger on a particular channel, the channel has to be set up and enabled.

The trigger will fire based on the threshold and direction, if enabled, the trigger will capture after delay ticks pass. If trigger conditions do not hold it will fire automatically after timeout milliseconds.

Parameters:
  • channel (str) – The channel to trigger on.

  • threshold (float) – The value to trigger on.

  • direction (str) – The direction to trigger on (“above”, “below”, “rising”, “falling”).

  • delay (int) – The delay for capture after trigger (clock ticks).

  • timeout (int) – The timeout in milliseconds.

  • enable (bool) – Whether to enable or disable this trigger.

stop()

Stop the capture, if any.

TIME_UNITS: Mapping
handle: c_short
frequency: Optional[int]
pretrig: Optional[int]
posttrig: Optional[int]
samples: Optional[int]
timebase: Optional[int]
buffers: MutableMapping
ranges: MutableMapping
class pyecsca.sca.scope.picoscope_sdk.PS5000Scope(variant=None)[source]

Bases: PicoScopeSdk

PicoScope 5000 series oscilloscope.

MODULE: Library = <picosdk.ps5000.Ps5000lib object>
PREFIX: str = 'ps5000'
CHANNELS: Mapping = {'A': 0, 'B': 1, 'C': 2, 'D': 3}
RANGES: Mapping = {0.01: 0, 0.02: 1, 0.05: 2, 0.1: 3, 0.2: 4, 0.5: 5, 1.0: 6, 2.0: 7, 5.0: 8, 10.0: 9, 20.0: 10, 50.0: 11}
MAX_ADC_VALUE: int = 32512
MIN_ADC_VALUE: int = -32512
COUPLING: Mapping = {'AC': 0, 'DC': 1}
set_frequency(frequency, pretrig, posttrig)[source]
TRIGGERS: Mapping = {'above': 0, 'below': 1, 'falling': 3, 'rising': 2}
arm()

Arm the scope, it will listen for the trigger after this point.

capture(timeout=None)

Wait for the trace to capture, this will block until the scope has a trace.

Parameters:

timeout (Optional[int]) – A time in milliseconds to wait for the trace, returns None if it runs out.

Return type:

bool

Returns:

Whether capture was successful (or it timed out).

property channels

A list of channels available on this scope.

close()

Close the connection to the scope.

get_variant()
open()

Open the connection to the scope.

Return type:

None

retrieve(channel, type, dtype=<class 'numpy.float32'>)

Retrieve a captured trace of a channel.

Parameters:
  • channel (str) – The channel to retrieve the trace from.

  • type (SampleType) – The type of returned samples.

  • dtype – The data type of the returned samples, should be numpy dtype-like.

Return type:

Optional[Trace]

Returns:

The captured trace (if any).

set_buffer(channel, enable)
set_channel(channel, enabled, coupling, range, offset)
set_trigger(type, enabled, value, channel, delay, timeout)
setup_capture(channel, enable)

Setup the capture for a channel.

Parameters:
  • channel (str) – The channel to capture.

  • enable (bool) – Whether to enable or disable capture.

setup_channel(channel, coupling, range, offset, enable)

Setup a channel to use the coupling method and measure the given voltage range.

Parameters:
  • channel (str) – The channel to measure.

  • coupling (str) – The coupling method (“AC” or “DC).

  • range (float) – The voltage range to measure.

  • offset (float) – The analog voltage offset added to the input. Not supported on many scopes.

  • enable (bool) – Whether to enable or disable the channel.

setup_frequency(frequency, pretrig, posttrig)

Setup the frequency and sample count for the measurement.

The scope might not support the requested values and will adjust them to get the next best frequency and the largest supported number of samples (or the number of samples requested).

Parameters:
  • frequency (int) – The requested frequency in Hz.

  • pretrig (int) – The requested number of samples to measure before the trigger.

  • posttrig (int) – The requested number of samples to measure after the trigger.

Return type:

Tuple[int, int]

Returns:

A tuple of the actual set frequency and the actual number of samples.

setup_trigger(channel, threshold, direction, delay, timeout, enable)

Setup a trigger on a particular channel, the channel has to be set up and enabled.

The trigger will fire based on the threshold and direction, if enabled, the trigger will capture after delay ticks pass. If trigger conditions do not hold it will fire automatically after timeout milliseconds.

Parameters:
  • channel (str) – The channel to trigger on.

  • threshold (float) – The value to trigger on.

  • direction (str) – The direction to trigger on (“above”, “below”, “rising”, “falling”).

  • delay (int) – The delay for capture after trigger (clock ticks).

  • timeout (int) – The timeout in milliseconds.

  • enable (bool) – Whether to enable or disable this trigger.

stop()

Stop the capture, if any.

TIME_UNITS: Mapping
handle: c_short
frequency: Optional[int]
pretrig: Optional[int]
posttrig: Optional[int]
samples: Optional[int]
timebase: Optional[int]
buffers: MutableMapping
ranges: MutableMapping
class pyecsca.sca.scope.picoscope_sdk.PS6000Scope(variant=None)[source]

Bases: PicoScopeSdk

PicoScope 6000 series oscilloscope.

MODULE: Library = <picosdk.ps6000.Ps6000lib object>
PREFIX: str = 'ps6000'
CHANNELS: Mapping = {'A': 0, 'B': 1, 'C': 2, 'D': 3}
RANGES: Mapping = {0.01: 0, 0.02: 1, 0.05: 2, 0.1: 3, 0.2: 4, 0.5: 5, 1.0: 6, 2.0: 7, 5.0: 8, 10.0: 9, 20.0: 10, 50.0: 11}
MAX_ADC_VALUE: int = 32512
MIN_ADC_VALUE: int = -32512
TRIGGERS: Mapping = {'above': 0, 'below': 1, 'falling': 3, 'rising': 2}
arm()

Arm the scope, it will listen for the trigger after this point.

capture(timeout=None)

Wait for the trace to capture, this will block until the scope has a trace.

Parameters:

timeout (Optional[int]) – A time in milliseconds to wait for the trace, returns None if it runs out.

Return type:

bool

Returns:

Whether capture was successful (or it timed out).

property channels

A list of channels available on this scope.

close()

Close the connection to the scope.

get_variant()
retrieve(channel, type, dtype=<class 'numpy.float32'>)

Retrieve a captured trace of a channel.

Parameters:
  • channel (str) – The channel to retrieve the trace from.

  • type (SampleType) – The type of returned samples.

  • dtype – The data type of the returned samples, should be numpy dtype-like.

Return type:

Optional[Trace]

Returns:

The captured trace (if any).

set_trigger(type, enabled, value, channel, delay, timeout)
setup_capture(channel, enable)

Setup the capture for a channel.

Parameters:
  • channel (str) – The channel to capture.

  • enable (bool) – Whether to enable or disable capture.

setup_channel(channel, coupling, range, offset, enable)

Setup a channel to use the coupling method and measure the given voltage range.

Parameters:
  • channel (str) – The channel to measure.

  • coupling (str) – The coupling method (“AC” or “DC).

  • range (float) – The voltage range to measure.

  • offset (float) – The analog voltage offset added to the input. Not supported on many scopes.

  • enable (bool) – Whether to enable or disable the channel.

setup_frequency(frequency, pretrig, posttrig)

Setup the frequency and sample count for the measurement.

The scope might not support the requested values and will adjust them to get the next best frequency and the largest supported number of samples (or the number of samples requested).

Parameters:
  • frequency (int) – The requested frequency in Hz.

  • pretrig (int) – The requested number of samples to measure before the trigger.

  • posttrig (int) – The requested number of samples to measure after the trigger.

Return type:

Tuple[int, int]

Returns:

A tuple of the actual set frequency and the actual number of samples.

setup_trigger(channel, threshold, direction, delay, timeout, enable)

Setup a trigger on a particular channel, the channel has to be set up and enabled.

The trigger will fire based on the threshold and direction, if enabled, the trigger will capture after delay ticks pass. If trigger conditions do not hold it will fire automatically after timeout milliseconds.

Parameters:
  • channel (str) – The channel to trigger on.

  • threshold (float) – The value to trigger on.

  • direction (str) – The direction to trigger on (“above”, “below”, “rising”, “falling”).

  • delay (int) – The delay for capture after trigger (clock ticks).

  • timeout (int) – The timeout in milliseconds.

  • enable (bool) – Whether to enable or disable this trigger.

stop()

Stop the capture, if any.

TIME_UNITS: Mapping
handle: c_short
frequency: Optional[int]
pretrig: Optional[int]
posttrig: Optional[int]
samples: Optional[int]
timebase: Optional[int]
buffers: MutableMapping
ranges: MutableMapping
COUPLING: Mapping = {'AC': 0, 'DC': 1, 'DC_50': 2}
open()[source]

Open the connection to the scope.

set_channel(channel, enabled, coupling, range, offset)[source]
set_buffer(channel, enable)[source]
set_frequency(frequency, pretrig, posttrig)[source]