2014-10-11 13:00:27 +08:00
|
|
|
from artiq import *
|
2014-10-19 23:51:49 +08:00
|
|
|
from artiq.coredevice.runtime_exceptions import RTIOUnderflow
|
2014-10-11 13:00:27 +08:00
|
|
|
|
|
|
|
|
2015-02-18 07:14:18 +08:00
|
|
|
class PulseRate(AutoDB):
|
2015-02-21 05:01:34 +08:00
|
|
|
__artiq_unit__ = "Pulse rate"
|
|
|
|
|
2015-01-12 18:51:23 +08:00
|
|
|
class DBKeys:
|
2015-03-08 18:37:53 +08:00
|
|
|
core = Device()
|
2015-01-12 18:51:23 +08:00
|
|
|
ttl0 = Device()
|
2015-02-18 07:14:18 +08:00
|
|
|
pulse_rate = Result()
|
2014-10-11 13:00:27 +08:00
|
|
|
|
|
|
|
@kernel
|
|
|
|
def run(self):
|
|
|
|
T = time_to_cycles(100*ns)
|
|
|
|
while True:
|
|
|
|
try:
|
|
|
|
for i in range(1000):
|
2014-12-03 18:20:30 +08:00
|
|
|
self.ttl0.pulse(cycles_to_time(T))
|
2014-10-11 13:00:27 +08:00
|
|
|
delay(cycles_to_time(T))
|
|
|
|
except RTIOUnderflow:
|
|
|
|
T += 1
|
2014-11-21 04:38:52 +08:00
|
|
|
self.core.recover_underflow()
|
2014-10-11 13:00:27 +08:00
|
|
|
else:
|
2015-02-18 07:14:18 +08:00
|
|
|
self.pulse_rate = cycles_to_time(2*T)
|
2014-10-11 13:00:27 +08:00
|
|
|
break
|