From cff85ee13b0f144d420745921b8accaa80efcb0f Mon Sep 17 00:00:00 2001 From: Robert Jordens Date: Thu, 22 Feb 2018 23:08:50 +0100 Subject: [PATCH] novogorny: simplify and fix coefficient --- artiq/coredevice/novogorny.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/artiq/coredevice/novogorny.py b/artiq/coredevice/novogorny.py index f5d3911fd..8892073af 100644 --- a/artiq/coredevice/novogorny.py +++ b/artiq/coredevice/novogorny.py @@ -47,20 +47,19 @@ def adc_value(data, v_ref=5.): """Convert a ADC result packet to SI units (Volt)""" softspan = adc_softspan(data) data = adc_data(data) + g = 625 if softspan & 4: - g3 = 2 - else: - g3 = 1 + g *= 2 if softspan & 2: - g2 = 1 << 15 + h = 1 << 15 else: - g2 = 1 << 16 + h = 1 << 16 + data = -(data & h) + (data & ~h) if softspan & 1: - g1 = 1000 + h *= 500 else: - g1 = 1023 - data = -(data & g2) + (data & ~g2) - v_per_lsb = v_ref*(1250*g3)/(g1*g2) + h *= 512 + v_per_lsb = v_ref*g/h return data*v_per_lsb