pyMSO4.pyMSO4 module
- class pyMSO4.pyMSO4.MSO4(trig_type: ~typing.Type[~pyMSO4.triggers.MSO4EdgeTrigger] | ~typing.Type[~pyMSO4.triggers.MSO4WidthTrigger] = <class 'pyMSO4.triggers.MSO4EdgeTrigger'>, timeout: float = 2000.0, debug: bool = False)[source]
Bases:
object
Tektronix MSO 4-Series scope object. This is not usable until
MSO4.con()
is called.- __init__(trig_type: ~typing.Type[~pyMSO4.triggers.MSO4EdgeTrigger] | ~typing.Type[~pyMSO4.triggers.MSO4WidthTrigger] = <class 'pyMSO4.triggers.MSO4EdgeTrigger'>, timeout: float = 2000.0, debug: bool = False)[source]
Creates a new MSO4 object.
- Parameters:
trig_type – The type of trigger to use. This can be changed later.
timeout – Timeout (in ms) for each VISA operation, including the CURVE? query.
debug – Enable printing each VISA operation to the console
- rm: ResourceManager
pyvisa ResourceManager object used tp setup the connection
- sc: MessageBasedResource
pyvisa MessageBasedResource object used to communicate with the scope
- acq: MSO4Acquisition
MSO4Acquisition instance used to control the acquisition settings
- ch_a: list[MSO4AnalogChannel]
List of MSO4AnalogChannel instances used to control the analog channels
- debug: bool
Debug mode
- connect_status: bool
Current connection status
- clear_cache() None [source]
Resets the local configuration cache so that values will be fetched from the scope. Is recursively called on all subobjects (trigger, acquisition, channels).
This is useful when the scope configuration is (potentially) changed externally.
- con(ip: str = '', usb_vid_pid: tuple[int, int] = (), **kwargs) bool [source]
- Connects to scope and:
clears event queue, standard event status register, status byte register
sets timeout = timeout from
MSO4.__init__()
Either
ip
orusb_vid_pid
must be specified (not both).- Parameters:
ip (str) – IP address of scope
usb_vid_pid (tuple[int, int]) – USB VID and PID of scope
kwargs – Additional arguments to pass to
pyvisa.ResourceManager.open_resource
- Returns:
True if successful, False otherwise
- Raises:
ValueError – Both or neither IP address and USB VID/PID were specified
OSError – Invalid vendor or model returned from scope
- reboot() None [source]
Reboots the UI (as well as VISA server) on the scope. Note this will kill the current connection
- busy() bool [source]
Queries the status of the scope
Returns: True if the scope is currently busy processing commands that generate an OPC Message, False otherwise.
- ch_a_enable(value: list[bool]) None [source]
Convenience function to enable/disable analog channels. Will start at channel 1 and enable/disable as many channels as there are values in the list.
- property trigger: Type[MSO4EdgeTrigger] | Type[MSO4WidthTrigger]
Current trigger object instance.
- Getter:
Return the current trigger object instance (MSO4Triggers)
- Setter:
Instantiate a new trigger object given a MSO4Triggers type. Also applies the configuration to the scope.
- property timeout: float
Timeout (in ms) for each VISA operation (also those that will stall on the scope end, like CURVE?).
- Getter:
Return the number of milliseconds before a timeout (float)
- Setter:
Set the timeout in milliseconds (float)
- property ch_a_num: int
Number of analog channels on the scope.
- Getter:
Return the number of analog channels (int)
- property display: bool
Enable or disable the waveform display on the scope display.
Not cached
- Getter:
Return the display state (bool)
- Setter:
Set the display state (bool)
- pyMSO4.pyMSO4.usb_reboot(vid: int, pid: int) bool [source]
Reboots the scope via USB when it is not reachable through TCP/IP. Does not require a pre-existing connection to the scope.
- Parameters:
vid – USB Vendor ID
pid – USB Product ID
- Returns:
True if the reboot command was sent successfully, False otherwise
pyMSO4.acquisition module
- class pyMSO4.acquisition.MSO4Acquisition(res: MessageBasedResource, ch_a_count: int)[source]
Bases:
DisableNewAttr
Handle all the properties related to waveform acquisition.
- __init__(res: MessageBasedResource, ch_a_count: int)[source]
Create a new acquisition object.
- Parameters:
res – The VISA resource object
ch_a_count – The number of analog channels available on the scope (1-based, so 4 if the scope has 4 channels)
- clear_caches()[source]
Resets the local configuration cache so that values will be fetched from the scope.
This is useful when the scope configuration is (potentially) changed externally.
- configured() bool [source]
Check if the scope have been configured for acquisition.
Returns: True if configured, raises otherwise
Raises: ValueError if any of the required variables are not set
- property mode: str
- The acquisition mode of the scope. Valid modes are:
sample
: SAMple specifies that the displayed data point value is the sampled value that is taken during the acquisition intervalpeakdetect
: PEAKdetect specifies the display of high-low range of the samples taken from a single waveform acquisition.hires
: HIRes specifies Hi Res mode where the displayed data point value is the average of all the samples taken during the acquisition intervalaverage
: AVErage specifies averaging mode, in which the resulting waveform shows an average of SAMple data points from several separate waveform acquisitions.envelope
: ENVelope specifies envelope mode, where the resulting waveform displays the range of PEAKdetect from continued waveform acquisitions.
Not cached
- Getter:
Return the acquisition mode
- Setter:
Set the acquisition mode
- property stop_after: str
- Wether the instrument continually acquires waves or acquires a single sequence. Valid modes are:
sequence
: specifies that the next acquisition will be a single-sequence acquisitionrunstop
: specifies that the instrument will continually acquire data, if ACQuire:STATE is turned on.
Not cached
- Getter:
Return the acquisition mode
- Setter:
Set the acquisition mode.
- property num_seq: int
In single sequence acquisition mode, specify the number of acquisitions or measurements that comprise the sequence.
Not cached
- Getter:
Return the number of acquisitions or measurements
- Setter:
Set the number of acquisitions or measurements
- property horiz_mode: str
- The horizontal operating mode. Valid values are:
auto
: automatically adjusts the sample rate and record length to provide a high acquisition rate in Fast Acq or signal fidelity in analysismanual
: lets you change the sample rate, horizontal scale, and record length. These values interact. For example, when you change record length then the horizontal scale also changes.
Not cached
- Getter:
Return the mode
- Setter:
Set the mode
- property horiz_sample_rate: float
The horizontal sample rate of the waveform.
Not cached
- Getter:
Return the sample rate in Hz
- Setter:
Set the sample rate in Hz (int or float)
- property horiz_scale: float
The horizontal scale of the waveform.
Not cached
- Getter:
Return the scale in s
- Setter:
Set the scale in s (int or float)
- property horiz_pos: float
The horizontal position of the waveform in percent of the screen: 0% is the left edge of the screen and 100% is the right edge of the screen.
Not cached
- Getter:
Return the position in %
- Setter:
Set the position in % (int or float)
- property horiz_record_length: int
The horizontal record length of the waveform.
Not cached
- Getter:
Return the record length
- Setter:
Set the record length
- property wfm_src: list[str]
Source of the retrieved waveform (analog FlexChannel(s) source(s)). Valid values are
chN
(Analog channel n).Not cached
- Getter:
Return the source
- Setter:
Set the source
- property wfm_start: int
The starting data point for waveform transfer.
Not cached
- Getter:
Return the start index
- Setter:
Set the start index
- property wfm_stop: int
The last data point that will be transferred when retrieving the waveform.
Not cached
- Getter:
Return the stop index
- Setter:
Set the stop index
- property wfm_len: int
The number of data points in the waveform.
Not cached
- Getter:
Return the number of data points
- property wfm_encoding: str
- The encoding of the waveform data. Valid values are:
binary
: Binaryascii
: ASCII
Cached
- Getter:
Return the encoding
- Setter:
Set the encoding
- Raises:
ValueError – Invalid encoding
- property wfm_binary_format: str
- The data format of binary waveform data. Valid values are:
ri
: Signed integerrp
: Unsigned integerfp
: Floating point
Cached
- Getter:
Return the data format
- Setter:
Set the data format
- Raises:
ValueError – Invalid data format
- property wfm_byte_nr: int
The number of bytes per data point in the waveform.
Cached
- Getter:
Return the number of bytes per data point
- Setter:
Set the number of bytes per data point NOTE: Check the programmer manual for valid values § WFMOutpre:BYT_Nr. If unsure, clear the cache with
scope._clear_cache()
and read back the value
- property wfm_byte_order: str
- The byte order of the waveform data. Valid values are:
lsb
: Least significant byte firstmsb
: Most significant byte first
Cached
- Getter:
Return the byte order
- Setter:
Set the byte order
- Raises:
ValueError – Invalid byte order
- property is_big_endian: bool
Return True if the byte order is big endian, False otherwise.
Cached
- property curvestream: bool
Enable or disable curvestream mode.
Cached
- Getter:
Return the curvestream state
- Setter:
Set the curvestream state
- property fast_acq: bool
Enable or disable fast acquisition mode.
Cached
- Getter:
Return the fast acquisition state
- Setter:
Set the fast acquisition state
pyMSO4.channel module
- class pyMSO4.channel.MSO4AnalogChannel(res: MessageBasedResource, channel: int)[source]
Bases:
DisableNewAttr
Settings for each analog channel
- __init__(res: MessageBasedResource, channel: int)[source]
Creates a new channel object
- Parameters:
res – The VISA resource to use for communication
channel – The channel number (1-n)
- property enable: bool
Enables the channel.
Not cached
- Getter:
Return the enable status
- Setter:
Set the enable status
- property scale: float
Sets the vertical scale of the waveform.
Not cached
- Getter:
Return the scale in V (float)
- Setter:
Set the scale in V (int or float)
- property position: float
Sets the vertical position of the waveform.
Not cached
- Getter:
Return the position in V (float)
- Setter:
Set the position in V (int or float)
pyMSO4.triggers module
- class pyMSO4.triggers.MSO4TriggerBase(res: MessageBasedResource, ch_a_count: int, event: str = 'A')[source]
Bases:
DisableNewAttr
Base trigger for the MSO 4-Series, used for settings shared by all trigger types
- __init__(res: MessageBasedResource, ch_a_count: int, event: str = 'A')[source]
Create a new trigger object
- Parameters:
res – The VISA resource to use for communication
ch_a_count – The number of analog channels available on the scope
event – The event channel (
A
orB
) to use as a trigger. See: 4/5/6 Series MSO Help § Trigger on sequential events (A and B triggers) (https://www.tek.com/en/sitewide-content/manuals/4/5/6/4-5-6-series-mso-help)
- clear_caches()[source]
Resets the local configuration cache so that values will be fetched from the scope.
This is useful when the scope configuration is (potentially) changed externally.
- property source
The source of the event currently configured as a trigger. Valid values are
chN
(Analog channel n) andauxiliary
,aux
,line
Cached
- Getter:
Return the current trigger source
- Setter:
Set the trigger source
- Raises:
ValueError – if value is not one of the allowed strings
- property coupling: str
The coupling of the trigger source. Valid couplings are
dc
,hfrej
,lfrej
,noiserej
Cached
- Getter:
Return the current trigger coupling
- Setter:
Set the trigger coupling
- Raises:
ValueError – if value is not one of the allowed strings
- property level: float
The trigger level
Cached
- Getter:
Return the current trigger level
- Setter:
Set the trigger level (int or float)
- Raises:
ValueError – if value is not an int or float
- property mode: str
The trigger mode (
auto
/normal
)Cached
- Getter:
Return the current trigger mode
- Setter:
Set the trigger mode
- Raises:
NotImplementedError – if trigger event is not A
ValueError – if value is not one of the allowed strings
- class pyMSO4.triggers.MSO4EdgeTrigger(res: MessageBasedResource, ch_a_count: int, event: str = 'A')[source]
Bases:
MSO4TriggerBase
Edge trigger
- __init__(res: MessageBasedResource, ch_a_count: int, event: str = 'A')[source]
Create a new trigger object
- Parameters:
res – The VISA resource to use for communication
ch_a_count – The number of analog channels available on the scope
event – The event channel (
A
orB
) to use as a trigger. See: 4/5/6 Series MSO Help § Trigger on sequential events (A and B triggers) (https://www.tek.com/en/sitewide-content/manuals/4/5/6/4-5-6-series-mso-help)
- clear_caches()[source]
Resets the local configuration cache so that values will be fetched from the scope.
This is useful when the scope configuration is (potentially) changed externally.
- property edge_slope: str
The edge slope (
rise
/fall
/either
)Cached
- Getter:
Return the current edge slope
- Setter:
Set the edge slope
- Raises:
ValueError – if value is not one of the allowed strings
- class pyMSO4.triggers.MSO4WidthTrigger(res: MessageBasedResource, ch_a_count: int, event: str = 'A')[source]
Bases:
MSO4TriggerBase
Pulse Width trigger
- __init__(res: MessageBasedResource, ch_a_count: int, event: str = 'A')[source]
Create a new trigger object
- Parameters:
res – The VISA resource to use for communication
ch_a_count – The number of analog channels available on the scope
event – The event channel (
A
orB
) to use as a trigger. See: 4/5/6 Series MSO Help § Trigger on sequential events (A and B triggers) (https://www.tek.com/en/sitewide-content/manuals/4/5/6/4-5-6-series-mso-help)
- clear_caches()[source]
Resets the local configuration cache so that values will be fetched from the scope.
This is useful when the scope configuration is (potentially) changed externally.
- property lowlimit: float
The low limit of the pulse width (in seconds)
Cached
- Getter:
Return the current low limit
- Setter:
Set the low limit (int or float)
- Raises:
ValueError – if value is not an int or float
- property highlimit: float
The high limit of the pulse width (in seconds)
Cached
- Getter:
Return the current high limit
- Setter:
Set the high limit (int or float)
- Raises:
ValueError – if value is not an int or float
- property when: str
Trigger when a pulse is detected with a width
lessthan
,morethan
,equal
,unequal
the width specified withlowlimit
. When bothlowlimit
andhighlimit
are set, the trigger can occur when a pulse is eitherwithin
oroutside
the specified width range.Cached
- Getter:
Return the current when
- Setter:
Set the when (str)
- Raises:
ValueError – if value is not one of the allowed strings
- property polarity: str
The polarity of the pulse (
positive
/negative
)Cached
- Getter:
Return the current polarity
- Setter:
Set the polarity (str)
- Raises:
ValueError – if value is not one of the allowed strings
- property logicqualification: str
The logic qualification (
on
/off
). See the oscilloscope help (p. 122) for more information.Cached
- Getter:
Return the current logic qualification
- Setter:
Set the logic qualification (str)
- Raises:
ValueError – if value is not one of the allowed strings
pyMSO4.util module
- class pyMSO4.util.DisableNewAttr[source]
Bases:
object
Provides an ability to disable setting new attributes in a class, useful to prevent typos.
Usage: 1. Make a class that inherits this class: >>> class MyClass(DisableNewAttr): >>> # Your class definition here
2. After setting up all attributes that your object needs, call disable_newattr(): >>> def __init__(self): >>> self.my_attr = 123 >>> self.disable_newattr()
3. Subclasses raise an AttributeError when trying to make a new attribute: >>> obj = MyClass() >>> #obj.my_new_attr = 456 <– Raises AttributeError