From a8f0ee1c86534839e32c6cbc72bdf4f580e752d0 Mon Sep 17 00:00:00 2001 From: Robert Jordens Date: Sat, 24 Mar 2018 15:45:42 +0100 Subject: [PATCH] ad53xx: refactor offset_to_mu(), fix docs --- artiq/coredevice/ad53xx.py | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/artiq/coredevice/ad53xx.py b/artiq/coredevice/ad53xx.py index a07c28794..b3393c0eb 100644 --- a/artiq/coredevice/ad53xx.py +++ b/artiq/coredevice/ad53xx.py @@ -69,28 +69,17 @@ def ad53xx_cmd_read_ch(channel, op): @portable -def voltage_to_mu(voltage, offset_dacs=8192, vref=5.): +def voltage_to_mu(voltage, offset_dacs=0x2000, vref=5.): """Returns the DAC register value required to produce a given output voltage, assuming offset and gain errors have been trimmed out. - :param voltage: Voltage - :param offset_dacs: Register value for the two offset DACs (default - :0x1555) - :param vref: DAC reference voltage (default: 5.) - """ - return int(round(0x10000*(voltage/(4.*vref)) + offset_dacs*0x4)) - - -@portable -def offset_to_mu(voltage, offset_dacs=8192, vref=5.): - """Returns the offset register value required to produce a given voltage - when the DAC register is set to mid-scale. - + Also used to return offset register value required to produce a given + voltage when the DAC register is set to mid-scale. An offset of V can be used to trim out a DAC offset error of -V. - :param voltage: Offset voltage - :param offset_dacs: Register value for the two offset DACs (default - :0x1555) + :param voltage: Voltage + :param offset_dacs: Register value for the two offset DACs + (default: 0x2000) :param vref: DAC reference voltage (default: 5.) """ return int(round(0x10000*(voltage/(4.*vref)) + offset_dacs*0x4)) @@ -219,8 +208,8 @@ class AD53xx: :param voltage: the offset voltage """ - self.write_offset_mu(channel, offset_to_mu(voltage, self.offset_dacs, - self.vref)) + self.write_offset_mu(channel, voltage_to_mu(voltage, self.offset_dacs, + self.vref)) @kernel def write_dac_mu(self, channel, value):