2
0
mirror of https://github.com/m-labs/artiq.git synced 2024-12-23 02:14:01 +08:00
artiq/examples/rtio_skew.py

29 lines
613 B
Python
Raw Normal View History

2014-10-14 15:54:28 +08:00
from artiq import *
def print_skew(p):
print("Input/output skew: {} ns".format(p))
def print_failed():
print("Pulse was not received back")
class RTIOSkew(AutoContext):
2014-12-03 18:20:30 +08:00
pmt0 = Device("ttl_in")
ttl0 = Device("ttl_out")
2014-10-14 15:54:28 +08:00
@kernel
def run(self):
with parallel:
2014-12-03 18:20:30 +08:00
self.pmt0.gate_rising(10*us)
2014-10-14 15:54:28 +08:00
with sequential:
delay(5*us)
out_t = now()
2014-12-03 18:20:30 +08:00
self.ttl0.pulse(5*us)
in_t = self.pmt0.timestamp()
2014-10-14 15:54:28 +08:00
if in_t < 0*s:
print_failed()
else:
print_skew(int((out_t - in_t)/(1*ns)))