2020-06-16 22:22:12 +08:00
|
|
|
use super::{Channel, Error};
|
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 {
|
2020-06-10 18:40:44 +08:00
|
|
|
fn sample_converter(&mut self, channel: Channel) -> Result<f32, Error>;
|
2020-06-09 00:20:10 +08:00
|
|
|
|
2020-06-11 19:39:12 +08:00
|
|
|
/// Measure the power of an input channel in dBm.
|
2020-06-11 17:51:52 +08:00
|
|
|
///
|
|
|
|
/// Note: This function assumes the input channel is connected to an AD8363 output.
|
|
|
|
///
|
|
|
|
/// Args:
|
2020-06-11 19:39:12 +08:00
|
|
|
/// * `channel` - The pounder channel to measure the power of in dBm.
|
2020-06-10 18:40:44 +08:00
|
|
|
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
|
2020-06-11 19:39:12 +08:00
|
|
|
// 100MHz. It also indicates a y-intercept of -58dBm.
|
|
|
|
Ok(analog_measurement / 0.0517 - 58.0)
|
2020-06-09 00:20:10 +08:00
|
|
|
}
|
|
|
|
}
|