1111# #
1212#####################################################################
1313
14- import __init__ # only have to do this because we're inside the labscript directory
14+ import __init__ # only have to do this because we're inside the labscript directory
1515from labscript import *
1616from labscript_devices .PulseBlaster import PulseBlaster
17- from labscript_devices .NI_PCIe_6363 import NI_PCIe_6363
17+ from labscript_devices .NI_DAQmx . labscript_devices import NI_PCIe_6363
1818from labscript_devices .NovaTechDDS9M import NovaTechDDS9M
1919from labscript_devices .Camera import Camera
2020from labscript_devices .PineBlaster import PineBlaster
21- from labscript_devices .NI_PCI_6733 import NI_PCI_6733
22- from labscript_utils .unitconversions import *
21+ from labscript_devices .NI_DAQmx . labscript_devices import NI_PCI_6733
22+ from labscript_utils .unitconversions import example1 , example2 , example3
2323
24- PulseBlaster (name = 'pulseblaster_0' , board_number = 0 )
25- ClockLine (name = 'pulseblaster_0_clockline_fast' , pseudoclock = pulseblaster_0 .pseudoclock , connection = 'flag 0' )
26- ClockLine (name = 'pulseblaster_0_clockline_slow' , pseudoclock = pulseblaster_0 .pseudoclock , connection = 'flag 1' )
27- NI_PCIe_6363 (name = 'ni_card_0' , parent_device = pulseblaster_0_clockline_fast , clock_terminal = 'ni_pcie_6363_0/PFI0' , MAX_name = 'ni_pcie_6363_0' , acquisition_rate = 100e3 )
28- NovaTechDDS9M (name = 'novatechdds9m_0' , parent_device = pulseblaster_0_clockline_slow , com_port = "com10" )
24+ PulseBlaster (name = "pulseblaster_0" , board_number = 0 )
25+ ClockLine (
26+ name = "pulseblaster_0_clockline_fast" ,
27+ pseudoclock = pulseblaster_0 .pseudoclock ,
28+ connection = "flag 0" ,
29+ )
30+ ClockLine (
31+ name = "pulseblaster_0_clockline_slow" ,
32+ pseudoclock = pulseblaster_0 .pseudoclock ,
33+ connection = "flag 1" ,
34+ )
35+ NI_PCIe_6363 (
36+ name = "ni_card_0" ,
37+ parent_device = pulseblaster_0_clockline_fast ,
38+ clock_terminal = "ni_pcie_6363_0/PFI0" ,
39+ MAX_name = "ni_pcie_6363_0" ,
40+ acquisition_rate = 100e3 ,
41+ )
42+ NovaTechDDS9M (
43+ name = "novatechdds9m_0" ,
44+ parent_device = pulseblaster_0_clockline_slow ,
45+ com_port = "com10" ,
46+ )
2947
3048# Create a BIAS Camera, tirggered to take photos with flag 3 of pulseblaster_0
31- Camera ('andor_ixon_0' , pulseblaster_0 .direct_outputs , 'flag 3' , BIAS_port = 42520 , serial_number = "0000" , SDK = "IMAQdx" , effective_pixel_size = 4.6e-6 , exposure_time = .1 , orientation = 'top' )
49+ Camera (
50+ "andor_ixon_0" ,
51+ pulseblaster_0 .direct_outputs ,
52+ "flag 3" ,
53+ BIAS_port = 42520 ,
54+ serial_number = "0000" ,
55+ SDK = "IMAQdx" ,
56+ effective_pixel_size = 4.6e-6 ,
57+ exposure_time = 0.1 ,
58+ orientation = "top" ,
59+ )
3260
3361# A second pseudoclock to just clock a NI_PCI_6733 Card
34- PineBlaster (name = 'pineblaster_0' , trigger_device = ni_card_0 , trigger_connection = 'port0/line15' , usbport = 'COM7' )
35- NI_PCI_6733 (name = 'ni_card_1' , parent_device = pineblaster_0 .clockline , clock_terminal = 'ni_pcie_6733_0/PFI0' , MAX_name = 'ni_pci_6733_0' )
36-
37- # Create the output/input channels on the above devices
38- AnalogOut ( 'analog0' , ni_card_1 , 'ao0' , unit_conversion_class = example1 ) # use the example1 conversion class located in pythonlib/unitconversions/example.py with default paremeters
39-
40- # same as above, but we are changing some parameters used in the conversion and specifying a prefix to be used with units. You can now program in mA, uA, mGauss, uGauss
41- AnalogOut ( 'analog1' , ni_card_1 , 'ao1' , unit_conversion_class = example1 , unit_conversion_parameters = {'a' :5 , 'b' :1 , 'magnitudes' :['m' ,'u' ]})
42- AnalogOut ( 'analog2' , ni_card_0 , 'ao2' )
43- AnalogIn ( 'input1' , ni_card_0 , 'ai0' )
44- Shutter ( 'shutter1' , ni_card_0 , 'port0/line1' , delay = (0 ,0 ))
45- Shutter ( 'shutter2' , pulseblaster_0 .direct_outputs , 'flag 2' , delay = (0 ,0 ))
46- DigitalOut ( 'switch' , pulseblaster_0 .direct_outputs , 'flag 4' )
47-
48- DDS ( 'dds1' , novatechdds9m_0 , 'channel 0' )
49- DDS ( 'dds2' , novatechdds9m_0 , 'channel 1' )
50- StaticDDS ( 'dds5' , novatechdds9m_0 , 'channel 2' )
51- # The next DDS is special because it has the frequency and amplitude calibrated using example2 and example3 classes from pythonlib/unitconversions/example.py
52- DDS ( 'dds3' , pulseblaster_0 .direct_outputs , 'dds 0' , freq_conv_class = example2 , freq_conv_params = {'a' :4 , 'b' :6 }, amp_conv_class = example3 , amp_conv_params = {'a' :2 , 'b' :22 , 'magnitudes' :['m' ]})
53- DDS ( 'dds4' , pulseblaster_0 .direct_outputs , 'dds 1' )
62+ PineBlaster (
63+ name = "pineblaster_0" ,
64+ trigger_device = ni_card_0 ,
65+ trigger_connection = "port0/line15" ,
66+ usbport = "COM7" ,
67+ )
68+ NI_PCI_6733 (
69+ name = "ni_card_1" ,
70+ parent_device = pineblaster_0 .clockline ,
71+ clock_terminal = "ni_pcie_6733_0/PFI0" ,
72+ MAX_name = "ni_pci_6733_0" ,
73+ )
74+
75+ # Create the output/input channels on the above devices use the example1 conversion
76+ # class located in pythonlib/unitconversions/example.py with default paremeters
77+ AnalogOut ("analog0" , ni_card_1 , "ao0" , unit_conversion_class = example1 )
78+
79+ # same as above, but we are changing some parameters used in the conversion and
80+ # specifying a prefix to be used with units. You can now program in mA, uA, mGauss,
81+ # uGauss
82+ AnalogOut (
83+ "analog1" ,
84+ ni_card_1 ,
85+ "ao1" ,
86+ unit_conversion_class = example1 ,
87+ unit_conversion_parameters = {"a" : 5 , "b" : 1 , "magnitudes" : ["m" , "u" ]},
88+ )
89+ AnalogOut ("analog2" , ni_card_0 , "ao2" )
90+ AnalogOut ("analog3" , ni_card_0 , "ao3" )
91+ AnalogIn ("input1" , ni_card_0 , "ai0" )
92+ DigitalOut ("do0" , ni_card_0 , "port0/line2" )
93+ Shutter ("shutter1" , ni_card_0 , "port0/line1" , delay = (0 , 0 ))
94+ Shutter ("shutter2" , pulseblaster_0 .direct_outputs , "flag 2" , delay = (0 , 0 ))
95+ DigitalOut ("switch" , pulseblaster_0 .direct_outputs , "flag 4" )
96+
97+ DDS ("dds1" , novatechdds9m_0 , "channel 0" )
98+ DDS ("dds2" , novatechdds9m_0 , "channel 1" )
99+ StaticDDS ("dds5" , novatechdds9m_0 , "channel 2" )
100+ # The next DDS is special because it has the frequency and amplitude calibrated using
101+ # example2 and example3 classes from pythonlib/unitconversions/example.py
102+ DDS (
103+ "dds3" ,
104+ pulseblaster_0 .direct_outputs ,
105+ "dds 0" ,
106+ freq_conv_class = example2 ,
107+ freq_conv_params = {"a" : 4 , "b" : 6 },
108+ amp_conv_class = example3 ,
109+ amp_conv_params = {"a" : 2 , "b" : 22 , "magnitudes" : ["m" ]},
110+ )
111+ DDS ("dds4" , pulseblaster_0 .direct_outputs , "dds 1" )
54112
55113# This sets up the inputs/counters/etc that will monitor
56114# The first paremeter is the name for the WaitMonitor device
57- # The second and third paremeters are the device and channel respectively that goes high when a wait begins and low when it ends. This output should be
115+ # The second and third paremeters are the device and channel respectively that goes
116+ # high when a wait begins and low when it ends. This output should be
58117# physically connected to a counter specified in the next two paremeters.
59- # The final two paremeters specify the device/channel that is to trigger the pseudoclock if the WAIT instruction hits the specified timeout. The output of
60- # this channel should be physicaly connect to the external trigger of the master pseudoclock.
61- WaitMonitor ('wait_monitor' , ni_card_0 , 'port0/line0' , ni_card_0 , 'ctr0' , ni_card_0 , 'pfi1' )
118+ # The final two paremeters specify the device/channel that is to trigger the
119+ # pseudoclock if the WAIT instruction hits the specified timeout. The output of
120+ # this channel should be physicaly connect to the external trigger of the master
121+ # pseudoclock.
122+ WaitMonitor (
123+ "wait_monitor" , ni_card_0 , "port0/line0" , ni_card_0 , "ctr0" , ni_card_0 , "pfi1"
124+ )
62125
63126# A variable to define the acquisition rate used for the analog outputs below.
64127# This is just here to show you that you can use variables instead of typing in numbers!
65- # Furthermore, these variables could be defined within runmanager (rather than in the code like this one is)
128+ # Furthermore, these variables could be defined within runmanager (rather than in the
129+ # code like this one is)
66130# for easy manipulation via a graphical interface.
67131rate = 1e4
68132
69133# The time (in seconds) we wish the pineblaster pseudoclock to start after
70134# the master pseudoclock (the pulseblaster)
71- pineblaster_0 .set_initial_trigger_time (1 )
135+ pineblaster_0 .set_initial_trigger_time (0.9 )
72136
73137# Start the experiment!
74138start ()
75139
76140# A variable to keep track of time
77141t = 0
78142
79- # Analog Acquisitions are acquired at the sample rate specified when the *device* is instantiated (eg NI_PCIE_6363() above)
143+ # Analog Acquisitions are acquired at the sample rate specified when the *device* is
144+ # instantiated (eg NI_PCIE_6363() above)
80145# Acquire an analog trace on this channel from t=0s to t=1s
81146input1 .acquire ('measurement1' , 0 , 1 )
82147# Acquire an analog trace on this channel from t=3s to t=5s
91156
92157# Set some values for dds2 at t=1s. They will have value '0' before this
93158# time unless otherwise set
94- dds2 .setamp (t + 1 , 0.9 )
95- dds2 .setfreq (t + 1 , 1.0 )
96- dds2 .setphase (t + 1 , 1.1 )
159+ dds2 .setamp (t + 1 , 0.9 )
160+ dds2 .setfreq (t + 1 , 1.0 )
161+ dds2 .setphase (t + 1 , 1.1 )
97162
98163# dds5 is a "static" DDS. This means its value can only be set once, and
99164# will be set just before the experiment begins
100- dds5 .setfreq (90 * MHz )
165+ dds5 .setfreq (90 * MHz )
101166dds5 .setamp (1 )
102167dds5 .setphase (0 )
103168
104169# Have the shutters start in the closed state (t=0)
105170shutter1 .close (t )
106171shutter2 .close (t )
107172
108- # Analog0 is attached to ni_card_1, which is an NI-pci_6733 card (MAX name ni_pcie_6733_0) clocked by a pineblaster
109- # The pineblaster is being triggered to start by a pulseblaster, which introduces a delay into the start of output from the NI card
110- # This is all handled by labscript, and you still specify times from the beginning of the experiment (when the master pseudoclock is started)
173+ # Analog0 is attached to ni_card_1, which is an NI-pci_6733 card (MAX name
174+ # ni_pcie_6733_0) clocked by a pineblaster
175+ # The pineblaster is being triggered to start by a pulseblaster, which introduces
176+ # a delay into the start of output from the NI card
177+ # This is all handled by labscript, and you still specify times from the beginning of
178+ # the experiment (when the master pseudoclock is started)
111179# YOU DO NOT HAVE TO TAKE INTO ACCOUNT THE DELAY YOURSELF!!
112- # You do however need to make sure you do not command output from this device before the device has actually started.
180+ # You do however need to make sure you do not command output from this device before
181+ # the device has actually started.
113182# To do so, make sure no commands happen on this channel before analog0.t0
114183# (this variable contains the delay time!)
115184analog0 .constant (analog0 .t0 , 2 )
120189analog2 .constant (t , 3 )
121190
122191# Again, this must not start until analog1.t0 or later!
123- analog1 .sine (analog1 .t0 , duration = 6 , amplitude = 5 , angfreq = 2 * pi ,
124- phase = 0 , dc_offset = 0.0 , samplerate = rate )
192+ analog1 .sine (
193+ analog1 .t0 ,
194+ duration = 6 ,
195+ amplitude = 5 ,
196+ angfreq = 2 * pi ,
197+ phase = 0 ,
198+ dc_offset = 0.0 ,
199+ samplerate = rate ,
200+ )
125201
126202# Let's increment our time variable!
127203t += max (1 , analog0 .t0 )
133209
134210# Take a picture
135211andor_ixon_0 .expose ('exposure_1' , t , 'flat' )
136- andor_ixon_0 .expose ('exposure_1' , t + 1 , 'atoms' )
212+ andor_ixon_0 .expose ('exposure_1' , t + 1 , 'atoms' )
137213
138214# Do some more things at various times!
139215# (these are ignoring the t variable)
140216def my_ramp (t , * args , ** kwargs ):
141217 lambda_func = functions .sine_ramp (* args , ** kwargs )
142218 return lambda_func (t )
143- analog2 .sine_ramp (t = 2.25 , duration = 3 , initial = 3 , final = 4 ,
144- samplerate = rate , truncation = 0.7 )
219+
220+
221+ analog2 .sine_ramp (
222+ t = 2.25 , duration = 3 , initial = 3 , final = 4 , samplerate = rate , truncation = 0.7
223+ )
145224shutter1 .open (t = 5.89 )
146225analog2 .constant (t = 5.9 , value = 5 )
147226analog2 .constant (t = 7 , value = 4 )
148227analog2 .constant (t = 8 , value = 5 )
149228
229+ # Incremenent t by 9 seconds
230+ t += 9
150231
151- t += 9 # set t=10 seconds
152232# Wait for an external trigger on the master pseudoclock
153233# Waits must be names
154234# The timeout defaults to 5s, unless otherwise specified.
155235# The timeout specifies how long to wait without seeing the external
156236# trigger before continuing the experiment
157237t += wait ('my_first_wait' , t = t , timeout = 2 )
158- # Waits take very little time as far as labscript is concerned. They only add on the retirggering time needed to start devices up and get them all in sync again.
159- # After a wait, labscript time (the t variable here) and execution time (when the hardware instructions are executed on the hardware) will not be the same
238+
239+ # Waits take very little time as far as labscript is concerned. They only add on the
240+ # retirggering time needed to start devices up and get them all in sync again.
241+ # After a wait, labscript time (the t variable here) and execution time (when the
242+ # hardware instructions are executed on the hardware) will not be the same
160243# as the wait instruction may take anywhere from 0 to "timeout" seconds,
161244# and this number is only determined during execution time.
162245
@@ -170,12 +253,18 @@ def my_ramp(t, *args, **kwargs):
170253analog1 .constant (t , value = 1000 , units = 'mGauss' )
171254dds3 .setfreq (t , value = 50 , units = 'detuned_MHz' )
172255dds3 .setamp (t , value = 1.9 , units = 'W' )
256+
257+ # Hold values for 2 seconds
173258t += 2
259+
174260analog0 .ramp (t , duration = 1 , initial = 5 , final = 7 , samplerate = rate , units = 'Gauss' )
175261analog1 .constant (t , value = 3e6 , units = 'uA' )
176262dds3 .setfreq (t , value = 60 , units = 'detuned_MHz' )
177263dds3 .setamp (t , value = 500 , units = 'mW' )
264+
265+ # Hold values for 2 seconds
178266t += 2
267+
179268# Stop at t=15 seconds, note that because of the wait timeout, this might
180269# be as late as 17s (Plus a little bit of retriggering time) in execution
181270# time
0 commit comments