forked from M-Labs/artiq
1
0
Fork 0

sampler: unroll conversion for speed

This commit is contained in:
Robert Jördens 2018-05-14 08:41:19 +00:00
parent d71e4e60a9
commit 4993ceec35
1 changed files with 10 additions and 4 deletions

View File

@ -23,10 +23,16 @@ def adc_mu_to_volt(data, gain=0):
:param gain: PGIA gain setting (0: 1, ..., 3: 1000)
:return: Voltage in Volts
"""
input_span = 20.
for i in range(gain):
input_span /= 10.
volt_per_lsb = input_span/(1 << 16)
if gain == 0:
volt_per_lsb = 20./(1 << 16)
elif gain == 1:
volt_per_lsb = 2./(1 << 16)
elif gain == 2:
volt_per_lsb = .2/(1 << 16)
elif gain == 3:
volt_per_lsb = .02/(1 << 16)
else:
raise ValueError("invalid gain")
return data*volt_per_lsb