Created
April 25, 2019 22:11
-
-
Save mfe5003/efcc613989ea7b7620756a60d0f54c89 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
######################################################################################################################## | |
# ParallelForLoopTest | |
# | |
# Connectivity | |
# * TTL4 [output] -> MSOX2024A Channel 1 (trigger) | |
# * TTL7 [output] -> MSOX2024A Channel 2 | |
# * Urukul0_ch0 [output] -> MSOX2024A Channel 3 | |
# | |
# Description | |
# * Depending on the order of operations the TTL pulses can silently fail | |
# | |
######################################################################################################################## | |
from artiq.experiment import * | |
class SetDigitalOutput(object): | |
def __init__(self, device, state, delay): | |
self._device = device | |
self._state = state | |
self._delay = delay | |
@kernel | |
def run(self): | |
with sequential: | |
delay(self._delay) | |
self._device.set_o(self._state) | |
class SetDDSProfile(object): | |
def __init__(self, device, frequency, amplitude, phase, switch_state): | |
self._device = device | |
self._ftw = self._device.frequency_to_ftw(frequency) | |
self._asf = self._device.amplitude_to_asf(amplitude) | |
self._pow = self._device.turns_to_pow(phase) | |
self._sw = switch_state | |
# self._attenuator = attenuator | |
@kernel | |
def run(self): | |
self._device.set_mu(self._ftw, pow_=self._pow, asf=self._asf) | |
self._device.sw.set_o(self._sw) | |
# delay(10*us) | |
# TODO: add attenuator setting | |
# self._device.set_att(self._attenuator) | |
class LED(EnvExperiment): | |
def build(self): | |
self.setattr_device("core") | |
self.setattr_device("ttl4") | |
self.setattr_device("ttl7") | |
self.dds_runners = [] | |
cycles = 5 | |
for cycle in range(cycles): | |
self.dds_runners.append([]) | |
for card in range(2): | |
self.setattr_device("urukul{}_cpld".format(card)) | |
for channel in range(2): | |
ch_name = "urukul{}_ch{}".format(card, channel) | |
self.setattr_device(ch_name) | |
for cycle in range(cycles): | |
self.dds_runners[cycle].append(SetDDSProfile( | |
getattr(self, ch_name), | |
100*MHz, | |
(cycle)/(cycles-1), | |
0.0, | |
channel < 2 # only turn on the first 2 channel for each card because these are hooked up | |
)) | |
@kernel | |
def run(self): | |
self.core.break_realtime() | |
delay(1*ms) | |
self.urukul1_cpld.init() | |
self.urukul1_ch0.init() | |
self.urukul1_ch1.init() | |
self.urukul0_cpld.init() | |
self.urukul0_ch0.init() | |
self.urukul0_ch1.init() | |
self.ttl4.pulse(1*ms) | |
delay(1 * ms) | |
self.urukul0_ch0.set_att(10.0) | |
self.urukul1_ch0.set_att(10.0) | |
self.urukul0_ch1.set_att(10.0) | |
self.urukul1_ch1.set_att(10.0) | |
for runner_list in self.dds_runners: | |
with parallel: | |
self.ttl4.pulse(2.5 * ms) | |
# self.ttl7.pulse(2.5 * ms) # this one works | |
for runner in runner_list: | |
runner.run() | |
self.ttl7.pulse(2.5 * ms) # this one doesn't work | |
delay(5*ms) | |
delay(10*ms) | |
self.urukul0_ch0.sw.off() | |
self.urukul0_ch1.sw.off() | |
self.urukul1_ch0.sw.off() | |
self.urukul1_ch1.sw.off() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment