Merge pull request #228 from matthuszagh/lockin-bin
Lock-in integration testing
This commit is contained in:
commit
147b0a6982
|
@ -17,7 +17,7 @@ pub type Complex<T> = (T, T);
|
||||||
/// Shifted and rounded value.
|
/// Shifted and rounded value.
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn shift_round(x: i32, shift: usize) -> i32 {
|
pub fn shift_round(x: i32, shift: usize) -> i32 {
|
||||||
(x + (1 << (shift - 1))) >> shift
|
x.saturating_add(1 << (shift - 1)) >> shift
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Integer division, round up half.
|
/// Integer division, round up half.
|
||||||
|
|
|
@ -62,18 +62,26 @@ impl TimestampHandler {
|
||||||
self.reference_frequency = frequency as u32 as i64;
|
self.reference_frequency = frequency as u32 as i64;
|
||||||
}
|
}
|
||||||
|
|
||||||
let demodulation_frequency = divide_round(
|
let demodulation_frequency: u32;
|
||||||
1 << (32 + self.adc_sample_ticks_log2),
|
let demodulation_initial_phase: u32;
|
||||||
self.reference_frequency,
|
|
||||||
) as u32;
|
if self.reference_frequency == 0 {
|
||||||
let demodulation_initial_phase = divide_round(
|
demodulation_frequency = u32::MAX;
|
||||||
(((self.batch_index as i64)
|
demodulation_initial_phase = u32::MAX;
|
||||||
<< (self.adc_sample_ticks_log2
|
} else {
|
||||||
+ self.sample_buffer_size_log2))
|
demodulation_frequency = divide_round(
|
||||||
- self.reference_phase)
|
1 << (32 + self.adc_sample_ticks_log2),
|
||||||
<< 32,
|
self.reference_frequency,
|
||||||
self.reference_frequency,
|
) as u32;
|
||||||
) as u32;
|
demodulation_initial_phase = divide_round(
|
||||||
|
(((self.batch_index as i64)
|
||||||
|
<< (self.adc_sample_ticks_log2
|
||||||
|
+ self.sample_buffer_size_log2))
|
||||||
|
- self.reference_phase)
|
||||||
|
<< 32,
|
||||||
|
self.reference_frequency,
|
||||||
|
) as u32;
|
||||||
|
}
|
||||||
|
|
||||||
if self.batch_index
|
if self.batch_index
|
||||||
< (1 << (32
|
< (1 << (32
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1019,9 +1019,9 @@ const APP: () = {
|
||||||
|
|
||||||
// shift cos/sin before multiplying to avoid i64 multiplication
|
// shift cos/sin before multiplying to avoid i64 multiplication
|
||||||
signal.0 =
|
signal.0 =
|
||||||
adc_samples[0][i] as i16 as i32 * shift_round(cos, 16);
|
|
||||||
signal.1 =
|
|
||||||
adc_samples[0][i] as i16 as i32 * shift_round(sin, 16);
|
adc_samples[0][i] as i16 as i32 * shift_round(sin, 16);
|
||||||
|
signal.1 =
|
||||||
|
adc_samples[0][i] as i16 as i32 * shift_round(cos, 16);
|
||||||
|
|
||||||
signal.0 =
|
signal.0 =
|
||||||
iir_lockin.update(&mut iir_state_lockin[0], signal.0);
|
iir_lockin.update(&mut iir_state_lockin[0], signal.0);
|
||||||
|
|
Loading…
Reference in New Issue