Tektronix AFG3000 series arbitrary function generator

[1]:
%matplotlib notebook
import matplotlib.pyplot as plt

import numpy as np

from qcodes_contrib_drivers.drivers.Tektronix.AFG3000 import AFG3000
[2]:
afg = AFG3000("AFG", address="TCPIP0::10.0.100.108::inst0::INSTR")
Connected to: TEKTRONIX AFG3252 (serial:C010219, firmware:SCPI:99.0 FV:3.2.4) in 3.94s
[3]:
afg.print_readable_snapshot(update=True)
AFG:
        parameter              value
--------------------------------------------------------------------------------
IDN                     :       {'vendor': 'TEKTRONIX', 'model': 'AFG3252', 'serial...
am_depth1               :       50 (%)
am_depth2               :       50 (%)
am_internal_efile1      :       ""
am_internal_efile2      :       ""
am_internal_freq1       :       10000 (Hz)
am_internal_freq2       :       10000 (Hz)
am_internal_function1   :       SIN
am_internal_function2   :       SIN
am_internal_source1     :       INT
am_internal_source2     :       INT
am_state1               :       False
am_state2               :       False
burst_mode1             :       TRIG
burst_mode2             :       TRIG
burst_ncycles1          :       1
burst_ncycles2          :       5
burst_state1            :       True
burst_state2            :       False
burst_tdelay1           :       0 (s)
burst_tdelay2           :       0 (s)
center_freq1            :       5.5e+05 (Hz)
center_freq2            :       5.5e+05 (Hz)
combine1                :       ""
combine2                :       ""
fm_deviation1           :       1e+06 (Hz)
fm_deviation2           :       1e+06 (Hz)
fm_internal_efile1      :       ""
fm_internal_efile2      :       ""
fm_internal_freq1       :       10000 (Hz)
fm_internal_freq2       :       10000 (Hz)
fm_internal_function1   :       SIN
fm_internal_function2   :       SIN
fm_internal_source1     :       INT
fm_internal_source2     :       INT
fm_state1               :       False
fm_state2               :       False
freq_concurrent1        :       False
freq_concurrent2        :       False
freq_cw1                :       10000 (Hz)
freq_cw2                :       1e+06 (Hz)
freq_mode1              :       CW
freq_mode2              :       CW
freq_span1              :       9e+05 (Hz)
freq_span2              :       9e+05 (Hz)
freq_start1             :       1e+05 (Hz)
freq_start2             :       1e+05 (Hz)
freq_stop1              :       1e+06 (Hz)
freq_stop2              :       1e+06 (Hz)
fsk_freq1               :       1e+06 (Hz)
fsk_freq2               :       1e+06 (Hz)
fsk_internal_rate1      :       50 (Hz)
fsk_internal_rate2      :       50 (Hz)
fsk_source1             :       INT
fsk_source2             :       INT
fsk_state1              :       False
fsk_state2              :       False
function_efile1         :       ""
function_efile2         :       ""
function_ramp_symmetry1 :       50 (%)
function_ramp_symmetry2 :       50 (%)
function_shape1         :       USER
function_shape2         :       SIN
impedance_output1       :       50 (Ohm)
impedance_output2       :       50 (Ohm)
noise_level3            :       10 (%)
noise_level4            :       10 (%)
phase1                  :       0 (degrees)
phase2                  :       0 (degrees)
pm_deviation1           :       1.5708 (degrees)
pm_deviation2           :       1.5708 (degrees)
pm_internal_efile1      :       ""
pm_internal_efile2      :       ""
pm_internal_freq1       :       10000 (Hz)
pm_internal_freq2       :       10000 (Hz)
pm_internal_function1   :       SIN
pm_internal_function2   :       SIN
pm_internal_source1     :       INT
pm_internal_source2     :       INT
pm_state1               :       False
pm_state2               :       False
polarity_output1        :       NORM
polarity_output2        :       NORM
pulse_delay1            :       0 (s)
pulse_delay2            :       0 (s)
pulse_duty_cycle1       :       50 (%)
pulse_duty_cycle2       :       50 (%)
pulse_hold1             :       DUTY
pulse_hold2             :       DUTY
pulse_period1           :       1e-06 (s)
pulse_period2           :       1e-06 (s)
pulse_trans_lead1       :       2.5e-09 (s)
pulse_trans_lead2       :       2.5e-09 (s)
pulse_trans_trail1      :       2.5e-09 (s)
pulse_trans_trail2      :       2.5e-09 (s)
pulse_width1            :       5e-07 (s)
pulse_width2            :       5e-07 (s)
pwm_duty_deviation1     :       5 (%)
pwm_duty_deviation2     :       5 (%)
pwm_internal_efile1     :       ""
pwm_internal_efile2     :       ""
pwm_internal_freq1      :       10000 (Hz)
pwm_internal_freq2      :       10000 (Hz)
pwm_internal_function1  :       SIN
pwm_internal_function2  :       SIN
pwm_internal_source1    :       INT
pwm_internal_source2    :       INT
pwm_state1              :       False
pwm_state2              :       False
ref_osc_source          :       INT
state_output1           :       True
state_output2           :       False
sweep_hold_time1        :       0 (s)
sweep_hold_time2        :       0 (s)
sweep_mode1             :       AUTO
sweep_mode2             :       AUTO
sweep_return_time1      :       0.001 (s)
sweep_return_time2      :       0.001 (s)
sweep_spacing1          :       LIN
sweep_spacing2          :       LIN
sweep_time1             :       0.01 (s)
sweep_time2             :       0.01 (s)
timeout                 :       20 (s)
trigger_mode            :       TRIG
trigger_slope           :       POS
trigger_source          :       TIM
trigger_timer           :       0.001 (s)
voltage_amplitude1      :       1
voltage_amplitude2      :       1
voltage_concurrent1     :       False
voltage_concurrent2     :       False
voltage_high1           :       0.5 (V)
voltage_high2           :       0.5 (V)
voltage_limit_high1     :       1 (V)
voltage_limit_high2     :       5 (V)
voltage_limit_low1      :       -1 (V)
voltage_limit_low2      :       -5 (V)
voltage_low1            :       -0.5 (V)
voltage_low2            :       -0.5 (V)
voltage_offset1         :       0 (V)
voltage_offset2         :       0 (V)
voltage_unit1           :       VPP
voltage_unit2           :       VPP

Upload an arbitrary waveform to the AFG and output it

Note that the waveform data values are in the range 0..1, but the actual voltages output by the AFG depend on the values of the afg.voltage_low1/2 and afg.voltage_high1/2 parameters.

Define the waveform we’re going to upload. Note that the values of the time axis don’t really mean anything; the duration of the waveform is determined by the afg.freq_cw1/2 parameters (see below).

[4]:
t = np.arange(0, 1000)

wf = np.exp(-t / 200) * np.sin(0.02 * np.pi * t) * 0.5 + 0.5

plt.figure().gca().plot(wf)
[4]:
[<matplotlib.lines.Line2D at 0xa471608>]

Upload the waveform to the memory slot USER1.

[5]:
afg.upload_waveform(wf, memory=1)

Configure the AFG to output the waveform stored in USER1 on channel 1.

[6]:
afg.state_output1(1) # enable output on ch1
afg.function_shape1("USER1")
afg.burst_state1(1)  # set the run mode to burst, so we get a pulse on each trigger
afg.trigger_source("TIM") # use internal trigger so we get output continuously

Adjust the timing of the waveform. The freq_cw1 parameter sets the inverse of the waveform length, while trigger_timer sets the repetition rate of the internal trigger.

[7]:
# set the waveform length to 100 us
afg.freq_cw1(1/100e-6)
[8]:
# repeat the waveform every 1 ms
afg.trigger_timer(1e-3)

Adjust the range of voltage values.

[11]:
# the waveform is scaled to +-0.5V (assuming that afg.voltage_limit_low1/high1 are large enough)
afg.voltage_low1(-0.5)
afg.voltage_high1(0.5)
[10]:
# the waveform is scaled to 0..1V
afg.voltage_low1(0)
afg.voltage_high1(1)

Stop output and disconnect.

[13]:
afg.state_output1(0)
[14]:
afg.close()