Tektronix AFG3152C#
Control the Tektronix AFG3152C function generator from Python with the AFG3152C driver.
Driver: pymeasure
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.