forked from M-Labs/artiq
1
0
Fork 0
artiq/examples/dds_test.py

44 lines
1.4 KiB
Python
Raw Normal View History

2014-07-24 07:09:49 +08:00
from artiq.language.units import *
from artiq.language.core import *
from artiq.devices import corecom_serial, core, dds_core, gpio_core
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):
i = 0
while i < 10000:
if i & 0x200:
self.led.set(1)
else:
self.led.set(0)
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)
i += 1
self.led.set(0)
2014-07-24 07:09:49 +08:00
if __name__ == "__main__":
2014-09-05 12:03:22 +08:00
with corecom_serial.CoreCom() as com:
coredev = core.Core(com)
exp = DDSTest(
core=coredev,
a=dds_core.DDS(core=coredev, dds_sysclk=1*GHz,
reg_channel=0, rtio_channel=0),
b=dds_core.DDS(core=coredev, dds_sysclk=1*GHz,
reg_channel=1, rtio_channel=1),
c=dds_core.DDS(core=coredev, dds_sysclk=1*GHz,
reg_channel=2, rtio_channel=2),
d=dds_core.DDS(core=coredev, dds_sysclk=1*GHz,
reg_channel=3, rtio_channel=3),
led=gpio_core.GPIOOut(core=coredev, channel=1)
)
exp.run()