QDAC-II arbitrary-waveform generatorΒΆ

[1]:
from time import sleep
from IPython.display import Image, display
import numpy
from qcodes_contrib_drivers.drivers.QDevil import QDAC2
qdac_addr = '192.168.8.17'
qdac = QDAC2.QDac2('QDAC', visalib='@py', address=f'TCPIP::{qdac_addr}::5025::SOCKET')
from qcodes.instrument_drivers.rigol import RigolDS1074Z

rigol_addr = '192.168.8.199'
scope = RigolDS1074Z('rigol', visalib='@py', address=f'TCPIP::{rigol_addr}::INSTR')
Connected to: QDevil QDAC-II (serial:3, firmware:10-1.4) in 0.21s
Connected to: RIGOL TECHNOLOGIES DS1104Z (serial:DS1ZA171812151, firmware:00.04.03) in 0.21s
[2]:
def capture():
    scope.write('stop')
    scope.write(":disp:data?")
    bmpdata = scope.visa_handle.read_raw()[2+9:]
    image = Image(data=bmpdata)
    display(image)
[4]:
scope.write('*rst')
qdac.reset()
[5]:
# Connect scope ch 3 to qdac ch 3
scope.write('chan1:disp off')
scope.write('chan3:disp on')
scope.write('chan3:bwl on')
scope.write('chan3:prob 1')
scope.write('chan3:scal 0.2')
scope.write('chan3:offs -0.2')
scope.write('trig:edge:sour chan3')
scope.write('trig:edge:level 0.1')
scope.write('tim:scal 2e-6')
scope.write('tim:offs 5e-6')
[6]:
qdac.remove_traces()
values = [0, 1, 0, 0.5, -0.5, 1, -0.8, 0.3, -0.7, 0]
trace = qdac.allocate_trace('my_trace', len(values))
trace.waveform(values)
awg = qdac.ch03.arbitrary_wave(trace.name)
qdac.errors()
[6]:
'0, "No error"'
[7]:
scope.write('sing')
sleep(2)
awg.start()
qdac.errors()
[7]:
'0, "No error"'
[8]:
capture()
../../../_images/examples_QDevil_QDAC2_AWG_7_0.png
[9]:
awg = qdac.ch03.arbitrary_wave(
    trace.name,
    repetitions=-1,
    scale=2,
    offset_V=-0.5
)
qdac.errors()
[9]:
'0, "No error"'
[10]:
scope.write('chan3:scal 0.25')
scope.write('chan3:offs 0.3')
scope.write('tim:scal 5e-6')
scope.write('tim:offs 0')
scope.write('trig:edge:level 0')
scope.write('run')
[11]:
awg.start()
[13]:
capture()
../../../_images/examples_QDevil_QDAC2_AWG_11_0.png
[12]:
scope.write('run')
sleep(2)
awg.abort()
[13]:
trigger = awg.period_end_marker()
qdac.ext4.width_s(2e-6)
qdac.ext4.polarity('norm')
qdac.ext4.source_from_trigger(trigger)
# Connect osc ch 4 to qdac out trigger 4
scope.write('chan4:disp on')
scope.write('chan4:bwl on')
scope.write('chan4:prob 1')
scope.write('chan4:scal 1')
scope.write('chan4:offs -2')
scope.write('tim:scal 2e-6')
scope.write('tim:offs 10e-6')
qdac.errors()
[13]:
'0, "No error"'
[15]:
scope.write('sing')
sleep(3)
awg.start()
[20]:
capture()
../../../_images/examples_QDevil_QDAC2_AWG_15_0.png
[16]:
points = 4 * 1024 * 1024
trace = qdac.allocate_trace('long_trace', points)
qdac.errors()
[16]:
'0, "No error"'
[17]:
values = numpy.sin(numpy.linspace(-1000*numpy.pi, 1000*numpy.pi, points, endpoint=False))
trace.waveform(values)
qdac.errors()
[17]:
'0, "No error"'
[21]:
# Connect scope ch 2 to qdac ch 2
scope.write('chan2:disp on')
scope.write('chan2:bwl on')
scope.write('chan2:prob 1')
scope.write('chan2:scal 0.5')
scope.write('chan2:offs 0')

scope.write('chan3:scal 0.5')
scope.write('chan3:offs 0')

scope.write('chan4:disp off')

scope.write('tim:scal 2e-3')
scope.write('tim:offs 0')
scope.write('trig:edge:level 0')

scope.write('run')
[22]:
awg = qdac.ch03.arbitrary_wave(trace.name, repetitions=-1, scale=1.5)
awg2 = qdac.ch02.arbitrary_wave(trace.name, repetitions=-1, scale=-0.5)
qdac.errors()
[22]:
'0, "No error"'
[23]:
scope.write('run')
qdac.start_all()
qdac.errors()
[23]:
'0, "No error"'
[29]:
capture()
../../../_images/examples_QDevil_QDAC2_AWG_21_0.png