Tektronix2SeriesMSO#
- class Tektronix2SeriesMSO(
- visa_resource: str | VisaConfig,
Bases:
ScopeDriverBaseSCPI driver for Tektronix 2 Series MSO oscilloscopes (MSO22, MSO24).
Methods
Drain
ALLEv?and raise on any event with code > 1.Delete every measurement slot on the scope and reset the local cache.
Close the underlying transport.
SEQuence``+``RUN, then*OPC?under a scoped VISA timeout.Fetch the waveform from
channeloverRIBinary(signed 16-bit).Force a trigger event immediately, regardless of the configured conditions.
Read back the current acquisition mode.
Read back the acquisition run state (RUNNING / STOPPED).
Read back the waveforms-to-average count.
Read back input coupling on
channel.Read back the timebase (seconds/div).
Read back
channel's probe attenuation ratio.Read back the current sample rate (samples per second).
Read back the trigger status (ARMED / READY / TRIGGERED / …).
Read back
channel's vertical offset (volts).Read back
channel's vertical scale (V/div).Recall a scope setup from
name.Read a built-in measurement from a persistent slot; the vendor's invalid sentinel maps to
NaN.Open the underlying transport.
Start continuous (free-running) acquisition.
Capture a screenshot.
Save the current scope setup.
Set the acquisition mode.
Set the number of waveforms to average.
Set AC/DC input coupling on
channel.Set the timebase to
seconds_per_div.Set
channel's probe attenuation ratio (e.g. 1, 10, 100, 1000).Set the trigger threshold to
level(volts).Set the trigger sweep mode (AUTO / NORMAL).
Set the trigger edge slope (RISING / FALLING / EITHER).
Set the trigger source to analog
channel.Set the trigger type (EDGE, PULSE, …).
Set
channel's vertical offset tooffset(volts).Set
channel's vertical scale tovolts_per_div(V/div).Ensure a persistent measurement slot exists for this type and channel.
Arm a single-shot acquisition.
Stop acquisition.
- open() None[source]#
Open the underlying transport. Idempotent.
Concrete drivers also perform any one-shot instrument setup here (e.g.
*CLS, remote-mode handshake).
- set_vertical_scale( ) None[source]#
Set
channel’s vertical scale tovolts_per_div(V/div).Drivers may snap to the nearest hardware-supported step. Callers that need the actual applied value should
get_vertical_scale()afterward.
- set_probe_attenuation( ) None[source]#
Set
channel’s probe attenuation ratio (e.g. 1, 10, 100, 1000).
- set_horizontal_scale(seconds_per_div: float) None[source]#
Set the timebase to
seconds_per_div. Applies globally to all channels.
- get_sample_rate() float[source]#
Read back the current sample rate (samples per second).
This is the effective hardware rate the scope is acquiring at; it depends on the timebase, memory depth, and interpolation settings.
- set_acquisition_mode(
- mode: AcquisitionMode,
Set the acquisition mode.
Drivers should raise
NotImplementedErrorforAcquisitionModevalues their scope doesn’t support (e.g. Keysight 1200X has no ENVELOPE mode).
- get_acquisition_mode() AcquisitionMode[source]#
Read back the current acquisition mode.
- set_average_count(count: int) None[source]#
Set the number of waveforms to average. Only takes effect in
AcquisitionMode.AVERAGE.
- stop() None[source]#
Stop acquisition. Leaves the captured data intact for
fetch_waveform/measure.
- single() None[source]#
Arm a single-shot acquisition.
Non-blocking — use
get_acquisition_stateto poll for STOPPED, or preferdigitize()which combines arming and waiting.
- digitize(timeout: float) None[source]#
SEQuence``+``RUN, then*OPC?under a scoped VISA timeout.clear()on timeout to restore the session.
- get_acquisition_state() AcquisitionState[source]#
Read back the acquisition run state (RUNNING / STOPPED).
- fetch_waveform(
- channel: int,
Fetch the waveform from
channeloverRIBinary(signed 16-bit).
- setup_measurement(
- measurement_type: ScopeMeasurementType,
- channel: int,
Ensure a persistent measurement slot exists for this type and channel.
Uses
MEASUrement:ADDMEAS <type>to create the slot atomically with the target type — this avoids the race whereADDNew "MEAS<n>"+MEAS<n>:TYPecreates a slot that briefly computes under the scope’s default type (typically Period) before the type change takes effect, causing the firstmeasure()call to return a stale, wrong-type value.ADDMEASdoesn’t take a name; the new slot’s name (the scope auto-assigns the nextMEAS<n>) is recovered by diffingMEASUrement:LIST?before and after the add.Tektronix computes measurements during acquisition, so the slot must exist before the scope triggers for results to be valid.
- clear_measurements() None[source]#
Delete every measurement slot on the scope and reset the local cache.
- measure(
- measurement_type: ScopeMeasurementType,
- channel: int,
Read a built-in measurement from a persistent slot; the vendor’s invalid sentinel maps to
NaN.
- set_trigger_source(channel: int) None[source]#
Set the trigger source to analog
channel.Drivers typically cache this value because the trigger-level SCPI on some scopes requires the source channel in the same command.
- set_trigger_type(
- trigger_type: TriggerType,
Set the trigger type (EDGE, PULSE, …).
- set_trigger_level(level: float) None[source]#
Set the trigger threshold to
level(volts). Applies to the configured trigger source.
- set_trigger_slope(
- slope: TriggerSlope,
Set the trigger edge slope (RISING / FALLING / EITHER).
- set_trigger_mode(
- mode: TriggerMode,
Set the trigger sweep mode (AUTO / NORMAL).
AUTO forces an acquisition if no trigger fires within the timeout; NORMAL waits indefinitely for a real trigger.
- force_trigger() None[source]#
Force a trigger event immediately, regardless of the configured conditions.
- get_trigger_status() TriggerStatus[source]#
Read back the trigger status (ARMED / READY / TRIGGERED / …).
- save_screenshot( ) bytes[source]#
Capture a screenshot.
- Parameters:
filepath
Output path. When
to_instrument=Falsethis is a host path; whenTrueit is a path on the scope’s filesystem (USB stick, internal storage).to_instrument
When
True, the scope writes the file itself and this returnsb"". WhenFalse, the image is transferred to the host, written tofilepath, and the raw bytes are returned for in-memory use.
- save_settings( ) bytes[source]#
Save the current scope setup. Path semantics mirror
save_screenshot().
- load_settings( ) None[source]#
Recall a scope setup from
name.With
from_instrument=Truethe scope reads from its own filesystem; otherwise the host readsnameand pushes the bytes to the scope. After loading, the callingInstroScopeshould invalidate its trackedScopeStateand resync if a fresh view is needed.