2
0
mirror of https://github.com/m-labs/artiq.git synced 2024-12-05 01:36:39 +08:00
artiq/examples/master/repository/dds_setter.py

34 lines
999 B
Python
Raw Normal View History

from operator import itemgetter
from artiq import *
class DDSSetter(EnvExperiment):
"""DDS Setter"""
def build(self):
2015-10-31 23:44:09 +08:00
self.setattr_device("core")
self.dds = dict()
2015-10-12 19:46:31 +08:00
device_db = self.get_device_db()
for k, v in sorted(device_db.items(), key=itemgetter(0)):
if (isinstance(v, dict)
and v["type"] == "local"
and v["module"] == "artiq.coredevice.dds"
and v["class"] in {"AD9858", "AD9914"}):
self.dds[k] = {
"driver": self.get_device(k),
2015-10-31 23:44:09 +08:00
"frequency": self.get_argument(
"{}_frequency".format(k),
NumberValue(100e6, scale=1e6, unit="MHz", ndecimals=6))
}
2015-10-31 23:44:09 +08:00
@kernel
def set_dds(self, dds, frequency):
dds.set(frequency)
delay(200*ms)
def run(self):
for k, v in self.dds.items():
2015-10-31 23:44:09 +08:00
self.set_dds(v["driver"], v["frequency"])