pounder_test/src/hardware/pounder/rf_power.rs

23 lines
860 B
Rust
Raw Normal View History

2020-06-16 22:22:12 +08:00
use super::{Channel, Error};
2020-06-09 00:20:10 +08:00
2021-05-26 22:09:26 +08:00
/// Provide an interface to measure RF input power in dBm.
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
/// Measure the power of an input channel in dBm.
2020-06-11 17:51:52 +08:00
///
/// Args:
2021-05-26 22:09:26 +08:00
/// * `channel` - The pounder input channel to measure the power of.
///
/// Returns:
/// Power in dBm after the digitally controlled attenuator before the amplifier.
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)?;
2021-05-26 22:09:26 +08:00
// The AD8363 with VSET connected to VOUT provides an output voltage of 51.7 mV/dB at
// 100MHz with an intercept of -58 dBm.
// It is placed behind a 20 dB tap.
Ok(analog_measurement * (1. / 0.0517) + (-58. + 20.))
2020-06-09 00:20:10 +08:00
}
}