From 6e94ffc13881527c757298aade412e65e719d526 Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Fri, 7 May 2021 14:23:03 +0200 Subject: [PATCH] Update src/hardware/dac.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Robert Jördens --- src/hardware/dac.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hardware/dac.rs b/src/hardware/dac.rs index 3afa06c..3df70e8 100644 --- a/src/hardware/dac.rs +++ b/src/hardware/dac.rs @@ -82,7 +82,7 @@ impl Into for DacCode { // the output stage is +/- 10.24 V. At a DAC code of zero, there is an output of -10.24 V, // and at a max DAC code, there is an output of (slightly less than) 10.24 V. - let dac_volts_per_lsb = 10.24 * 2.0 / u16::MAX as f32; + let dac_volts_per_lsb = 4.096 * 2.5 / (1u16 << 15) as f32; // Note that the bipolar table is an offset-binary code, but it is much more logical and // correct to treat it as a twos-complement value. TO do that, we XOR the most significant