Contents — find the section you need

Change parameters and verify

Open the panel, then press Run to load Python. You can stop execution and reset parameters. Results are computed on this device. No Python installation is required.

Local execution steps below are optional for reproducing the source results; they are not required for the browser experiment.

Open experiment panel in a new tab

Download reproduction source

Background and reading guide

Background PID, current/voltage and basic inverters.

Fundamentals · Follow the worked examples and checks under the stated conditions.

Explore current coordinates and electrical angle

The panel above is a one-instant coordinate exercise. Supply actual current components in the true rotor frame, mechanical angle, pole-pair count, an electrical-angle error, and a hypothetical torque constant. It constructs balanced phase currents and transforms them back using the supplied estimated angle. These are imposed currents, not current references tracked by a controller. No motor, inverter or local Python is required.

The convention is explicit: α aligns with phase a; β is +90° counterclockwise from α. The true d axis follows rotor flux at θe=p θm, with fixed zero offset 0; q leads d by +90°. Positive angles are counterclockwise. p counts pole pairs, not poles. The display includes unwrapped electrical angle and its modulo-360° direction. Four pole pairs and 90° mechanical angle give 360° electrical angle, equivalent to 0° for the transforms. Changing p here changes the angle mapping only; the separately supplied torque constant stays fixed.

We use amplitude-invariant Clarke normalization with zero sequence fixed to zero. With R(θ)=[[cosθ,−sinθ],[sinθ,cosθ]], first form [iα,iβ]=R(θe)[id,iq]. Generate ia=iα, ib=−iα/2+√3 iβ/2, ic=−iα/2−√3 iβ/2. Thus ia+ib+ic=0. Clarke recovers iα=(2/3)(ia−ib/2−ic/2) and iβ=(ib−ic)/√3. These are instantaneous signed amperes, not phase RMS values. This amplitude normalization is not power invariant: ia²+ib²+ic²=(3/2)(id²+iq²).

The estimated angle is θ̂e=θe+Δθe. Park computes [id̂,iq̂]=R(θ̂e)ᵀ[iα,iβ]. Consequently id̂=id cosΔ+iq sinΔ and iq̂=−id sinΔ+iq cosΔ. At true id=0, iq=3 A and error +90°, the displayed estimated components become id̂=3 A, iq̂≈0. The original phase currents stay the same when only this angle error changes. The diagram shows the same stationary current vector with true and estimated axes; axis-arrow lengths are illustrative and do not encode current. All current scales are shared across A/B.

The inverse uses the same estimated angle: [iα′,iβ′]=R(θ̂e)[id̂,iq̂], then the same inverse Clarke equations. The maximum absolute reconstructed-phase difference should be small even at an incorrect angle. This residual measures algebraic consistency and floating-point roundoff; it cannot establish encoder alignment, sensor accuracy or a working FOC loop. Presets compare +/−90° errors, 180° error, mixed d/q current, zero current, negative q current, and electrical-angle wrapping. A zero vector hides every angle error.

A separate simplified nonsalient PMSM relation gives Te=Kt × true iq. Default Kt=0.10 N m/A and iq=3 A give 0.30 N m. Kt is defined for this amplitude-invariant peak-dq convention and includes the motor-specific conversion; it is not a phase-RMS constant to substitute blindly. The model omits reluctance torque and assumes constant flux. Angle error changes the displayed components but does not change imposed current or modeled torque. A real feedback loop using the wrong angle may change currents; that behavior is not simulated. Nonzero d current is a coordinate example, not a field-weakening or current-limit recommendation.

No PI control, PWM, DC-bus limits, voltage equations, speed dynamics, saliency, field weakening, sensor noise, heating, protection or hardware operation is modeled. Inputs are synthetic teaching assumptions. Use the separate PID Lab for controller behavior and the reducer Lab for mechanical transmission arithmetic.

Reference reviewed 2026-09-20: TI PMSM FOC report, sections 4–5. This exercise states its normalization and sign convention directly; it does not reproduce the report's motor-control implementation.

A drive cannot directly set mechanical speed. It creates voltage, changes winding current and magnetic field, then produces torque that changes rotation. Field-oriented control (FOC) uses coordinates aligned with the rotating field to simplify current control. This introduction focuses on a permanent-magnet synchronous motor (PMSM).

Separate current, torque and speed

A simplified mechanical equation is:

J\frac{d\omega}{dt}=T_e-T_L-B\omega

J is inertia [kg m²], ω mechanical angular velocity [rad/s], Te electromagnetic torque [N m], TL load torque [N m] and B viscous resistance [N m s/rad]. Greater torque need not change speed immediately under substantial inertia or load. Maintaining constant speed can also require torque.

Outer speed loop, inner current loop

Speed error drives a PI controller producing a torque-related current reference. Inner current PI controllers generate voltage references; PWM realizes them through inverter switching.

Diagram 1 · Use the button to switch views
FOC speed/current loops with measured-current and angle feedback.

An asterisk denotes a reference. Outer-loop design assumes sufficiently responsive current tracking, but no universal bandwidth ratio can ignore plant dynamics and delay. Sections 4–5 of the TI PMSM FOC report explain transformations and the basic structure. This is an original explanatory schematic, not a product circuit diagram.

View three phases in rotating coordinates

Clarke transformation maps phase currents to stationary αβ axes; Park transformation rotates them into rotor-flux-aligned dq axes. d follows flux and q is perpendicular. This assumes negligible zero sequence in balanced phases and consistent amplitude/power normalization.

For a simplified surface-magnet motor at lower speeds, an appropriately defined torque constant permits Te≈Kt iq. A hypothetical Kt=0.10 N m/A and iq=3 A give 0.30 N m. This is arithmetic under an explicit convention, not permission to substitute phase RMS current indiscriminately. Match manufacturer constants to the dq transformation definition.

Electrical angle differs from mechanical angle

With p pole pairs, electrical angle is:

\theta_e=p\theta_m+\theta_0

Four pole pairs turn 90° mechanical motion into 360° electrical motion. Reversed encoder direction, incorrect zero offset or confusing poles with pole pairs rotates measured currents into the wrong axes. Check angle, phase order and current-sensor signs/offsets before tuning.

id=0 is not every operating condition

A basic example often sets the d-axis reference to zero. Interior-magnet saliency, maximum-torque-per-ampere operation and high-speed field weakening require other references. Increasing back EMF can also prevent current tracking within the available DC-bus voltage.

Current and voltage limits are distinct. Integrating through saturation delays recovery, motivating anti-windup. Failure to reach speed is not automatically insufficient speed gain.

Checks before implementation

This is a control-structure explanation, not a powered inverter test. Implementation must consider current-sampling timing, PWM synchronization, angle delay and protection/stop conditions. Before energizing hardware, feed known vectors and angles through dq and inverse transformations and verify round trips.

Use the PID experiment to examine saturation and integration, then the reducer introduction to connect motor/load speed, torque and inertia.

Current step · 4 / 5 · Power Electronics Primer

What to read next

Trace controlled motor torque through the transmission.Robot reducers: planetary, strain-wave and cycloidal mechanismsReview the backgroundInverter Circuits — Switching DC into ACContinue the seriesSiC and GaN Power Semiconductors — Why WBG Enables Speed