pounder_test/stabilizer/src/pounder/rf_power.rs

21 lines
743 B
Rust
Raw Normal View History

use super::{Error, Channel};
2020-06-09 00:20:10 +08:00
2020-06-11 17:51:52 +08:00
/// Provide an interface to measure RF input power in dB.
2020-06-09 00:20:10 +08:00
pub trait PowerMeasurementInterface {
fn sample_converter(&mut self, channel: Channel) -> Result<f32, Error>;
2020-06-09 00:20:10 +08:00
2020-06-11 17:51:52 +08:00
/// Measure the power of an inpu channel in dB.
///
/// Note: This function assumes the input channel is connected to an AD8363 output.
///
/// Args:
/// * `channel` - The pounder channel to measure the power of.
fn measure_power(&mut self, channel: Channel) -> Result<f32, Error> {
2020-06-09 00:20:10 +08:00
let analog_measurement = self.sample_converter(channel)?;
// The AD8363 with VSET connected to VOUT provides an output voltage of 51.7mV / dB at
// 100MHz.
Ok(analog_measurement / 0.0517)
}
}