"""
The main changed between this and the non-NAC3 TTL4_50Hz.
@nac3 decorator on the classes used by the artiq compiler.
delay(20 * ms) -> delay(20.0 * ms). The old version is incorrect because 20 is
int32 and ms is float. Typing is much more strict.
Type hinting changes: the old TNone and TStr has been depriciated. (print_elapsed_time)
"""
from artiq.experiment import nac3, delay, ms, kernel, EnvExperiment
import time
@nac3
class mains_TTL(EnvExperiment):
"""
Simple program to send 100 50Hz TTLs.
Currently, there is about 4 seconds between the build and run commands. Why
so slow?
Running this in the dasgboard does not make compiling / running any faster.
"""
def build(self):
self.t_start = time.time()
self.setattr_device("core")
self.setattr_device("ttl4")
self.print_elapsed_time("Build complete")
@kernel
def run(self):
self.print_elapsed_time("Run started")
self.core.reset()
self.print_elapsed_time("Core reset")
for i in range(100):
delay(20.0 * ms)
self.ttl4.pulse(20.0 * ms)
self.print_elapsed_time("Compiled")
def print_elapsed_time(self, msg: str) -> None:
print(f"{msg}: {time.time()*1e3 - self.t_start*1e3:.1f} ms elapsed.")
Here's the NAC3 code, I get the following error from artiq.experiment import nac3, delay, ms, kernel, EnvExperiment
ImportError: cannot import name 'nac3' from 'artiq.experiment' (C:\Users\James\anaconda3\envs\artiq\lib\site-packages\artiq\experiment.py)
. It does look like nac3 was installed, but perhaps not into the conda environment Im using? Since I've been following the documentation, I installed the base artiq module into a conda environment called "artiq".