Skip to content

Tektronix AFG

Bases: VisaDriver

A class representing a Tektronix Arbitrary Function Generator (AFG).

Initialize the AFG object.

Parameters:

Name Type Description Default
resource_location str

The resource location of the AFG.

required
model_name str

The model name of the AFG.

required
Source code in driverlib/tektronix/tektronix_afg.py
14
15
16
17
18
19
20
21
22
23
24
25
26
27
def __init__(self, resource_location: str, model_name: str):
    """
    Initialize the AFG object.

    Args:
        resource_location (str): The resource location of the AFG.
        model_name (str): The model name of the AFG.
    """
    del model_name
    super().__init__(resource_location)

    self._allow_attrs = self._allow_attrs + ["channel_idx"]

    self.channel_idx = 1

idn property

idn

Retrieve the identification string.

Returns:

Name Type Description
str str

The identification string of the device.

output_enabled property writable

output_enabled

Get the output state of the AFG.

Returns:

Name Type Description
bool bool

The output state of the AFG.

am property writable

am

Get the amplitude modulation state of the AFG.

Returns:

Name Type Description
bool bool

The amplitude modulation state of the AFG.

fm property writable

fm

Get the frequency modulation state of the AFG.

Returns:

Name Type Description
bool bool

The frequency modulation state of the AFG.

pm property writable

pm

Get the phase modulation state of the AFG.

Returns:

Name Type Description
bool bool

The phase modulation state of the AFG.

pwm property writable

pwm

Get the pulse width modulation state of the AFG.

Returns:

Name Type Description
bool bool

The pulse width modulation state of the AFG.

waveform property writable

waveform

Get the waveform shape of the AFG.

Returns:

Name Type Description
str str

The waveform shape of the AFG.

duty_cycle_high property writable

duty_cycle_high

Get the duty cycle high value of the AFG.

Returns:

Name Type Description
float float

The duty cycle high value of the AFG.

impedance property writable

impedance

Get the output impedance of the AFG.

Returns:

Name Type Description
float float

The output impedance of the AFG.

polarity property writable

polarity

Get the output polarity of the AFG.

Returns:

Name Type Description
str str

The output polarity of the AFG.

trigger_out_mode property writable

trigger_out_mode

Get the trigger output mode of the AFG.

Returns:

Name Type Description
str str

The trigger output mode of the AFG.

ref_oscillator property writable

ref_oscillator

Get the reference oscillator source of the AFG.

Returns:

Name Type Description
str str

The reference oscillator source of the AFG.

amplitude_lock property writable

amplitude_lock

Check if the voltages of both channels are locked to each other.

Returns:

Name Type Description
bool bool

True if the voltages of both channels are locked, False otherwise.

frequency_lock property writable

frequency_lock

Check if the frequencies of both channels are locked to each other.

Returns:

Name Type Description
bool bool

True if the frequencies of both channels are locked, False otherwise.

amplitude property writable

amplitude

Get the signal amplitude in Vpp.

Returns:

Name Type Description
float float

The signal amplitude in Vpp.

frequency property writable

frequency

Get the frequency of the AFG.

Returns:

Name Type Description
float float

The frequency of the AFG.

phase property writable

phase

Get or set the phase in degrees.

Parameters:

Name Type Description Default
value float

The phase to set in degrees. Defaults to 0.

required

Returns:

Name Type Description
float float

The phase in degrees.

offset property writable

offset

Get or set the offset.

Parameters:

Name Type Description Default
val float

The offset to set. Defaults to 0.

required

Returns:

Name Type Description
float float

The offset.

high property writable

high

Get or set the high value for voltage.

Parameters:

Name Type Description Default
value float

The high value for voltage to set. Defaults to 0.

required

Returns:

Name Type Description
float float

The high value for voltage.

low property writable

low

Get or set the low value for voltage.

Parameters:

Name Type Description Default
value float

The low value for voltage to set. Defaults to 0.

required

Returns:

Name Type Description
float float

The low value for voltage.

trigger_source property writable

trigger_source

Get or set the trigger source of the AFG.

Returns:

Name Type Description
str str

The trigger source of the AFG.

trigger_slope property writable

trigger_slope

Get or set the trigger slope of the AFG.

Parameters:

Name Type Description Default
val str

The trigger slope to set. Defaults to "POS".

required

Returns:

Name Type Description
str str

The trigger slope of the AFG.

trigger_timer property writable

trigger_timer

Get or set the trigger timer of the AFG.

Parameters:

Name Type Description Default
value float

The trigger timer to set. Defaults to 1.

required

Returns: float: The trigger timer of the AFG.

burst_enabled property writable

burst_enabled

Get or set the burst mode state of the AFG.

Returns:

Name Type Description
bool bool

If burst mode is enabled.

burst_cycles property writable

burst_cycles

Get or set the number of burst cycles of the AFG.

burst_delay property writable

burst_delay

Get or set the burst delay of the AFG.

burst_mode property writable

burst_mode

Get or set the burst mode of the AFG.

close

close()

Close the connection to the device.

Source code in driverlib/visa_driver.py
114
115
116
def close(self):
    """Close the connection to the device."""
    self.rm.close()

get_error

get_error()

Retrieve the error message from the device.

Returns:

Name Type Description
str

The error message.

Source code in driverlib/visa_driver.py
127
128
129
130
131
132
133
def get_error(self):
    """Retrieve the error message from the device.

    Returns:
        str: The error message.
    """
    return self.ask("SYST:ERR?")

print_error

print_error()

Print eventual errors occurred.

Source code in driverlib/visa_driver.py
135
136
137
def print_error(self):
    """Print eventual errors occurred."""
    print(f"Errors: {self.get_error()}", end="")

reset

reset()

Reset instrument to factory default state. Does not clear volatile memory.

Source code in driverlib/visa_driver.py
139
140
141
142
def reset(self):
    """Reset instrument to factory default state. Does not clear volatile memory."""
    self.write("*RST")
    self.write("*WAI")

clear

clear()

Clear event register, error queue -when power is cycled-.

Source code in driverlib/visa_driver.py
144
145
146
147
def clear(self):
    """Clear event register, error queue -when power is cycled-."""
    self.write("*CLS")
    self.write("*WAI")

lookup_resources

lookup_resources()

Look for all the available resources.

Source code in driverlib/visa_driver.py
149
150
151
152
153
154
155
156
157
158
159
160
def lookup_resources(self):
    """Look for all the available resources."""
    instruments = self.rm.list_resources()
    print(f"Found {len(instruments)} instruments:")
    for location in instruments:
        try:
            with OpenResource(self.rm, location, self.endline) as instr:
                idn = instr.query("*IDN?")
        except VisaIOError:
            idn = None

        print(f"Resource named: {idn if idn else 'Unable to determine'} @ '{location}'")

recall

recall(num='1')

Recall a saved configuration on the AFG.

Parameters:

Name Type Description Default
num str

The number of the saved configuration. Defaults to "1".

'1'
Source code in driverlib/tektronix/tektronix_afg.py
32
33
34
35
36
37
38
39
def recall(self, num: str = "1") -> None:
    """
    Recall a saved configuration on the AFG.

    Args:
        num (str, optional): The number of the saved configuration. Defaults to "1".
    """
    self.write(f"*RCL {num}")

save

save(num='1')

Save the current configuration on the AFG.

Parameters:

Name Type Description Default
num str

The number to save the configuration as. Defaults to "1".

'1'
Source code in driverlib/tektronix/tektronix_afg.py
41
42
43
44
45
46
47
48
def save(self, num: str = "1") -> None:
    """
    Save the current configuration on the AFG.

    Args:
        num (str, optional): The number to save the configuration as. Defaults to "1".
    """
    self.write(f"*SAV {num}")

calibrate

calibrate()

Perform calibration on the AFG.

Returns:

Name Type Description
bool bool

True if calibration is successful, False otherwise.

Source code in driverlib/tektronix/tektronix_afg.py
165
166
167
168
169
170
171
172
def calibrate(self) -> bool:
    """
    Perform calibration on the AFG.

    Returns:
        bool: True if calibration is successful, False otherwise.
    """
    return int(self.ask("*CAL?")) == 0

phase_initiate

phase_initiate()

Initialize the phase of the AFG.

Source code in driverlib/tektronix/tektronix_afg.py
174
175
176
177
178
def phase_initiate(self) -> None:
    """
    Initialize the phase of the AFG.
    """
    self.write(f"SOURce{self.channel_idx}:PHASe:INITiate")

trigger

trigger()

Trigger the measurement.

Source code in driverlib/tektronix/tektronix_afg.py
502
503
504
def trigger(self) -> None:
    """Trigger the measurement."""
    self.write("TRIGger:SEQuence:IMMediate")

sweep

sweep(start_freq, stop_freq, sweep_time)

Perform a frequency sweep on the AFG.

Parameters:

Name Type Description Default
start_freq float

The starting frequency of the sweep.

required
stop_freq float

The stopping frequency of the sweep.

required
sweep_time float

The duration of the sweep in seconds.

required
Source code in driverlib/tektronix/tektronix_afg.py
550
551
552
553
554
555
556
557
558
559
560
561
562
563
def sweep(self, start_freq: float, stop_freq: float, sweep_time: float) -> None:
    """Perform a frequency sweep on the AFG.

    Args:
        start_freq (float): The starting frequency of the sweep.
        stop_freq (float): The stopping frequency of the sweep.
        sweep_time (float): The duration of the sweep in seconds.
    """

    self.write(f"SOURce{self.channel_idx}:FREQuency:STARt {start_freq:f}Hz")
    self.write(f"SOURce{self.channel_idx}:FREQuency:STOP {stop_freq:f}Hz")
    self.write(f"SOURce{self.channel_idx}:SWEep:TIME {sweep_time:f}s")
    self.write(f"SOURce{self.channel_idx}:SWEep:MODE AUTO")
    self.write(f"SOURce{self.channel_idx}:SWEep:STATe ON")