Skip to main content

Pid

Struct Pid 

Source
pub struct Pid {
    pub kp: f64,
    pub ki: f64,
    pub kd: f64,
    pub n: f64,
}
Expand description

Parallel PID with a filtered derivative term, using the standard P, I, D, N (filter coefficient) parameterization common to block-diagram continuous-time controller blocks:

$$C(s) = K_p + \frac{K_i}{s} + \frac{K_d N s}{s + N}$$

The pure-derivative term Kd*s alone is not realizable as a proper (causal) transfer function, hence the filter pole at -N — a standard, universally-used approximation (a larger N tracks the ideal derivative more closely but stiffens the resulting ODE).

This struct is the compiled gain set only — see general_mna::block_graph::BlockKind::Pid for the netlist-facing component reference (parameters, errors, netlist form, example) and the anti-windup behavior, which lives at the block-graph evaluation layer, not here.

Fields§

§kp: f64

Proportional gain.

§ki: f64

Integral gain.

§kd: f64

Derivative gain.

§n: f64

Derivative filter coefficient; the filter pole sits at -n. Must be > 0 — see Pid::new.

Implementations§

Source§

impl Pid

Source

pub fn new(kp: f64, ki: f64, kd: f64, n: f64) -> Result<Self, PidError>

Source

pub fn to_transfer_function(&self) -> TransferFunction

Puts C(s) over the common denominator s*(s+N):

C(s) = [(Kp+Kd*N)*s^2 + (Kp*N+Ki)*s + Ki*N] / [s^2 + N*s]

Derived by hand before implementation (see docs/architecture.md’s Milestone 5 note): with Kd=0 this numerator factors exactly as (s+N)(Kp*s+Ki), so the filter pole/zero cancel and the closed-loop step response of the resulting state-space realization reduces to the ideal PI response y(t) = Kp + Ki*t for every t, not just asymptotically — tests/step_responses.rs checks exactly this.

Source

pub fn to_state_space(&self) -> StateSpace

Trait Implementations§

Source§

impl Clone for Pid

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 Pid

Source§

impl Debug for Pid

Source§

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

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

impl PartialEq for Pid

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 Pid

Auto Trait Implementations§

§

impl Forget for Pid

§

impl Freeze for Pid

§

impl Move for Pid

§

impl RefUnwindSafe for Pid

§

impl Send for Pid

§

impl Sync for Pid

§

impl Unpin for Pid

§

impl UnsafeUnpin for Pid

§

impl UnwindSafe for Pid

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.