Пример #1
0
 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_out_linear_calibration_real_range(voltage, value):
    analog_out = AnalogOut()
    voltage_out = winterbloom_voltageio.VoltageOut(analog_out)

    voltage_out.linear_calibration(0.0, 3.3)

    voltage_out.voltage = voltage
    assert analog_out.value == value
def test_out_linear_calibration_normalized(voltage, value):
    analog_out = AnalogOut()
    voltage_out = winterbloom_voltageio.VoltageOut(analog_out)

    voltage_out.linear_calibration(0.0, 1.0)

    voltage_out.voltage = voltage
    assert analog_out.value == value
def test_out_linear_calibration_bipolar(voltage, value):
    analog_out = AnalogOut()
    voltage_out = winterbloom_voltageio.VoltageOut(analog_out)

    voltage_out.linear_calibration(-0.5, 0.5)

    voltage_out.voltage = voltage
    assert analog_out.value == value
Пример #5
0
    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_out_direct_calibration(voltage, value):
    analog_out = AnalogOut()
    voltage_out = winterbloom_voltageio.VoltageOut(analog_out)

    # Very non-linear. The first volt takes up half of the range.
    voltage_out.direct_calibration({
        0: 0,
        1.0: 32768,
        10: 65535,
    })

    voltage_out.voltage = voltage
    assert analog_out.value == value
Пример #7
0
import board
from winterbloom_ad_dacs import ad5686
import winterbloom_voltageio
import supervisor
import neopixel
import microcontroller
import struct

supervisor.disable_autoreload()
pix = neopixel.NeoPixel(board.NEOPIXEL, 1, pixel_order=(0, 1, 2))
pix.brightness = 0.1
pix[0] = (255, 0, 255)

dac = ad5686.create_from_pins(cs=board.DAC_CS)
vio_a = winterbloom_voltageio.VoltageOut(dac.a)
vio_b = winterbloom_voltageio.VoltageOut(dac.b)
vio_c = winterbloom_voltageio.VoltageOut(dac.c)
vio_d = winterbloom_voltageio.VoltageOut(dac.d)


def set_dac(channel, dac_code):
    getattr(dac, channel).value = dac_code


def _vio_for_channel(channel):
    if channel == "a":
        return vio_a
    elif channel == "b":
        return vio_b
    elif channel == "c":
        return vio_c