Skip to content

Sensorless Motor Observers

Pulsim v1.5 ships two sensorless rotor observers — algorithms that estimate the rotor electrical angle and mechanical speed from stator voltages and currents alone, without any shaft encoder. Both follow the standard MixedDomainBlockChain block interface (.reset() + .update(*, ...) → tuple).

Why sensorless?

Industrial AC drives almost universally avoid the shaft encoder: - One less cable, one less point of failure. - No mechanical alignment / hall-sensor placement. - Cheaper BOM, smaller footprint. - A sealed shaft (no encoder feed-through) handles harsh environments.

Modern variable-frequency drives use sensorless control above ~10 % rated speed; the low-speed window is bridged by V/f-ramp startup or high-frequency-injection (HFI) variants — both queued for future Pulsim releases.

Available observers

SlidingModeObserver — for PMSM

Algorithm (Utkin §10 / TI InstaSPIN SPRABQ8):

  1. Sliding-mode current observer in α-β: $\(\frac{d\hat{i}_\alpha}{dt} = \frac{1}{L_s}\left(v_\alpha - R_s\hat{i}_\alpha - z_\alpha\right)\)$ \(z = K_{sl}\cdot\text{sat}(\hat{i} - i, \varepsilon)\) — saturating-sign injection.

  2. Equivalent-control LPF extracts the back-EMF estimate \(\hat{e}\) from \(z\).

  3. Angle PLL drives the d-axis projection of \(\hat{e}\) to zero; outputs \(\hat{\theta}_e\) and \(\hat{\omega}_e\) directly (the d-component \(\hat{e}_\alpha\cos\hat{\theta} + \hat{e}_\beta\sin\hat{\theta}\) equals \(-E\sin(\theta_e - \hat{\theta})\), a clean Goodwin-style phase detector).

FluxMRASObserver — for induction motor

Algorithm (Schauder 1992, with Tajima-Hori 1993 leaky-integrator enhancement):

  1. Reference model — voltage-driven rotor-flux estimate \(\psi_r^{\text{ref}}\) via \(\int(v - R_s i - \sigma L_s\,di/dt)\,(L_r/L_m)\,dt\). Pulsim replaces the pure integrator with a low-cutoff leaky integrator (default cutoff voltage_model_hpf_omega = 5 rad/s ≈ 0.8 Hz) to reject the DC drift that would otherwise blow up under any input bias.

  2. Adaptive model — current-driven (uses \(\hat{\omega}\)).

  3. Adaptation loop — Lyapunov-derived PI on the cross-product \(\epsilon = \psi_\beta^{\text{ref}}\hat{\psi}_\alpha - \psi_\alpha^{\text{ref}}\hat{\psi}_\beta\).

Quick start — PMSM SMO

import pulsim as p

smo = p.SlidingModeObserver(
    Rs=0.5, Ls=200e-6,
    K_sl=20.0,           # > peak back-EMF voltage
    f_init_hz=50.0,      # initial PLL guess (close to nominal helps)
    omega_lpf=2*math.pi*2000.0,
)

# Each step:
theta_hat, omega_hat, e_a, e_b, low_speed_flag = smo.update(
    v_alpha=v_a, v_beta=v_b,
    i_alpha=i_a, i_beta=i_b,
    dt=DT,
)

End-to-end runnable example: examples/scripts/run_pmsm_smo_sensorless.py. Synthetic 200 rad/s mechanical (800 rad/s electrical) trace; SMO locks the angle within 4.2° peak / 4.2° RMS after a 50 ms lock-in window, \(\hat{\omega}\) matches \(\omega_{e,\text{true}}\) to 7 sig figs.

Quick start — IM MRAS

import pulsim as p

# Either explicit:
mras = p.FluxMRASObserver(
    Rs=2.46, Ls=0.0948, Lr=0.0948, Lm=0.0874, Rr=1.23,
    voltage_model_hpf_omega=5.0,
    Kp_mras=10.0, Ki_mras=500.0,
)

# Or pulled from an existing motor handle:
mras = p.FluxMRASObserver.from_motor(motor)

omega_hat, psi_alpha_adj, psi_beta_adj = mras.update(
    v_alpha=v_a, v_beta=v_b,
    i_alpha=i_a, i_beta=i_b,
    dt=DT,
)

Closed-loop showcases

Both run a MixedDomainBlockChain of built-in blocks around an MNA-native machine fed by ideal voltage sources (no PWM); the controller reads only shunt drops and terminal voltages. Their printed claims are checked by python/tests/test_examples_claims.py (PULSIM_RUN_EXAMPLES=1).

examples/scripts/run_pmsm_foc_sensorless_smo.py — PMSM FOC with the SMO angle in the Park transforms: start-up, a 50 % load step, a +25 % → −25 % reversal. Below 10 % rated the drive runs I-f (a 5 A current vector turned at the reference) and hands over to the SMO above, bumpless both ways; a small script block (the supervisor) holds that rule. Measured: angle error ≤ 4.51° on every sensorless sample (≤ 0.61° from 10 ms after a hand-over); the SMO's angle error exceeds 18.2° only at |ω| ≤ 7.5 % rated, inside the I-f window. The start assumes the rotor parked at θ_e = 0; from θ_e = 160° the I-f start fails (measured). The hand-overs keep the angle but not the torque: the undamped I-f start leaves the rotor swinging (41.2 rad/s at a 31.4 rad/s reference at the first hand-over) and the true torque moves by up to 55 % rated.

examples/scripts/run_im_ifoc_sensorless_mras.py — IM indirect FOC with the MRAS speed in place of the encoder (the slip still comes from the current model), an I-f start, a hand-over at 5 % ± 1 % rated (below the lowest plateau), a 50 % load, plateaus at 10/25/50/75/100 % rated. Measured: speed-estimate error ≤ 0.834 % rated on every sensorless sample; rotor-flux angle within 9.41° of the commanded d axis.

Low speed: what the observers cannot do

Both read the back-EMF, which is zero at standstill: no setting fixes that. Measured limits and the rule each showcase uses:

lost below showcase rule
SMO (PMSM) angle error > 18.2° at |ω| ≤ 7.5 % rated I-f below 10 % rated
MRAS (IM) not measured below the hand-over I-f below 5 % ± 1 % rated

Default gains: where they come from

  • SMO PLL. The phase detector reads E·sin(θ_e − θ̂) with E = pp·ψ·|ω_m| in volts, so the loop is s² + E·Kp_pll·s + E·Ki_pll: ω_n = √(E·Ki_pll), ζ = Kp_pll·√E / (2·√Ki_pll). The defaults (Kp_pll = 200, Ki_pll = 1e4) give ω_n = 100 rad/s, ζ = 1 at E = 1 V; the bandwidth grows with √E, i.e. with the speed. K_sl must exceed the peak back-EMF so the sliding surface is reached; omega_lpf trades the angle lag atan(ω_e/ω_lpf) against chatter.
  • MRAS. With the normalised error ε = sin δ (δ the angle between the two flux estimates) and dδ/dt ≈ ω − ω̂ (the adaptive flux turns at ω̂ plus the slip, the reference at ω plus the slip), the loop is s² + Kp_mras·s + Ki_mras: ω_n = √Ki_mras, ζ = Kp_mras/(2·√Ki_mras). The defaults (50, 1e3) give 31.6 rad/s, ζ = 0.79; the IM showcase uses (200, 1e4): 100 rad/s, ζ = 1.

Tuning guide

SMO (PMSM)

Knob Default When to adjust
K_sl 50 V Set to ~ 2 × peak back-EMF. Higher = faster lock, more chatter.
omega_lpf 500 Hz ~10 × rated electrical frequency. Higher = less LPF delay, more noise pass-through.
Kp_pll 200 PI on the phase error. Increase if lock-in is too slow.
Ki_pll 1e4 Integral gain — PLL bandwidth ≈ √Ki.
epsilon 0.5 A Boundary-layer width for tanh(). Smaller = closer to bang-bang sign.
f_init_hz 50 Hz Initial PLL frequency guess. Match to nominal motor frequency for faster lock.
low_speed_threshold 0.05 V Back-EMF magnitude under which the low_speed_flag output goes True.
compensate_lpf_lag False Add atan(ω̂/ω_lpf) back to the angle output (the LPF lag: 11.3° at 1257 rad/s with a 1 kHz filter).

MRAS (IM)

Knob Default When to adjust
Rr 0.0 → falls back to 0.5·Rs heuristic Strongly recommended to set explicitly via from_motor(). Wrong Rr → proportional speed offset.
voltage_model_hpf_omega 5 rad/s Set to 0 for pure integrator (original Schauder). Increase if voltage-model drift dominates; decrease for cleaner low-frequency tracking.
filter_adaptive_model False Apply the reference model's leaky-integrator filter to the adaptive flux too, so its phase cancels; needed at low stator frequency (3.7 % → 0.30 % rated speed error at 10 % speed in the showcase).
Kp_mras, Ki_mras 50, 1e3 PI gains for the cross-product → \(\hat{\omega}\) loop. Lyapunov-derived; retune per-machine if oscillation.

Failure modes (honest catalog)

  • SMO at very low speed — back-EMF magnitude collapses toward K_sl, observer can lose lock. Use the low_speed_flag output to hand off to a V/f startup ramp (industry standard).
  • SMO at negative speed (fixed 2026-11-30) — the back-EMF E = pp·ψ·ω carries the speed's sign, and (E, θ) and (−E, θ+π) give the same estimate; the angle output was 180° off at negative speed. It now adds π when the PLL frequency is negative, in the Python block and in the YAML chain's C++ adapter (sliding_mode_observer), which also takes the compensate_lpf_lag / filter_adaptive_model keys.
  • MRAS at low speed — voltage-model integration drifts because \(R_s i_s\) becomes comparable to the integrand; the leaky-integrator mitigates but does not eliminate this.
  • MRAS bootstrap with \(\hat{\omega} = 0\) — the adaptive-model rotor-flux magnitude stays near zero until \(\hat{\omega}\) is in the neighbourhood of \(\omega_e^{\text{true}}\), so the cross-product error is dominated by amplitude mismatch instead of phase. Practical implementations bootstrap with a V/f-ramp open-loop start, then hand over to the closed-loop MRAS after ~10 % rated speed.
  • Parameter mismatch (Rs, Lr, Lm, Rr) — all observers are parametric. Plant-parameter drift (temperature, magnetic saturation) shows up as a steady-state speed/angle offset. PSIM / PLECS workarounds include real-time parameter adaptation; not yet shipped in Pulsim.

See also

  • Induction Motors, with the MNA-native PMSM, BLDC and induction machines (add_pmsm_mna, add_bldc_mna, add_induction_machine_mna).
  • python/pulsim/observers.py — source.
  • openspec/changes/archive/2026-11-30-add-sensorless-motor-observers/ — proposal + spec.