def advance(self): if self.invalidated: raise InvalidatedError() if not self.pdq.armed: raise ArmError() call_t = now_mu() trigger_start_t = call_t - self.core.seconds_to_mu(trigger_duration/2) if self.pdq.current_frame >= 0: # PDQ is in the middle of a frame. Check it is us. if self.pdq.current_frame != self.frame_number: raise FrameActiveError() else: # PDQ is in the jump table - set the selection signals # to play our first segment. self.pdq.current_frame = self.frame_number self.pdq.next_segment = 0 at_mu(trigger_start_t - self.core.seconds_to_mu(frame_setup)) self.pdq.set_frame(self.frame_number) at_mu(trigger_start_t) self.pdq.trigger.pulse(trigger_duration) at_mu(call_t) delay_mu(self.segment_delays[self.pdq.next_segment]) self.pdq.next_segment += 1 # test for end of frame if self.pdq.next_segment == self.segment_count: self.pdq.current_frame = -1 self.pdq.next_segment = -1
def test_demo_2tone(self): MHz = 1e-3 ns = 1. self.sawg0 = self.driver t_up = t_hold = t_down = 400 * ns a1 = .3 a2 = .4 order = 3 self.sawg0.frequency0.set(10 * MHz) self.sawg0.phase0.set(0.) self.sawg0.frequency1.set(1 * MHz) self.sawg0.phase1.set(0.) self.sawg0.frequency2.set(13 * MHz) self.sawg0.phase2.set(0.) t = now_mu() self.sawg0.amplitude1.smooth(.0, a1, t_up, order) at_mu(t) self.sawg0.amplitude2.smooth(.0, a2, t_up, order) self.sawg0.amplitude1.set(a1) self.sawg0.amplitude2.set(a2) delay(t_hold) t = now_mu() self.sawg0.amplitude1.smooth(a1, .0, t_down, order) at_mu(t) self.sawg0.amplitude2.smooth(a2, .0, t_down, order) self.sawg0.amplitude1.set(.0) self.sawg0.amplitude2.set(.0) out = self.run_channel(self.rtio_manager.outputs) out = sum(out, []) if True: import matplotlib.pyplot as plt plt.plot(out) plt.show()
def test_demo_2tone(self): MHz = 1e-3 ns = 1. self.sawg0 = self.driver t_up = t_hold = t_down = 400*ns a1 = .3 a2 = .4 order = 3 self.sawg0.frequency0.set(10*MHz) self.sawg0.phase0.set(0.) self.sawg0.frequency1.set(1*MHz) self.sawg0.phase1.set(0.) self.sawg0.frequency2.set(13*MHz) self.sawg0.phase2.set(0.) t = now_mu() self.sawg0.amplitude1.smooth(.0, a1, t_up, order) at_mu(t) self.sawg0.amplitude2.smooth(.0, a2, t_up, order) self.sawg0.amplitude1.set(a1) self.sawg0.amplitude2.set(a2) delay(t_hold) t = now_mu() self.sawg0.amplitude1.smooth(a1, .0, t_down, order) at_mu(t) self.sawg0.amplitude2.smooth(a2, .0, t_down, order) self.sawg0.amplitude1.set(.0) self.sawg0.amplitude2.set(.0) out = self.run_channel(self.rtio_manager.outputs) out = sum(out, []) if True: import matplotlib.pyplot as plt plt.plot(out) plt.show()