QUERY_CURVE_MSO2X
Returns the curve query on a MSO2X oscilloscope, in voltage vs time. Requires a CONNECT_MSO2X block to create the connection.
Tested on MSO22 and MSO24. Params: connection : VisaConnection The VISA address (requires the CONNECTION_MSO2X block). channel : int, default=1 Oscilloscope channel to query (eg 1 or 2 for a 2 channel scope) Returns: out : OrderedPair Curve query results, in voltage vs time.
Python Code
from typing import Optional
from flojoy import VisaConnection, flojoy, OrderedPair, DataContainer
from numpy import array, linspace
@flojoy(deps={"tm_devices": "1"}, inject_connection=True)
def QUERY_CURVE_MSO2X(
connection: VisaConnection,
input: Optional[DataContainer] = None,
channel: int = 1,
) -> OrderedPair:
"""Returns the curve query on a MSO2X oscilloscope, in voltage vs time.
Requires a CONNECT_MSO2X block to create the connection.
Tested on MSO22 and MSO24.
Parameters
----------
connection : VisaConnection
The VISA address (requires the CONNECTION_MSO2X block).
channel : int, default=1
Oscilloscope channel to query (eg 1 or 2 for a 2 channel scope)
Returns
-------
OrderedPair
Curve query results, in voltage vs time.
"""
# Retrieve oscilloscope instrument connection.
scope = connection.get_handle()
# Retrieve y axis and convert to voltage.
scope.commands.data.source.write(channel)
y = scope.curve_query(channel)
y = array(y, dtype=float)
num_bytes = scope.commands.wfmoutpre.byt_nr.query()
y /= 2 ** (8 * int(num_bytes))
y *= 5 * float(scope.query(f"CH{channel}:SCAL?"))
# Calculate the x axis from horizontal parameters.
x_divs = float(scope.commands.horizontal.divisions.query())
x_scale = float(scope.commands.horizontal.scale.query())
x_scale *= x_divs
x_shift = float(scope.commands.horizontal.position.query()) / -100
x = linspace(x_scale * x_shift, x_scale * (x_shift + 1), num=y.shape[0])
return OrderedPair(x=x, y=y)
Videos
Control Tektronix MSO Oscilloscope with Flojoy
Example
Having problems with this example app? Join our Discord community and we will help you out!
This app uses the Tektronix tm_measure library to load a setup file and extract curves from a Tektronix MSO24 oscilloscope.
A setup file in MSO24 can store most of the instruments settings including axis scales, trigger settings, etc. The settings must already be stored for this example app.
First the necessary blocks were added:
- 1
CONNECT_MSO2X
- 1
SETUP_FILE_MSO2X
- 1
AFG_MSO2X
- 3
QUERY_CURVE_MSO2X
- 3
LINE
Each of these blocks must change the connection
parameter to the correct instrument. The SETUP_FILE_MSO2X
can be set to recall flojoy
as a filename (this recalls the file located at c:/flojoy.set
).
The three QUERY_CURVE_MSO2X
blocks were set to channel 1, 2, and 3 (one each).
Note that the AFG settings are not loaded from the setup file. Note two inputs (CH2 and CH3) came from an external source.