From f050ba8e9f8a8cd2b20f31fdbdad76fddea23fea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20J=C3=B6rdens?= Date: Thu, 18 Feb 2021 14:29:47 +0100 Subject: [PATCH] lockin: let the lowpass do all filtering --- src/bin/lockin-external.rs | 6 +++--- src/bin/lockin-internal.rs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/bin/lockin-external.rs b/src/bin/lockin-external.rs index b3b9d4f..f24f251 100644 --- a/src/bin/lockin-external.rs +++ b/src/bin/lockin-external.rs @@ -118,12 +118,12 @@ const APP: () = { .zip(Accu::new(sample_phase, sample_frequency)) // Convert to signed, MSB align the ADC sample, update the Lockin (demodulate, filter) .map(|(&sample, phase)| { - let s = (sample as i16 as i32) - << (15 - design_parameters::SAMPLE_BUFFER_SIZE_LOG2 + 1); + let s = (sample as i16 as i32) << (15 + 1); lockin.update(s, phase, time_constant) }) // Decimate - .sum(); + .last() + .unwrap(); let conf = "frequency_discriminator"; let output = match conf { diff --git a/src/bin/lockin-internal.rs b/src/bin/lockin-internal.rs index 6913f0a..393130e 100644 --- a/src/bin/lockin-internal.rs +++ b/src/bin/lockin-internal.rs @@ -101,12 +101,12 @@ const APP: () = { .zip(Accu::new(sample_phase, sample_frequency)) // Convert to signed, MSB align the ADC sample, update the Lockin (demodulate, filter) .map(|(&sample, phase)| { - let s = (sample as i16 as i32) - << (15 - design_parameters::SAMPLE_BUFFER_SIZE_LOG2 + 1); + let s = (sample as i16 as i32) << (15 + 1); lockin.update(s, phase, time_constant) }) // Decimate - .sum(); + .last() + .unwrap(); for value in dac_samples[1].iter_mut() { *value = (output.arg() >> 16) as u16 ^ 0x8000;