The following program hangs on the last line of the code below. TTL6 (output) is connected to TTL0 (input) to test the edge counter.
from artiq.experiment import *
class PMT(EnvExperiment):
def build(self):
self.setattr_device("core")
self.setattr_device("ttl0_counter")
self.setattr_device("ttl6")
@kernel
def run(self):
self.core.reset()
self.core.break_realtime()
for i in range(1000):
with parallel:
with sequential:
for kk in range(5):
delay(100*ns)
self.ttl6.pulse(100*ns)
self.ttl0_counter.gate_rising(4*us)
delay(4*us)
print(self.ttl0_counter.fetch_count())
The related section in device_db.py is also attached.
device_db["ttl0_counter"] = {
"type": "local",
"module": "artiq.coredevice.edge_counter",
"class": "EdgeCounter",
"arguments": {"channel": 0x000000},
}
device_db["ttl0"] = {
"type": "local",
"module": "artiq.coredevice.ttl",
"class": "TTLInOut",
"arguments": {"channel": 0x000000},
}
device_db["ttl6"] = {
"type": "local",
"module": "artiq.coredevice.ttl",
"class": "TTLOut",
"arguments": {"channel": 0x000006},
}
The connections are correct and both TTL0 and TTL6 are working correctly as tested with the code below. It prints interleaved "0" and "1"s as expected.
from artiq.experiment import *
class RTIORead(EnvExperiment):
def build(self):
self.setattr_device("core")
self.setattr_device("ttl0")
self.setattr_device("ttl6")
@kernel
def run(self):
self.core.reset()
self.ttl0.input()
self.core.break_realtime()
for i in range(10):
delay(50*ms)
self.ttl0.sample_input()
delay(50*ms)
self.ttl6.pulse(50*ms)
self.ttl0.sample_input()
self.ttl6.pulse(50*ms)
for i in range(20):
print(self.ttl0.sample_get())
Can anyone let me know what I missed here? Also, would fetch_count() block or return 0 if it does not detect edges during a count period? Thanks!