InstroAWG#

class InstroAWG(
name: str | None = None,
driver: AWGDriverBase | None = None,
num_channels: int | None = None,
publishers: list[Publisher] | None = None,
config: AWGConfig | dict | Path | str | None = None,
autostart: bool = False,
**kwargs,
)[source]#

Bases: Instrument

AWG instrument. Methods return Measurement/Command for publishing.

Initialize an InstroAWG. Provide either config or driver/num_channels together, not both.

Attributes

background_interval

Seconds between background daemon iterations (0 = no wait).

channel_names

Return an insertion-ordered snapshot of all published channel names.

Methods

add_background_daemon_function

Append method to the daemon's call list.

add_publisher

Register a publisher to receive this instrument's Measurement/Command data.

align_phase

Sync the phase of all channels.

burst_enable

Enable or disable burst mode on the given channel.

close

Close the underlying driver.

convert_amplitude

Convert an amplitude value between units using channel's configured waveform.

define_background_daemon

Replace all daemon functions with a single method (called with the given args).

fire_burst_trigger

Fire a burst trigger on channel now; the trigger source must already be MANUAL.

fire_sweep_trigger

Fire a sweep trigger on channel now; the trigger source must already be MANUAL.

get_amplitude

Read back the current amplitude and its measurement unit on channel.

get_burst_delay

Read back the burst trigger delay (seconds) on channel.

get_burst_gate_polarity

Read back the gate polarity for GATED bursts on channel.

get_burst_ncycles

Read back the number of cycles per trigger for NCYCLE bursts on channel.

get_burst_period

Read back the internal burst period (seconds) on channel.

get_burst_state

Read back whether burst mode is enabled on channel.

get_burst_trigger

Read back the burst trigger source on channel.

get_burst_type

Read back the burst type currently active on channel.

get_channel

Return the most recent length samples for channel_name from the in-memory buffer.

get_modulation_state

Read back whether modulation is enabled on channel.

get_modulation_type

Read back the modulation type currently active on channel.

get_offset

Read back the DC offset (volts) on channel.

get_output_load

Read back the output load impedance on channel.

get_output_state

Read back whether the output is enabled on channel.

get_single_channel_value

Return the most recent sample for channel_name from the in-memory buffer.

get_sweep_end_freq

Read back the sweep end frequency (Hz) on channel.

get_sweep_return_time

Read back the sweep return time (seconds) on channel.

get_sweep_start_freq

Read back the sweep start frequency (Hz) on channel.

get_sweep_start_hold_time

Read back the sweep start hold time (seconds) on channel.

get_sweep_state

Read back whether sweep mode is enabled on channel.

get_sweep_stop_hold_time

Read back the sweep stop hold time (seconds) on channel.

get_sweep_time

Read back the sweep time (seconds) on channel.

get_sweep_trigger

Read back the sweep trigger source on channel.

get_sweep_type

Read back the sweep type currently configured on channel.

get_waveform

Read back the current waveform definition on channel.

modulation_enable

Enable or disable modulation on the given channel.

open

Open the underlying driver and apply any configured channel state.

output_enable

Enable or disable the output on channel.

publish

Fan data out to every configured publisher; kwargs pass through.

set_amplitude

Set the output amplitude on channel.

set_burst

Configure channel's burst type.

set_burst_delay

Set the burst trigger delay (seconds) on channel.

set_burst_gate_polarity

Set the gate polarity for GATED bursts on channel.

set_burst_ncycles

Set the number of cycles per trigger for NCYCLE bursts on channel.

set_burst_period

Set the internal burst period (seconds) on channel.

set_burst_trigger

Set the burst trigger source on channel.

set_modulation

Configure channel's carrier modulation with modulator shape.

set_offset

Set the DC offset (volts) on channel.

set_output_load

Set the output load impedance; None means high-Z.

set_sweep

Configure the sweep type on channel.

set_sweep_end_freq

Set the sweep end frequency (Hz) on channel.

set_sweep_return_time

Set the sweep return time (seconds) on channel.

set_sweep_start_freq

Set the sweep start frequency (Hz) 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.

set_sweep_time

Set the sweep time (seconds) on channel.

set_sweep_trigger

Set the sweep trigger source on channel.

set_waveform

Program channel with a waveform.

start

Start the background daemon.

stop

Signal the background daemon to stop and join it.

sweep_enable

Enable or disable sweep mode on channel.

property background_interval#

Seconds between background daemon iterations (0 = no wait).

start() → None[source]#

Start the background daemon.

open() → None[source]#

Open the underlying driver and apply any configured channel state.

close() → None[source]#

Close the underlying driver.

set_waveform(
channel: int,
waveform: Sine | Square | Sawtooth | Triangle | Pulse | Arbitrary | StaticValue,
**kwargs,
) → Command[source]#

Program channel with a waveform.

get_waveform(
channel: int,
) → Sine | Square | Sawtooth | Triangle | Pulse | Arbitrary | StaticValue[source]#

Read back the current waveform definition on channel.

set_amplitude(
channel: int,
amplitude: float,
unit: AmplitudeMeasurementUnit,
**kwargs,
) → Command[source]#

Set the output amplitude on channel.

get_amplitude(
channel: int,
) → tuple[float, AmplitudeMeasurementUnit][source]#

Read back the current amplitude and its measurement unit on channel.

convert_amplitude(
channel: int,
amplitude: float,
from_unit: AmplitudeMeasurementUnit,
to_unit: AmplitudeMeasurementUnit,
impedance_ohms: float | None = None,
) → float[source]#

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(
channel: int,
offset_v: float,
**kwargs,
) → Command[source]#

Set the DC offset (volts) on channel.

output_enable(
channel: int,
enable: bool,
**kwargs,
) → Command[source]#

Enable or disable the output on channel.

set_output_load(
channel: int,
load: float | None,
**kwargs,
) → Command[source]#

Set the output load impedance; None means high-Z.

align_phase(**kwargs) → Command[source]#

Sync the phase of all channels.

get_offset(
channel: int,
**kwargs,
) → Measurement | None[source]#

Read back the DC offset (volts) on channel.

get_output_state(
channel: int,
**kwargs,
) → Measurement | None[source]#

Read back whether the output is enabled on channel.

get_output_load(
channel: int,
**kwargs,
) → Measurement | None[source]#

Read back the output load impedance on channel.

set_modulation(
channel: int,
mod_type: ModulationType,
shape: Sine | Square | Sawtooth | Triangle | Pulse | Arbitrary | StaticValue,
magnitude: float,
**kwargs,
) → Command[source]#

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(
channel: int,
enable: bool,
**kwargs,
) → Command[source]#

Enable or disable modulation on the given channel.

get_modulation_type(
channel: int,
**kwargs,
) → Measurement | None[source]#

Read back the modulation type currently active on channel.

get_modulation_state(
channel: int,
**kwargs,
) → Measurement | None[source]#

Read back whether modulation is enabled on channel.

set_burst(
channel: int,
burst_type: BurstType,
**kwargs,
) → Command[source]#

Configure channel’s burst type.

burst_enable(
channel: int,
enable: bool,
**kwargs,
) → Command[source]#

Enable or disable burst mode on the given channel.

get_burst_type(
channel: int,
**kwargs,
) → Measurement | None[source]#

Read back the burst type currently active on channel.

get_burst_state(
channel: int,
**kwargs,
) → Measurement | None[source]#

Read back whether burst mode is enabled on channel.

set_burst_trigger(
channel: int,
source: BurstTriggerSource,
**kwargs,
) → Command[source]#

Set the burst trigger source on channel.

get_burst_trigger(
channel: int,
**kwargs,
) → Measurement | None[source]#

Read back the burst trigger source on channel.

fire_burst_trigger(
channel: int,
**kwargs,
) → Command[source]#

Fire a burst trigger on channel now; the trigger source must already be MANUAL.

set_burst_delay(
channel: int,
delay_s: float,
**kwargs,
) → Command[source]#

Set the burst trigger delay (seconds) on channel.

get_burst_delay(
channel: int,
**kwargs,
) → Measurement | None[source]#

Read back the burst trigger delay (seconds) on channel.

set_burst_gate_polarity(
channel: int,
gate_polarity: GatePolarity,
**kwargs,
) → Command[source]#

Set the gate polarity for GATED bursts on channel.

get_burst_gate_polarity(
channel: int,
**kwargs,
) → Measurement | None[source]#

Read back the gate polarity for GATED bursts on channel.

set_burst_ncycles(
channel: int,
n_cycles: int,
**kwargs,
) → Command[source]#

Set the number of cycles per trigger for NCYCLE bursts on channel.

get_burst_ncycles(
channel: int,
**kwargs,
) → Measurement | None[source]#

Read back the number of cycles per trigger for NCYCLE bursts on channel.

set_burst_period(
channel: int,
period: float,
**kwargs,
) → Command[source]#

Set the internal burst period (seconds) on channel.

get_burst_period(
channel: int,
**kwargs,
) → Measurement | None[source]#

Read back the internal burst period (seconds) on channel.

set_sweep(
channel: int,
sweep_type: SweepType,
**kwargs,
) → Command[source]#

Configure the sweep type on channel.

get_sweep_type(
channel: int,
**kwargs,
) → Measurement | None[source]#

Read back the sweep type currently configured on channel.

sweep_enable(
channel: int,
enable: bool,
**kwargs,
) → Command[source]#

Enable or disable sweep mode on channel.

get_sweep_state(
channel: int,
**kwargs,
) → Measurement | None[source]#

Read back whether sweep mode is enabled on channel.

set_sweep_trigger(
channel: int,
source: SweepTriggerSource,
**kwargs,
) → Command[source]#

Set the sweep trigger source on channel.

get_sweep_trigger(
channel: int,
**kwargs,
) → Measurement | None[source]#

Read back the sweep trigger source on channel.

set_sweep_start_freq(
channel: int,
frequency_hz: float,
**kwargs,
) → Command[source]#

Set the sweep start frequency (Hz) on channel.

get_sweep_start_freq(
channel: int,
**kwargs,
) → Measurement | None[source]#

Read back the sweep start frequency (Hz) on channel.

set_sweep_end_freq(
channel: int,
frequency_hz: float,
**kwargs,
) → Command[source]#

Set the sweep end frequency (Hz) on channel.

get_sweep_end_freq(
channel: int,
**kwargs,
) → Measurement | None[source]#

Read back the sweep end frequency (Hz) on channel.

set_sweep_time(
channel: int,
sweep_time: float,
**kwargs,
) → Command[source]#

Set the sweep time (seconds) on channel.

get_sweep_time(
channel: int,
**kwargs,
) → Measurement | None[source]#

Read back the sweep time (seconds) on channel.

set_sweep_start_hold_time(
channel: int,
hold_time: float,
**kwargs,
) → Command[source]#

Set the sweep start hold time (seconds) on channel.

get_sweep_start_hold_time(
channel: int,
**kwargs,
) → Measurement | None[source]#

Read back the sweep start hold time (seconds) on channel.

set_sweep_stop_hold_time(
channel: int,
hold_time: float,
**kwargs,
) → Command[source]#

Set the sweep stop hold time (seconds) on channel.

get_sweep_stop_hold_time(
channel: int,
**kwargs,
) → Measurement | None[source]#

Read back the sweep stop hold time (seconds) on channel.

set_sweep_return_time(
channel: int,
return_time: float,
**kwargs,
) → Command[source]#

Set the sweep return time (seconds) on channel.

get_sweep_return_time(
channel: int,
**kwargs,
) → Measurement | None[source]#

Read back the sweep return time (seconds) on channel.

fire_sweep_trigger(
channel: int,
**kwargs,
) → Command[source]#

Fire a sweep trigger on channel now; the trigger source must already be MANUAL.

add_background_daemon_function(
method: Callable,
*args,
**kwargs,
)#

Append method to the daemon’s call list. Use define_background_daemon to replace instead.

add_publisher(
publisher: Publisher,
)#

Register a publisher to receive this instrument’s Measurement/Command data.

property channel_names: tuple[str, ...]#

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.

define_background_daemon(
method: Callable,
*args,
**kwargs,
)#

Replace all daemon functions with a single method (called with the given args).

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

    Name of the channel to retrieve.

  • length

    Number of trailing samples to return.

  • wait_for_new_samples

    Block until at least length new values arrive.

  • timeout

    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=True and channel did not appear within timeout.

  • ChannelValueTimeoutError – wait_for_new_samples=True and values did not arrive within timeout.

get_single_channel_value(
channel_name: str,
) → float | str | 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:

channel_name

Name of the channel to retrieve.

Raises:

RuntimeError – No background buffer; start() was not called.

publish(
data: Measurement | Command,
**kwargs,
)#

Fan data out to every configured publisher; kwargs pass through.

stop()#

Signal the background daemon to stop and join it. No-op if not running.