Motor Parameter Tuning
Overview — Motor Parameters for Sensorless FOC
Sensorless FOC requires accurate motor parameters to operate correctly. The observers (FAST and ESMO) and the current/speed PI regulators all depend on these values. Before running a motor, you must supply at minimum the nameplate electrical parameters. If you do not have them, the SDK provides two automated identification tools — InstaSPIN and TiTune — that measure the parameters directly from the motor.
The required parameters are:
Parameter |
|
Description |
|---|---|---|
Pole pairs |
|
Number of rotor pole pairs |
Stator resistance |
|
Phase resistance (Ω) |
D-axis inductance |
|
D-axis stator inductance (H) |
Q-axis inductance |
|
Q-axis stator inductance (H) |
Back-EMF constant |
|
Back-EMF constant Ke (V/Hz) — measured when the motor runs in closed-loop current control at rated current and rated electrical speed. If the datasheet value is not available, use a typical value based on the application’s target operating speed range. Required by FAST as an initial estimate. |
Rated current |
|
Rated phase current (A) |
Rotor inertia |
|
Rotor inertia (kg·m²) — used by TiTune |
Rated speed |
|
Rated electrical speed (Hz) |
Rated voltage |
|
Rated phase voltage (V) |
Both identification tools work with either observer:
Identification Tool |
FAST ( |
ESMO ( |
|---|---|---|
InstaSPIN |
Supported |
Supported |
TiTune |
Supported |
Supported |
Note
FAST additionally uses RatedFlux_VpHz as an initial estimate for the flux observer. Provide
a reasonable nameplate value even when using automated identification, as it seeds the FAST
estimator during the open-loop phase.
Step 1 — Enter Nameplate Parameters
All motor parameters are stored in
motor_params.h
and
motor_params.c.
To add a new motor:
Open
motor_params.hand add a macro block for your motor. Use an existing motor block as a template:/* ---- MY_MOTOR nameplate parameters ---- */ #define MOTOR_MY_MOTOR_NUM_POLE_PAIRS (4U) #define MOTOR_MY_MOTOR_Rs_Ohm (0.35f) #define MOTOR_MY_MOTOR_Ls_d_H (0.000180f) #define MOTOR_MY_MOTOR_Ls_q_H (0.000210f) #define MOTOR_MY_MOTOR_RATED_FLUX_VpHz (0.0415f) #define MOTOR_MY_MOTOR_RATED_CURRENT_A (5.0f) #define MOTOR_MY_MOTOR_INERTIA_Kgm2 (0.000010f) #define MOTOR_MY_MOTOR_RATED_SPEED_Hz (200.0f) #define MOTOR_MY_MOTOR_RATED_VOLTAGE_V (24.0f)
Also update the
MOTOR_PH_Ls_d_HandMOTOR_PH_Ls_q_Haliases at the bottom of the file (used by the MTPA look-up table generator):#define MOTOR_PH_Ls_d_H MOTOR_MY_MOTOR_Ls_d_H #define MOTOR_PH_Ls_q_H MOTOR_MY_MOTOR_Ls_q_H
Open
motor_params.cand add aconst Motor_ParamsTypeentry for your motor:const Motor_ParamsType Motor_MyMotorParams = { .NumPolePairs = MOTOR_MY_MOTOR_NUM_POLE_PAIRS, .Rs_Ohm = MOTOR_MY_MOTOR_Rs_Ohm, .Ls_d_H = MOTOR_MY_MOTOR_Ls_d_H, .Ls_q_H = MOTOR_MY_MOTOR_Ls_q_H, .RatedFlux_VpHz = MOTOR_MY_MOTOR_RATED_FLUX_VpHz, .RatedCurrent_A = MOTOR_MY_MOTOR_RATED_CURRENT_A, .Inertia_Kgm2 = MOTOR_MY_MOTOR_INERTIA_Kgm2, .RatedSpeed_Hz = MOTOR_MY_MOTOR_RATED_SPEED_Hz, .RatedVoltage_V = MOTOR_MY_MOTOR_RATED_VOLTAGE_V, /* Copy startup, ESMO gains, and timing fields from an existing motor entry */ };
Update the
motorParams_M1pointer inmotor_params.cto point to your new entry:const Motor_ParamsType *motorParams_M1 = &Motor_MyMotorParams;
Note
If you do not yet know Rs_Ohm, Ls_d_H, Ls_q_H, or RatedFlux_VpHz, enter approximate
values from the motor datasheet (or leave the defaults from a similar motor). The identification
tools in the next steps will measure the actual values and you can update the macros afterwards.
Step 2 — Choose a Parameter Identification Method
Use the following decision tree to decide how to proceed:
Do you have accurate Rs, Ls, Ke values from a datasheet or previous measurement?
│
├── YES → Enter them in motor_params.h (Step 1) and skip identification.
│ Proceed directly to running the motor.
│
└── NO → Use automated identification.
│
├── Do you want a quick single-step identification?
│ └── YES → Use InstaSPIN (Section below)
│
└── Do you want full identification including inertia and PI gains?
└── YES → Use TiTune (Section below)
Both tools are triggered from the watch window at runtime — no recompile is needed to switch between them.
InstaSPIN Parameter Identification
Overview
InstaSPIN is TI’s on-the-fly motor parameter identification engine embedded in the FAST
observer library. It estimates Rs, Ls_d, Ls_q, and Ke (flux) by injecting test signals
at standstill and during a brief open-loop spin. It also computes initial current and speed PI
gains. InstaSPIN runs as part of the FAST estimator state machine and completes in a single
automated sequence.
How to Enable
Before triggering identification, set the estimator mode in the watch window:
Expression |
Value |
|---|---|
|
|
Then trigger identification:
Set
motorVars_M1.inputCtrl.motorParamIdentifyMethod = MOTOR_PARAM_IDENTIFY_INSTASPINSet
motorVars_M1.inputCtrl.flagEnableMotorIdentify = trueEnable the motor run command to allow the identification sequence to proceed.
Monitor
motorVars_M1.statusVars.flagMotorIdentified— it goestruewhen complete.
Warning
The motor shaft will rotate briefly during the flux (Ke) identification phase. Ensure the shaft is free to spin and the load is safe to move before triggering identification.
Tuning the Estimation (user_mtr1.h INSTASPIN_EST_ parameters)
The following parameters in user_mtr1.h
control the test signal levels used during identification. Review and adjust them for your
motor before running InstaSPIN.
Parameter |
Default |
Description |
|---|---|---|
|
|
DC current for Rs estimation (A) — set to 50–70% of rated |
|
|
AC current for Ls estimation (A, negative) — set to 40–60% of rated |
|
|
Ls_d compensation coefficient (0.0–0.5) |
|
|
Ls_q compensation coefficient (0.0–0.5) |
|
|
Ls minimum coefficient (0.5–1.0) |
|
|
Flux excitation frequency (Hz) |
|
|
Near-zero speed frequency limit (Hz) |
The estimation scale factors below fine-tune the FAST observer response. Adjust these if the observer shows oscillation or poor tracking at high speed:
Parameter |
Location |
Default |
Description |
|---|---|---|---|
|
|
|
Flux estimation scale factor (0.1–1.25) |
|
|
|
Frequency estimation scale factor (0.5–1.5) |
|
|
|
BEMF estimation scale factor (0.50–1.25) |
Watch Window — Monitoring Identification
Expression |
Description |
|---|---|
|
Set |
|
Set to |
|
Goes |
|
Current FAST estimator state during identification |
Results — Where to Find Identified Parameters
After InstaSPIN completes, the identified values are written to motorSetVars_M1:
Expression |
Description |
|---|---|
|
Identified stator resistance (Ω) |
|
Identified d-axis inductance (H) |
|
Identified q-axis inductance (H) |
|
Identified back-EMF constant (V/Hz) |
|
Computed d-axis current loop Kp |
|
Computed d-axis current loop Ki |
|
Computed q-axis current loop Kp |
|
Computed q-axis current loop Ki |
|
Computed speed loop Kp |
|
Computed speed loop Ki |
Copy these values into the macro block in
motor_params.h
to make them permanent. See Applying Results to motor_params.h.
TiTune Parameter Identification
Overview
TiTune is TI’s automated motor parameter identification and PI tuning utility. It runs a
structured state machine that measures Rs, Ld, Lq at standstill and Ke at low
speed, then estimates rotor inertia (J) and damping (B) via a coast-down test. From these
measurements it computes optimal current and speed PI gains. TiTune works with both FAST and
ESMO observers.
TiTune is the recommended tool when you also need inertia estimation or want fully computed PI gains for the speed loop.
How to Enable
Set the estimator mode before triggering identification:
Expression |
Value |
|---|---|
|
|
Verify the per-unit base values match your motor nameplate before starting:
Expression |
Description |
|---|---|
|
Per-unit current base — must match motor rated current (A) |
|
Per-unit speed base — must match motor rated electrical speed (Hz) |
Then trigger identification:
Set
motorVars_M1.inputCtrl.motorParamIdentifyMethod = MOTOR_PARAM_IDENTIFY_TITUNESet
motorVars_M1.inputCtrl.flagEnableMotorIdentify = trueEnable the motor run command to allow the identification sequence to proceed.
Monitor
TiTune_M1.Status.stateto track the current phase.Monitor
motorVars_M1.statusVars.flagMotorIdentified— it goestruewhen complete.
Warning
The motor shaft will rotate during the open-loop ramp (TiTune_STATE_OL_RUN) and closed-loop
settle phases. Ensure the shaft is free to spin and the load is safe to move before triggering
identification.
Identification Sequence (state machine phases with tuning guidance)
TiTune progresses through the following states automatically. Each state has tuning parameters you can adjust if the identification fails or produces poor results.
TiTune_STATE_LDQ_EST — Inductance Estimation
The motor is at standstill with the rotor locked. TiTune injects a high-frequency AC voltage signal into the d-axis while scanning for the rotor position. At each angle step, the algorithm measures the current responses and identifies the minimum inductance (Ld) and maximum inductance (Lq) from the scan and also detects the initial rotor angle position.
LDQ Estimation Parameters
The parameters below are set in TiTune_LDQ_setParams() in
ti_tune.c.
The user-tunable values are defined in Section B of
ti_tune.h.
Parameter |
Location |
Default |
Description / Tuning Guidance |
|---|---|---|---|
|
|
|
Electrical angle step per measurement point (per-unit, 0→0.5 = 180°). Default gives ~0.72° per step. For surface-mount PMSM with very similar Ld/Lq, reduce for finer resolution. |
|
|
|
Initial half-period samples — sets the starting injection frequency. Higher value = lower frequency. |
|
|
|
Maximum half-period samples — sets the minimum injection frequency. For motors with very high inductance (large motors), increase to allow lower injection frequencies. |
|
|
|
Injection periods for settling before DFT measurement begins. |
|
|
|
Starting injection voltage magnitude (per-unit of Vdc). Intentionally small — the algorithm ramps up automatically. No need to change in most cases. |
|
|
|
Minimum acceptable current response (per-unit of rated current). For large motors with high inductance, consider reducing if the algorithm fails to find a suitable voltage. |
|
|
|
Maximum acceptable current response (per-unit of rated current). For small motors with low rated current, consider reducing to prevent overcurrent. |
|
|
|
Hard ceiling on injection voltage (per-unit of Vdc). Do not increase above 1.0. If this limit is reached and current response is still insufficient, the algorithm automatically reduces the injection frequency instead. |
Automatic Voltage Adjustment
The algorithm keeps the current response within the IS_MAGN_MIN_LIM / IS_MAGN_MAX_LIM
window by adjusting the injection voltage automatically:
If the motor draws too little current → injection voltage is doubled until
TI_TUNE_LDQ_INJ_VOL_MAGN_MAX_LIMis reached.If the motor draws too much current → injection voltage is halved.
Watch Window — LDQ Estimation
Expression |
Description |
|---|---|
|
Current injection voltage magnitude (per-unit of Vdc) |
|
Current injection frequency (per-unit) |
|
Current response magnitude (per-unit of rated current) |
|
Current scan angle (0 to 0.5 per-unit = 0° to 180°) |
|
Running minimum inductance (per-unit) |
|
Running maximum inductance (per-unit) |
|
Set to 1.0 when scan is complete |
|
Set to 1.0 if algorithm failed to find suitable voltage (error condition) |
Results from LDQ Estimation
Expression |
Description |
|---|---|
|
Identified Ld in Henries |
|
Identified Lq in Henries |
|
Detected initial rotor angle (per-unit, 0→1 = 0°→360°) |
These values are automatically used by subsequent TiTune phases: the Rs estimation phase uses the initial rotor angle, and the current controller gain computation uses Ld and Lq.
Troubleshooting LDQ Estimation
If
VoltageNotFound = 1.0after the scan: the motor inductance is too high for the current frequency range. IncreaseTI_TUNE_LDQ_INJ_HALF_PRD_MAXto allow lower injection frequencies.If the scan completes but
ld_Finalandlq_Finalare nearly identical: this is expected for surface-mount PMSM (non-salient). The algorithm still correctly identifies Ld = Lq.
TiTune_STATE_RS_EST — Resistance Estimation
The motor is at standstill. Before Rs estimation begins, TiTune sets up closed-loop current
control using the Ld and Lq values identified in the LDQ phase. The current loop bandwidth is
set by TI_TUNE_TORQUE_LOOP_BW_RADPS. TiTune then injects DC current at the rotor angle
detected by the LDQ phase. Two distinct DC current levels are applied sequentially. The
differential voltage and current measurements between the two levels cancel the inverter
dead-time voltage offset, yielding an accurate stator resistance that includes cable and switch
resistances. A voltage distortion compensation gain (Vdist) is also computed for use by the
observer.
Current Loop Setup for Rs Estimation
Before the Rs measurement begins, TiTune computes the current PI gains from the Ld and Lq
values identified in the LDQ phase and the configured current loop bandwidth
TI_TUNE_TORQUE_LOOP_BW_RADPS:
D-axis:
Kp = Ld × BW,Kiuses a bandwidth-squared designQ-axis:
Kp = Lq × BW,Kiuses a bandwidth-squared design
After Rs is measured, Ki is automatically updated to a pole-zero cancellation design using the measured Rs before the open-loop ramp phase begins. The user does not need to take any action for this update.
Set TI_TUNE_TORQUE_LOOP_BW_RADPS to match the motor’s electrical bandwidth. For motors with
low inductance (high electrical bandwidth), increase the value. For motors with high inductance,
reduce it. Typical range is 200–2000 rad/s.
Parameter |
Location |
Default |
Description / Tuning Guidance |
|---|---|---|---|
|
|
|
Current loop bandwidth in rad/s used to compute PI gains from Ld/Lq. Increase for low-inductance motors; decrease for high-inductance motors. Typical range: 200–2000 rad/s. |
Rs Estimation Parameters
The parameters below are set in TiTune_Rs_setParams() in
ti_tune.c.
The user-tunable values are defined in Section B of
ti_tune.h.
Parameter |
Location |
Default |
Description / Tuning Guidance |
|---|---|---|---|
|
|
|
First DC test current as a fraction of rated current. Increase for motors with very low resistance where the voltage drop at 40% rated current is too small to measure accurately. |
|
|
|
Second DC test current as a fraction of rated current. Keep the ratio between current 1 and current 2 approximately 1.25× for best differential accuracy. |
Watch Window — Rs Estimation
Expression |
Description |
|---|---|
|
Current test mode: |
|
D-axis current reference being applied (per-unit of rated current) |
|
D-axis current feedback (per-unit of rated current) |
|
|
|
|
|
|
|
D-axis current loop Kp (set from Ld × BW) |
|
D-axis current loop Ki |
|
Q-axis current loop Kp (set from Lq × BW) |
|
Q-axis current loop Ki |
Results from Rs Estimation
Expression |
Description |
|---|---|
|
Identified stator resistance in Ohms |
|
Identified voltage distortion compensation gain (per-unit) |
Note
After Rs estimation completes, TiTune automatically updates Ki to a pole-zero cancellation
design using the measured Rs before the open-loop ramp begins. No user action is required.
If the motor oscillates during the open-loop ramp, check TiTune_M1.TiTune_PI_Id.Ki and
TiTune_M1.TiTune_PI_Iq.Ki to verify the gains are reasonable.
Troubleshooting Rs Estimation
If
TiTune_M1.TiTune_Rs.TimeOutError = 1.0: the current loop could not settle within the maximum allowed time. The estimation continues with the best available data. To prevent the timeout, verify that the current PI gains are reasonable (check that LDQ estimation completed successfully) or reduce the test current fractions.If
Rs_Finalappears too high or too low: verify thatTiTune_M1.RatedCurrent_Amatches the motor nameplate rated current. An incorrect base value shifts all per-unit calculations.If the two test current levels are too close together, the differential measurement becomes noisy. Ensure
TI_TUNE_RS_TEST_CURRENT2_FRACTIONis at least 1.1× larger thanTI_TUNE_RS_TEST_CURRENT1_FRACTION.
TiTune_STATE_OL_RUN — Open-Loop Ramp
The motor shaft begins to rotate in this phase. TiTune drives the motor in open-loop forced-angle mode, ramping the electrical frequency from zero to a target speed. The observer (FAST or ESMO) runs in parallel and acquires lock as the speed builds. Once the target speed is reached, TiTune blends the open-loop angle toward the observer angle and holds at the target speed for a configurable settle time before handing control to the observer.
Warning
The motor shaft rotates during this phase. Ensure the shaft is free to spin and the load is safe to move before starting identification.
Open-Loop Ramp Parameters
The parameters below are defined in Section B of
ti_tune.h.
Parameter |
Location |
Default |
Description / Tuning Guidance |
|---|---|---|---|
|
|
|
Open-loop target speed as a fraction of rated electrical speed. Must be above the minimum observer lock speed. Increase to |
|
|
|
Open-loop Iq current as a fraction of rated current. Increase for high-friction or high-inertia loads that require more torque to accelerate. Reduce if the motor oscillates during the ramp. |
|
|
|
Open-loop d-axis current injection as a fraction of rated current. A small Id injection during OL startup improves angle convergence stability at low angle error. |
|
|
|
Time (seconds) to hold at the open-loop target speed before handing off to the observer. Increase if the observer needs more time to stabilize before the closed-loop transition. |
Watch Window — Open-Loop Ramp
Expression |
Description |
|---|---|
|
Current open-loop speed reference (Hz, electrical) |
|
Target open-loop speed (Hz, electrical) |
|
Open-loop Iq current command (A) |
|
Angle difference between open-loop and observer angles (rad) — approaches zero as blending completes |
|
Settle counter — counts up to the settle target after reaching target speed |
|
Observer estimated electrical speed (Hz) — should track |
Troubleshooting Open-Loop Ramp
If the motor stalls or fails to accelerate: increase
TI_TUNE_OL_CURRENT_FRACTIONto provide more torque. For high-inertia loads, also consider reducing the speed ramp rate (Section C parameterTI_TUNE_OL_SPEED_RAMP_HZ_PER_SEC).If the observer does not lock (speed estimate diverges from
OL.Speed_Hz): increaseTI_TUNE_OL_SPEED_TARGET_FRACTIONso the observer has a higher speed to work with, or increaseTI_TUNE_OL_SETTLE_TIME_SECto give the observer more time to converge.If the motor oscillates during the ramp: reduce
TI_TUNE_OL_CURRENT_FRACTION. Excessive current on a lightly loaded motor can cause instability.
TiTune_STATE_CL_TORQUE_SETTLE — Closed-Loop Torque Settle
In this state the motor enters closed-loop torque control. TiTune switches the Park/iPark
transforms to use the observer angle. The Iq reference is held constant at the value inherited
from the open-loop handoff. The Id reference is ramped from the open-loop injection level down
to zero over TI_TUNE_CL_ID_RAMP_TIME_SEC. This phase waits for the Id ramp to complete
before entering inertia estimation.
Closed-Loop Torque Settle Parameters
The parameters below are defined in Section B of
ti_tune.h.
Parameter |
Location |
Default |
Description / Tuning Guidance |
|---|---|---|---|
|
|
|
Time (seconds) to ramp Id from the open-loop injection level to zero after the OL-to-CL handoff. Increase if the motor oscillates during the Id ramp-down. |
Watch Window — Closed-Loop Torque Settle
Expression |
Description |
|---|---|
|
Iq reference held constant at OL handoff value (A) |
|
Id reference ramping from OL injection level to zero (A) |
|
Elapsed settle time counter (samples) |
|
Required settle time in samples (derived from |
|
Observer estimated electrical speed (Hz) — should stabilize during this phase |
|
Measured Iq feedback (A) — should track |
Troubleshooting Closed-Loop Torque Settle
If the motor oscillates during the Id ramp-down: increase
TI_TUNE_CL_ID_RAMP_TIME_SECto slow the ramp. Also verify that the current PI gains are reasonable (check that LDQ and Rs estimation completed without errors).If the motor decelerates to a stop during this phase: the Iq inherited from OL handoff may be too low. Increase
TI_TUNE_OL_CURRENT_FRACTIONso the OL phase runs at a higher current.If the motor accelerates beyond a safe speed: reduce
TI_TUNE_OL_CURRENT_FRACTION.
TiTune_STATE_INERTIA_EST — Inertia and Damping Estimation
TiTune estimates rotor inertia (J) and damping (B) using a two-phase process:
Upward current ramp with torque-speed capture: The algorithm ramps Iq upward from the CL handoff level toward a target speed (
TI_TUNE_J_COAST_TARGET_SPEED_FRACTION). The speed range is divided intoTI_TUNE_J_COAST_NUM_STEPSequal steps. At each step it waits for the speed to settle, then records the torque-speed operating point. A linear regression over the collected points estimates the DC plant gain (G_DC).Coast-down (freewheel): After the ramp, Iq is set to zero and the speed decay is recorded. An exponential fit of the speed decay yields the mechanical time constant (
tau_estimated). Combined withG_DCand the identified Ke, the algorithm computes the speed PI gainsKp_spdandKi_spd.
Inertia Estimation Parameters
The parameters below are set in TiTune_J_Coast_setParams() in
ti_tune.c.
The user-tunable values are defined in Section B of
ti_tune.h.
Parameter |
Location |
Default |
Description / Tuning Guidance |
|---|---|---|---|
|
|
|
Settling time per speed-step test point (seconds). The motor is held at each speed step for this duration before recording data. Increase for high-inertia loads (fans, pumps) that take longer to reach steady state. |
|
|
|
Speed loop crossover frequency as a fraction of the estimated plant pole frequency. Increase for faster speed loop response; decrease for more conservative (stable) tuning. |
|
|
|
Coast-down stop threshold as a fraction of the initial coast-down speed. The coast-down recording stops when speed falls below this fraction. Reduce for high-damping systems where speed decays slowly. |
|
|
|
IIR low-pass filter cutoff frequency for Iq and Vq signals during speed-step settling (Hz). Reduce for noisy current measurements. |
|
|
|
IIR low-pass filter cutoff frequency for speed signal during speed-step settling (Hz). Reduce for noisy speed feedback. |
Watch Window — Inertia Estimation
Expression |
Description |
|---|---|
|
Current sub-state of the inertia estimation state machine |
|
Number of valid torque-speed data points collected so far |
|
IIR-filtered speed feedback during speed-step settling (per-unit) |
|
IIR-filtered Iq reference during speed-step settling (per-unit) |
|
Estimated DC plant gain delta-we/delta-Iq (rad/s per A) — available after ramp |
|
Estimated mechanical time constant from coast-down (seconds) |
|
Estimated back-EMF constant lambda_PM (V*s/rad) — diagnostic cross-check against Ke |
|
|
|
|
Results from Inertia Estimation
Expression |
Description |
|---|---|
|
Identified rotor inertia (kg*m^2) |
|
Identified back-EMF constant (V/Hz) |
|
Computed speed loop proportional gain |
|
Computed speed loop integral gain |
Troubleshooting Inertia Estimation
If
TiTune_M1.TiTune_J_Coast.error = true: the estimation failed. Common causes are that the motor speed does not change when current changes (motor stalled or load too heavy), or that the coast-down speed decays too quickly to collect enough samples. Check that the motor is spinning freely and thatTI_TUNE_OL_CURRENT_FRACTIONis high enough to keep the motor running into the inertia phase.If
numSteadyStatePointsstays at zero: the speed is not reaching the first step threshold. IncreaseTI_TUNE_OL_CURRENT_FRACTIONso the motor enters the inertia phase at a higher speed, or reduceTI_TUNE_J_COAST_NUM_STEPSfor fewer, larger speed steps.If the speed loop is too aggressive after applying the computed gains: reduce
TI_TUNE_J_COAST_CROSSOVER_FREQ_FACTOR(for example, from0.2to0.1) to lower the crossover frequency and increase phase margin.If the speed loop is too slow: increase
TI_TUNE_J_COAST_CROSSOVER_FREQ_FACTOR(for example, from0.2to0.4).For noisy systems where
G_DCortau_estimatedappear unreliable: increaseTI_TUNE_J_COAST_SETTLING_TIME_SECand reduce the filter cutoff frequenciesTI_TUNE_J_COAST_IQ_FILTER_CUTOFF_HZandTI_TUNE_J_COAST_SPD_FILTER_CUTOFF_HZ.
TiTune_STATE_DONE — Identification Complete
All parameters have been identified. Results are available in TiTune_M1.Results.
motorVars_M1.statusVars.flagMotorIdentified is set to true.
Key Tuning Parameters (Section B of ti_tune.h)
The following parameters are in Section B of
ti_tune.h
and are intended for user adjustment. Do not modify Section C parameters.
Parameter |
Default |
Description |
|---|---|---|
|
|
Current loop bandwidth (rad/s) — increase for low-inductance motors |
|
|
Rs test current 1 (fraction of rated) |
|
|
Rs test current 2 (fraction of rated) |
|
|
Open-loop target speed (fraction of rated) |
|
|
Open-loop Iq current (fraction of rated) |
|
|
Open-loop d-axis current injection (fraction of rated) |
|
|
Open-loop settle time before observer handoff (s) |
|
|
CL Id ramp-down time from OL injection level to zero (s) |
|
|
Settling time per speed-step test point (s) |
|
|
Speed loop crossover frequency factor (fraction of plant pole) |
Watch Window — Monitoring Identification
Expression |
Description |
|---|---|
|
Set |
|
Set to |
|
Current identification phase (see state list above) |
|
Per-unit current base — verify matches motor nameplate |
|
Per-unit speed base — verify matches motor nameplate |
|
Goes |
Results — Where to Find Identified Parameters
After TiTune completes, the identified values are in TiTune_M1.Results:
Expression |
Description |
|---|---|
|
Identified stator resistance (Ω) |
|
Identified d-axis inductance (H) |
|
Identified q-axis inductance (H) |
|
Identified back-EMF constant (V/Hz) |
|
Identified rotor inertia (kg·m²) |
|
Computed d-axis current loop Kp |
|
Computed d-axis current loop Ki |
|
Computed q-axis current loop Kp |
|
Computed q-axis current loop Ki |
|
Computed speed loop Kp |
|
Computed speed loop Ki |
Copy these values into the macro block in
motor_params.h
to make them permanent. See Applying Results to motor_params.h.
Applying Results to motor_params.h
After a successful identification run (InstaSPIN or TiTune), copy the identified values back
into the motor macro block in
motor_params.h:
Read the identified values from the watch window (see Results sections above).
Update the corresponding macros in the
MOTOR_MY_MOTOR_*block:#define MOTOR_MY_MOTOR_Rs_Ohm (0.342f) /* from motorSetVars_M1.Rs_Ohm or TiTune_M1.Results.Rs_Ohm */ #define MOTOR_MY_MOTOR_Ls_d_H (0.000178f) /* from motorSetVars_M1.Ls_d_H or TiTune_M1.Results.Ld_H */ #define MOTOR_MY_MOTOR_Ls_q_H (0.000208f) /* from motorSetVars_M1.Ls_q_H or TiTune_M1.Results.Lq_H */ #define MOTOR_MY_MOTOR_RATED_FLUX_VpHz (0.0412f) /* from motorSetVars_M1.flux_VpHz or TiTune_M1.Results.Ke_VpHz */ #define MOTOR_MY_MOTOR_INERTIA_Kgm2 (0.0000095f) /* from TiTune_M1.Results.J_Kgm2 (TiTune only) */
Rebuild and flash the firmware. The motor will now use the identified parameters on every power-up without requiring re-identification.
Note
After updating motor_params.h, you can disable identification on the next run by leaving
motorVars_M1.inputCtrl.flagEnableMotorIdentify at its default false value. The stored
parameters will be used directly.
Real-Time Diagnostics — DAC Output and Serial Plot
The AM13E232X includes a CMPSSLITE DAC that can be used to output any floating-point motor variable as an analogue voltage on a physical pin, viewable on an oscilloscope (CRO). The same variable pointers are also used by the Serial Plot feature, which streams two float values over the back-channel UART to a PC serial plotter.
Both features share the same RAM_DAC_CNTRL_T control structures inside SYSTEM_Vars_t
and are configured once in initDACOutputs()
called from main.c before the ISR starts.
DAC Output — Plotting Variables on an Oscilloscope
How It Works
HAL_updateDACOutputs()
reads the variable pointed to by systemVars.dacCtrl1.pDacOutAddr, scales it to a
12-bit integer (0–4095), and writes it to the CMPSSLITE DAC low register via
DL_CMPSSLITE_setDACValueLow().
The DAC output appears on the CMPSSLITE output pin and can be probed with an oscilloscope.
The scaling formula depends on the mode field:
|
Formula |
Use case |
|---|---|---|
|
|
Signed signals centred at mid-rail (angle, current) |
|
|
Unsigned signals (speed magnitude, DC bus) |
DAC_MAX_VALUE is defined as 4095 in
hal_obj.h.
Configuration in initDACOutputs()
Edit motor_common.c
inside initDACOutputs() to select which variables to plot:
/* motor_common.c — initDACOutputs() */
/* Enable DAC channel 1 */
sysVarsPtr->dacCtrl1.dacEn = 1U;
/* Example A: Plot FOC angle (bipolar, 0–2π → 0–4095) */
sysVarsPtr->dacCtrl1.pDacOutAddr = (float32_t *)&obj->outVars.angleFOC_rad;
sysVarsPtr->dacCtrl1.dacScalingFactor = (DAC_MAX_VALUE / MATH_TWO_PI);
sysVarsPtr->dacCtrl1.mode = 0; /* bipolar */
/* Example B: Plot phase-A current (bipolar, ±maxCurrent → 0–4095) */
/* sysVarsPtr->dacCtrl1.pDacOutAddr =
* (float32_t *)&obj->halInterface->halFOCDataHandle->adcData.I_A.value[0];
* sysVarsPtr->dacCtrl1.dacScalingFactor = (DAC_MAX_VALUE / objUser->maxCurrent_A);
* sysVarsPtr->dacCtrl1.mode = 0; */
DAC output of angleFOC_rad viewed on an oscilloscope — sawtooth waveform at motor
electrical frequency.
DAC output of phase-A current viewed on an oscilloscope — sinusoidal waveform at motor electrical frequency.
Common Variable Addresses for DAC
Signal |
Pointer expression |
Scaling |
|---|---|---|
FOC angle |
|
|
Phase-A current |
|
|
Phase-B current |
|
|
Speed (Hz) |
|
|
Iq reference |
|
|
ESMO Ealpha |
|
|
Where HAL_updateDACOutputs() Is Called
HAL_updateDACOutputs() is called from runMotorDataLogging() in
motor_common.c.
To activate it, uncomment the runMotorDataLogging() call in application_run():
/* application.c — application_run() */
/* Section 5: DATA LOGGING — uncomment to enable DAC + serial plot */
runMotorDataLogging();
Note
runMotorDataLogging() executes inside the FOC ISR. For best ISR performance, consider
moving it to the low-priority background loop by calling it from
FOC_runLowPriorityStateMachine() instead.
Serial Plot — Streaming Variables to a PC
The Serial Plot feature streams two float variables over UART to a PC serial plotter (e.g. the Arduino Serial Plotter, or any tool that accepts the same framing).
Back-Channel UART — Hardware
The AM13E232X LaunchPad routes UC1 / PA0 to the XDS110 back-channel UART, which appears as a virtual COM port on the PC when the LaunchPad USB cable is connected. No additional hardware is required.
SysConfig name |
Peripheral |
Pin |
Baud rate |
|---|---|---|---|
|
|
|
10 000 000 |
The UART is already configured in the reference .syscfg file
(3sh_sen_less_foc_drv8323rh_am13e232x.syscfg).
Packet Format
HAL_updateSerialPlot()
sends a 10-byte packet over SERIAL_DATA_PLOT_INST (the generated macro for UC1):
Byte |
Content |
|---|---|
0 |
|
1 |
|
2–5 |
|
6–9 |
|
The same pDacOutAddr pointers configured for the DAC are reused for the serial plot,
so both outputs always show the same two variables.
Configuring the Serial Plotter
Open a serial terminal or plotter on the XDS110 back-channel COM port at the baud rate
configured for SERIAL_DATA_PLOT in the .syscfg file (see the table above). Configure
the tool to expect the 0xAA 0x55 header followed by two 4-byte little-endian floats.
Serial plotter configuration — set the baud rate to match the .syscfg and header bytes to 0xAA 0x55.
Serial plotter showing angleFOC_rad (channel 1) and speed_Hz (channel 2) during
motor run.
Enabling Serial Plot
HAL_updateSerialPlot() is called from runMotorDataLogging() alongside
HAL_updateDACOutputs(). Uncomment runMotorDataLogging() in application_run() as
described in the DAC section above.
To change which variables are plotted, update pDacOutAddr in initDACOutputs():
/* Plot angle on channel 1, speed on channel 2 */
sysVarsPtr->dacCtrl1.pDacOutAddr = (float32_t *)&obj->outVars.angleFOC_rad;
sysVarsPtr->dacCtrl2.pDacOutAddr = (float32_t *)&obj->outVars.speed_Hz;
sysVarsPtr->dacCtrl2.dacEn = 1U;
Back-Channel UART — Using It for Custom Communication
The same UC1 / PA0 UART can be used for any custom serial communication from the
background loop. The SCI_writeBytesNonBlocking()
helper writes bytes to the UART TX FIFO without blocking the caller:
/* Custom background task — send a status byte over back-channel UART */
static void myCustomUARTTask(void)
{
uint8_t txBuf[6];
uint16_t idx = 0;
/* Pack speed as a 4-byte float */
float32_t speed = motorVars_M1.outVars.speed_Hz;
memcpy(&txBuf[0], &speed, sizeof(float32_t));
txBuf[4] = (uint8_t)motorVars_M1.outVars.motorState;
txBuf[5] = '\n';
SCI_writeBytesNonBlocking(SERIAL_DATA_PLOT_INST, txBuf, &idx, 6U);
}
Call this from the 1 ms background loop in main.c:
while (systemVars.flagEnableSystem == true)
{
if (systemVars.timerCntFOCCtrlISR > LOW_PRIORITY_WAIT_TIME_1ms)
{
systemVars.timerCntFOCCtrlISR = 0;
FOC_runLowPriorityStateMachine(&motorVars_M1);
myCustomUARTTask(); /* custom serial output */
}
}
Warning
Do not call SCI_writeBytesNonBlocking() from inside the FOC ISR
(ADC0_INT1_IRQHandler) or application_run(). UART FIFO writes from the ISR add
latency to the FOC loop and can cause ISR overruns at high PWM frequencies. Always
place UART communication in the low-priority background loop.