Skip to content

Commit

Permalink
ad53xx: make LDAC and CLR optional
Browse files Browse the repository at this point in the history
  • Loading branch information
sbourdeauducq committed Mar 26, 2018
1 parent bab6723 commit 5ca5946
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions artiq/coredevice/ad53xx.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,23 @@ def voltage_to_mu(voltage, offset_dacs=0x2000, vref=5.):
return int(round(0x10000*(voltage/(4.*vref)) + offset_dacs*0x4))


class _DummyTTL:
@portable
def on(self):
pass

@portable
def off(self):
pass


class AD53xx:
"""Analog devices AD53[67][0123] family of multi-channel Digital to Analog
Converters.
:param spi_device: SPI bus device name
:param ldac_device: LDAC RTIO TTLOut channel name
:param clr_device: CLR RTIO TTLOut channel name
:param ldac_device: LDAC RTIO TTLOut channel name (optional)
:param clr_device: CLR RTIO TTLOut channel name (optional)
:param chip_select: Value to drive on SPI chip select lines during
transactions (default: 1)
:param div_write: SPI clock divider for write operations (default: 4,
Expand All @@ -108,12 +118,18 @@ class AD53xx:
kernel_invariants = {"bus", "ldac", "clr", "chip_select", "div_write",
"div_read", "vref", "core"}

def __init__(self, dmgr, spi_device, ldac_device, clr_device,
def __init__(self, dmgr, spi_device, ldac_device=None, clr_device=None,
chip_select=1, div_write=4, div_read=8, vref=5.,
offset_dacs=8192, core="core"):
self.bus = dmgr.get(spi_device)
self.ldac = dmgr.get(ldac_device)
self.clr = dmgr.get(clr_device)
if ldac_device is None:
self.ldac = _DummyTTL()
else:
self.ldac = dmgr.get(ldac_device)
if clr_device is None:
self.clr = _DummyTTL()
else:
self.clr = dmgr.get(clr_device)
self.chip_select = chip_select
self.div_write = div_write
self.div_read = div_read
Expand Down Expand Up @@ -256,6 +272,8 @@ def set_dac_mu(self, values, channels=list(range(40))):
in the past. The DACs will synchronously start changing their output
levels `now`.
If no LDAC device was defined, the LDAC pulse is skipped.
See :meth load:.
:param values: list of DAC values to program
Expand Down Expand Up @@ -283,6 +301,8 @@ def set_dac(self, voltages, channels=list(range(40))):
in the past. The DACs will synchronously start changing their output
levels `now`.
If no LDAC device was defined, the LDAC pulse is skipped.
:param voltages: list of voltages to program the DAC channels to
:param channels: list of DAC channels to program. If not specified,
we program the DAC channels sequentially, starting at 0.
Expand Down

0 comments on commit 5ca5946

Please sign in to comment.