Tektronix AFG3152C#
Control the Tektronix AFG3152C function generator from Python with the AFG3152C driver.
Library: pymeasure (docs)
Type: Function and waveform generators
Manufacturer: Tektronix

Represents the Tektronix AFG 3000 series (one or two channels) arbitrary function generator and provides a high-level for interacting with the instrument.
Publishing through instro#
instro publishes the commands you send to a AFG3152C 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.tektronix import AFG3152C
from instro.pymeasure import PymeasureInstrument
with PymeasureInstrument(
name="afg",
instrument=AFG3152C("GPIB::1"),
dataset_rid="<dataset rid>",
) as afg:
afg.device.reset() # Reset to default
afg.device.ch1.shape='sinusoidal' # Sinusoidal shape
afg.device.ch1.unit='VPP' # Sets CH1 unit to VPP
afg.device.ch1.amp_vpp=1 # Sets the CH1 level to 1 VPP
afg.device.ch1.frequency=1e3 # Sets the CH1 frequency to 1KHz
afg.device.ch1.enable() # Enables the output from CH1
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.tektronix import AFG3152C
from instro.lib import NominalCorePublisher
from instro.pymeasure import attach
afg=AFG3152C("GPIB::1") # AFG on GPIB 1
recorder = attach(afg, "afg", [NominalCorePublisher(dataset_rid="<dataset rid>")])
afg.reset() # Reset to default
afg.ch1.shape='sinusoidal' # Sinusoidal shape
afg.ch1.unit='VPP' # Sets CH1 unit to VPP
afg.ch1.amp_vpp=1 # Sets the CH1 level to 1 VPP
afg.ch1.frequency=1e3 # Sets the CH1 frequency to 1KHz
afg.ch1.enable() # Enables the output from CH1
recorder.close() # flush and close the publishers
The examples are adapted from the pymeasure documentation for AFG3152C, which lists every property and method.
Send the data to Nominal#
With pymeasure, the Tektronix AFG3152C sends each reading to a Nominal dataset, where your team can plot it, compare runs, and analyze it together. This code creates an asset for the bench, a dataset and a run, and a workbook scoped to the run, then publishes the readings to the dataset. See Bench bring-up for the same steps on a whole bench.
from pymeasure.instruments.tektronix import AFG3152C
from instro.lib import NominalCorePublisher
from instro.pymeasure import PymeasureInstrument
import pandas as pd
from nominal.core import NominalClient
client = NominalClient.from_profile("default")
bench = client.get_or_create_asset_by_properties(
{"bench_id": "bench-1"}, name="Bench 1"
)
dataset = bench.get_or_create_dataset("bench", name="Bench 1 instruments")
run = bench.create_run(
"Bench 1 session", start=pd.Timestamp.now(tz="UTC").floor("s"), end=None
)
afg3152c = PymeasureInstrument(
name="afg3152c",
instrument=AFG3152C("<visa_resource>"),
publishers=[NominalCorePublisher(dataset=dataset)],
)
workbook = run.create_workbook(title="Tektronix AFG3152C readings")
print(workbook.nominal_url) # open it to plot the channels
Open the Workbook link and plot the instrument’s channels, as in the mock below.
A workbook link looks like this: https://app.gov.nominal.io/w/[workbook_id]...