sinarads/examples/pll.py

45 lines
995 B
Python
Raw Normal View History

2022-02-04 17:18:09 +08:00
from artiq.experiment import *
class MirnyEnv(EnvExperiment):
def build(self):
self.setattr_device("core")
self.cpld = self.get_device("mirny0_cpld")
self.pll0 = self.get_device("mirny0_ch0")
@kernel
def init_mirny(self):
self.core.reset()
self.cpld.init()
self.pll0.init()
self.pll0.set_frequency(1*GHz)
self.pll0.set_att_mu(0b11001100)
self.pll0.sw.on()
class PowerControl(MirnyEnv):
@kernel
def run(self):
self.core.reset()
self.init_mirny()
# Run other code here
delay(5*s)
self.pll0.set_output_power_mu(0)
print(self.pll0.output_power_mu())
class ToggleSwitch(MirnyEnv):
@kernel
def run(self):
self.core.reset()
self.init_mirny()
delay_mu(8) # Avoid RTIO collision
self.pll0.sw.off()
delay(1*s)
while True:
self.pll0.sw.pulse(100*us)
delay(900*us)