Skip to main content

Vco

Struct Vco 

Source
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: f64

Implementations§

Source§

impl Vco

Source

pub fn new(f_min: f64, f_max: f64) -> Result<Self, VcoError>

Source

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).

Trait Implementations§

Source§

impl Clone for Vco

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Vco

Source§

impl Debug for Vco

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Vco

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Vco

Auto Trait Implementations§

§

impl Forget for Vco

§

impl Freeze for Vco

§

impl RefUnwindSafe for Vco

§

impl Send for Vco

§

impl Sync for Vco

§

impl Unpin for Vco

§

impl UnsafeUnpin for Vco

§

impl UnwindSafe for Vco

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.