Advanced Features

This section describes optional algorithms that improve performance, efficiency, and operating range during steady-state closed-loop operation. These features are independent of the startup sequence and can be enabled or disabled at runtime.

Algorithm

Purpose

Field Weakening (FWC)

Extends operating speed above base speed by reducing d-axis flux

MTPA

Maximises torque output per ampere for IPM motors

Dead-Time Compensation

Corrects inverter voltage distortion due to dead-time

ESMO

Sliding mode back-EMF observer for sensorless angle estimation

FAST Observer

TI proprietary sensorless observer providing high-accuracy angle, speed, and torque estimation


Field Weakening (FWC)

Field Weakening Control (FWC) allows the motor to operate above its base speed by injecting a negative d-axis current to reduce the rotor flux linkage. This reduces the back-EMF and allows the inverter to maintain voltage control at speeds where the back-EMF would otherwise saturate the voltage output.

How It Works

The FWC algorithm uses a PI controller that monitors the output voltage magnitude |Vs| and compares it against the reference VsRef_pu. When |Vs| approaches the limit, the PI controller generates a negative d-axis current reference (field weakening angle) to reduce the flux:

angleFWC_rad = PI_controller(VsRef_pu - |Vs|)
Id_ref = Id_MTPA + Id_FWC(angleFWC_rad)

The FWC PI controller output is clamped between USER_M1_FWC_MIN_ANGLE_RAD (0°, no weakening) and USER_M1_FWC_MAX_ANGLE_RAD (typically −15°, maximum weakening).

The FWC PI controller object is embedded in the MOTOR_Vars_t structure:

/* In motor_common.h */
PI_Obj pi_fwc;  /* Field weakening PI controller object — motorVars_M1.pi_fwc */

When to Use

  • When the application requires operation above the motor’s base speed (constant-power region).

  • Fan and pump loads where speed range beyond rated speed is needed.

  • Applications with a wide DC bus voltage range where the effective base speed varies.

Configuration

FWC parameters are defined in user_mtr1.h and applied in mtr1_init.c:

/* user_mtr1.h — FWC PI controller gains and angle limits */
#define USER_M1_FWC_KP            (0.0225f)   /* FWC proportional gain */
#define USER_M1_FWC_KI            (0.00225f)  /* FWC integral gain */
#define USER_M1_FWC_MAX_ANGLE     (-15.0f)    /* Maximum field weakening angle (degrees) */
#define USER_M1_FWC_MAX_ANGLE_RAD (USER_M1_FWC_MAX_ANGLE / 180.0f * MATH_PI)
#define USER_M1_FWC_MIN_ANGLE     (0.0f)      /* Minimum angle — no weakening */
#define USER_M1_FWC_MIN_ANGLE_RAD (USER_M1_FWC_MIN_ANGLE / 180.0f * MATH_PI)

/* mtr1_init.c — FWC PI controller initialisation */
PI_setGains(&obj->pi_fwc, USER_M1_FWC_KP, USER_M1_FWC_KI);
PI_setUi(&obj->pi_fwc, 0.0);
PI_setMinMax(&obj->pi_fwc, USER_M1_FWC_MAX_ANGLE_RAD, USER_M1_FWC_MIN_ANGLE_RAD);

objSets->Kp_fwc          = USER_M1_FWC_KP;
objSets->Ki_fwc          = USER_M1_FWC_KI;
objSets->angleFWCMax_rad = USER_M1_FWC_MAX_ANGLE_RAD;

/* Activation delay after closed-loop entry */
objSets->fwcTimeDelay_cnt =
    (uint32_t)(objUser->ctrlFreq_Hz * motorParams->FwcDelay_sec);

/* Enable FWC */
obj->inputCtrl.flagEnableFWC = true;

The FwcDelay_sec parameter is defined per-motor in motor_params.h:

#define MOTOR_<NAME>_FWC_DELAY_sec  (2.0f)   /* Delay before FWC activates after CL entry (s) */

/* In motor_params.c */
.FwcDelay_sec = MOTOR_<NAME>_FWC_DELAY_sec,

Key Parameters

Parameter

Source

Description

Example

USER_M1_FWC_KP

user_mtr1.h

FWC PI proportional gain

0.0225

USER_M1_FWC_KI

user_mtr1.h

FWC PI integral gain

0.00225

USER_M1_FWC_MAX_ANGLE

user_mtr1.h

Maximum field weakening angle (degrees, negative)

−15.0°

FwcDelay_sec

Motor_ParamsType

Delay after closed-loop entry before FWC activates

2.0 s

flagEnableFWC

mtr1_init.c

Enable/disable field weakening

true

Note

USER_M1_FWC_MAX_ANGLE sets the maximum d-axis current injection angle. A value of −15° is a good starting point for most SPM motors. For IPM motors with higher saliency, a larger angle (e.g. −30°) may be needed to achieve the desired speed extension.

FwcDelay_sec should be long enough for the speed and current controllers to settle after closed-loop entry before field weakening is activated. A value of 1–2 s is typical.

Watch Window — Runtime Control

Watch Window Expression

Type

Description

motorVars_M1.inputCtrl.flagEnableFWC

bool

Enable (true) or disable (false) field weakening

motorVars_M1.outVars.angleFWC_rad

float

Current field weakening angle output (rad)

motorSetVars_M1.Kp_fwc

float

FWC PI proportional gain

motorSetVars_M1.Ki_fwc

float

FWC PI integral gain

motorSetVars_M1.angleFWCMax_rad

float

Maximum field weakening angle (rad)

motorVars_M1.pi_fwc.Ui

float

FWC PI integrator state


MTPA (Maximum Torque Per Ampere)

Maximum Torque Per Ampere (MTPA) is an optimisation algorithm for Interior Permanent Magnet (IPM) motors that computes the optimal d/q current split to maximise the torque produced per unit of stator current. For IPM motors, the reluctance torque component (due to the difference between d-axis and q-axis inductances) can be exploited to produce additional torque without increasing the current magnitude.

How It Works

For a PMSM, the electromagnetic torque is:

Te = (3/2) × P × [λ_pm × Iq + (Ld - Lq) × Id × Iq]

where λ_pm is the permanent magnet flux, Ld and Lq are the d/q inductances, and P is the number of pole pairs. For SPM motors (Ld ≈ Lq), the reluctance term is negligible and MTPA reduces to Id = 0. For IPM motors (Lq > Ld), a negative Id produces additional reluctance torque.

The MTPA algorithm computes the optimal Id reference as a function of the total current magnitude |Is| using a pre-computed look-up table (LUT) derived from the motor inductances:

Id_MTPA = f(|Is|, Ld, Lq, λ_pm)

The LUT is computed at compile time from the motor inductance macros in motor_params.h via the MOTOR_PH_Ls_d_H / MOTOR_PH_Ls_q_H aliases.

The MTPA handle is embedded in the MOTOR_Vars_t structure:

/* In motor_common.h */
MTPA_Handle mtpaHandle;  /* MTPA handle — motorVars_M1.mtpaHandle */

When to Use

  • IPM motors with significant saliency (Lq/Ld > 1.2). MTPA provides the most benefit for motors with high saliency ratios.

  • Applications where efficiency and thermal performance are critical.

  • Not required for SPM motors where Ld ≈ Lq.

Configuration

The MTPA LUT is computed at compile time from the active motor’s inductance aliases in motor_params.h:

/* motor_params.h — MTPA compile-time inductance aliases */
/* These MUST point to the same motor as motorParams_M1 in motor_params.c */
#define MOTOR_PH_Ls_d_H  MOTOR_PANASONIC_BLOWER_Ls_d_H  /* Active motor d-axis inductance */
#define MOTOR_PH_Ls_q_H  MOTOR_PANASONIC_BLOWER_Ls_q_H  /* Active motor q-axis inductance */

The MTPA object is initialised in mtr1_init.c:

/* Initialise MTPA and compute parameters from motor inductances */
obj->mtpaHandle = MTPA_init(&mtpa_M1, sizeof(MTPA_Obj));
MTPA_computeParameters(obj->mtpaHandle,
                       objUser->motor_Ls_d_H,
                       objUser->motor_Ls_q_H,
                       objUser->motor_ratedFlux_Wb);

/* Enable MTPA */
obj->inputCtrl.flagEnableMTPA = true;

Note

When switching the active motor, update both the motorParams_M1 pointer in motor_params.c and the MOTOR_PH_Ls_d_H / MOTOR_PH_Ls_q_H aliases in motor_params.h. The MTPA LUT is a static const array evaluated at compile time — a rebuild is required after changing the aliases.

Key Parameters

Parameter

Source

Description

MOTOR_PH_Ls_d_H

motor_params.h

Active motor d-axis inductance for MTPA LUT (compile-time)

MOTOR_PH_Ls_q_H

motor_params.h

Active motor q-axis inductance for MTPA LUT (compile-time)

flagEnableMTPA

mtr1_init.c

Enable/disable MTPA optimisation

Watch Window — Runtime Control

Watch Window Expression

Type

Description

motorVars_M1.inputCtrl.flagEnableMTPA

bool

Enable (true) or disable (false) MTPA

motorVars_M1.outVars.angleMTPA_rad

float

Current MTPA angle output (rad)

motorVars_M1.outVars.mtpaKconst

float

MTPA K constant (saliency factor)

motorVars_M1.statusVars.flagUpdateMTPAParams

bool

true while MTPA parameters are being updated

Related Algorithms

  • Field Weakening (FWC) — MTPA operates in the constant-torque region; FWC extends the speed range above base speed. Both can be active simultaneously.

  • TiTune — identifies Ld and Lq used to compute the MTPA LUT.


Dead-Time Compensation

Dead-time compensation (DTC) corrects the voltage distortion introduced by the mandatory dead-time inserted between the turn-off of one switch and the turn-on of the complementary switch in an inverter leg. Without compensation, the dead-time causes harmonic distortion in the output voltage, leading to torque ripple and reduced control accuracy, especially at low speeds and low modulation indices.

Background

In a three-phase inverter, dead-time is inserted to prevent shoot-through (simultaneous conduction of both switches in a leg). During dead-time, the actual output voltage depends on the direction of the phase current:

  • If current is positive (flowing out of the inverter): the output is clamped to the negative rail — voltage error is negative.

  • If current is negative (flowing into the inverter): the output is clamped to the positive rail — voltage error is positive.

The average voltage error per PWM period is:

ΔV = ±(t_dead / T_pwm) × V_dc

where t_dead is the dead-time duration, T_pwm is the PWM period, and V_dc is the DC bus voltage.

Compensation Method

The SDK implements a dynamic current control dead-time compensation that adds a corrective voltage term to the reference voltages before the Space Vector PWM (SVPWM) modulator:

/* In mtr1_init.c — DTC initialisation */
obj->deadTimeCompHandle = DTC_getInstance(DTC_MOTOR_1);

DTC_InitParams_t dtcParams;
DTC_setDefaultParams(&dtcParams);
dtcParams.maxOutFactor       = DTC_DEFAULT_MAX_OUT_FACTOR;
dtcParams.enableDTC          = false;   /* disabled by default */
DTC_initParams(obj->deadTimeCompHandle, &dtcParams);

/* Update compensation gains from current controller Ki values */
DTC_updateGains(obj->deadTimeCompHandle,
                objSets->Ki_Id, objSets->Ki_Iq,
                DTC_DEFAULT_GAIN_ID_SF, DTC_DEFAULT_GAIN_IQ_SF);

Key Parameters

The DTC module is configured via DTC_InitParams_t in dead_time_comp.h:

Parameter

Default

Description

speedEnableLimit_Hz

10.0 Hz

Minimum electrical speed to activate DTC. Below this speed, DTC is disabled.

speedDisableLimit_Hz

5.0 Hz

Speed at which DTC is deactivated when decelerating (hysteresis). Must be less than speedEnableLimit_Hz.

maxOutFactor

0.05

Maximum compensation voltage as a fraction of DC bus voltage (V_comp_max = maxOutFactor × V_dc). Clamps over-compensation.

gainIdSf

0.5

D-axis compensation gain scale factor applied to the current controller Ki.

gainIqSf

0.5

Q-axis compensation gain scale factor applied to the current controller Ki.

Note

  • speedEnableLimit_Hz and speedDisableLimit_Hz form a hysteresis band. At very low speeds, the phase current sign is unreliable (near zero-crossing), so DTC is disabled below speedDisableLimit_Hz and only re-enabled above speedEnableLimit_Hz.

  • maxOutFactor should be set to approximately (t_dead / T_pwm) — the theoretical dead-time voltage error fraction. Setting it too high risks over-compensation; too low reduces effectiveness.

  • gainIdSf and gainIqSf scale the compensation relative to the current controller integral gain. The default 0.5 is a conservative starting point.

How to Enable

DTC is disabled by default. Enable it at runtime via the watch window or configure it during initialisation in mtr1_init.c:

/* In mtr1_init.c — DTC initialisation with speed thresholds */
DTC_InitParams_t dtcParams;
DTC_setDefaultParams(&dtcParams);

/* Set speed thresholds for automatic enable/disable */
dtcParams.speedEnableLimit_Hz  = 10.0f;  /* Enable DTC above 10 Hz electrical speed */
dtcParams.speedDisableLimit_Hz = 5.0f;   /* Disable DTC below 5 Hz electrical speed */

/* Set maximum compensation voltage (5% of DC bus) */
dtcParams.maxOutFactor = DTC_DEFAULT_MAX_OUT_FACTOR;  /* 0.05 */

dtcParams.enableDTC = true;  /* Enable DTC at startup */
DTC_initParams(obj->deadTimeCompHandle, &dtcParams);

Effect on Performance

Condition

Without DTC

With DTC

Low-speed torque ripple

High

Reduced

Current THD

Elevated

Improved

Speed control bandwidth

Limited

Improved

Watch Window — Runtime Control

Watch Window Expression

Type

Description

motorVars_M1.inputCtrl.flagEnableDTC

bool

Enable (true) or disable (false) dead-time compensation

Related Algorithms

  • ESMO — benefits from improved voltage accuracy provided by DTC, especially at low speeds.

  • TiTune — automated PI tuning that benefits from accurate voltage delivery enabled by dead-time compensation.


ESMO (Extended Sliding Mode Observer)

The Extended Sliding Mode Observer (ESMO) is a sensorless rotor position and speed estimation algorithm based on sliding mode control theory. It estimates the back-EMF of the motor from measured phase currents and applied voltages, then extracts the rotor angle from the estimated back-EMF components.

ESMO is well-suited for medium-to-high speed sensorless FOC applications and is computationally efficient, making it a good choice for cost-sensitive designs.

Algorithm Description

The ESMO operates in two stages:

Stage 1: Sliding Mode Current Observer

A sliding mode observer estimates the stator currents in the stationary reference frame. The observer uses a switching function (signum or sigmoid) to drive the estimation error to zero:

d(i_α̂)/dt = (1/Ls) × (V_α - Rs × i_α̂ - ê_α - k × sign(i_α̂ - i_α))
d(i_β̂)/dt = (1/Ls) × (V_β - Rs × i_β̂ - ê_β - k × sign(i_β̂ - i_β))

where k is the sliding mode gain and ê_α, ê_β are the estimated back-EMF components.

Stage 2: Back-EMF Extraction and PLL-Based Angle Tracking

The sliding control output is low-pass filtered to extract the estimated back-EMF components:

Eα = Eα + Kslf × (Zα - Eα)
Eβ = Eβ + Kslf × (Zbeta - Eβ)

where Kslf is the back-EMF filter coefficient (set via EsmoBemfKslfFcSf).

The estimated back-EMF is then projected onto the estimated d-q reference frame using the current estimated angle θ:

Ed = Eα × cos(θ) + Eβ × sin(θ)
Eq = Eβ × cos(θ) - Eα × sin(θ)

A PI controller drives Ed → 0 to lock the estimated angle onto the true rotor angle. When the estimated angle is correct, all back-EMF appears in the q-axis (Eq) and Ed = 0. The normalised angle error fed to the PI controller is:

θ_err = Ed / |Eq|

The PI output represents the estimated electrical speed, which is integrated to generate the rotor angle:

ω_est = Kp × θ_err + Ki × ∫θ_err dt
θ = θ + ω_est × Ts

A low-pass filter smooths the speed estimate for output.

The ESMO handle is embedded in the MOTOR_Vars_t structure:

/* In motor_common.h */
// obj->esmoHandle — accessed via motorVars_M1.esmoHandle

How to Enable

Select ESMO as the active estimator at runtime via the watch window or in mtr1_init.c:

/* Select ESMO as the sensorless observer */
obj->inputCtrl.estimatorMode = ESTIMATOR_MODE_ESMO;

Key Parameters and Configuration

ESMO observer gains are defined as macros in motor_params.h and stored in the Motor_ParamsType struct in motor_params.c. To configure for your motor, update the macro block and struct initializer:

/* In motor_params.h — define per-motor ESMO gain macros */
#define MOTOR_<NAME>_ESMO_KSLIDE_MAX       (0.5f)        /* Max sliding mode gain */
#define MOTOR_<NAME>_ESMO_KSLIDE_MIN       (0.1f)        /* Min sliding mode gain */
#define MOTOR_<NAME>_ESMO_PLL_KP_MAX       (10.0f)       /* PLL max Kp */
#define MOTOR_<NAME>_ESMO_PLL_KP_MIN       (1.5f)        /* PLL min Kp */
#define MOTOR_<NAME>_ESMO_PLL_KP_SF        (5.0f)        /* PLL Kp speed-scaling factor */
#define MOTOR_<NAME>_ESMO_PLL_KI           (2.8125E-06f) /* PLL Ki (wn^2 * Ts) */
#define MOTOR_<NAME>_ESMO_BEMF_THRESHOLD   (0.5f)        /* BEMF threshold (fraction of Vrated) */
#define MOTOR_<NAME>_ESMO_BEMF_KSLF_FC_SF  (0.5f)       /* BEMF LPF coefficient (fc*2pi*Ts) */
#define MOTOR_<NAME>_ESMO_THETA_OFFSET_SF  (1.0f)        /* Angle offset compensation */
#define MOTOR_<NAME>_ESMO_SPEED_LPF_FC_Hz  (50.0f)      /* Speed LPF cutoff (Hz) */

/* In motor_params.c — populate the Motor_ParamsType struct */
.EsmoKslideMax     = MOTOR_<NAME>_ESMO_KSLIDE_MAX,
.EsmoKslideMin     = MOTOR_<NAME>_ESMO_KSLIDE_MIN,
.EsmoPllKpMax      = MOTOR_<NAME>_ESMO_PLL_KP_MAX,
.EsmoPllKpMin      = MOTOR_<NAME>_ESMO_PLL_KP_MIN,
.EsmoPllKpSf       = MOTOR_<NAME>_ESMO_PLL_KP_SF,
.EsmoPllKi         = MOTOR_<NAME>_ESMO_PLL_KI,
.EsmoBemfThreshold = MOTOR_<NAME>_ESMO_BEMF_THRESHOLD,
.EsmoBemfKslfFcSf  = MOTOR_<NAME>_ESMO_BEMF_KSLF_FC_SF,
.EsmoThetaOffsetSf = MOTOR_<NAME>_ESMO_THETA_OFFSET_SF,
.EsmoSpeedLpfFc_Hz = MOTOR_<NAME>_ESMO_SPEED_LPF_FC_Hz,

Parameter (Motor_ParamsType field)

Description

Example (Teknic)

EsmoKslideMax

Maximum sliding mode gain k

0.5

EsmoKslideMin

Minimum sliding mode gain k

0.1

EsmoPllKpMax

PLL maximum proportional gain

10.0

EsmoPllKpMin

PLL minimum proportional gain

1.5

EsmoPllKpSf

PLL Kp speed-scaling coefficient

5.0

EsmoPllKi

PLL integral gain (ωn² × Ts)

2.8125e-6

EsmoBemfThreshold

Back-EMF threshold (fraction of rated voltage)

0.5

EsmoBemfKslfFcSf

Back-EMF LPF coefficient (fc × 2π × Ts)

0.5

EsmoThetaOffsetSf

Angle offset compensation coefficient

1.0

EsmoSpeedLpfFc_Hz

Speed low-pass filter cutoff frequency

50.0 Hz

These are consumed by mtr1_init.c:

ESMO_setKslideParams(obj->esmoHandle, motorParams->EsmoKslideMax, motorParams->EsmoKslideMin);
ESMO_setPLLParams(obj->esmoHandle, motorParams->EsmoPllKpMax,
                  motorParams->EsmoPllKpMin, motorParams->EsmoPllKpSf);
ESMO_setPLLKi(obj->esmoHandle, motorParams->EsmoPllKi);
ESMO_setBEMFThreshold(obj->esmoHandle, motorParams->EsmoBemfThreshold);
ESMO_setOffsetCoef(obj->esmoHandle, motorParams->EsmoThetaOffsetSf);
ESMO_setBEMFKslfFreq(obj->esmoHandle, motorParams->EsmoBemfKslfFcSf);
ESMO_setSpeedFilterFreq(obj->esmoHandle, motorParams->EsmoSpeedLpfFc_Hz);
ESMO_setParams(obj->esmoHandle, obj->userParamsHandle);

Watch Window — Runtime Control

Watch Window Expression

Type

Description

motorVars_M1.inputCtrl.estimatorMode

ESTIMATOR_Mode_e

Set to ESTIMATOR_MODE_ESMO to use ESMO observer

motorVars_M1.outVars.speed_Hz

float

Estimated rotor speed (Hz)

motorVars_M1.outVars.angleFOC_rad

float

FOC angle used by the controller (rad)

Comparison with FAST Observer

Feature

ESMO

FAST

Computational load

Low

Medium

Low-speed performance

Limited

Better

Parameter sensitivity

Moderate

Low

Torque estimation

No

Yes

Implementation complexity

Simple

Complex

Limitations

  • Performance degrades at very low speeds (< 5–10% of rated speed) due to low back-EMF magnitude.

  • Requires accurate motor parameters (Rs, Ls) for good estimation.

  • The sliding mode switching function introduces chattering that must be filtered.

Related Algorithms

  • IPD — used at standstill before ESMO can operate.

  • FAST Observer — higher-performance alternative for demanding applications.

  • Dead-Time Compensation — improves voltage accuracy, benefiting ESMO estimation quality.


FAST Observer (Flux, Angle, Speed, Torque)

The FAST (Flux, Angle, Speed, Torque) observer is TI’s proprietary sensorless estimation algorithm embedded in the InstaSPIN-FOC library. It provides high-accuracy rotor angle, speed, and torque estimation across a wide speed range, including very low speeds.

FAST is the default and recommended observer for most applications. It is selected by setting estimatorMode = ESTIMATOR_MODE_FAST in mtr1_init.c.

Key Characteristics

Feature

Description

Speed range

Operates from near-zero speed to above rated speed

Torque estimation

Yes — provides real-time torque estimate

Parameter sensitivity

Low — robust to parameter variations

Computational load

Medium

Flux estimation

Yes — tracks rotor flux magnitude

Configuration

FAST observer parameters are set via the USER_M1_* macros in user_mtr1.h and the motor nameplate parameters in motor_params.h. See Motor Parameter Tuning for the full parameter setup procedure.

Watch Window — Runtime Control

Watch Window Expression

Type

Description

motorVars_M1.inputCtrl.estimatorMode

ESTIMATOR_Mode_e

Set to ESTIMATOR_MODE_FAST to use FAST observer

motorVars_M1.outVars.speed_Hz

float

Estimated rotor speed (Hz)

motorVars_M1.outVars.angleFOC_rad

float

FOC angle used by the controller (rad)

motorVars_M1.outVars.torque_Nm

float

Estimated motor torque (Nm)

Related Algorithms