2014-09-30 17:38:02 +08:00
|
|
|
from artiq import *
|
2014-10-19 23:51:49 +08:00
|
|
|
from artiq.coredevice import comm_serial, core, dds, rtio
|
2014-09-13 19:38:15 +08:00
|
|
|
|
|
|
|
|
|
|
|
class PhotonHistogram(AutoContext):
|
2014-12-02 17:19:05 +08:00
|
|
|
bd = Device("dds")
|
|
|
|
bdd = Device("dds")
|
|
|
|
pmt = Device("ttl_in")
|
|
|
|
repeats = Parameter()
|
|
|
|
nbins = Parameter()
|
2014-09-13 19:38:15 +08:00
|
|
|
|
|
|
|
def report(self, i, n):
|
|
|
|
print(i, n)
|
|
|
|
|
|
|
|
@kernel
|
|
|
|
def cool_detect(self):
|
|
|
|
with parallel:
|
|
|
|
self.bd.pulse(200*MHz, 1*ms)
|
|
|
|
self.bdd.pulse(300*MHz, 1*ms)
|
|
|
|
self.bd.pulse(210*MHz, 100*us)
|
|
|
|
with parallel:
|
|
|
|
self.bd.pulse(220*MHz, 100*us)
|
2014-09-30 16:42:07 +08:00
|
|
|
self.pmt.gate_rising(100*us)
|
2014-09-13 19:38:15 +08:00
|
|
|
self.bd.on(200*MHz)
|
|
|
|
self.bdd.on(300*MHz)
|
2014-09-30 16:42:07 +08:00
|
|
|
return self.pmt.count()
|
2014-09-13 19:38:15 +08:00
|
|
|
|
|
|
|
@kernel
|
|
|
|
def run(self):
|
|
|
|
hist = array(0, self.nbins)
|
|
|
|
|
|
|
|
for i in range(self.repeats):
|
|
|
|
n = self.cool_detect()
|
|
|
|
if n >= self.nbins:
|
|
|
|
n = self.nbins-1
|
|
|
|
hist[n] += 1
|
|
|
|
|
|
|
|
for i in range(self.nbins):
|
|
|
|
self.report(i, hist[i])
|
|
|
|
|
|
|
|
|
2014-10-05 16:24:21 +08:00
|
|
|
def main():
|
2014-10-19 23:51:49 +08:00
|
|
|
with comm_serial.Comm() as comm:
|
|
|
|
coredev = core.Core(comm)
|
2014-09-13 19:38:15 +08:00
|
|
|
exp = PhotonHistogram(
|
|
|
|
core=coredev,
|
2014-10-19 23:51:49 +08:00
|
|
|
bd=dds.DDS(core=coredev, dds_sysclk=1*GHz,
|
2014-11-30 15:50:57 +08:00
|
|
|
reg_channel=0, rtio_switch=2),
|
2014-10-19 23:51:49 +08:00
|
|
|
bdd=dds.DDS(core=coredev, dds_sysclk=1*GHz,
|
2014-11-30 15:50:57 +08:00
|
|
|
reg_channel=1, rtio_switch=3),
|
2014-10-19 23:51:49 +08:00
|
|
|
pmt=rtio.RTIOIn(core=coredev, channel=0),
|
2014-09-13 19:38:15 +08:00
|
|
|
repeats=100,
|
|
|
|
nbins=100
|
|
|
|
)
|
|
|
|
exp.run()
|
2014-10-05 16:24:21 +08:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|