Active Technologies AWG401x_AWG#

Control the Active Technologies AWG401x_AWG function generator from Python with the AWG401x_AWG driver.

Driver: pymeasure
Type: Function and waveform generators
Manufacturer: Active Technologies

Represents the Active Technologies AWG-401x Arbitrary Waveform Generator in AWG mode.

Publishing through instro#

instro publishes the commands you send to a AWG401x_AWG and the values you read from it, through any publisher. It takes two forms, both described in the pymeasure guide. Install with uv add "instro[pymeasure]".

With a PymeasureInstrument#

PymeasureInstrument wraps the driver in an instro instrument, with tags and background polling. The instrument is created inside the with block, and .device is the pymeasure instrument.

from pymeasure.instruments.activetechnologies import AWG401x_AWG
from instro.pymeasure import PymeasureInstrument

with PymeasureInstrument(
    name="wfg",
    instrument=AWG401x_AWG("TCPIP::192.168.0.123::INSTR"),
    dataset_rid="<dataset rid>",
) as wfg:

    wfg.device.reset()             # Reset the instrument at default state

    # Set a oscillating waveform
    wfg.device.waveforms["MyWaveform"] = [1, 0] * 8

    for i in range(1, wfg.device.num_ch + 1):
        wfg.device.entries[1].channels[i].voltage_high = 1       # Sets high voltage = 1
        wfg.device.entries[1].channels[i].voltage_low = 0        # Sets low voltage = 1
        wfg.device.entries[1].channels[i].waveform = "SQUARE"    # Sets a square wave
        wfg.device.setting_ch[i].enabled = True            # Enable channel

    wfg.device.entries.resize(2)           # Resize the number of entries to 2

    wfg.device.entries[2].channels[1].waveform = "MyWaveform"   # Set custom waveform

    wfg.device.enabled = True              # Enable output of waveform generator
    wfg.device.beep()                      # "beep"

    print(wfg.device.check_errors())       # Get the error queue

With existing pymeasure code (attach())#

attach() adds publishing to pymeasure code you already have. The imports, the attach() call after the instrument is created, and recorder.close() are all that instro adds.

from pymeasure.instruments.activetechnologies import AWG401x_AWG
from instro.lib import NominalCorePublisher
from instro.pymeasure import attach

wfg = AWG401x_AWG("TCPIP::192.168.0.123::INSTR")
recorder = attach(wfg, "wfg", [NominalCorePublisher(dataset_rid="<dataset rid>")])

wfg.reset()             # Reset the instrument at default state

# Set a oscillating waveform
wfg.waveforms["MyWaveform"] = [1, 0] * 8

for i in range(1, wfg.num_ch + 1):
    wfg.entries[1].channels[i].voltage_high = 1       # Sets high voltage = 1
    wfg.entries[1].channels[i].voltage_low = 0        # Sets low voltage = 1
    wfg.entries[1].channels[i].waveform = "SQUARE"    # Sets a square wave
    wfg.setting_ch[i].enabled = True            # Enable channel

wfg.entries.resize(2)           # Resize the number of entries to 2

wfg.entries[2].channels[1].waveform = "MyWaveform"   # Set custom waveform

wfg.enabled = True              # Enable output of waveform generator
wfg.beep()                      # "beep"

print(wfg.check_errors())       # Get the error queue

recorder.close()  # flush and close the publishers

The examples are adapted from the pymeasure documentation for AWG401x_AWG, which lists every property and method.