Hello Artiq users,
I am trying to develop a simple photon counter to measure a time trace of photons from my PMT. Below I attach the code I wrote.
Issues:
- I get an RTIOOverflow for high number of data points (> 10k)
TerminationRequested
does not work properly in Dashboard
Do you know any better methods for this simple application? Ideally, I want to get rid of the delays in-between the data point acquisition.
from artiq.experiment import *
from artiq.coredevice.edge_counter import CounterOverflow
import time
import numpy as np
class PhotonCounterCurrent2(EnvExperiment):
def build(self):
self.setattr_device("core")
self.setattr_device("ttl2")
self.setattr_device("ttl_counter2")
self.setattr_argument("n_points", NumberValue(1000,ndecimals=0, step=1)) #steps number
self.setattr_argument("det_time", NumberValue(0.01*ms,ndecimals=3, unit="ms", step=0.001)) #time of detection
def run(self):
tc = time.time()
try:
self.run_kernel()
except TerminationRequested:
print('Terminated.')
print("Time elapsed: {:.2f} seconds" .format(time.time() - tc))
@kernel
def run_kernel(self):
self.core.reset()
i = 0 ;
self.set_dataset("Photon_Counts", np.full(self.n_points, np.nan), broadcast=True)
# self.core.break_realtime()
delay(10*ms)
for _ in range(self.n_points):
num_rising_edges = self.counting_style3()
delay(100*us)
self.mutate_dataset("Photon_Counts", i, num_rising_edges)
i += 1
@kernel
def counting_style4(self):
self.ttl_counter2.gate_rising(self.det_time) #needs to be initialised in the programme
return self.ttl_counter2.fetch_count()
@kernel
def counting_style3(self):
gate_end_mu = self.ttl2.gate_rising(self.det_time)
return self.ttl2.count(now_mu())