pub struct Vco {
pub f_min: f64,
pub f_max: f64,
}Expand description
A voltage-controlled oscillator: given a frequency command (Hz, clamped to [f_min, f_max]), outputs a repeating ramp in [0, 1) — the same standard block block-diagram
simulation tools provide (their own “VCO”/“Repeating Sequence” blocks), used here to build a
frequency-modulated PWM carrier. LLC-family resonant converters regulate by switching
frequency, not duty, unlike buck/boost, which is why this block exists alongside Pid
rather than folding frequency modulation into Pid or into dae-runtime directly — a
closed loop wires Sum -> Pid -> Gain -> Vco as separate, independently reusable blocks,
the same way a real block-diagram tool would, rather than one function that hardcodes the
whole topology.
Deliberately not a crate::StateSpace: the wraparound is a genuine discontinuity a
linear system can’t express, the same reason crate::math_ops::saturation is evaluated
directly rather than folded into one. Composing freq = f_nom + k*control is the caller’s
job (chain a crate::math_ops::gain block, or a Sum with a constant, ahead of this
one) — this block’s only responsibility is the oscillator itself.
Fields§
§f_min: f64§f_max: f64Implementations§
Source§impl Vco
impl Vco
pub fn new(f_min: f64, f_max: f64) -> Result<Self, VcoError>
Sourcepub fn step(&self, phase: f64, freq_command: f64, dt: f64) -> f64
pub fn step(&self, phase: f64, freq_command: f64, dt: f64) -> f64
Advances the oscillator by one step. phase is the previous step’s output (in [0, 1), the block’s own state), freq_command this step’s input (Hz, clamped internally
to [f_min, f_max]), dt the step size. Returns the new phase, also in [0, 1).