def __init__(self): self._dac = ad5689.create_from_pins(cs=board.DAC_CS) self._dac.soft_reset() self._cv_a = voltageio.VoltageOut(self._dac.a) self._cv_a.direct_calibration(calibration.channel_a) self._cv_b = voltageio.VoltageOut(self._dac.b) self._cv_b.direct_calibration(calibration.channel_b) self._cv_c = voltageio.VoltageOut(self._dac.a) self._cv_c.direct_calibration(calibration.channel_c) self._cv_d = voltageio.VoltageOut(self._dac.b) self._cv_d.direct_calibration(calibration.channel_d) self._gate_1 = digitalio.DigitalInOut(board.G1) self._gate_1.direction = digitalio.Direction.OUTPUT self._gate_2 = digitalio.DigitalInOut(board.G2) self._gate_2.direction = digitalio.Direction.OUTPUT self._gate_3 = digitalio.DigitalInOut(board.G3) self._gate_3.direction = digitalio.Direction.OUTPUT self._gate_4 = digitalio.DigitalInOut(board.G4) self._gate_4.direction = digitalio.Direction.OUTPUT self._gate_1_trigger = trigger.Trigger(self._gate_1) self._gate_2_trigger = trigger.Trigger(self._gate_2) self._gate_3_trigger = trigger.Trigger(self._gate_3) self._gate_4_trigger = trigger.Trigger(self._gate_4) self._gate_1_retrigger = trigger.Retrigger(self._gate_1) self._gate_2_retrigger = trigger.Retrigger(self._gate_2) self._gate_3_retrigger = trigger.Retrigger(self._gate_3) self._gate_4_retrigger = trigger.Retrigger(self._gate_4) self.led = StatusLED()
def test_empty_step(): output = DigitalInOutStub() trig = trigger.Trigger(output) trig.step() assert output.value is False
def __init__(self): if _utils.is_beta(): dac_driver = ad5689 # 5689 is calibrated from nominal values. calibration = _calibration.beta_nominal_calibration() else: dac_driver = ad5686 # 5686 is externally calibrated. calibration = _calibration.load_calibration() self._dac = dac_driver.create_from_pins(cs=board.DAC_CS) self._dac.soft_reset() self._cv_a = voltageio.VoltageOut(self._dac.a) self._cv_a.direct_calibration(calibration["a"]) self._cv_b = voltageio.VoltageOut(self._dac.b) self._cv_b.direct_calibration(calibration["b"]) # 5686 has 4 channels. if dac_driver == ad5686: self._cv_c = voltageio.VoltageOut(self._dac.c) self._cv_c.direct_calibration(calibration["c"]) self._cv_d = voltageio.VoltageOut(self._dac.d) self._cv_d.direct_calibration(calibration["d"]) self._gate_1 = digitalio.DigitalInOut(board.G1) self._gate_1.direction = digitalio.Direction.OUTPUT self._gate_2 = digitalio.DigitalInOut(board.G2) self._gate_2.direction = digitalio.Direction.OUTPUT self._gate_3 = digitalio.DigitalInOut(board.G3) self._gate_3.direction = digitalio.Direction.OUTPUT self._gate_4 = digitalio.DigitalInOut(board.G4) self._gate_4.direction = digitalio.Direction.OUTPUT self._gate_1_trigger = trigger.Trigger(self._gate_1) self._gate_2_trigger = trigger.Trigger(self._gate_2) self._gate_3_trigger = trigger.Trigger(self._gate_3) self._gate_4_trigger = trigger.Trigger(self._gate_4) self._gate_1_retrigger = trigger.Retrigger(self._gate_1) self._gate_2_retrigger = trigger.Retrigger(self._gate_2) self._gate_3_retrigger = trigger.Retrigger(self._gate_3) self._gate_4_retrigger = trigger.Retrigger(self._gate_4) self.led = StatusLED()
def test_trigger_custom_duration(time_monotonic): output = DigitalInOutStub() trig = trigger.Trigger(output) time_monotonic.return_value = 0 trig(duration=50) time_monotonic.return_value = 0.049 trig.step() assert output.value is True time_monotonic.return_value = 0.051 trig.step() assert output.value is False
def test_trigger_basic(time_monotonic): output = DigitalInOutStub() trig = trigger.Trigger(output) time_monotonic.return_value = 0 trig() assert output.value is True time_monotonic.return_value = 0.014 trig.step() assert output.value is True time_monotonic.return_value = 0.016 trig.step() assert output.value is False
def test_overlapping_trigger(): output = DigitalInOutStub() trig = trigger.Trigger(output) assert trig(True) assert not trig(True)