tekhsi_rs 0.1.1

High-performance client for Tektronix TekHSI enabled oscilloscopes
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
const POWER_EPS: f64 = 1e-18;

pub(super) fn vrms_from_vpeak(v_peak: f64) -> f64 {
    // For a sinusoid, Vrms = Vpeak / sqrt(2).
    v_peak / std::f64::consts::SQRT_2
}

pub(super) fn dbm_from_vrms(v_rms: f64, impedance_ohms: f64) -> f64 {
    // Convert Vrms into power over the load and express it in dBm.
    if impedance_ohms <= 0.0 {
        return f64::NEG_INFINITY;
    }
    let power = (v_rms * v_rms) / impedance_ohms;
    10.0 * (power / 1e-3).max(POWER_EPS).log10()
}