artiq/examples/dds_test.py

44 lines
1.3 KiB
Python
Raw Normal View History

2014-09-30 17:38:02 +08:00
from artiq import *
2014-10-19 23:51:49 +08:00
from artiq.coredevice import comm_serial, core, dds, gpio
2014-07-24 07:09:49 +08:00
2014-09-05 12:03:22 +08:00
2014-08-13 18:30:57 +08:00
class DDSTest(AutoContext):
2014-09-05 12:03:22 +08:00
parameters = "a b c d led"
@kernel
def run(self):
2014-09-10 16:06:27 +08:00
for i in range(10000):
2014-09-05 12:03:22 +08:00
if i & 0x200:
self.led.on()
2014-09-05 12:03:22 +08:00
else:
self.led.off()
2014-09-05 12:03:22 +08:00
with parallel:
with sequential:
self.a.pulse(100*MHz + 4*i*kHz, 500*us)
self.b.pulse(120*MHz, 500*us)
with sequential:
self.c.pulse(200*MHz, 100*us)
self.d.pulse(250*MHz, 200*us)
self.led.off()
2014-07-24 07:09:49 +08:00
2014-10-05 16:24:21 +08:00
def main():
2014-10-19 23:51:49 +08:00
with comm_serial.Comm() as comm:
coredev = core.Core(comm)
2014-09-05 12:03:22 +08:00
exp = DDSTest(
core=coredev,
2014-10-19 23:51:49 +08:00
a=dds.DDS(core=coredev, dds_sysclk=1*GHz,
reg_channel=0, rtio_switch=2),
2014-10-19 23:51:49 +08:00
b=dds.DDS(core=coredev, dds_sysclk=1*GHz,
reg_channel=1, rtio_switch=3),
2014-10-19 23:51:49 +08:00
c=dds.DDS(core=coredev, dds_sysclk=1*GHz,
reg_channel=2, rtio_switch=4),
2014-10-19 23:51:49 +08:00
d=dds.DDS(core=coredev, dds_sysclk=1*GHz,
reg_channel=3, rtio_switch=5),
2014-10-19 23:51:49 +08:00
led=gpio.GPIOOut(core=coredev, channel=0)
2014-09-05 12:03:22 +08:00
)
exp.run()
2014-10-05 16:24:21 +08:00
if __name__ == "__main__":
main()