---
title: Sensorless control
heading: Finding a rotor's position from the motor's own voltages and currents
eyebrow: S12 · Lesson 43 · Sensorless control
xp: 50
---

::: hook
Field-oriented control (lessons 41 and 42) needs the rotor's angle, and lesson 32's brushless motors need it to know when to switch phases. An encoder or Hall sensors provide it, but they cost money, add wires, and fail in hot or dirty places: drones, compressors, washing machines and fans mostly run **sensorless**, reading the rotor's position from the electrical behavior of the motor itself. Two signals carry it: the back-EMF, whose phase follows the rotor and whose size is proportional to speed, and the magnetic saliency of some rotors, which can be probed with a small injected signal even at standstill. Each has a speed range where it works and a reason it fails outside it.
:::

::: play
- The relative error in a back-EMF speed estimate caused by a 10% error in the assumed winding resistance, against speed, for a motor with $R$ = 0.5 Ω carrying 10 A and a flux linkage of 0.05 V·s.
- The resistance error makes a fixed voltage error, $\Delta R \cdot I$; the back-EMF grows with speed, so the relative error falls as $1/\omega$. Below a few percent of rated speed, the estimate is useless.
:::

```sim plot
view: graph
x: w = 5..1000 log
y: e = 0.1..200 log
slider: dR = 1..30 step 1 = 10
plot: dR/100*0.5*10/(0.05*w)*100 | label: speed error, %
plot: 5 + 0*w | dashed | color: ch2 | label: 5% error
readout: speed below which the error exceeds 5%, rad/s = dR/100*0.5*10/(0.05*0.05)
```

::: predict
## A brushless motor with 4 pole pairs spins at 3000 rpm in six-step commutation. How often must the controller commutate?

- [ ] Every 3.3 ms
- [x] Every 833 µs
- [ ] Every 5 ms
- [ ] Every 208 µs

::: reveal
The electrical frequency is $3000 \times 4/60$ = 200 Hz, a 5 ms electrical period, and six-step drive switches every 60 electrical degrees: $5/6$ ms = 833 µs. A sensorless controller detects each floating phase's back-EMF zero crossing and commutates 30° later, 417 µs after it.
:::
:::

::: nameit
## Back-EMF methods

A spinning permanent-magnet rotor induces a back-EMF $e = \omega\lambda_{pm}$ (electrical speed ω, flux linkage $\lambda_{pm}$) whose phase marks the rotor's position.

- **Six-step BLDC:** one phase floats in each 60° step; its terminal voltage crosses the midpoint (the back-EMF's zero) halfway through, 30° before the next commutation. Detect the crossing, wait 30°, commutate.
- **Observers for FOC:** estimate the back-EMF vector from the model, $\mathbf e = \mathbf v - R\mathbf i - L\,d\mathbf i/dt$, and take its angle; or run a flux observer, $\boldsymbol\lambda = \int(\mathbf v - R\mathbf i)\,dt$. A phase-locked loop on the estimate gives a smooth angle and speed.

All back-EMF methods fail at low speed: the EMF shrinks to zero, while errors in $R$, voltage measurement and inverter dead time stay fixed. A motor starts open-loop, ramping a rotating field until the speed is high enough for the estimator.

## Saliency methods

An interior-PM or reluctance rotor has different inductances along its d and q axes ($L_d < L_q$, typically). Injecting a high-frequency voltage $v_h$ at $\omega_h$ gives currents of size $v_h/(\omega_hL)$ that depend on the rotor's angle through the varying inductance. Demodulating them reveals the position even at standstill, at the cost of audible noise, extra loss and a sign ambiguity (north and south look alike) that a magnetic-polarity test resolves.

## Speed and position

Electrical frequency $f_e = np/60$ for $n$ rpm and $p$ pole pairs; mechanical angle is electrical angle divided by $p$.
:::

::: example
## A drone motor with 7 pole pairs runs at 12 000 rpm. Find the electrical frequency, the time between six-step commutations, and the delay from a zero crossing to the next commutation.

::: solution
1. **Electrical frequency.**
   $$\begin{aligned} f_e &= \frac{12\,000 \times 7}{60} \\ &= 1400\ \text{Hz} \end{aligned}$$
   a period of 714 µs.
2. **Time between commutations.** Commutations come every 60°: 119 µs.
3. **Zero crossing to commutation.** That's 30°: 59.5 µs.
4. **Timing resolution.** At those intervals the controller's comparator and timer resolution matter: a 10 µs error is 5° of commutation timing.

**Answer:** the electrical frequency is 1400 Hz, commutations come every 119 µs, and the next commutation follows a zero crossing by 59.5 µs.
:::
:::

::: example
## A PMSM has $\lambda_{pm}$ = 0.05 V·s and $R$ = 0.5 Ω. The controller's resistance estimate is 10% off while 10 A flows. What speed error results at 100 rad/s and at 10 rad/s (electrical)?

::: solution
1. **Voltage error.** A 10% error in 0.5 Ω, with 10 A flowing, gives
   $$0.05 \times 10 = 0.5\ \text{V}$$
2. **At 100 rad/s.** The EMF is $0.05 \times 100$ = 5 V, so the error is 10%.
3. **At 10 rad/s.** The EMF is 0.5 V, equal to the error: 100%, and the estimate is meaningless.
4. **What drives do about it.** Hence the open-loop start, and why resistance is often estimated online as the motor warms.

**Answer:** a 10% speed error at 100 rad/s, and 100% at 10 rad/s.
:::
:::

::: example
## An interior-PM motor has $L_d$ = 2 mH and $L_q$ = 5 mH. A 10 V, 1 kHz injection: what current amplitudes result along each axis?

::: solution
1. **Current along d.** With $I = v_h/(\omega_hL)$,
   $$\begin{aligned} I_d &= \frac{10}{2\pi \times 1000 \times 0.002} \\ &= 0.80\ \text{A} \end{aligned}$$
2. **Current along q.** The same with 5 mH gives 0.32 A.
3. **Reading the position.** As the rotor turns, the current response swings between these, at twice the electrical angle; the controller demodulates that variation into a position estimate.
4. **Surface-mount motors.** With $L_d = L_q$ (a surface-mount PM motor) there's no variation, and the method doesn't work.

**Answer:** 0.80 A along d and 0.32 A along q.
:::
:::

::: check
given: n = 1500 | 3000 | 12000; p = 2 | 4 | 7
answer: n*p/60
unit: Hz
tolerance: 0.5%

## A {p}-pole-pair motor spins at {n} rpm. What is its electrical frequency?

::: right
Right. $np/60$ = {answer}.
:::

::: misses
- [n/60] Multiply by the pole pairs: each mechanical turn is {p} electrical cycles.
- [n*p] Convert rpm to revolutions per second.
- [any] Not yet. $f_e = np/60$.
:::
:::

::: check
given: n = 1500 | 3000 | 12000; p = 2 | 4 | 7
answer: 60/(n*p)/6*1e6
unit: µs
tolerance: 0.5%

## In six-step drive, how often does a {p}-pole-pair motor at {n} rpm commutate?

::: right
Right. Every 60 electrical degrees: {answer}.
:::

::: misses
- [60/(n*p)*1e6] That's a whole electrical period; six-step switches six times per period.
- [60/n/6*1e6] Use the electrical period: divide by the pole pairs.
- [any] Not yet. $1/(6f_e)$.
:::
:::

::: check
given: lam = 0.02 | 0.05 | 0.1; w = 10 | 50 | 300; R = 0.2 | 0.5; I = 5 | 20; e = 5 | 10 | 20
answer: e/100*R*I/(lam*w)*100
tolerance: 0.5%

## A PMSM's flux linkage is {lam} V·s. Its resistance estimate ({R} Ω) is {e}% off with {I} A flowing. What percentage speed error results at {w} rad/s electrical?

::: right
Right. $\Delta R\,I/(\omega\lambda_{pm})$ = {answer}%.
:::

::: misses
- [e/100*R*I/lam*100] Divide by the speed too: the EMF is $\omega\lambda$.
- [any] Not yet. Voltage error over back-EMF.
:::
:::

::: check
kind: parts
given: Ld = 1 | 2 | 4; Lq = 3 | 5 | 10; v = 5 | 10; f = 0.5 | 1 | 2

## An IPM motor ($L_d$ = {Ld} mH, $L_q$ = {Lq} mH) receives a {v} V high-frequency injection at {f} kHz.

::: part
answer: v/(2*pi*f*1e3*Ld*1e-3)
unit: A
tolerance: 0.5%

### What current flows along the d axis?

::: misses
- [v/(2*pi*f*1e3*Lq*1e-3)] That's the q axis.
- [v/(f*1e3*Ld*1e-3)] Use $\omega = 2\pi f$.
- [any] Not yet. $v_h/(\omega_hL_d)$.
:::
:::

::: part
answer: Lq/Ld
tolerance: 0.5%

### What is the ratio of the d-axis current to the q-axis current?

::: misses
- [Ld/Lq] The smaller inductance passes the larger current.
- [any] Not yet. $L_q/L_d$.
:::
:::

::: right
Right. The larger that ratio, the stronger the position signal: saliency is what this method reads.
:::
:::

::: check
given: lam = 0.02 | 0.05; R = 0.3 | 1; I = 5 | 15; t = 5 | 10
answer: R*I/(t/100*lam)
unit: rad/s
tolerance: 0.5%

## A back-EMF estimator is usable once the resistive voltage {R} Ω × {I} A is at most {t}% of the EMF. Above what electrical speed is that, for a flux linkage of {lam} V·s?

::: right
Right. $\omega > RI/(t\lambda_{pm})$ = {answer}.
:::

::: misses
- [R*I/lam] Include the {t}% threshold.
- [any] Not yet. Solve $RI = (t/100)\omega\lambda$.
:::
:::

::: check
kind: choice

## Why can't a surface-mount permanent-magnet motor be tracked at standstill by high-frequency injection?

- [x] Its d- and q-axis inductances are nearly equal, so the injected current doesn't change with rotor angle
- [ ] It has no back-EMF
- [ ] Its magnets block high-frequency fields
- [ ] Injection would demagnetize it

::: right
Right. Injection reads saliency. A surface-mount rotor's magnets have about the permeability of air, so the rotor looks the same in every direction to the injected signal.
:::

::: misses
- [2] It has back-EMF when spinning, but that's the other method, and it vanishes at standstill.
- [3] The magnets are nearly transparent to the field, which is exactly the problem.
- [4] Small injections don't threaten the magnets.
:::
:::

::: check
kind: python
given: p = 2 | 4; rpm = 600 | 3000; noise = 0.02 | 0.1

## Detect zero crossings. A floating phase's back-EMF is $e(t) = E\sin(2\pi f_et)$ with $E$ = 1 V, $f_e$ from `rpm` = {rpm} and `p` = {p} pole pairs, sampled at 100 kHz for one second, plus Gaussian noise of RMS `noise` = {noise} V (`numpy.random.default_rng(1)`). Detect rising zero crossings with hysteresis: a crossing occurs when the signal rises above +0.5 V after having been below −0.5 V. Set `fe_est`, the electrical frequency from the mean interval between detected crossings, and `n_cross`, the number detected.

```python starter
import numpy as np
fe_est = rpm / 60
n_cross = 0
```

```python solution
import numpy as np
fs = 100000
fe = rpm * p / 60
t = np.arange(fs) / fs
x = np.sin(2 * np.pi * fe * t) + noise * np.random.default_rng(1).standard_normal(fs)
armed, times = False, []
for k in range(fs):
    if x[k] < -0.5:
        armed = True
    elif armed and x[k] > 0.5:
        times.append(t[k]); armed = False
n_cross = len(times)
fe_est = 1 / float(np.mean(np.diff(times)))
```

```python tests
import numpy as np
fe = rpm * p / 60
assert abs(fe_est - fe) < 0.005 * fe, f"The electrical frequency is {fe:.1f} Hz."
assert abs(n_cross - round(fe)) <= 1, "There should be about one rising crossing per electrical period."
```

::: right
Right. Hysteresis keeps noise from causing false crossings, at the price of a small, consistent delay that the controller compensates.
:::
:::

::: explain
## A sensorless ceiling-fan controller sometimes fails to start under load, spinning backward briefly or stalling, though it runs perfectly once moving. Explain why, and how the starting sequence handles it.

::: model
Back-EMF sensorless control needs the rotor to be turning: at standstill there's no EMF to detect, and at very low speed it's buried under resistive drops, noise and inverter dead-time errors. The controller therefore starts open-loop: it aligns the rotor by energizing one phase, then ramps a rotating field at increasing frequency, hoping the rotor follows, and switches to closed-loop sensorless control once the EMF is large enough. Under load, or with the wrong alignment, the rotor may lag too far behind the ramp and slip, stall or jerk backward, and the switchover happens with a wrong position estimate. Fixes include a longer alignment, a slower ramp with more current, detecting the initial position by inductance probing (if there's any saliency), or adding a cheap Hall sensor for starting only.
:::
:::

::: practice

::: check
given: n = 900 | 6000; p = 3 | 5
answer: n*p/60
unit: Hz
tolerance: 0.5%

## What is the electrical frequency of a {p}-pole-pair motor at {n} rpm?

::: misses
- [n/60] Multiply by the pole pairs.
- [any] $np/60$.
:::
:::

::: check
given: v = 3 | 20; f = 0.4 | 4; L = 1.5 | 8
answer: v/(2*pi*f*1e3*L*1e-3)
unit: A
tolerance: 0.5%

## What current does a {v} V, {f} kHz injection drive through {L} mH?

::: misses
- [v/(f*1e3*L*1e-3)] Use $2\pi f$.
- [any] $v/(\omega L)$.
:::
:::
:::
