artiq/examples/pulse_performance.py

35 lines
974 B
Python
Raw Normal View History

2014-10-11 13:00:27 +08:00
from artiq import *
2014-10-19 23:51:49 +08:00
from artiq.coredevice import comm_serial, core, rtio
from artiq.coredevice.runtime_exceptions import RTIOUnderflow
2014-10-11 13:00:27 +08:00
def print_min_period(p):
print("Minimum square wave output period: {} ns".format(p))
class PulsePerformance(AutoContext):
o = Device("ttl_out")
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):
self.o.pulse(cycles_to_time(T))
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:
print_min_period(int(cycles_to_time(2*T)/(1*ns)))
break
if __name__ == "__main__":
2014-10-19 23:51:49 +08:00
with comm_serial.Comm() as comm:
coredev = core.Core(comm)
2014-10-11 13:00:27 +08:00
exp = PulsePerformance(core=coredev,
o=rtio.RTIOOut(core=coredev, channel=2))
2014-10-11 13:00:27 +08:00
exp.run()