Motor Control — Frequently Asked Questions

This page is a navigation guide for engineers new to the AM13E232X motor control solution. Each question links directly to the relevant section of the documentation.


Quick Navigation

Getting Started

Understanding the Software Architecture

Motor Parameter Identification

Motor Startup Sequence

Porting to a New Board

Adding Custom Code

Control Algorithms


Getting Started

Which example should I start with?

Start with the 3-shunt example (per-phase current sensing, DRV8323RH gate driver):


What files do I actually need to edit to get the motor spinning?

Only three files need changes for a first bring-up on the reference hardware:

  1. user_mtr1.h — set PWM frequency, current/voltage scale factors, and over-current limit to match your board schematic

  2. motor_params.c — add your motor’s nameplate data (Rs, Ld, Lq, flux, pole pairs)

  3. The .syscfg file — reassign ADC, PWM, and GPIO pins if your board differs from the reference EVM

See the full Migration Checklist for a step-by-step list.


What hardware is required to run the reference examples?

See the Hardware Requirements section in the example README:


What is SysConfig and why does the motor control solution use it?

SysConfig is a graphical peripheral configuration tool. The motor control solution uses it to configure all hardware peripherals (ADC, MCPWM, CMPSS, GPIO, UART) and auto-generate ti_sdk_dl_config.h / ti_sdk_dl_config.c. This means pin assignments and peripheral settings can be changed without editing C source code.

See SysConfig Integration for details on what SysConfig configures and how the generated macros are used in the HAL.


How are the peripherals configured in SysConfig for the motor control application?

SysConfig configures all hardware peripherals (MCPWM, ADC, CMPSS, crossbar, GPIO, UART) and auto-generates ti_sdk_dl_config.h / ti_sdk_dl_config.c.

The 3-shunt (DRV8323RH) example uses:

Peripheral

3-Shunt (DRV8323RH)

MCPWM

MCPWM0 — three-phase centre-aligned PWM

ADC

ADC0, ADC1, ADC2 — one per phase current + phase/DC voltages

CMPSS

CMPSS0/1/2 — per-phase hardware OC trip

Crossbar

INPUTXBAR, PWMXBAR, OUTPUTXBAR for fault routing

UART

UC1 / PA0 — serial data plot (baud rate set in the .syscfg)

For the complete pin mapping, ADC SOC sequencing, CMPSS DAC thresholds, crossbar routing, and software handle assignments, see the dedicated peripheral configuration page:


Understanding the Software Architecture

What is the overall file structure of the motor control solution?

See File Structure and Software Layers. The key directories are:

Directory

Contents

ufoc_lp_bxl/3sh_sen_less_foc_drv8323rh/

Example entry point: main.c, isr.c, main.h, .syscfg

common_files/app_lib/

FOC algorithm, state machines, data structures

common_files/hal/

Hardware abstraction: FOC interface, gate driver interface

ufoc_lp_bxl/<solution>/system_config/

Board constants (user_mtr1.h), motor init (mtr1_init.c), hardware wiring (system_config.c)

common_files/app_lib/ (shared)

Motor parameter tables (motor_params.h/c)


How does the FOC algorithm execute? What calls what?

The FOC runs inside the ADC ISR, triggered every PWM cycle:

MCPWM → ADC SOC trigger → ADC0_INT1_IRQHandler (isr.c)
    └─ application_run()
           ├─ FOC_runFeedback()      — read ADC, compute currents/voltages
           ├─ FOC_runObservers()     — FAST or ESMO angle/speed estimation
           ├─ FOC_runStateMachine()  — state transitions
           ├─ FOC_runFeedforward()   — Park transform, SVPWM output
           └─ data logging

See Execution Architecture for the full diagram including the background loop.


How fast does the ISR run? Can I change the ISR frequency?

The ISR runs at the same frequency as the PWM switching frequency. The default is 15 kHz (66 µs per tick). It can be scaled up to 100 kHz by changing USER_M1_PWM_FREQ_kHz in user_mtr1.h and matching the MCPWM period in SysConfig.

See Execution Architecture for the PWM→ADC trigger chain explanation.


What are the motor control state machines and how do they interact?

There are three state machines:

State Machine

Runs In

Frequency

Purpose

High-priority SM

ADC ISR

Every PWM cycle

FOC angle/current control, state transitions

Low-priority SM

Background loop

~1 ms

Fault checking, trajectory, monitoring

TiTune SM

ADC ISR (during IDENT)

Every PWM cycle

Automated motor parameter identification

See State Machines for diagrams of all three.


What happens during startup before the motor runs?

Two calibration phases must complete before the motor can be commanded:

  1. Comparator DAC offset calibration — blocking, runs before ISR starts, calibrates CMPSS hardware over-current trip points

  2. ADC IIR offset calibration — ISR-driven, runs with PWM active at 0% duty, calibrates ADC current/voltage channel offsets

See Startup and Calibration Sequence for the full sequence diagram and explanation of why two phases are needed.


What motor states exist and what do they mean?

See High-Priority State Machine for the full state diagram. Key states:

State

Meaning

MOTOR_STOP_IDLE

Motor stopped, waiting for command

MOTOR_OFFSET_CALIB

ADC calibration running

MOTOR_ALIGNMENT

Rotor forced to known angle

MOTOR_OL_START

Open-loop speed ramp

MOTOR_CTRL_RUN

Closed-loop FOC active

MOTOR_FAULT_STOP

Fault active, PWM disabled


What data structures control the motor at runtime?

See Motor Data Structures. The key structures are:

Structure

Purpose

MOTOR_SetVars_t

Runtime setpoints — speed reference, current limits, enable flags

MOTOR_InputCtrl_t

User commands — start/stop, mode selection

MOTOR_OutVars_t

FOC outputs — Id, Iq, Vd, Vq, angle, speed

MOTOR_StatusVars_t

Internal status — observer state, PI integrators

MOTOR_Vars_t

Master object — contains all of the above

Motor_ParamsType

Motor nameplate — Rs, Ld, Lq, flux, pole pairs


What is HAL_FOC_Data_Obj and what does it carry at the hardware/FOC boundary?

HAL_FOC_Data_Obj is the mutable runtime data object that sits at the boundary between the hardware abstraction layer (HAL) and the FOC algorithm. It is updated every PWM cycle inside the ADC ISR and carries all the live data the FOC algorithm needs to read from hardware and write back to it.

Field

Type

Direction

Purpose

adcData

HAL_ADCData_t

HAL → FOC

Phase currents (I_A), DC-bus voltage (VdcBus_V), ADC offset calibration values

pwmData

HAL_PWMData_t

FOC → HAL

Duty-cycle commands (Vabc_pu), compare register values, PWM enable flag, ADC SOC triggers

gdDataHandle

HAL_GD_DATA_Obj *

HAL → FOC (read-only)

Gate driver scaling constants and fault thresholds; FOC reads these to scale currents and voltages correctly

compOffsetData[3]

float32_t

HAL → FOC

Comparator DAC trip-point offsets for hardware over-current protection

ADC data and offset calibration: adcData.offset_I_ad[] holds the IIR-filtered ADC zero-current offset for each phase. These are computed during the MOTOR_OFFSET_CALIB state and must be near mid-scale (≈ 2048 for 3-shunt, ≈ 511 for 1-shunt) before the motor can run.

PWM data flow: The FOC algorithm writes normalised duty cycles to pwmData.Vabc_pu[]. The HAL converts these to compare register values (cmpValue[]) and writes them to the MCPWM hardware. flagEnablePwm gates the output — the HAL only updates the compare registers when this flag is set.

Gate driver fault communication: gdDataHandle points to the gate driver’s read-only data object. The FOC layer reads gdDataHandle->overCurrentFaultThreshold_A and the voltage scaling constants from this handle. The gate driver ISR sets fault bits in the same object, which the low-priority state machine polls to trigger MOTOR_FAULT_STOP.

See HAL FOC Data Object for the complete field reference, sub-structure descriptions, and data-flow diagrams.


How do I command the motor to start/stop and set speed?

Use the MOTOR_InputCtrl_t fields in the watch window or via your application code:

/* Set speed reference and direction */
motorVars_M1.inputCtrl.speedRef_Hz = 50.0f;
motorVars_M1.inputCtrl.direction   = 1.0f;

/* Select estimator (FAST or ESMO) */
motorVars_M1.inputCtrl.estimatorMode = ESTIMATOR_MODE_ESMO;

/* Enable run */
motorVars_M1.inputCtrl.flagEnableRunAndIdentify = true;

To stop the motor, clear flagEnableRunAndIdentify:

motorVars_M1.inputCtrl.flagEnableRunAndIdentify = false;

See MOTOR_InputCtrl_t — User Commands for all available fields.


Motor Parameter Identification

How do I identify my motor’s Rs, Ld, Lq, and flux linkage parameters?

Use TiTune — the automated parameter identification tool built into the solution. Set motorParamIdentifyMethod = MOTOR_PARAM_IDENTIFY_TITUNE and enable flagEnableRunAndIdentify. TiTune runs a sequence of HF injection, DC injection, open-loop ramp, and closed-loop flux estimation to identify all parameters automatically.

See TiTune State Machine for the identification sequence and Motor Parameter Tuning for step-by-step instructions.


What does TiTune identify and what does it output?

Parameter

Identification Method

Output Field

Ld, Lq

HF voltage injection at standstill

TiTune_Obj.ld_Final, lq_Final

Rs

DC current injection

TiTune_Obj.Rs_Final

λ_PM (flux)

Closed-loop flux estimation

TiTune_Obj.lambda_PM

J (inertia)

Coast-down frequency sweep

TiTune_Obj.J_Kgm2

Speed PI gains

Computed from J/Kt

TiTune_PI_Speed

See TiTune State Descriptions.


Motor Startup Sequence

How does the motor start from standstill — Motor Align or IPD?

Before a sensorless FOC drive can enter closed-loop control, the rotor’s initial angular position must be established. Two methods are available:

Method

How It Works

When to Use

Motor Align

Applies a fixed DC voltage vector for a configurable hold time, forcing the rotor to a known angle

SPM motors, or when brief rotor movement at startup is acceptable

IPD (Initial Position Detection)

Injects high-frequency voltage pulses in six sectors and measures the current response to detect the d-axis angle without moving the rotor

IPM motors, or when rotor movement at startup is not acceptable

Select the method in mtr1_init.c:

/* Motor Align (default) */
obj->inputCtrl.flagEnableAlignment = true;
obj->inputCtrl.startupMode = STARTUP_ALIGN;

/* IPD */
obj->inputCtrl.startupMode = STARTUP_IPD;

Key parameters in motor_params.h:

Parameter

Method

Description

AlignCurrent_A

Motor Align

DC hold current (A) — must be enough to move the rotor

AlignDelay_sec

Motor Align

Hold duration (s) — allow 5 s for the rotor to fully settle

IpdPulseCurrent_A

IPD

Peak current limit for each injection pulse (A)

IpdCycleCountMax

IPD

Number of injection cycles per sector

See Motor Startup for the full configuration guide, watch window expressions, and troubleshooting tips.


How do I tune the open-loop ramp and closed-loop transition?

After initial position detection, the motor accelerates in open-loop (forced angle) until the sensorless observer locks on, then transitions to closed-loop FOC. The key parameters are in motor_params.h:

Parameter

Description

Tuning Guidance

OlTorqueCurrent_A

Torque current applied during the open-loop ramp

Start at 50–70% of rated current

OlAccelRate_Hzps

Open-loop speed ramp rate (Hz/s)

Too high → rotor loses sync; too low → slow startup

OlSpeedThr_Hz

Electrical speed at which OL→CL handover is triggered

Must be high enough for the observer to lock on (≥10–20% of rated speed for ESMO)

OlThetaRampRate_dps

Angle blending step rate at the OL→CL transition

Smaller value = smoother handover; 360 deg/s is a good starting point

ClAccelRate_Hzps

Closed-loop speed ramp rate after CL entry

Too high → current saturation; too low → slow ramp to target speed

To hold the motor in open-loop for debugging, set motorVars_M1.inputCtrl.flagEnableOpenLoopDebug = true in the watch window.

See Open-Loop Ramp and Closed-Loop Transition for the full parameter reference and watch window expressions.


How do I enable Flying Start for a motor that may already be spinning?

Flying Start (ISD — Initial Speed Detection) allows the drive to detect a spinning rotor and transition directly to closed-loop without a full restart sequence. It is designed for fan, blower, and high-inertia loads that coast after a stop command or power interruption.

Enable it in mtr1_init.c:

obj->inputCtrl.flagEnableFlyingStart = true;

When enabled, the state machine enters MOTOR_SEEK_POS at startup. The sensorless observer runs passively for FlyingStartDelay_sec seconds. If the estimated speed exceeds FlyingStartMinSpeed_Hz, the drive transitions directly to closed-loop. Otherwise it falls through to the normal Motor Align → Open-Loop Ramp sequence.

Key parameters in motor_params.h:

Parameter

Description

Example

FlyingStartMinSpeed_Hz

Minimum electrical speed to consider the rotor spinning

3.0 Hz

FlyingStartDelay_sec

Detection window — how long to observe before deciding

0.5 s

Note

Flying Start does not require DC bus voltage sensing. Speed detection relies entirely on the sensorless observer (FAST or ESMO) using only phase current measurements.

See Flying Start (ISD) for the full configuration guide and watch window expressions.


Porting to a New Board

My PCB uses the same gate driver but has different pin assignments. What needs to change?

Only SysConfig and user_mtr1.h:

  1. Open the .syscfg file and reassign ADC channels, PWM pins, CMPSS inputs, and GPIO to match your board’s pin connections

  2. Update USER_M1_CURRENT_SF, USER_M1_VOLTAGE_SF, and USER_M1_MAX_CURRENT_A in user_mtr1.h to match your shunt resistor value, op-amp gain, and voltage divider

See Step 2 — Update SysConfig and Step 3 — Update user_mtr1.h.


My design uses a different gate driver IC. How do I add support for it?

Create a new gate driver interface header following the pattern of the existing ones (drv8329a_interface.h / drv8323rh_interface.h), implement the HAL_GD_vTable_t virtual function table, and add the header directory to the CCS project include paths.

See Adding a New Gate Driver Interface for the complete step-by-step guide with code templates.


What is the board guard macro (DRV8329AEVM_REVA, BSXL8323RH_REVB) and where is it defined?

Each gate driver interface header is wrapped in an #ifdef BOARD_GUARD_MACRO guard. The correct macro must be defined as a compile-time preprocessor symbol in the CCS project settings (Project Properties → Build → Arm Compiler → Predefined Symbols).

See Existing Gate Driver Interfaces for the macro names and Step 4 — Define the board guard macro for how to set it in CCS.


What is the difference between 1-shunt and 3-shunt current sensing?

Aspect

1-Shunt (DRV8329A)

3-Shunt (DRV8323RH)

Shunt location

DC link (single resistor)

Per phase (three resistors)

ADC channels

1 current channel

3 current channels

Current reconstruction

Required (sample timing critical)

Not needed

ADC offset

~4096/8 (unipolar)

4096/2 (bipolar)

Sample timing macros

DCLINKSS_MIN_DURATION, DCLINKSS_SAMPLE_DELAY

Not needed

See 1-Shunt vs 3-Shunt Topology and Key Differences: 1-Shunt vs 3-Shunt.


Is there a migration checklist I can follow when porting to a new board?

Yes. The Migration Checklist in the board migration guide provides a step-by-step list covering all required changes:

Step

What to Do

1

Copy the reference project for your topology (1-shunt or 3-shunt)

2

Update SysConfig (.syscfg) — reassign ADC, PWM, CMPSS, and GPIO pins

3

Update user_mtr1.h — set current/voltage scale factors and over-current limit

4

Define the board guard macro in the project preprocessor settings

5

Update or create the gate driver interface header

6

Update the hardware wiring file (drv8323_3sh_config.c / drv8329_1sh_config.c)

7

Enter motor nameplate parameters in motor_params.h / motor_params.c

8

Run motor parameter identification (TiTune or InstaSPIN)

See Board Migration Guide for the complete step-by-step instructions with code examples for each step.


How do I validate the signal path after porting to a new board?

Use the four-step Signal Path Diagnostics procedure in the Board Migration Guide. It walks through each layer of the signal chain in order, so you can isolate problems before attempting closed-loop motor operation:

Step

What It Validates

Key Variables

1 — ADC & CMP Offsets

ADC offset calibration completed correctly; CMPSS DAC trip-points are non-zero

halFOCData.adcData.offset_I_ad[], halFOCData.compOffsetData[]

2 — Align Debug (voltage mode)

ADC channel-to-phase mapping, current scaling, and sign convention

motorVars_M1.motorOutVars.Iabc_A, Id_A, Iq_A

3 — Continuous Align (closed-loop current)

Current loop gains (Kp/Ki) are correctly tuned

motorVars_M1.motorOutVars.Id_A tracks alignCurrent_A; Iq_A ≈ 0

4 — Open-Loop Debug (observer lock)

Speed observer converges before closing the speed loop

motorVars_M1.motorStatusVars.speedObs_Hz tracks speedStart_Hz

Enable flags (set in the CCS Watch Window):

/* Step 2 — voltage-mode align */
motorVars_M1.motorCtrl.flagEnableAlignDebug = 1
motorVars_M1.motorCtrl.flagEnableContAlign  = 1

/* Step 3 — closed-loop current, clear align-debug */
motorVars_M1.motorCtrl.flagEnableAlignDebug = 0
motorVars_M1.motorCtrl.flagEnableContAlign  = 1

/* Step 4 — open-loop observer validation */
motorVars_M1.motorCtrl.flagEnableOpenLoopDebug = 1

See Signal Path Diagnostics for the complete procedure with pass/fail criteria and troubleshooting guidance for each step.


Adding Custom Code

How do I add a new interrupt-driven peripheral (e.g., a custom UART or timer ISR)?

  1. Add the peripheral in SysConfig to get the generated init code and IRQ number

  2. Write the ISR handler in isr.c

  3. Set the NVIC priority lower than the ADC ISR (higher numeric value) so it cannot preempt the FOC execution

See Adding an Interrupt-Based Routine.


How do I add code that runs synchronously with the FOC ISR at the same rate?

Add your code inside application_run() in application.c, after the five FOC sections. Keep execution time within the ISR budget (1000 / USER_M1_PWM_FREQ_kHz µs — e.g. 66 µs at 15 kHz, 10 µs at 100 kHz). Place time-critical code in RAM using the MOTOR_CTRL_RAMFUNC attribute.

See Adding Synchronous Routines.


How do I add a slow background task (e.g., a status report or outer-loop controller)?

Add it to the background loop in main.c or inside FOC_runLowPriorityStateMachine(). The background loop runs approximately every 1 ms. Use the timerCntFOCCtrlISR counter to create sub-multiples of the 1 ms tick if needed.

See Adding Asynchronous Low-Priority Routines.


How much ISR execution time is available for custom code?

At 15 kHz the ISR budget is 66 µs. At 100 kHz it is 10 µs. Use the CPU_TIME_Obj (cpuTime) in main.h to measure actual ISR execution time. Custom code added to application_run() must be RAM-resident (MOTOR_CTRL_RAMFUNC) to avoid flash wait-state latency.

See ISR Execution Budget.


Control Algorithms

Which observer should I use — FAST or ESMO?

Observer

Best For

FAST (InstaSPIN)

Wide speed range, robust startup, handles parameter variation

ESMO

Simpler tuning, lower CPU load, good for steady-state operation

See FAST Observer and ESMO Observer for configuration details and a comparison table.


How do I enable Field Weakening (FWC) to run above base speed?

Set flagEnableFWC = TRUE in MOTOR_SetVars_t and configure the FWC voltage limit (VsRef) and maximum negative d-axis current (IdMin_A).

See Field Weakening.


What is MTPA and when should I use it?

MTPA (Maximum Torque Per Ampere) minimizes copper losses by finding the optimal d/q current split for a given torque. It is most beneficial for interior permanent magnet (IPM) motors where Ld ≠ Lq. Enable with flagEnableMTPA = TRUE.

See MTPA.


What is dead-time compensation and when should I enable it?

Dead-time compensation (DTC) corrects the voltage distortion introduced by the mandatory dead-time inserted between complementary switch transitions in each inverter leg. Without compensation, 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.

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

/* In mtr1_init.c — enable DTC during initialisation */
DTC_InitParams_t dtcParams;
DTC_setDefaultParams(&dtcParams);
dtcParams.speedEnableLimit_Hz  = 10.0f;  /* Enable DTC above 10 Hz electrical speed */
dtcParams.speedDisableLimit_Hz = 5.0f;   /* Disable DTC below 5 Hz (hysteresis) */
dtcParams.enableDTC = true;
DTC_initParams(obj->deadTimeCompHandle, &dtcParams);

Or toggle at runtime:

/* Watch window expression */
motorVars_M1.inputCtrl.flagEnableDTC = true;

Parameter

Default

Description

speedEnableLimit_Hz

10.0 Hz

Minimum electrical speed to activate DTC

speedDisableLimit_Hz

5.0 Hz

Speed at which DTC deactivates when decelerating

maxOutFactor

0.05

Maximum compensation voltage as a fraction of DC bus voltage

DTC is most effective when:

  • The motor runs at low speed or low modulation index

  • The ESMO observer is used (DTC improves voltage accuracy for the back-EMF estimator)

  • Torque ripple or current THD at low speed is unacceptable

See Dead-Time Compensation for the full configuration guide and effect on performance.


What should I tune if the motor vibrates or makes noise at low speed?

Common causes and tuning targets:

Symptom

Likely Cause

Where to Tune

Vibration at low speed

Current loop bandwidth too high or Rs mismatch

USER_M1_CURRENT_SF, current PI gains

Noise during open-loop ramp

OlAccelRate_Hzps too fast

motor_params.c

Oscillation after OL→CL transition

Observer not locked, OlSpeedThr_Hz too low

motor_params.c

Dead-time distortion at low speed

Dead-time compensation not enabled

Dead-Time Compensation


How do I monitor and debug motor variables on an oscilloscope or serial plotter?

The solution provides two real-time diagnostic output paths that share the same variable pointer configuration:

Method

Output

Hardware Required

DAC output

Analogue voltage on CMPSSLITE pin, viewable on a CRO

Oscilloscope probe on the DAC output pin

Serial Plot

Two float values streamed over back-channel UART (UC1 / PA0)

PC serial plotter at the baud rate configured in the .syscfg, via XDS110 USB

To select which variables to plot, edit initDACOutputs() in motor_common.c and point pDacOutAddr at any float32_t field in motorVars_M1:

/* Plot FOC angle on channel 1 (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;   /* 0 = bipolar, 1 = unipolar */
sysVarsPtr->dacCtrl1.dacEn            = 1U;

/* Plot speed on channel 2 */
sysVarsPtr->dacCtrl2.pDacOutAddr = (float32_t *)&obj->outVars.speed_Hz;
sysVarsPtr->dacCtrl2.dacEn       = 1U;

To activate both outputs, uncomment runMotorDataLogging() in application_run():

/* application.c — Section 5: DATA LOGGING */
runMotorDataLogging();

Common variable addresses for the DAC pointer:

Signal

Pointer expression

FOC angle

&obj->outVars.angleFOC_rad

Phase-A current

&obj->halInterface->halFOCDataHandle->adcData.I_A.value[0]

Speed (Hz)

&obj->outVars.speed_Hz

Iq reference

&obj->outVars.IdqRef_A.value[1]

ESMO Ealpha

&obj->esmoHandle->Ealpha

See Real-Time Diagnostics — DAC Output and Serial Plot for the full configuration guide, scaling formulas, packet format, and oscilloscope screenshots.


Where are all the tunable parameters and what do they control?

See Motor Data Structures for a complete map of all runtime parameters and their locations. Key tuning parameters:

Parameter

Location

Controls

speedRef_Hz

MOTOR_SetVars_t

Speed setpoint

IsRef_A

MOTOR_SetVars_t

Current limit

Kp_spd, Ki_spd

MOTOR_SetVars_t

Speed PI gains

Kp_Id, Ki_Id

MOTOR_SetVars_t

D-axis current PI gains

Kp_Iq, Ki_Iq

MOTOR_SetVars_t

Q-axis current PI gains

OlAccelRate_Hzps

Motor_ParamsType

Open-loop ramp rate

AlignCurrent_A

Motor_ParamsType

Alignment current