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: f64Speed setpoint at the last profile cycle, and its rate until the next one.
acc_set: f64§since_setpoint: f64Time since the profile generator last wrote the setpoints; the controller adds a base step after each.
torque_ff: f64§friction_ff: f64With 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: f64The 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: f64The position loop’s share of the speed command, Kv times the following error, held between its cycles.
feedforward_torque: f64The 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: f64What the velocity loop asks for, before the torque limit; torque_command is what the limit leaves of it.
torque_command: f64§torque_injection: f64A 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: f64Winding current and the voltage the current controller applies.
voltage: f64§power: f64Electrical power into the winding, the mean u i over the last base step; negative while the motor feeds back.
copper_loss: f64Copper loss and the power the torque gave the shaft, means over the last step like power.
shaft_power: f64§temperature_rise: f64Temperature of the winding above its surroundings.
housing_rise: f64With effects.motor_thermal_nodes: temperature of the stator and housing above the surroundings; 0 without.
d_current: f64With 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: f64The 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: f64With 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: f64With effects.iron_loss: the stator’s iron loss over the last step, W, at the speed the step started with.
emf_loss: f64With 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: f64The 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: f64With effects.braking_resistor_heating: the braking resistor’s temperature above its surroundings, K.
enable_energy: f64The 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: f64DC 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: f64With 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: f64With 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: NoiseThe drive’s own stream of sensor noise.
at_limit: boolWhether 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: PhasesA stepper’s or an induction motor’s windings and drive (Phases); unused for the servo.
Implementations§
Source§impl Drive
impl Drive
Sourcepub fn at_rest(p: &DriveParams, pos: f64, torque: f64, torque_ff: f64) -> Self
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).
Sourcepub fn winding_states(&self, p: &DriveParams) -> [f64; 7]
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.
Sourcepub fn winding_energy(&self, p: &DriveParams) -> f64
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).
Sourcepub fn magnetic_energy(&self, p: &DriveParams) -> f64
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.
Sourcepub fn detent_moved(&mut self, p: &DriveParams, before: f64)
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.
Sourcepub fn hold_current(&mut self, p: &DriveParams)
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).
pub fn encoder(&self) -> f64
pub fn mode(&self) -> DriveMode
Sourcepub fn set_mode(&mut self, mode: DriveMode)
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.
Sourcepub fn retune(&mut self)
pub fn retune(&mut self)
The next velocity loop starts its PI from the torque last asked for (see set_mode).
Sourcepub fn phase_current(&self) -> f64
pub fn phase_current(&self) -> f64
The RMS phase current: of the q current current and the d current together.
Sourcepub fn phase_voltage(&self, p: &DriveParams) -> f64
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).
Sourcepub fn thermal_current(&self, p: &DriveParams) -> f64
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).
Sourcepub fn measured_speed(&self) -> f64
pub fn measured_speed(&self) -> f64
The speed the velocity loop measured at its last cycle, filtered.
Sourcepub fn overload_nodes(&self) -> [f64; 2]
pub fn overload_nodes(&self) -> [f64; 2]
The thermal image’s nodes [slow, chips] (effects.drive_overload).
Sourcepub fn flux(&self, p: &DriveParams) -> f64
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.
Sourcepub fn shift_encoder(&mut self, by: f64)
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.
Sourcepub fn shift_setpoint(&mut self, by: f64)
pub fn shift_setpoint(&mut self, by: f64)
Moves the position setpoints by by, for a motor that was set elsewhere without turning there.
Sourcepub fn read_encoder(&mut self, p: &DriveParams, pos: f64)
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).
Sourcepub fn position_loop(&mut self, p: &DriveParams, measured: f64, cycle: f64)
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.
Sourcepub fn max_voltage(&self, p: &DriveParams) -> f64
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.
Sourcepub fn velocity_loop(&mut self, p: &DriveParams, true_speed: f64)
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.
Sourcepub fn current_control(&mut self, p: &DriveParams, speed: f64)
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.
Sourcepub fn winding_resistance(&self, p: &DriveParams) -> f64
pub fn winding_resistance(&self, p: &DriveParams) -> f64
The winding’s resistance over the next base step: at the temperature the step starts with.
Sourcepub fn winding_stepped(
&mut self,
p: &DriveParams,
current: f64,
[electrical, copper, work]: [f64; 3],
)
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.
Sourcepub fn disabled_step(&mut self, p: &DriveParams, speed: f64)
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).