pyecsca.sca.scope.base module

Provides an abstract base class for oscilloscopes.

class SampleType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

The sample unit.

Raw = 1[source]
Volt = 2[source]
class Scope[source]

Bases: object

An oscilloscope.

open()[source]

Open the connection to the scope.

Return type:

None

property channels: Sequence[str][source]

A list of channels available on this scope.

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.

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.

Return type:

None

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.

Return type:

None

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.

Return type:

None

arm()[source]

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

Return type:

None

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=None)[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.

Return type:

None

close()[source]

Close the connection to the scope.

Return type:

None