lockin: let the lowpass do all filtering

This commit is contained in:
Robert Jördens 2021-02-18 14:29:47 +01:00
parent 07b7751dbc
commit f050ba8e9f
2 changed files with 6 additions and 6 deletions

View File

@ -118,12 +118,12 @@ const APP: () = {
.zip(Accu::new(sample_phase, sample_frequency)) .zip(Accu::new(sample_phase, sample_frequency))
// Convert to signed, MSB align the ADC sample, update the Lockin (demodulate, filter) // Convert to signed, MSB align the ADC sample, update the Lockin (demodulate, filter)
.map(|(&sample, phase)| { .map(|(&sample, phase)| {
let s = (sample as i16 as i32) let s = (sample as i16 as i32) << (15 + 1);
<< (15 - design_parameters::SAMPLE_BUFFER_SIZE_LOG2 + 1);
lockin.update(s, phase, time_constant) lockin.update(s, phase, time_constant)
}) })
// Decimate // Decimate
.sum(); .last()
.unwrap();
let conf = "frequency_discriminator"; let conf = "frequency_discriminator";
let output = match conf { let output = match conf {

View File

@ -101,12 +101,12 @@ const APP: () = {
.zip(Accu::new(sample_phase, sample_frequency)) .zip(Accu::new(sample_phase, sample_frequency))
// Convert to signed, MSB align the ADC sample, update the Lockin (demodulate, filter) // Convert to signed, MSB align the ADC sample, update the Lockin (demodulate, filter)
.map(|(&sample, phase)| { .map(|(&sample, phase)| {
let s = (sample as i16 as i32) let s = (sample as i16 as i32) << (15 + 1);
<< (15 - design_parameters::SAMPLE_BUFFER_SIZE_LOG2 + 1);
lockin.update(s, phase, time_constant) lockin.update(s, phase, time_constant)
}) })
// Decimate // Decimate
.sum(); .last()
.unwrap();
for value in dac_samples[1].iter_mut() { for value in dac_samples[1].iter_mut() {
*value = (output.arg() >> 16) as u16 ^ 0x8000; *value = (output.arg() >> 16) as u16 ^ 0x8000;