3-Shunt Sensorless FOC motor control solution using the DRV8323RH gate driver
Note
Common source files are linked from their original SDK locations for easier maintenance during development.
Overview
This solution demonstrates three-shunt sensorless Field Oriented Control (FOC) for PMSM/BLDC motors using the TI DRV8323RH gate driver on the AM13E2X LaunchPad.
Key Features
Three-phase current sensing with individual shunt resistors
Sensorless rotor position estimation using eSMO (enhanced Sliding Mode Observer)
FAST observer library support for motor parameter identification
Field Oriented Control (FOC) with Space Vector PWM
Flux weakening capability for extended speed range
Maximum Torque Per Ampere (MTPA) control
Real-time tuning support via TI Tune interface
Hardware Requirements
AM13E232X LaunchPad (LP-AM13E232X)
BOOSTXL-DRV8323RH booster pack
Compatible PMSM/BLDC motor
DC power supply (appropriate voltage for motor)
Software Dependencies
TI ARM Clang Compiler or IAR Embedded Workbench
SysConfig tool for peripheral configuration
Code Composer Studio (CCS) or IAR EWARM IDE
FAST observer library (pre-built, included)
External Connections
For the complete boosterpack connector pin mapping (LaunchPad header assignments), refer to the 3-Shunt FOC Peripheral Configuration page in the Solutions section of the user guide.
Build Instructions
Import the project into your IDE (CCS or IAR)
Build the project using the default configuration
Connect the hardware and flash the device
Use the debugger or TI Tune to control motor operation
Motor Configuration
Motor parameters are configured in the motor_params.c file:
Common motor control data structures and types are defined in motor_common.h:
Update the following fields in the motorParams structure to match your motor specifications:
Rs_Ohm— Stator resistance (Ω)Ls_d_H/Ls_q_H— D/Q-axis stator inductance (H)flux_VpHz/flux_Wb— Motor flux linkagenumPolePairs— Number of pole pairsratedCurrent_A— Rated phase current (A)
Watch Window Variables
For the quickest setup, import the pre-configured watch variables file into the CCS Watch Window. In CCS, open the Debug:watch view, Right click - Import button (or use View - Debug - Watch Expressions), and select
This will automatically add all key variables for controlling and monitoring the motor controller at runtime.
Alternatively, you can selectively add the following expressions to the CCS Watch Window to monitor and tune the motor controller at runtime:
Input Control (motorVars.inputCtrl) — User Commands
Variable |
Purpose |
|---|---|
|
Start motor and trigger identification ( |
|
Pulse high to clear active fault register ( |
|
Speed setpoint in Hz ( |
|
Motor direction: 1.0 = forward, -1.0 = reverse ( |
|
Detect spinning rotor before start ( |
|
Startup mode: ALIGN / IPD / FREE / HFI ( |
|
Enable auto-restart after fault ( |
|
Enable Dead Time Compensation ( |
|
Enable Field Weakening Control ( |
|
Enable Maximum Torque Per Ampere ( |
|
FAST or ESMO estimator selection ( |
|
Space vector modulation mode ( |
Output Variables (motorVars.outVars) — FOC Outputs
Variable |
Purpose |
|---|---|
|
Current state machine state ( |
|
Active (raw) fault register ( |
|
Controller speed in Hz ( |
|
Controller speed in rad/s ( |
|
Stator current magnitude (A) ( |
|
Measured d/q currents (A) ( |
|
D/Q current reference (A) ( |
|
D/Q voltage command (V) ( |
|
FOC angle used by controller (rad) ( |
|
Field weakening angle output (rad) ( |
|
MTPA angle output (rad) ( |
|
Estimated torque (N·m) ( |
|
Active power (W) ( |
Status Variables (motorVars.statusVars) — Internal Status
Variable |
Purpose |
|---|---|
|
Motor parameter identification complete ( |
|
Currently running identification and online mode ( |
|
Estimator state ( |
|
Masked active fault register ( |
|
Previous fault register (fault history) ( |
|
Absolute speed magnitude (Hz) ( |
|
Speed from FAST estimator (Hz) ( |
|
Speed from PLL/eSMO (Hz) ( |
|
Observer angle — primary observer output (rad) ( |
|
Angle from FAST estimator (rad) ( |
|
Angle from SMO (rad) ( |
|
Angle from PLL (rad) ( |
|
RMS phase currents — 3 phases (A) ( |
|
Restart attempts counter ( |
Set Variables (*motorVars.motorSetsHandle) — Tuning Setpoints
Variable |
Purpose |
|---|---|
|
Speed PI controller gains ( |
|
D-axis current PI gains ( |
|
Q-axis current PI gains ( |
|
Field weakening PI gains ( |
|
Maximum current limit (A) ( |
|
Over voltage fault threshold (V) ( |
|
Under voltage fault threshold (V) ( |
|
Over current threshold (A) ( |
|
Closed-loop max acceleration (Hz/s) ( |
For a detailed description of all motor data structures and runtime setpoints, see the Motor Data Structures page.
AM13E232X Peripheral Configuration
For detailed AM13E232X peripheral configuration including signal routing diagrams, ADC/PWM/CMPSS/crossbar setup, and complete pin summary, refer to the 3-Shunt FOC Peripheral Configuration page.