Newer
Older
Martin Drechsler
committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import numpy as np
from artiq.experiment import *
from pyLIAF.artiq.controllers import UrukulCh
class PMTCalibration(EnvExperiment):
"""BOTH - Blinking script plotting for pmt calibration - Plots the abs Fluo, and the Signal to Background ratio"""
def build(self):
self.setattr_device("ccb")
self.setattr_device("scheduler")
self.setattr_device("core")
self.pmt = self.get_device("ttl0")
self.laserUV = UrukulCh(self, ch=2, freq=110.0, amp=0.3, name="UV") #corresponde a 0.7 Vpp
self.laserIR = UrukulCh(self, ch=1, freq=208.0, amp=0.35, name="IR") #corresponde a 0.8 Vpp
self.setattr_argument(f"t_readout",
NumberValue(100*ms, unit='ms', scale=ms, min=1*ms),
"PMT Calibration")
@rpc
def create_datasets(self):
self.set_dataset("pmt_counts_diff", np.zeros(1, dtype=int), broadcast=True, archive=False)
self.set_dataset("pmt_counts_on", np.zeros(1, dtype=int), broadcast=True, archive=False)
self.set_dataset("pmt_counts_off", np.zeros(1, dtype=int), broadcast=True, archive=False)
@rpc
def create_applets(self):
self.ccb.issue("create_applet", "ON_OFF_calibration_pmt_blinking",
"${python} -m pyLIAF.artiq.applets.realtime "
"200 "
"pmt_counts_on "
"--y2 pmt_counts_off")
self.ccb.issue("create_applet", "DIFF_calibration_pmt_blinking",
"${python} -m pyLIAF.artiq.applets.realtime "
"200 "
"pmt_counts_diff")
@kernel
def init_kernel(self):
self.core.reset()
#self.laserIR.initialize_channel()
#self.laserUV.channel.cpld.init()
#self.laserUV.channel.init()
#self.laserIR.channel.cpld.init()
#self.core.wait_until_mu(now_mu())
#self.laserIR.channel.init()
#self.laserUV.initialize_channel()
Martin Drechsler
committed
self.pmt.input()
Martin Drechsler
committed
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
self.laserIR.set_channel()
self.laserUV.set_channel()
self.core.wait_until_mu(now_mu())
delay(1*ms)
self.laserIR.on()
self.laserUV.on()
def run(self):
self.create_datasets()
self.create_applets()
self.init_kernel()
try:
while True:
self.measure_counts()
while self.scheduler.check_pause():
print("PAUSED BLINKING")
self.core.comm.close()
self.scheduler.pause()
# TODO: reset freqs/amps
print("RESUMED BLINKING")
except TerminationRequested:
self.cleanup()
print("STOPPED BLINKING")
@kernel
def readout(self):
"""Registro de cuentas emitidas"""
here = self.pmt.gate_rising(self.t_readout)
cuentas = self.pmt.count(here)
delay(1*us)
return cuentas
@kernel
def measure_counts(self):
self.core.break_realtime()
self.laserUV.on()
self.laserIR.off()
delay(10*us)
counts_off = self.readout()
self.mutate_dataset("pmt_counts_off", 0, counts_off)
at_mu(self.core.get_rtio_counter_mu() + 10000)
self.laserIR.on()
delay(10*us)
counts_on = self.readout()
self.mutate_dataset("pmt_counts_on", 0, counts_on)
at_mu(self.core.get_rtio_counter_mu() + 10000)
self.mutate_dataset("pmt_counts_diff", 0, counts_on/counts_off)
@kernel
def cleanup(self):
self.core.break_realtime()
self.laserIR.off()
self.laserUV.off()