Arbitrary Waveform Generator (AWG)¤
This category ships in the instro-unstable package (instro[unstable]); its API is not settled and may change without notice.
Errors raised by these methods are documented in Exceptions.
Interface¤
Bases: Instrument
AWG instrument. Methods return Measurement/Command for publishing.
background_interval
property
writable
¤
background_interval
Seconds between background daemon iterations (0 = no wait).
channel_names
property
¤
Return an insertion-ordered snapshot of all published channel names.
Names are complete after one full daemon iteration: {name}.loop_time publishes every iteration, so call get_channel("loop_time", wait_for_new_samples=True) then read channel_names to ensure the complete set has arrived.
Raises:
-
RuntimeError–No background buffer;
start()was not called.
add_publisher
¤
add_publisher(publisher: Publisher)
Register a publisher to receive this instrument's Measurement/Command data.
publish
¤
publish(data: Measurement | Command, **kwargs)
Fan data out to every configured publisher; kwargs pass through.
add_background_daemon_function
¤
add_background_daemon_function(method: Callable, *args, **kwargs)
Append method to the daemon's call list. Use define_background_daemon to replace instead.
get_channel
¤
get_channel(
channel_name: str,
length: int = 1,
wait_for_new_samples: bool = False,
timeout: float = 10.0,
) -> Measurement
Return the most recent length samples for channel_name from the in-memory buffer.
If the channel does not exist yet, or no sample is available, the code will always block until timeout expires.
Parameters:
-
(channel_name¤str) –Name of the channel to retrieve.
-
(length¤int, default:1) –Number of trailing samples to return.
-
(wait_for_new_samples¤bool, default:False) –Block until at least
lengthnew values arrive. -
(timeout¤float, default:10.0) –Seconds to wait when insufficient data exists or
wait_for_new_samples=True.
Raises:
-
RuntimeError–No background buffer;
start()was not called. -
ChannelNotFoundError–channel had no values and no data appeared before
timeout.wait_for_new_samples=Trueand channel did not appear withintimeout. -
ChannelValueTimeoutError–wait_for_new_samples=Trueand values did not arrive withintimeout.
get_single_channel_value
¤
get_single_channel_value(channel_name: str) -> float | None
Return the most recent sample for channel_name from the in-memory buffer.
This will not wait, if data is not available then None is returned.
Parameters:
Raises:
-
RuntimeError–No background buffer;
start()was not called.
define_background_daemon
¤
define_background_daemon(method: Callable, *args, **kwargs)
Replace all daemon functions with a single method (called with the given args).
set_waveform
¤
Program channel with a waveform.
get_waveform
¤
Read back the current waveform definition on channel.
set_amplitude
¤
set_amplitude(
channel: int,
amplitude: float,
unit: AmplitudeMeasurementUnit,
**kwargs,
) -> Command
Set the output amplitude on channel.
get_amplitude
¤
get_amplitude(channel: int) -> tuple[float, AmplitudeMeasurementUnit]
Read back the current amplitude and its measurement unit on channel.
convert_amplitude
¤
convert_amplitude(
channel: int,
amplitude: float,
from_unit: AmplitudeMeasurementUnit,
to_unit: AmplitudeMeasurementUnit,
impedance_ohms: float | None = None,
) -> float
Convert an amplitude value between units using channel's configured waveform.
DBM conversions need a load impedance; if impedance_ohms isn't given, channel's
output load is used instead. Raises ValueError if neither is available.
set_offset
¤
Set the DC offset (volts) on channel.
output_enable
¤
Enable or disable the output on channel.
set_output_load
¤
Set the output load impedance; None means high-Z.
get_offset
¤
get_offset(channel: int, **kwargs) -> Measurement | None
Read back the DC offset (volts) on channel.
get_output_state
¤
get_output_state(channel: int, **kwargs) -> Measurement | None
Read back whether the output is enabled on channel.
get_output_load
¤
get_output_load(channel: int, **kwargs) -> Measurement | None
Read back the output load impedance on channel.
set_modulation
¤
set_modulation(
channel: int,
mod_type: ModulationType,
shape: Waveform,
magnitude: float,
**kwargs,
) -> Command
Configure channel's carrier modulation with modulator shape.
NOTE: magnitude varies by mod_type: AM: depth, FM: frequency deviation, PM: phase deviation, ASK: 2nd amplitude, FSK: hop frequency.
modulation_enable
¤
Enable or disable modulation on the given channel.
get_modulation_type
¤
get_modulation_type(channel: int) -> ModulationType
Read back the modulation type currently active on channel.
get_modulation_state
¤
get_modulation_state(channel: int, **kwargs) -> Measurement | None
Read back whether modulation is enabled on channel.
set_burst
¤
Configure channel's burst type.
burst_enable
¤
Enable or disable burst mode on the given channel.
get_burst_type
¤
Read back the burst type currently active on channel.
get_burst_state
¤
get_burst_state(channel: int, **kwargs) -> Measurement | None
Read back whether burst mode is enabled on channel.
set_burst_trigger
¤
set_burst_trigger(
channel: int, source: BurstTriggerSource, **kwargs
) -> Command
Set the burst trigger source on channel.
get_burst_trigger
¤
get_burst_trigger(channel: int) -> BurstTriggerSource
Read back the burst trigger source on channel.
fire_burst_trigger
¤
Fire a burst trigger on channel now; the trigger source must already be MANUAL.
set_burst_delay
¤
Set the burst trigger delay (seconds) on channel.
get_burst_delay
¤
get_burst_delay(channel: int, **kwargs) -> Measurement | None
Read back the burst trigger delay (seconds) on channel.
set_burst_gate_polarity
¤
set_burst_gate_polarity(
channel: int, gate_polarity: GatePolarity, **kwargs
) -> Command
Set the gate polarity for GATED bursts on channel.
get_burst_gate_polarity
¤
get_burst_gate_polarity(channel: int) -> GatePolarity
Read back the gate polarity for GATED bursts on channel.
set_burst_ncycles
¤
Set the number of cycles per trigger for NCYCLE bursts on channel.
get_burst_ncycles
¤
get_burst_ncycles(channel: int, **kwargs) -> Measurement | None
Read back the number of cycles per trigger for NCYCLE bursts on channel.
set_burst_period
¤
Set the internal burst period (seconds) on channel.
get_burst_period
¤
get_burst_period(channel: int, **kwargs) -> Measurement | None
Read back the internal burst period (seconds) on channel.
set_sweep
¤
Configure the sweep type on channel.
get_sweep_type
¤
Read back the sweep type currently configured on channel.
sweep_enable
¤
Enable or disable sweep mode on channel.
get_sweep_state
¤
get_sweep_state(channel: int, **kwargs) -> Measurement | None
Read back whether sweep mode is enabled on channel.
set_sweep_trigger
¤
set_sweep_trigger(
channel: int, source: SweepTriggerSource, **kwargs
) -> Command
Set the sweep trigger source on channel.
get_sweep_trigger
¤
get_sweep_trigger(channel: int) -> SweepTriggerSource
Read back the sweep trigger source on channel.
set_sweep_start_freq
¤
Set the sweep start frequency (Hz) on channel.
get_sweep_start_freq
¤
get_sweep_start_freq(channel: int, **kwargs) -> Measurement | None
Read back the sweep start frequency (Hz) on channel.
set_sweep_end_freq
¤
Set the sweep end frequency (Hz) on channel.
get_sweep_end_freq
¤
get_sweep_end_freq(channel: int, **kwargs) -> Measurement | None
Read back the sweep end frequency (Hz) on channel.
set_sweep_time
¤
Set the sweep time (seconds) on channel.
get_sweep_time
¤
get_sweep_time(channel: int, **kwargs) -> Measurement | None
Read back the sweep time (seconds) on channel.
set_sweep_start_hold_time
¤
Set the sweep start hold time (seconds) on channel.
get_sweep_start_hold_time
¤
get_sweep_start_hold_time(channel: int, **kwargs) -> Measurement | None
Read back the sweep start hold time (seconds) on channel.
set_sweep_stop_hold_time
¤
Set the sweep stop hold time (seconds) on channel.
get_sweep_stop_hold_time
¤
get_sweep_stop_hold_time(channel: int, **kwargs) -> Measurement | None
Read back the sweep stop hold time (seconds) on channel.
set_sweep_return_time
¤
Set the sweep return time (seconds) on channel.
get_sweep_return_time
¤
get_sweep_return_time(channel: int, **kwargs) -> Measurement | None
Read back the sweep return time (seconds) on channel.
Types & Configuration¤
AWG shared types and waveform definitions.
Waveform
module-attribute
¤
AmplitudeMeasurementUnit
¤
BurstType
¤
BurstTriggerSource
¤
GatePolarity
¤
SweepType
¤
SweepTriggerSource
¤
Sine
dataclass
¤
Square
dataclass
¤
Sawtooth
dataclass
¤
Triangle
dataclass
¤
Pulse
dataclass
¤
Arbitrary
dataclass
¤
convert_amplitude
¤
convert_amplitude(
value: float,
from_unit: AmplitudeMeasurementUnit,
to_unit: AmplitudeMeasurementUnit,
waveform: Waveform,
impedance_ohms: float | None = None,
) -> float
Convert an amplitude value between measurement units for a waveform shape.
VPP/VP/VRMS conversions depend on the waveform's crest factor, which is universal
math shared across every driver. DBM additionally requires impedance_ohms (the
load the instrument drives), since power depends on it.
Driver Interface¤
Bases: ABC
Vendor AWG driver contract. Concrete drivers own their transport and lifecycle.
set_waveform
abstractmethod
¤
Program channel with the waveform definition.
get_waveform
abstractmethod
¤
Get the current waveform on channel.
set_amplitude
abstractmethod
¤
set_amplitude(
channel: int, amplitude: float, unit: AmplitudeMeasurementUnit
) -> None
Set the output amplitude on channel.
get_amplitude
abstractmethod
¤
get_amplitude(channel: int) -> tuple[float, AmplitudeMeasurementUnit]
Get the current output amplitude and voltage unit on channel.
set_offset
abstractmethod
¤
Set the DC offset (volts) on channel.
output_enable
abstractmethod
¤
Enable or disable the output on channel.
get_output_state
abstractmethod
¤
Return True if the output on channel is enabled.
set_output_load
¤
Set the output load impedance; None means high-Z.
get_output_load
¤
Get the output load impedance; None means high-Z.
set_modulation
¤
set_modulation(
channel: int,
mod_type: ModulationType,
shape: Waveform,
magnitude: float,
) -> None
Configure channel's carrier modulation with modulator shape.
modulation_enable
¤
Enable or disable modulation on the given channel.
get_modulation_type
¤
get_modulation_type(channel: int) -> ModulationType
Get the modulation type currently active on channel.
get_modulation_state
¤
Get the modulation enabled state currently active on channel.
burst_enable
¤
Enable or disable burst mode on the given channel.
get_burst_type
¤
Get the burst type currently active on channel.
get_burst_state
¤
Return True if burst mode is enabled on channel.
set_burst_trigger
¤
set_burst_trigger(channel: int, source: BurstTriggerSource) -> None
Set the burst trigger source on channel.
get_burst_trigger
¤
get_burst_trigger(channel: int) -> BurstTriggerSource
Get the burst trigger source on channel.
fire_burst_trigger
¤
fire_burst_trigger(channel: int) -> None
Fire a burst trigger on channel now; the trigger source must already be MANUAL.
set_burst_delay
¤
Set the burst trigger delay (seconds) on channel.
get_burst_delay
¤
Get the burst trigger delay (seconds) on channel.
set_burst_gate_polarity
¤
set_burst_gate_polarity(
channel: int, gate_polarity: GatePolarity
) -> None
Set the gate polarity for GATED bursts on channel.
get_burst_gate_polarity
¤
get_burst_gate_polarity(channel: int) -> GatePolarity
Get the gate polarity for GATED bursts on channel.
set_burst_ncycles
¤
Set the number of cycles per trigger for NCYCLE bursts on channel.
get_burst_ncycles
¤
Get the number of cycles per trigger for NCYCLE bursts on channel.
set_burst_period
¤
Set the internal burst period (seconds) on channel.
get_burst_period
¤
Get the internal burst period (seconds) on channel.
set_sweep
¤
Configure the sweep type on channel.
get_sweep_type
¤
Get the sweep type currently configured on channel.
sweep_enable
¤
Enable or disable sweep mode on channel.
get_sweep_state
¤
Return True if sweep mode is enabled on channel.
set_sweep_trigger
¤
set_sweep_trigger(channel: int, source: SweepTriggerSource) -> None
Set the sweep trigger source on channel.
get_sweep_trigger
¤
get_sweep_trigger(channel: int) -> SweepTriggerSource
Get the sweep trigger source on channel.
set_sweep_start_freq
¤
Set the sweep start frequency (Hz) on channel.
get_sweep_start_freq
¤
Get the sweep start frequency (Hz) on channel.
set_sweep_end_freq
¤
Set the sweep end frequency (Hz) on channel.
get_sweep_end_freq
¤
Get the sweep end frequency (Hz) on channel.
set_sweep_time
¤
Set the sweep time (seconds) on channel.
set_sweep_start_hold_time
¤
Set the sweep start hold time (seconds) on channel.
set_sweep_stop_hold_time
¤
Set the sweep stop hold time (seconds) on channel.
get_sweep_start_hold_time
¤
Get the sweep start hold time (seconds) on channel.
get_sweep_stop_hold_time
¤
Get the sweep stop hold time (seconds) on channel.
set_sweep_return_time
¤
Set the sweep return time (seconds) on channel.
get_sweep_return_time
¤
Get the sweep return time (seconds) on channel.
Vendor Drivers¤
Keysight 33521B¤
Keysight 33521B arbitrary waveform generator driver (33500 series).
Keysight33521B
¤
Keysight33521B(visa_resource: str | VisaConfig)
Bases: AWGDriverBase
SCPI driver for the Keysight 33521B arbitrary waveform generator.
set_amplitude
¤
set_amplitude(
channel: int, amplitude: float, unit: AmplitudeMeasurementUnit
) -> None
set_modulation
¤
set_modulation(
channel: int,
mod_type: ModulationType,
shape: Waveform,
magnitude: float,
) -> None
Configures modulation. Enabled state is persistent across set_modulation calls.
modulation_enable
¤
Enables the most recently configured modulation type, or disables modulation.
get_modulation_type
¤
get_modulation_type(channel: int) -> ModulationType
Returns modulation type currently enabled, or the last type set by the user when modulation is not enabled.
get_burst_type
¤
NCYCLE reads back as INFINITE when BURS:NCYC is the hardware's high-water sentinel for INF.
set_burst_gate_polarity
¤
set_burst_gate_polarity(
channel: int, gate_polarity: GatePolarity
) -> None
set_sweep_stop_hold_time
¤
The 33521B has no SWEep:HTIMe:STARt; HTIMe only holds at the stop frequency.
set_sweep_start_hold_time
¤
Set the sweep start hold time (seconds) on channel.
Rigol DG1022Z¤
Rigol DG1022Z arbitrary waveform generator driver (DG1000Z series).
RigolDG1022Z
¤
RigolDG1022Z(visa_resource: str | VisaConfig)
Bases: AWGDriverBase
SCPI driver for the Rigol DG1022Z two-channel arbitrary waveform generator.
set_amplitude
¤
set_amplitude(
channel: int, amplitude: float, unit: AmplitudeMeasurementUnit
) -> None
set_modulation
¤
set_modulation(
channel: int,
mod_type: ModulationType,
shape: Waveform,
magnitude: float,
) -> None
set_burst_gate_polarity
¤
set_burst_gate_polarity(
channel: int, gate_polarity: GatePolarity
) -> None