Skip to main content

Drive

Struct Drive 

Source
pub struct Drive {
Show 45 fields pub pos_set: f64, pub vel_set: f64, pub acc_set: f64, pub since_setpoint: f64, pub torque_ff: f64, pub friction_ff: f64, pub position_setpoint: f64, pub following_error: f64, pub position_part: f64, pub feedforward_torque: f64, pub controller_torque: f64, pub speed_command: f64, pub torque_demand: f64, pub torque_command: f64, pub torque_injection: f64, pub torque: f64, pub current: f64, pub voltage: f64, pub power: f64, pub copper_loss: f64, pub shaft_power: f64, pub temperature_rise: f64, pub housing_rise: f64, pub d_current: f64, pub d_voltage: f64, pub overload_image: f64, pub overload_chip: f64, pub overloaded: bool, pub iron_loss: f64, pub emf_loss: f64, pub torque_hold: f64, pub resistor_rise: f64, pub enable_energy: f64, pub dc_voltage: f64, pub resistor_power: f64, pub tripped: bool, pub rectifier_power: f64, pub mains_power: f64, pub line_loss: f64, pub discharge_power: f64, pub noise: Noise, pub at_limit: bool, pub fault_speed: Option<f64>, pub pulses_off: bool, pub phases: Phases, /* private fields */
}
Expand description

The loops and filters of one drive.

Fields§

§pos_set: f64§vel_set: f64

Speed setpoint at the last profile cycle, and its rate until the next one.

§acc_set: f64§since_setpoint: f64

Time since the profile generator last wrote the setpoints; the controller adds a base step after each.

§torque_ff: f64§friction_ff: f64

With drive.friction_feedforward_model = "machine" (Precontrol::machine_friction): the friction the machine’s own model has at the planned speed (Machine::steady_friction), written with the setpoints; 0 otherwise.

§position_setpoint: f64

The setpoint the position loop compared with at its last cycle: pos_set run on between profile cycles (Precontrol::fine_interpolation) and balanced (Precontrol::balance_time). following_error is from it.

§following_error: f64§position_part: f64

The position loop’s share of the speed command, Kv times the following error, held between its cycles.

§feedforward_torque: f64

The velocity loop’s output at its last cycle in its two parts, before filters and limits: the feedforward (torque_ff weighted, and friction) and the PI controller’s.

§controller_torque: f64§speed_command: f64§torque_demand: f64

What the velocity loop asks for, before the torque limit; torque_command is what the limit leaves of it.

§torque_command: f64§torque_injection: f64

A test signal added to what the velocity loop asks for, before the limit: the loop is measured by it (analysis::velocity_loop_response). Zero otherwise.

§torque: f64§current: f64

Winding current and the voltage the current controller applies.

§voltage: f64§power: f64

Electrical power into the winding, the mean u i over the last base step; negative while the motor feeds back.

§copper_loss: f64

Copper loss and the power the torque gave the shaft, means over the last step like power.

§shaft_power: f64§temperature_rise: f64

Temperature of the winding above its surroundings.

§housing_rise: f64

With effects.motor_thermal_nodes: temperature of the stator and housing above the surroundings; 0 without.

§d_current: f64

With effects.field_weakening: the d current, held over the base step like the voltage; 0 without. It follows the setpoint the drive works out (DriveParams::d_current_for) as the tuned current loop does, with the time constant L_d / Kp (the controller’s Tn = L / R cancels the winding’s own), exactly per step. The RMS phase current is the hypotenuse of it and current (phase_current).

§d_voltage: f64

The servo winding’s d-axis voltage the current loop set with voltage (current_control), in the winding’s units; 0 for the other motors and while disabled. phase_voltage is the vector of both.

§overload_image: f64

With effects.drive_overload: the drive’s thermal image (Overload), both nodes together, the chips’ node alone, and whether it has lowered its current limit to the base load current.

§overload_chip: f64§overloaded: bool§iron_loss: f64

With effects.iron_loss: the stator’s iron loss over the last step, W, at the speed the step started with.

§emf_loss: f64

With a back-EMF constant other than the torque constant (DriveParams::ke): the electrical power the winding takes beyond the copper loss, the winding’s stored energy and the shaft power over the last step, (kE - kt) i w, W. It is booked as a loss of its own in the energy budget (the magnets’ and iron’s, which the maker’s two constants differ by); signed, as i w is. 0 for equal constants, a stepper and an induction motor.

§torque_hold: f64

The torque the machine’s rigid model needs to hold the planned pose, where the feedforward is the constant inertia (drive.torque_feedforward_model = "inertia": no gravity in torque_ff) and the torque-band monitor is on, plus with that monitor, on a machine that does not report its friction torque, the friction at the planned speed (fault::Settings::torque_band); 0 otherwise. What the monitor expects beside torque_ff (fault::Watch::check).

§resistor_rise: f64

With effects.braking_resistor_heating: the braking resistor’s temperature above its surroundings, K.

§enable_energy: f64

The energy L i^2 / 2 a drive enabled without the DC link simulated put into its winding (Control::hold_here): drawn from the supply in the first step, booked there with the step’s electrical power.

§dc_voltage: f64

DC link voltage, the power the braking resistor burns, and whether the drive has tripped on overvoltage. With the DC link switched off the voltage stays at the bus level.

§resistor_power: f64§tripped: bool§rectifier_power: f64

With the DC link simulated: the power drawn from the line for the DC link, and with the regenerative supply the power fed back into the mains, over the last step; and what the line module lost either way (ratings.line_module_efficiency: of what it draws, the efficiency arrives in the DC link).

§mains_power: f64§line_loss: f64§discharge_power: f64

With the DC link simulated and the drive off: what its discharge through the bleeder took out of the DC link over the last step, as a mean power (the rectifier draws it back while the link is held at the bus level).

§noise: Noise

The drive’s own stream of sensor noise.

§at_limit: bool

Whether the velocity loop’s output was beyond the torque limit at its last cycle (fault::Watch).

§fault_speed: Option<f64>

While the drive stops on a fault (fault::Reaction): the speed setpoint of its stop ramp, which the velocity loop follows without the position loop and without feedforward. And once its pulses are off: no voltage, no current, no torque, while the others may still be stopping.

§pulses_off: bool§phases: Phases

A stepper’s or an induction motor’s windings and drive (Phases); unused for the servo.

Implementations§

Source§

impl Drive

Source

pub fn at_rest(p: &DriveParams, pos: f64, torque: f64, torque_ff: f64) -> Self

A drive at rest at pos, already delivering torque (so a hanging axis does not sag at start).

Source

pub fn winding_states(&self, p: &DriveParams) -> [f64; 7]

The electrical states this drive’s winding starts a base step with, in the order of WINDING_STATES.

Source

pub fn winding_energy(&self, p: &DriveParams) -> f64

The magnetic energy in the winding: L i^2 / 2 for the servo and the stepper (both phases), the induction motor’s own (induction::Induction::stored_energy).

Source

pub fn magnetic_energy(&self, p: &DriveParams) -> f64

The energy stored in the drive’s field, winding_energy. A stepper’s detent potential is not stored: its changes are booked as they happen (detent_moved), so that it neither appears nor vanishes at an enable or a disable.

Source

pub fn detent_moved(&mut self, p: &DriveParams, before: f64)

A stepper’s base step done with the rotor from before to phases.angle: the detent’s work is in the shaft’s, and what the magnets gave for it, the change of Stepper::detent_potential, is the step’s emf_loss (exact, the torque being conservative). Nothing for the other motors.

Source

pub fn hold_current(&mut self, p: &DriveParams)

The current loop holding its current at rest: the voltage R i, with the winding’s resistance at its temperature, in its integrator, its output and its delay. Before 14 November 2026 the cold resistance, so a winding started or enabled warm began with a voltage step of (R(rise) - R) i (found by the closed-loop reference written in Python for one belt axis, see docs/validation.md).

Source

pub fn encoder(&self) -> f64

Source

pub fn mode(&self) -> DriveMode

Source

pub fn set_mode(&mut self, mode: DriveMode)

Switches the operating mode. A change between position, velocity and torque mode does not make the torque jump where the drive’s own loops take over: the next velocity loop sets the PI integrator so that it asks for the torque it asked for last (retune). Into torque mode the outside setpoint acts at once, and the integrator is held meanwhile; a jump there is the outside controller’s.

Source

pub fn retune(&mut self)

The next velocity loop starts its PI from the torque last asked for (see set_mode).

Source

pub fn phase_current(&self) -> f64

The RMS phase current: of the q current current and the d current together.

Source

pub fn phase_voltage(&self, p: &DriveParams) -> f64

motor.<id>.voltage, one meaning for every motor: the amplitude of the phase voltage’s space vector, V. The induction motor’s and the stepper’s vectors are phase amplitudes already (voltage); the servo’s one winding has three times the RMS phase voltage in each axis, so its vector (q voltage, d d_voltage) is multiplied by sqrt 2 / 3 (the DC link’s sqrt(3/2) U gives U / sqrt 3).

Source

pub fn thermal_current(&self, p: &DriveParams) -> f64

The current that heats the winding as the step’s copper loss does, against DriveParams::stall_current: the phase current; for an induction motor, whose rotor is heated too, sqrt(copper loss / R_s).

Source

pub fn measured_speed(&self) -> f64

The speed the velocity loop measured at its last cycle, filtered.

Source

pub fn overload_nodes(&self) -> [f64; 2]

The thermal image’s nodes [slow, chips] (effects.drive_overload).

Source

pub fn flux(&self, p: &DriveParams) -> f64

The magnets’ flux against the catalogue’s (effects.magnet_temperature): 1 + coefficient (rise - rated rise), the catalogue’s torque constant holding at the rated rise. The magnets sit in the rotor next to the stator: at the housing’s rise with effects.motor_thermal_nodes, else at the winding’s. 1 without the effect or without winding heating (the motor then stands at its rated rise throughout). shortcut: the rotor has no temperature of its own; give it a node if magnet heating by eddy currents matters.

Source

pub fn shift_encoder(&mut self, by: f64)

Moves the encoder’s readings so far by by, for a motor that was set elsewhere without turning there.

Source

pub fn shift_setpoint(&mut self, by: f64)

Moves the position setpoints by by, for a motor that was set elsewhere without turning there.

Source

pub fn read_encoder(&mut self, p: &DriveParams, pos: f64)

Reads the motor encoder: the position as it reports it, with its noise, in whole counts. Once per base step in which a loop is due, so that the position and the velocity loop see the same sample (encoder).

Source

pub fn position_loop(&mut self, p: &DriveParams, measured: f64, cycle: f64)

Position loop, every cycle: following error times Kv against the position setpoint (position_setpoint), with the measured position measured: the motor encoder’s (encoder) or a load-side one’s.

Source

pub fn max_voltage(&self, p: &DriveParams) -> f64

The voltage limit of the winding: what the DC link has at this moment with effects.dc_link, else the nominal one.

Source

pub fn velocity_loop(&mut self, p: &DriveParams, true_speed: f64)

Velocity loop: PI on the measured speed (from read_encoder), plus torque feedforward, then filters and limits.

Source

pub fn current_control(&mut self, p: &DriveParams, speed: f64)

Current loop: PI on the winding current. The voltage it sets is held over the next base step, in which the integrator takes the winding through it (DriveParams::winding_rates); then winding_stepped.

Source

pub fn winding_resistance(&self, p: &DriveParams) -> f64

The winding’s resistance over the next base step: at the temperature the step starts with.

Source

pub fn winding_stepped( &mut self, p: &DriveParams, current: f64, [electrical, copper, work]: [f64; 3], )

The base step done: the integrator has taken the winding through it (DriveParams::winding_rates) and left the current at its end and the electrical energy, the copper loss and the work on the shaft over it. Then the DC link of its own and the winding’s heating.

Source

pub fn disabled_step(&mut self, p: &DriveParams, speed: f64)

A base step with the drive disabled: no current, no torque. The winding cools and the DC link discharges through its bleeder, a shared one once all drives have had this step (shared_dc_link).

A current still in the winding when the pulses stop freewheels through the inverter’s diodes into the DC link, against its voltage: it is gone within microseconds, well inside the step, and its energy L i^2 / 2 goes to the DC link (as power fed back over this step; without the DC link simulated, back to the supply).

speed is the rotor’s, at the motor: a turning rotor has its iron loss and drag with the drive off (effects.iron_loss, DriveParams::iron_drag): torque is the drag, the shaft takes -drag w and the same power is heat in the iron (iron_loss; and emf_loss, the budget’s row for it).

Trait Implementations§

Source§

impl Clone for Drive

Source§

fn clone(&self) -> Drive

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 Debug for Drive

Source§

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

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

impl Default for Drive

Source§

fn default() -> Drive

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Drive

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Drive

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl Freeze for Drive

§

impl RefUnwindSafe for Drive

§

impl Send for Drive

§

impl Sync for Drive

§

impl Unpin for Drive

§

impl UnsafeUnpin for Drive

§

impl UnwindSafe for Drive

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.