pub struct DriveParams {Show 64 fields
pub kv: f64,
pub kp: f64,
pub ki: f64,
pub velocity_ff: f64,
pub torque_ff: f64,
pub kt: f64,
pub resistance: f64,
pub ke: f64,
pub max_voltage: f64,
pub fundamental_gain: f64,
pub current_kp: f64,
pub current_ki: f64,
pub current_cycle: f64,
pub peak_torque: f64,
pub rated_torque: f64,
pub rated_speed: f64,
pub no_load_speed: f64,
pub max_speed: f64,
pub limit: bool,
pub encoder_step: f64,
pub speed_from_positions: bool,
pub velocity_filter: f64,
pub torque_filter: f64,
pub notch: Option<[f64; 5]>,
pub velocity_cycle: f64,
pub current_delay: usize,
pub velocity_delay: usize,
pub inductance: f64,
pub pole_pairs: f64,
pub heating: bool,
pub rated_rise: f64,
pub housing_max_rise: f64,
pub rated_current: f64,
pub thermal_time_constant: f64,
pub start_rise: f64,
pub saturation: f64,
pub max_current: f64,
pub drive_max_current: f64,
pub dc_link: bool,
pub shared_dc_link: bool,
pub bus_voltage: f64,
pub dc_capacitance: f64,
pub braking_threshold: f64,
pub resistor_peak: f64,
pub overvoltage: f64,
pub discharge_time_constant: f64,
pub regenerative: bool,
pub line_max_power: f64,
pub line_efficiency: f64,
pub encoder_noise: f64,
pub current_noise: f64,
pub noise_seed: u64,
pub field_weakening: Option<FieldWeakening>,
pub overload: Option<Overload>,
pub thermal_nodes: Option<ThermalNodes>,
pub iron_loss_rated: f64,
pub iron_drag_rated: f64,
pub stall_current: f64,
pub static_torque: f64,
pub s1_curve: Vec<[f64; 2]>,
pub magnet_coefficient: f64,
pub resistor_heating: Option<ResistorHeating>,
pub precontrol: Precontrol,
pub motor: Motor,
}Fields§
§kv: f64§kp: f64§ki: f64§velocity_ff: f64Feedforward weights; 0 when switched off.
torque_ff: f64§kt: f64Motor winding: torque per current and resistance (the inductance is below).
resistance: f64§ke: f64Back-EMF per speed; 0 when switched off. The torque constant unless drive.back_emf_constant_v_s_rad gives
another (the maker’s printed voltage constant, in the one winding’s scale: sqrt(3) times the line-to-line one).
max_voltage: f64Highest voltage at the winding, WINDING_PER_DC_LINK times the DC link voltage; infinite when the
limit is switched off.
fundamental_gain: f64drive.overmodulation: the fundamental of the six-step (square) wave over the sinusoidal limit, else 1: 2 sqrt 3 / pi
= 1.1027 for the three-phase bridge of a servo or induction motor, 4 / pi for a stepper’s H-bridges. The model then
carries the fundamental only, without the square wave’s harmonics (and their loss). dc_gain is it times
WINDING_PER_DC_LINK.
current_kp: f64Current controller gains, and its cycle (the base step).
current_ki: f64§current_cycle: f64§peak_torque: f64§rated_torque: f64What the motor can give continuously: the limit for the RMS torque of a cycle.
rated_speed: f64§no_load_speed: f64§max_speed: f64The highest speed the motor may turn at, drive.max_speed_rad_s (the catalogue’s mechanical or inverter limit);
the no-load speed where the config leaves it out. The time-optimal plan keeps within it (path), “motor-speed”
judges a cycle against it where the config gives it, and check_limits warns of axis limits beyond it.
limit: bool§encoder_step: f64Encoder step in rad; 0 for an ideal encoder.
speed_from_positions: boolThe velocity loop’s speed is the encoder’s difference per cycle (a real encoder: encoder_step or
encoder_noise above 0), else the true speed. Its own field so that the loop measurement can take the rounding
and the noise away and keep the difference (Controller::unrounded_encoders).
velocity_filter: f64Low-pass gains per velocity cycle; 1 when the filter is off.
torque_filter: f64§notch: Option<[f64; 5]>§velocity_cycle: f64§current_delay: usizeCycles between computing a value and it acting: of the current loop for the voltage, of the velocity loop for the torque setpoint. 0 when the delay is switched off.
velocity_delay: usize§inductance: f64Winding inductance, for the winding’s time constant once its resistance changes with temperature.
pole_pairs: f64Pole pairs motor.pole_pairs, where the config has them (0 where it has none): the electrical speed w L i of the
servo winding’s reactance takes the q axis’s voltage (current_control, voltage_limited_current).
heating: boolHeating of the winding: whether it is on, the temperature rise at the rated current, the rated current, the thermal time constant and the rise the simulation starts with.
rated_rise: f64§housing_max_rise: f64The housing’s highest rise, K (ratings.housing_max_rise_k; absent: rated_rise), what the utilisation chart holds
its rise against.
rated_current: f64§thermal_time_constant: f64§start_rise: f64§saturation: f64Saturation: the share of the torque constant lost at the maximum current; 0 when switched off.
max_current: f64§drive_max_current: f64effects.drive_current_limit: the drive’s maximum output current, ratings.drive_max_current_a, A. The torque
setpoint is held to the torque of this current (torque_range), as the drive holds its current setpoint.
Infinite with the effect off or without the rating.
dc_link: boolDC link with a braking chopper: whether it is simulated, the voltage the rectifier holds, the capacitance, the voltage at which the chopper switches the braking resistor in, the most the resistor takes, and the voltage at which the drive trips.
The drives of the machine share one DC link (shared_dc_link); only with dc_link.
bus_voltage: f64§dc_capacitance: f64§braking_threshold: f64§resistor_peak: f64§overvoltage: f64§discharge_time_constant: f64Time constant R C with which a disabled drive’s DC link discharges through its bleeder and the drive’s own consumption, down to the bus level the rectifier holds.
regenerative: boolRegenerative supply (regenerative_supply, only with dc_link): above the bus level the line module feeds
the DC link’s energy back into the mains, up to line_max_power, of which line_efficiency arrives there.
line_max_power: f64§line_efficiency: f64§encoder_noise: f64Sensor noise, as standard deviations: on the measured position in rad and on the measured current. 0 when switched off.
current_noise: f64§noise_seed: u64§field_weakening: Option<FieldWeakening>effects.field_weakening: the winding as the q axis of a d-q model, with a d current (FieldWeakening).
overload: Option<Overload>effects.drive_overload: the drive’s thermal image, which lowers its current limit (Overload).
thermal_nodes: Option<ThermalNodes>effects.motor_thermal_nodes: winding and housing as two heat capacities (ThermalNodes); without it one.
iron_loss_rated: f64effects.iron_loss: hysteresis and eddy-current loss in the stator iron at the rated speed, W (iron_loss_at), and
the stall current motor.stall_current_a, at which the copper loss alone brings the winding to its rated rise.
The iron loss is what the copper loss at the rated speed leaves of that, R (I_0^2 - I_N^2): Siemens’ rated and
static data both hold for the rated rise. 0 and the rated current with the effect off. This is the speed losses’
heat as the winding feels it, in copper-loss watts (iron_heating), not the power they take from the shaft
(iron_drag_rated): on the 144 1FK7/1FT7 rows with a printed resistance the printed torque gap (k_t I_N - M_N)
times the rated speed is a median 2.9 times it, and the printed efficiency’s losses beyond copper side with the gap
(median 0.75 of it, 2.3 times this): iron and bearings heat the winding less than its own copper does.
iron_drag_rated: f64effects.iron_loss, a servo: the drag torque of the speed losses at the rated speed, N m (iron_drag): what the
printed rated point leaves of the torque constant times the rated current, k_t I_N (with saturation) - M_N, less
the shaft friction the model has of its own there (motor.friction_* with effects.motor_friction), at least 0;
so the shaft gives the printed rated torque at the rated current and speed. 0 with the effect off.
stall_current: f64§static_torque: f64The static torque k_t I_0 of the S1 curve, from motor.stall_current_a whether or not effects.iron_loss is on; 0
where the config has no stall current (s1_torque).
s1_curve: Vec<[f64; 2]>The S1 curve the config prints (motor.s1_curve_speed_rad_s, motor.s1_curve_torque_nm) as (speed, torque) points,
speeds rising; empty where it has none (s1_torque then takes the straight line).
magnet_coefficient: f64effects.magnet_temperature: the magnets’ flux per kelvin, motor.magnet_temperature_coefficient_1_k (negative); the
torque constant and back-EMF are the catalogue’s at the rated rise and change with it (Drive::flux). 0 off.
resistor_heating: Option<ResistorHeating>effects.braking_resistor_heating: the braking resistor’s temperature (ResistorHeating); None without.
precontrol: PrecontrolFine interpolation, the torque feedforward’s model, friction feedforward and balancing (Precontrol).
motor: Motormotor.kind: the motor the drive turns (Motor); the servo motor this module models by default.
Implementations§
Source§impl DriveParams
impl DriveParams
Sourcepub fn from_config(
cfg: &Config,
dt: f64,
velocity_cycle: f64,
) -> Result<Self, ConfigError>
pub fn from_config( cfg: &Config, dt: f64, velocity_cycle: f64, ) -> Result<Self, ConfigError>
dt is the base step, which is also the current-loop cycle.
Sourcepub fn torque_range(&self, speed: f64) -> (f64, f64)
pub fn torque_range(&self, speed: f64) -> (f64, f64)
Torque limits (lowest, highest) at a speed: the current limit everywhere, and in the direction of rotation the torque-speed curve that the voltage limit leaves. With the drive’s current limit (effects.drive_current_limit) also the torque of the drive’s maximum current, where that is the lower: the current setpoint, the torque’s, then stays within min(motor, drive maximum current).
Sourcepub fn torque_range_at(&self, speed: f64, max_voltage: f64) -> (f64, f64)
pub fn torque_range_at(&self, speed: f64, max_voltage: f64) -> (f64, f64)
torque_range with the winding getting max_voltage at most (the DC link’s at the moment, Drive::max_voltage).
Sourcepub fn dc_gain(&self) -> f64
pub fn dc_gain(&self) -> f64
The winding’s voltage limit per DC link voltage: WINDING_PER_DC_LINK, times fundamental_gain.
Sourcepub fn iron_loss_at(&self, speed: f64) -> f64
pub fn iron_loss_at(&self, speed: f64) -> f64
effects.iron_loss: the iron loss at a speed, iron_loss_rated times (|speed| / rated speed)^1.5: hysteresis grows
with the frequency, eddy currents with its square. One exponent stands for both parts: no maker prints the split.
This is the heat the winding’s thermal model takes (Drive::iron_loss, iron_heating); the power the shaft loses
to the same losses follows the same law from the printed torque gap (iron_drag).
Sourcepub fn iron_drag(&self, speed: f64) -> f64
pub fn iron_drag(&self, speed: f64) -> f64
effects.iron_loss: the drag torque of the speed losses on a servo’s shaft, against the motion: iron_drag_rated at
the rated speed and P(w) / w with P = c |w|^1.5 over speed, written T_N w |w|^-0.5 / w_N^0.5 so that it is smooth
through 0 (0 at standstill, no sign jump). The shaft gets the air-gap torque less this, so shaft power = air-gap
power - this loss, with the drive disabled too.
Sourcepub fn resistance_at(&self, rise: f64) -> f64
pub fn resistance_at(&self, rise: f64) -> f64
Winding resistance at a temperature rise.
Sourcepub fn torque_of(&self, current: f64) -> f64
pub fn torque_of(&self, current: f64) -> f64
Torque of a current: the torque constant, less what saturation takes at high current.
Sourcepub fn current_for(&self, torque: f64) -> f64
pub fn current_for(&self, torque: f64) -> f64
The current that gives a torque, the inverse of torque_of, up to the maximum current. Newton’s
method from below: the curve bends down, so every step stays below the answer and none overshoots.
Sourcepub fn back_emf(&self, current: f64, speed: f64) -> f64
pub fn back_emf(&self, current: f64, speed: f64) -> f64
Back-EMF at a current and speed. The torque constant that saturation leaves is the back-EMF constant too, so that the electrical power is the shaft power plus the copper loss.
Sourcepub fn winding_rates(
&self,
voltage: f64,
resistance: f64,
current: f64,
speed: f64,
d_current: f64,
flux: f64,
) -> [f64; 4]
pub fn winding_rates( &self, voltage: f64, resistance: f64, current: f64, speed: f64, d_current: f64, flux: f64, ) -> [f64; 4]
The winding’s rates at a moment of a base step, for the integrator (Sim::step), with the voltage and the
resistance held over the step: [di/dt, electrical power u i, copper loss R i^2, shaft power torque w]. With
the back-EMF on, u i = R i^2 + L i di/dt + torque w at every moment, so the winding’s energy closes.
With field weakening the d current d_current is held over the step as the controller set it (FieldWeakening):
it adds w L_d i_d to what the q axis meets, u_d i_d to the electrical power, R i_d^2 to the copper loss and the
reluctance torque to the shaft. u_q i_q + u_d i_d = R (i_q^2 + i_d^2) + L i_q di_q/dt + torque w still closes.
With effects.iron_loss the shaft power is the air-gap power less the iron loss (iron_drag w): what the electrical
power leaves beyond copper, stored energy and shaft power is Drive::emf_loss, which then holds the iron loss.
flux scales the torque constant and the back-EMF for the magnets’ temperature (Drive::flux, 1 without
effects.magnet_temperature).
Sourcepub fn torque_with(&self, current: f64, d_current: f64, flux: f64) -> f64
pub fn torque_with(&self, current: f64, d_current: f64, flux: f64) -> f64
Torque of a q current and a d current: torque_of times the magnets’ flux, plus the reluctance torque pole
pairs (L_d - L_q) i_d i_q with field weakening.
Sourcepub fn d_current_for(
&self,
q: f64,
speed: f64,
max_voltage: f64,
limit: f64,
resistance: f64,
flux: f64,
) -> f64
pub fn d_current_for( &self, q: f64, speed: f64, max_voltage: f64, limit: f64, resistance: f64, flux: f64, ) -> f64
The d current the drive sets for a q current at a speed with the voltage max_voltage: none while
u_q^2 + u_d^2 (steady, FieldWeakening) stays within it, else the least negative one that brings it there, at
most limit. Where none does, the one that needs the least voltage. 0 without field weakening. With the winding’s
resistance at its temperature and the magnets’ flux (Drive::flux), as the winding has them.
The back-EMF is the unsaturated k_E w: the drive’s own model of the motor, which the winding’s saturated back-EMF
(back_emf) undercuts, so the d current leaves a voltage reserve (at most the saturation’s share of the
back-EMF: 11 % at the maximum current of the test motor, 17 % for the 1FK2106-6AF). Taken saturated (tried
17 November 2026) the steady point sits on the voltage circle, where braking beyond the curve is unstable: the q
voltage that the circle leaves falls as the braking current rises (u_d = R i_d - w L i_q grows), faster than R and
the back-EMF’s fall hold it; the test motor at 400 rad/s and -3.8 N m ran away to 18.8 A of its 9.5 A
(braking_at_the_voltage_limit_does_not_run_away). The torque-speed curve takes the same model, so it is what the
drive reaches: 3.6 % below the saturated optimum at 380 rad/s there (3.3255 against 3.4514 N m).
Sourcepub fn voltage_limited_current(
&self,
speed: f64,
umax: f64,
motoring: bool,
) -> f64
pub fn voltage_limited_current( &self, speed: f64, umax: f64, motoring: bool, ) -> f64
Without field weakening: the largest current magnitude the voltage umax leaves at a speed of at least 0, within the
motor’s maximum current, steady and cold. The q axis meets e = kE speed (motoring: R i + e; braking: e - R i) and
the d axis the reactance x i, x = p speed L (current_control): (R i + e)^2 + (x i)^2 <= U^2, so with
a = R^2 + x^2 and b = +-R e the root of a i^2 + 2 b i + e^2 - U^2 = 0, i = (-b + sqrt(b^2 - a (e^2 - U^2))) / a.
Without reactance that is (U - e) / R motoring and (U + e) / R braking.
Braking above the speed where e alone exceeds U the same circle is solved, for the braking current i against e:
(e - R i)^2 + (x i)^2 <= U^2, an interval of currents [forced_braking_current, the root returned here]; the
smaller one is what the inverter’s diodes force at a speed the voltage cannot hold (the uncontrolled generator).
Where the circle leaves none (x e > sqrt(a) U) the nearest current is returned, the circle’s closest approach R e / a.
Sourcepub fn forced_braking_current(&self, speed: f64, umax: f64) -> f64
pub fn forced_braking_current(&self, speed: f64, umax: f64) -> f64
Braking above the speed where the back-EMF alone exceeds umax: the smallest braking current the voltage circle
(e - R i)^2 + (x i)^2 <= U^2 leaves, the one the rectifier diodes force, i = (R e - sqrt(a U^2 - x^2 e^2)) / a with
a = R^2 + x^2; the nearest current R e / a where the circle leaves none. 0 while e <= U (nothing is forced).
Sourcepub fn settled_rise(&self, rms_current: f64, iron_loss: f64) -> f64
pub fn settled_rise(&self, rms_current: f64, iron_loss: f64) -> f64
The temperature rise the winding settles at when a cycle with this RMS current and this mean iron loss (effects.iron_loss, W) repeats for long: the copper loss, with the resistance at that temperature, against the loss at the rated current (with the iron loss, at the stall current), plus the iron loss’s share. That share is all of it with one thermal node, and with effects.motor_thermal_nodes the housing’s, 1 - s: the iron is in the stator.
Sourcepub fn rated_loss(&self) -> f64
pub fn rated_loss(&self) -> f64
The copper loss at which the winding settles at its rated rise: at the stall current with effects.iron_loss (the iron loss is apart), else at the rated current, which then stands for both.
Sourcepub fn s1_torque(&self, speed: f64) -> f64
pub fn s1_torque(&self, speed: f64) -> f64
The S1 torque at a speed, as the motor-s1 verdict has it (analysis::s1_torque) and the torque-speed chart draws it:
s1_line from the static torque k_t I_0 (motor.stall_current_a, read with effects.iron_loss off too); flat at the
rated torque where the config has no stall current.
Sourcepub fn iron_heating(&self, loss: f64) -> f64
pub fn iron_heating(&self, loss: f64) -> f64
A loss in the rise it would settle at alone, K: rated rise per rated_loss.
Sourcepub fn torque_curve(&self, speed: f64) -> (f64, f64)
pub fn torque_curve(&self, speed: f64) -> (f64, f64)
The same limits, whether or not the limit is switched on: what the motor and drive can give.
With field weakening the curve is the d-q model’s (FieldWeakening), up to the peak torque; without it the
torque fades out linearly between the rated and the no-load speed.
Sourcepub fn torque_curve_at(&self, speed: f64, max_voltage: f64) -> (f64, f64)
pub fn torque_curve_at(&self, speed: f64, max_voltage: f64) -> (f64, f64)
torque_curve with the winding getting max_voltage at most. Without field weakening the fade’s two speeds
scale with it against max_voltage (the back-EMF the voltage leaves room for).
Sourcepub fn voltage_limited_torque(&self, speed: f64, dc_voltage: f64) -> (f64, f64)
pub fn voltage_limited_torque(&self, speed: f64, dc_voltage: f64) -> (f64, f64)
The torque (lowest, highest) the winding’s voltage leaves at a speed with a DC link of dc_voltage, within the
motor’s maximum current, steady and cold, whether or not the limit is switched on: the voltage-limit curve of the
torque-speed chart. With field weakening the d-q model’s (torque_curve’s, before the peak torque caps it);
without it the winding has no d current, but its reactance is there: the steady voltage vector is
(R i + kE speed, p speed L i) and the limit (R i + kE speed)^2 + (p speed L i)^2 <= U^2 in the direction of motion
(voltage_limited_current; the pole pairs motor.pole_pairs, none without them: R i + kE speed <= U).
Sourcepub fn motor_rates(
&self,
d: &Drive,
w: &[f64],
angle: f64,
speed: f64,
rates: &mut [f64],
) -> f64
pub fn motor_rates( &self, d: &Drive, w: &[f64], angle: f64, speed: f64, rates: &mut [f64], ) -> f64
The rates of drive d’s electrical states w (WINDING_STATES, as Drive::winding_states gives them) at a
moment of a base step, with the rotor at angle and speed at the motor, into rates; returns the motor torque.
The servo’s are winding_rates and torque_with.
Trait Implementations§
Source§impl Clone for DriveParams
impl Clone for DriveParams
Source§fn clone(&self) -> DriveParams
fn clone(&self) -> DriveParams
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more