Skip to content

AFG_MSO2X

Download Flojoy Studio to try this app
Set the MSO2XX Function Generator settings. 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). function : select, default=sine The type of waveform to use. frequency : float, default=100e6 The frequency of the waveform, in Hz. amplitude : float, default=0.2 The peak to peak voltage of the waveform, in volts. offset : float, default=0 The voltage offset of the waveform, in volts. ramp_symmetry : float, default=50 The ramp symmetry if the ramp waveform is used, in percent. square_duty : float, default=50 The duty of the square waveform if used, in percent. pulse_width : float, default=1e-6 The pulse width in seconds if the pulse waveform is used. impedance : select, default=unchanged The impedance of the output. mode : select, default=continuous The mode to use. Returns: out : String AFG settings
Python Code
from typing import Optional, Literal
from flojoy import VisaConnection, flojoy, DataContainer, String


@flojoy(deps={"tm_devices": "1"}, inject_connection=True)
def AFG_MSO2X(
    connection: VisaConnection,
    input: Optional[DataContainer] = None,
    function: Literal[
        "sine",
        "square",
        "pulse",
        "ramp",
        "noise",
        "DC",
        "sinc",
        "gaussian",
        "lorentz ",
        "erise",
        "edecay",
        "haversine",
        "cardiac",
    ] = "sine",
    frequency: float = 100e6,
    amplitude: float = 0.2,
    offset: float = 0,
    ramp_symmetry: float = 50,
    square_duty: float = 50,
    pulse_width: float = 1e-6,
    impedance: Literal["unchanged", "fifty", "highZ"] = "unchanged",
    mode: Literal["off", "continuous", "burst"] = "continuous",
) -> String:
    """Set the MSO2XX Function Generator settings.

    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).
    function : select, default=sine
        The type of waveform to use.
    frequency : float, default=100e6
        The frequency of the waveform, in Hz.
    amplitude : float, default=0.2
        The peak to peak voltage of the waveform, in volts.
    offset : float, default=0
        The voltage offset of the waveform, in volts.
    ramp_symmetry : float, default=50
        The ramp symmetry if the ramp waveform is used, in percent.
    square_duty : float, default=50
        The duty of the square waveform if used, in percent.
    pulse_width : float, default=1e-6
        The pulse width in seconds if the pulse waveform is used.
    impedance : select, default=unchanged
        The impedance of the output.
    mode : select, default=continuous
        The mode to use.

    Returns
    -------
    String
        AFG settings
    """

    # Retrieve oscilloscope instrument connection
    scope = connection.get_handle()

    scope.commands.afg.function.write(function)
    scope.commands.afg.frequency.write(frequency)
    scope.commands.afg.amplitude.write(amplitude)
    scope.commands.afg.offset.write(offset)

    if function == "ramp":
        scope.commands.afg.ramp.symmetry.write(ramp_symmetry)
    if function == "square":
        scope.commands.afg.square.duty.write(square_duty)
    if function == "pulse":
        scope.commands.afg.pulse.width.write(pulse_width)
    if impedance != "unchanged":
        scope.commands.afg.output.load.impedance.write(impedance)

    scope.commands.afg.output.mode.write(mode)

    return String(s="AFG settings")

Find this Flojoy Block on GitHub

Videos

Control Tektronix MSO Oscilloscope with Flojoy

Example App

Having problems with this example app? Join our Discord community and we will help you out!
React Flow mini map

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.