2014-10-14 15:54:28 +08:00
|
|
|
from artiq import *
|
2014-10-19 23:51:49 +08:00
|
|
|
from artiq.coredevice import comm_serial, core, rtio
|
2014-10-14 15:54:28 +08:00
|
|
|
|
|
|
|
|
|
|
|
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-02 17:19:05 +08:00
|
|
|
i = Device("ttl_in")
|
|
|
|
o = Device("ttl_out")
|
2014-10-14 15:54:28 +08:00
|
|
|
|
|
|
|
@kernel
|
|
|
|
def run(self):
|
|
|
|
with parallel:
|
|
|
|
self.i.gate_rising(10*us)
|
|
|
|
with sequential:
|
|
|
|
delay(5*us)
|
|
|
|
out_t = now()
|
|
|
|
self.o.pulse(5*us)
|
|
|
|
in_t = self.i.timestamp()
|
|
|
|
if in_t < 0*s:
|
|
|
|
print_failed()
|
|
|
|
else:
|
|
|
|
print_skew(int((out_t - in_t)/(1*ns)))
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2014-10-19 23:51:49 +08:00
|
|
|
with comm_serial.Comm() as comm:
|
|
|
|
coredev = core.Core(comm)
|
2014-10-14 15:54:28 +08:00
|
|
|
exp = RTIOSkew(core=coredev,
|
2014-10-19 23:51:49 +08:00
|
|
|
i=rtio.RTIOIn(core=coredev, channel=0),
|
2014-11-30 15:50:57 +08:00
|
|
|
o=rtio.RTIOOut(core=coredev, channel=2))
|
2014-10-14 15:54:28 +08:00
|
|
|
exp.run()
|