wavemeter: decimate wavelength output
This commit is contained in:
parent
c48a30bb9b
commit
9a6cccaf4a
@ -40,7 +40,9 @@ struct Config {
|
|||||||
position_mon_time: f64, // The time during which position is monitored to compute min/max
|
position_mon_time: f64, // The time during which position is monitored to compute min/max
|
||||||
duty_cycle: f64, // Fraction of the scan used for counting input laser fringes
|
duty_cycle: f64, // Fraction of the scan used for counting input laser fringes
|
||||||
|
|
||||||
|
debug: bool, // Enable debug output of wavelength determination code
|
||||||
motion_cutoff: f64, // Cut-off frequency of the motion filter
|
motion_cutoff: f64, // Cut-off frequency of the motion filter
|
||||||
|
decimation: u32, // Decimation/averaging factor for the final wavelength output
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_config_from_file<P: AsRef<Path>>(path: P) -> Result<Config, Box<dyn Error>> {
|
fn read_config_from_file<P: AsRef<Path>>(path: P) -> Result<Config, Box<dyn Error>> {
|
||||||
@ -145,6 +147,7 @@ fn do_wavemeter(config: &Config) {
|
|||||||
|
|
||||||
let mut first_fringe = 0;
|
let mut first_fringe = 0;
|
||||||
let mut fringe_count = 0;
|
let mut fringe_count = 0;
|
||||||
|
let mut decimator = noptica::Decimator::new(config.decimation);
|
||||||
|
|
||||||
noptica::sample(&config.sample_command, |rising, _falling| {
|
noptica::sample(&config.sample_command, |rising, _falling| {
|
||||||
refpll.tick(rising & (1 << config.bit_ref) != 0);
|
refpll.tick(rising & (1 << config.bit_ref) != 0);
|
||||||
@ -176,13 +179,19 @@ fn do_wavemeter(config: &Config) {
|
|||||||
}
|
}
|
||||||
if !in_duty & prev_in_duty {
|
if !in_duty & prev_in_duty {
|
||||||
let wavelength = (fringe_position - first_fringe).abs()/fringe_count;
|
let wavelength = (fringe_position - first_fringe).abs()/fringe_count;
|
||||||
|
let wavelength_nm = (wavelength as f64)/(noptica::Dpll::TURN as f64)*1.0e9*config.ref_wavelength;
|
||||||
|
if config.debug {
|
||||||
let displacement = ((fringe_position - first_fringe).abs() as f64)/(noptica::Dpll::TURN as f64)*config.ref_wavelength;
|
let displacement = ((fringe_position - first_fringe).abs() as f64)/(noptica::Dpll::TURN as f64)*config.ref_wavelength;
|
||||||
println!("{:.4} {} {} {:.1}",
|
println!("DEBUG: {:.4} {} {} {:.1}",
|
||||||
(wavelength as f64)/(noptica::Dpll::TURN as f64)*1.0e9*config.ref_wavelength,
|
wavelength_nm,
|
||||||
fringe_count,
|
fringe_count,
|
||||||
if fringe_position > first_fringe { "UP " } else { "DOWN" },
|
if fringe_position > first_fringe { "UP " } else { "DOWN" },
|
||||||
1.0e9*displacement);
|
1.0e9*displacement);
|
||||||
|
}
|
||||||
fringe_count = 0;
|
fringe_count = 0;
|
||||||
|
if let Some(wavelength_nm) = decimator.input(wavelength_nm) {
|
||||||
|
println!("{:.4} nm", wavelength_nm);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fringe_count += 1;
|
fringe_count += 1;
|
||||||
prev_in_duty = in_duty;
|
prev_in_duty = in_duty;
|
||||||
|
@ -15,5 +15,7 @@
|
|||||||
"position_mon_time": 0.25,
|
"position_mon_time": 0.25,
|
||||||
"duty_cycle": 0.9,
|
"duty_cycle": 0.9,
|
||||||
|
|
||||||
"motion_cutoff": 100e3
|
"debug": false,
|
||||||
|
"motion_cutoff": 100e3,
|
||||||
|
"decimation": 50
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user