Skip to content

BASIC_PARAMETERS_AFG31000

Download Flojoy Studio to try this app
Set basic parameters such as frequency for a single channel. This block should also work with compatible Tektronix AFG31XXX instruments. Params: connection : VisaConnection The VISA address (requires the CONNECTION_AFG31000 block). channel : select, default=1 Choose the channel to alter. frequency : float, default=1e6 The voltage of the waveform to set, in Hz. amplitude : float, default=1 The voltage of the waveform to set. offset : float, default=0 The voltage offset to set the waveform to, in volts. phase : float, default=0 The phase to set the waveform to, in degrees. Returns: out : String Placeholder
Python Code
from flojoy import flojoy, DataContainer, String, VisaConnection
from typing import Optional, Literal


@flojoy(inject_connection=True)
def BASIC_PARAMETERS_AFG31000(
    connection: VisaConnection,
    source: Literal["1", "2"] = "1",
    frequency: float = 1e6,
    amplitude: float = 1,
    offset: float = 0,
    phase: float = 0,
    input: Optional[DataContainer] = None,
) -> String:
    """Set basic parameters such as frequency for a single channel.

    This block should also work with compatible Tektronix AFG31XXX instruments.

    Parameters
    ----------
    connection: VisaConnection
        The VISA address (requires the CONNECTION_AFG31000 block).
    channel: select, default=1
        Choose the channel to alter.
    frequency: float, default=1e6
        The voltage of the waveform to set, in Hz.
    amplitude: float, default=1
        The voltage of the waveform to set.
    offset: float, default=0
        The voltage offset to set the waveform to, in volts.
    phase: float, default=0
        The phase to set the waveform to, in degrees.

    Returns
    -------
    String
        Placeholder
    """

    assert -180.0 <= phase <= 180.0, "The phase must be between -180 and 180 degrees."

    afg = connection.get_handle()

    afg.write(f"SOURCE{source}:FREQUENCY {frequency}")
    afg.write(f"SOURCE{source}:VOLTAGE:AMPLITUDE {amplitude}")
    afg.write(f"SOURCE{source}:VOLTAGE:OFFSET {offset}")
    afg.write(f"SOURCE{source}:PHASE:ADJUST {phase}DEG")

    return String(s="Set FG parameters")

Find this Flojoy Block on GitHub

Example App

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

In this example, an Tektronix AFG31000 is used to generate an arbitrary waveform.

First the necessary blocks were added:

  • CONNECT_AFG31000
  • COPY_AFG31000
  • ARBITRARY_AFG31000
  • BASIC_PARAMETERS_AFG31000
  • OUTPUT_AFG31000
  • 3x BASIC_OSCILLATOR
  • MULTIPLY
  • LINE

The instrument address was set for each AFG31000 block. Ensure the OUTPUT_AFG31000 block has channel 1 output turned on. Note the COPY_AFG31000 block is rename PLACEHOLDER here and it preset for block running order reasons. The BASIC_PARAMETERS_AFG31000 block is used to change frequency, offset, voltage, and phase for a single channel, without changing the function itself.

The blocks were connected as shown and the app was run. The 3 BASIC_OSCILLATOR blocks were used to generate the arbitrary waveform. Any waveform generated in Flojoy can be used as the input for ARBITRARY_AFG31000 to allow for any output.

An oscilloscope was connected to the AFG31000 resulting in waveform:

image