Migration to a New Board

This section describes how to adapt the motor control solution to a new hardware board — whether that means a different PCB layout (new pin assignments), a different gate driver IC, or a different motor. The changes are localized to a small set of files.


What Needs to Change

digraph what_needs_change { rankdir=TB; size="7,10"; node [shape=box, style="filled,rounded", fontname="Helvetica", fontsize=12, margin="0.35,0.18", width=3.0]; edge [color="#555555", fontname="Helvetica", fontsize=10]; A [label="What changed?", shape=diamond, fillcolor="#f2f3f4", color="#7f8c8d", width=2.5]; /* Cause nodes — same rank */ { rank=same; B; C; D; E; } B [label="New pin assignments\n(same gate driver)", fillcolor="#f2f3f4", color="#7f8c8d"]; C [label="New gate driver IC", fillcolor="#f2f3f4", color="#7f8c8d"]; D [label="New motor", fillcolor="#f2f3f4", color="#7f8c8d"]; E [label="New current sensing topology\n(1-shunt ↔ 3-shunt)", fillcolor="#f2f3f4", color="#7f8c8d"]; /* Action nodes — same rank */ { rank=same; F; G; } F [label="Update SysConfig (.syscfg)\nReassign ADC, PWM, GPIO pins", fillcolor="#fdebd0", color="#e67e22"]; G [label="Update user_mtr1.h\nSense scale factors, OC limits", fillcolor="#fdebd0", color="#e67e22"]; { rank=same; H; I; } H [label="Add new gate driver interface\nhal/gate_driver_interface/new_driver/", fillcolor="#d5f5e3", color="#27ae60"]; I [label="Add gate driver header\nto project include path", fillcolor="#d5f5e3", color="#27ae60"]; { rank=same; J; K; } J [label="Add entry to motor_params.c\nUpdate motorParams_M1 pointer", fillcolor="#d4e6f1", color="#2980b9"]; K [label="Switch example folder\n1sh_sen_less_foc_drv8329a ↔ 3sh_sen_less_foc_drv8323rh", fillcolor="#fdebd0", color="#e67e22"]; A -> B; A -> C; A -> D; A -> E; B -> F; B -> G; C -> F; C -> G; C -> H; C -> I; D -> J; E -> F; E -> K; }


Step-by-Step Migration Guide

Step 1 — Copy an Existing Example

Start from the example that most closely matches your topology:

# For 3-shunt topology
solutions/motor_control/ufoc_lp_bxl/3sh_sen_less_foc_drv8323rh/

# For 1-shunt topology
solutions/motor_control/ufoc_lp_bxl/1sh_sen_less_foc_drv8329a/

Copy the entire example folder and rename it for your board. The main.c, isr.c, and main.h files require minimal changes — most customization is in the files described below.


Step 2 — Update SysConfig (.syscfg)

Open the .syscfg file in SysConfig GUI (or edit as text) and reassign peripherals to match your board’s pin connections.

Key peripherals to configure:

Peripheral

What to Configure

Impact

ADC

Channel assignments for phase currents and bus voltage

MTR1_IW_SEN, MTR1_VU_SEN, MTR1_VW_SEN macros

MCPWM

PWM output pins for U/V/W phases

MTR1_PWM_U/V/W macros

CMPSS

Comparator inputs for over-current protection

MTR1_CMPSS_U/V/W macros

PWM XBAR

ADC trigger source (must be PWM-synchronous)

DL_ADC_TRIGGER_PWM4_SOCA

GPIO

Gate driver enable, nFAULT, ISR timing pin

MTR1_DRV_EN_PORT/PIN, MTR1_FOC_CTRL_ISR_TIMING_PORT/PIN

UART

Serial plot output

SERIAL_DATA_PLOT_INST

ECAP

IPD pulse capture (if using IPD startup)

MTR1_ECAP_INST

After saving the .syscfg file, SysConfig regenerates ti_sdk_dl_config.h and ti_sdk_dl_config.c with the new peripheral macros. The HAL and application code use these macros — no other source changes are needed for pin reassignment.

Note

Run SysConfig → Generate after any .syscfg change to ensure ti_sdk_dl_config.h is up to date before building.


Step 3 — Update user_mtr1.h

user_mtr1.h contains board-level constants that must match your hardware. These are not generated by SysConfig — they must be set manually.

Critical parameters to review:

/* PWM frequency — must match MCPWM configuration in SysConfig */
#define USER_M1_PWM_FREQ_kHz    (15)

/* Current sense scale factor — depends on shunt resistor and op-amp gain */
/* Formula: I_A = ADC_count × USER_M1_CURRENT_SF                          */
/* For DRV8323RH: use DRV8323_CURRENT_SF from drv8323rh_interface.h       */
/* For DRV8329A:  use DRV8329_CURRENT_SF from drv8329a_interface.h        */
#define USER_M1_CURRENT_SF      (float32_t)(DRV8323_CURRENT_SF)

/* DC bus voltage scale factor — depends on voltage divider ratio          */
/* For DRV8323RH: use DRV8323_VOLTAGE_SF from drv8323rh_interface.h       */
/* For DRV8329A:  use DRV8329_VOLTAGE_SF from drv8329a_interface.h        */
#define USER_M1_VOLTAGE_SF      (float32_t)(DRV8323_VOLTAGE_SF)

/* Hardware over-current trip threshold — set to match CMPSS DAC level */
#define USER_M1_MAX_CURRENT_A   (float32_t)(10.0f)

/* ADC offset calibration time — increase if offsets are noisy */
#define USER_M1_OFFSET_CALIB_TIME_SEC   (float32_t)(0.5f)

Warning

Incorrect USER_M1_CURRENT_SF or USER_M1_VOLTAGE_SF will cause wrong current/voltage readings, leading to incorrect PI gains and potential over-current faults. Verify these values against your board schematic before running the motor.


Step 4 — Update the Motor Parameters

If connecting a different motor, add its parameters to motor_params.c and update the active motor pointer:

/* motor_params.c — add new motor entry */
const Motor_ParamsType Motor_myMotor = {
    .NumPolePairs       = 4,
    .Rs_Ohm             = 0.85f,
    .Ls_d_H             = 0.00135f,
    .Ls_q_H             = 0.00135f,
    .RatedFlux_VpHz     = 0.0415f,
    .RatedCurrent_A     = 5.0f,
    .Inertia_Kgm2       = 0.0001f,
    .RatedSpeed_Hz      = 100.0f,
    .OlSpeedThr_Hz      = 20.0f,
    .OlTorqueCurrent_A  = 1.5f,
    .AlignCurrent_A     = 1.0f,
    /* ESMO gains — tune after first run */
    .EsmoKslideMax      = 0.5f,
    .EsmoKslideMin      = 0.05f,
    .EsmoPllKpMax       = 10.0f,
    .EsmoPllKpMin       = 1.0f,
    .EsmoPllKi          = 0.001f,
};

/* Select active motor */
const Motor_ParamsType *motorParams_M1 = &Motor_myMotor;

If motor parameters are unknown, use TiTune to identify them automatically. See the Motor Parameter Tuning guide.


Step 5 — Update the Gate Driver Interface

Each gate driver has a dedicated interface header that defines the hardware-specific scale factors, offset calibration values, and GPIO object. When migrating to a new board or gate driver, these macros must be updated to match your hardware.

Existing Gate Driver Interfaces

The two supported gate drivers are located at:

common_files/hal/gate_driver_interface/
├── drv8329a/
│   └── drv8329a_interface.h    ← 1-shunt (DRV8329A EVM RevA)
└── drv8323rh/
    └── drv8323rh_interface.h   ← 3-shunt (BSXL8323RH RevB)

Each file is guarded by a board-identification #ifdef that must be defined in the project’s compile-time defines (CCS project settings or SysConfig):

Gate Driver

Guard Macro

Topology

DRV8329A

DRV8329AEVM_REVA

1-shunt (DC-link)

DRV8323RH

BSXL8323RH_REVB

3-shunt (per-phase)


DRV8329A Interface Macros (1-Shunt)

File: drv8329a_interface.h

Macro

Value

Description

DRV8329_ADC_FULL_SCALE_VOLTAGE_V

76.045f

Full-scale DC bus voltage at ADC input (set by voltage divider: 110kΩ/4.99kΩ)

DRV8329_VOLTAGE_FILTER_POLE_Hz

326.6f

Analog voltage filter pole frequency (110kΩ/4.99kΩ/100nF)

DRV8329_ADC_FULL_SCALE_CURRENT_A

33.0f

Full-scale DC-link current at ADC input (Rs=10mΩ, CSA gain=10V/V)

DRV8329_VOLTAGE_SF

= FULL_SCALE_V / 4096

Voltage scale factor: ADC count → Volts

DRV8329_CURRENT_SF

= FULL_SCALE_A / 4096

Current scale factor: ADC count → Amps

DRV8329_CURRENT_INV_SF

= 4096 / FULL_SCALE_A

Inverse current scale factor

DRV8329_SIGN_CURRENT_SF

1.0f

Current polarity: 1.0f = inverting op-amp, -1.0f = non-inverting

DRV8329_IDC_OFFSET_AD

516.717f

DC-link current ADC offset (≈ 4096/8, mid-scale for unipolar sensing)

DRV8329_IDC_OFFSET_CMPSS

(uint16_t)(IDC_OFFSET_AD)

CMPSS DAC offset for hardware over-current trip

DRV8329_IDC_OFFSET_AD_MAX/MIN

±100 counts

Acceptable offset calibration range

DRV8329_VA/VB/VC_OFFSET_SF

~0.507f

Phase voltage ADC offset scale factors (≈ 0.5 = mid-scale)

DRV8329_OVER_VOLTAGE_FAULT_V

54.5f

DC bus over-voltage fault threshold

DRV8329_OVER_VOLTAGE_NORM_V

52.5f

DC bus over-voltage recovery threshold

DRV8329_UNDER_VOLTAGE_FAULT_V

0.0f

DC bus under-voltage fault threshold

DRV8329_DCLINKSS_MIN_DURATION

525

Minimum ADC sampling window (clock cycles): Tdt+Tpd+Tr+Ts+Ts&h

DRV8329_DCLINKSS_SAMPLE_DELAY

490

ADC sample delay (clock cycles): Tdt+Tpd+Tr+Ts

GPIO object (HAL_DRV8329_Obj):

Field

Description

gateNSleepGPIO / gateNSleepGPIONum

GPIO port/pin for DRV8329A nSLEEP pin

gateDriverOffGPIO / gateDriverOffGPIONum

GPIO port/pin for driver off control


DRV8323RH Interface Macros (3-Shunt)

File: drv8323rh_interface.h

Macro

Value

Description

DRV8323_NOMINAL_DC_BUS_VOLTAGE_V

48

Nominal DC bus voltage

DRV8323_ADC_FULL_SCALE_VOLTAGE_V

57.529f

Full-scale DC bus voltage at ADC input

DRV8323_VOLTAGE_FILTER_POLE_Hz

680.5f

Analog voltage filter pole frequency

DRV8323_ADC_FULL_SCALE_CURRENT_A

47.143f

Full-scale phase current at ADC input

DRV8323_VOLTAGE_SF

= FULL_SCALE_V / 4096

Voltage scale factor: ADC count → Volts

DRV8323_CURRENT_SF

= FULL_SCALE_A / 4096

Current scale factor: ADC count → Amps

DRV8323_CURRENT_INV_SF

= 4096 / FULL_SCALE_A

Inverse current scale factor

DRV8323_SIGN_CURRENT_SF

1.0f

Current polarity sign

DRV8323_IDC_OFFSET_AD

2048.0f

Phase current ADC offset (mid-scale: 4096/2, bipolar sensing)

DRV8323_IS_OFFSET_CMPSS

= IDC_OFFSET_AD

CMPSS DAC offset for hardware over-current trip

DRV8323_VA/VB/VC_OFFSET_SF

~0.507f

Phase voltage ADC offset scale factors

DRV8323_IA/IB/IC_OFFSET_AD_MAX/MIN

±150 counts

Acceptable per-phase offset calibration range

DRV8323_OVER_VOLTAGE_FAULT_V

54.5f

DC bus over-voltage fault threshold

DRV8323_UNDER_VOLTAGE_FAULT_V

8 V

DC bus under-voltage fault threshold

DRV8323_NUM_CURRENT_SENSORS

3

Number of current sensors (one per phase)

DRV8323_NUM_VOLTAGE_SENSORS

4

Number of voltage sensors (3 phase + 1 DC bus)

GPIO object (HAL_DRV8323_Obj):

Field

Description

gateCalGPIO / gateCalGPIONum

GPIO port/pin for DRV8323RH calibration pin

gateEnableGPIO / gateEnableGPIONum

GPIO port/pin for gate driver enable


Key Differences: 1-Shunt vs 3-Shunt Current Sensing

Parameter

DRV8329A (1-Shunt)

DRV8323RH (3-Shunt)

Current offset

~516 counts (≈ 4096/8)

2048 counts (= 4096/2)

Sensing type

Unipolar (DC-link, always positive)

Bipolar (per-phase, positive and negative)

CMPSS offset

Same as ADC offset

Same as ADC offset

Sample timing

DCLINKSS_MIN_DURATION / DCLINKSS_SAMPLE_DELAY required

Not needed (direct sampling)

Current sensors

1

3

The 1-shunt offset is near 4096/8 because the DC-link current is always positive (unipolar), so the ADC input is biased to a low value. The 3-shunt offset is at 4096/2 (mid-scale) because phase currents are bipolar (positive and negative).


Adding a New Gate Driver Interface

If your board uses a gate driver not already supported, implement the HAL_GD_vTable_t virtual function table interface defined in hal_gate_driver.h.

1. Create the interface header with the same macro pattern:

/* my_new_driver_interface.h */
#ifdef MY_NEW_DRIVER_BOARD_REV

/* --- Scale factors (compute from your schematic) --- */
#define MY_DRV_ADC_FULL_SCALE_VOLTAGE_V   (48.0f)   /* Vbus divider ratio × 3.3V */
#define MY_DRV_ADC_FULL_SCALE_CURRENT_A   (20.0f)   /* Ishunt_max = Vref / (Rs × gain) */
#define MY_DRV_VOLTAGE_SF    (MY_DRV_ADC_FULL_SCALE_VOLTAGE_V / 4096.0f)
#define MY_DRV_CURRENT_SF    (MY_DRV_ADC_FULL_SCALE_CURRENT_A / 4096.0f)
#define MY_DRV_CURRENT_INV_SF (4096.0f / MY_DRV_ADC_FULL_SCALE_CURRENT_A)
#define MY_DRV_SIGN_CURRENT_SF (1.0f)   /* 1.0f = inverting, -1.0f = non-inverting */

/* --- ADC offsets (measure after calibration or compute from circuit) --- */
#define MY_DRV_IDC_OFFSET_AD      (2048.0f)   /* 4096/2 for bipolar, 4096/8 for unipolar */
#define MY_DRV_IDC_OFFSET_CMPSS   (uint16_t)(MY_DRV_IDC_OFFSET_AD)

/* --- Fault thresholds --- */
#define MY_DRV_OVER_VOLTAGE_FAULT_V   (54.5f)
#define MY_DRV_UNDER_VOLTAGE_FAULT_V  (8.0f)

/* --- GPIO object --- */
typedef struct _HAL_MY_DRV_Obj_
{
    uint32_t gateEnableGPIO;
    uint32_t gateEnableGPIONum;
} HAL_MY_DRV_Obj;

#endif /* MY_NEW_DRIVER_BOARD_REV */

2. Create the vtable implementation:

/* my_new_driver_interface.c */
#include "hal_gate_driver.h"
#include "my_new_driver_interface.h"

static void MyDriver_init(const HAL_GD_DATA_Obj *gdData)
{
    /* Configure SPI registers, set CSA gain, etc. */
}

static void MyDriver_enable(const HAL_GD_DATA_Obj *gdData)
{
    HAL_setGPIOHigh(MY_DRV_EN_PORT, MY_DRV_EN_PIN);
}

const HAL_GD_vTable_t MyDriver_vTable = {
    .init   = MyDriver_init,
    .enable = MyDriver_enable,
};

3. Add the gate driver header to the project include path in CCS project settings:

Open Project Properties → Build → Arm Compiler → Include Options and add:

hal/gate_driver_interface/my_new_driver

4. Define the board guard macro in CCS project settings:

Open Project Properties → Build → Arm Compiler → Predefined Symbols and add:

MY_NEW_DRIVER_BOARD_REV

Step 6 — Update the Motor Config Wiring File

The file system_config.c (3-shunt) (and its header system_config.h) is the primary hardware wiring file for the 3-shunt example. It instantiates and links together all hardware-specific objects that the application layer uses at runtime.

When migrating to a new board or gate driver, copy this file pair into your new example folder and update the following objects:

HAL_FOC_Config_t halFOCConfig_M1

Maps SysConfig-generated macros to the HAL FOC configuration. After updating SysConfig (Step 2), verify that the ADC, PWM, CMPSS, and ECAP macro names used here match the names generated in ti_sdk_dl_config.h:

const HAL_FOC_Config_t halFOCConfig_M1 = {
    /* ADC current channels — update if ADC pin assignments changed */
    .adcCurrentCfg[0].adcResultBase = (uint32_t)MTR1_IU_SEN_ADC_RESULT_BASE,
    .adcCurrentCfg[1].adcResultBase = (uint32_t)MTR1_IV_SEN_ADC_RESULT_BASE,
    .adcCurrentCfg[2].adcResultBase = (uint32_t)MTR1_IW_SEN_ADC_RESULT_BASE,
    /* ADC voltage channels */
    .adcVoltageCfg[0].adcResultBase = (uint32_t)MTR1_VU_SEN_ADC_RESULT_BASE,
    /* ... */
    /* PWM peripheral */
    .pwmCfg.pwmHandle = (uint32_t)MTR1_MCPWM_BASE_BASE,
    /* CMPSS overcurrent comparators */
    .cmpCfg.cmpssHandle[0] = (uint32_t)MTR1_CMPSS_U_BASE_BASE,
    /* ECAP for IPD */
    .ecapIPDConfig.base = (uint32_t)IPD_CAPTURE_BASE,
    /* ... */
};

HAL_DRV8323_Obj drv8323Inst_M1

Holds the GPIO port/pin assignments for the gate driver control signals. Update these to match your board’s GPIO connections for the gate driver enable and calibration pins:

const HAL_DRV8323_Obj drv8323Inst_M1 = {
    .gateCalGPIO       = (uint32_t)MTR1_DRV_CAL_PORT,
    .gateCalGPIONum    = (uint32_t)MTR1_DRV_CAL_PIN,
    .gateEnableGPIO    = (uint32_t)MTR1_DRV_EN_PORT,
    .gateEnableGPIONum = (uint32_t)MTR1_DRV_EN_PIN,
};

HAL_GD_Interface_t halGDInst and HAL_FOC_Interface_t halFOCInterface

These link the vtable, instance data, and configuration together. If you are using the same gate driver (DRV8323RH) on a new board, these do not need to change — only the GPIO macros above need updating. If switching to a different gate driver IC, update the vtable pointer to point to the new driver’s vtable:

const HAL_GD_Interface_t halGDInst = {
    .vTable   = &halDRV8323FnTable,   /* ← change for new gate driver */
    .instance = &drv8323Inst_M1,
    .data     = &drv8323Data_M1,
};

MOTOR_Vars_t motorVars_M1

Links the gate driver and FOC interfaces into the top-level motor object. This typically does not need to change when migrating boards:

MOTOR_Vars_t motorVars_M1 = {
    .halInterface = &halFOCInterface,
};

Note

For the 1-shunt topology, the equivalent file is system_config.c (1-shunt). The same update procedure applies.


Migration Checklist

Note

Use this checklist when migrating to a new board:

  • SysConfig: ADC channels reassigned to new pin names

  • SysConfig: PWM outputs assigned to correct phase pins

  • SysConfig: CMPSS inputs connected to correct current sense signals

  • SysConfig: GPIO pins for gate driver EN, nFAULT, timing pin updated

  • user_mtr1.h: USER_M1_CURRENT_SF verified against schematic

  • user_mtr1.h: USER_M1_VOLTAGE_SF verified against schematic

  • user_mtr1.h: USER_M1_MAX_CURRENT_A set to hardware OC limit

  • user_mtr1.h: USER_M1_PWM_FREQ_kHz matches SysConfig MCPWM setting

  • motor_params.c: New motor entry added, motorParams_M1 pointer updated

  • Gate driver header: ADC_FULL_SCALE_VOLTAGE_V computed from voltage divider schematic

  • Gate driver header: ADC_FULL_SCALE_CURRENT_A computed from shunt resistor value and CSA gain

  • Gate driver header: IDC_OFFSET_AD set correctly (≈4096/8 for unipolar 1-shunt, ≈4096/2 for bipolar 3-shunt)

  • Gate driver header: OVER_VOLTAGE_FAULT_V / UNDER_VOLTAGE_FAULT_V set to system limits

  • Gate driver header: DCLINKSS_MIN_DURATION / DCLINKSS_SAMPLE_DELAY set (1-shunt only)

  • Gate driver header: Board guard macro defined in project compile-time defines (DRV8329AEVM_REVA, BSXL8323RH_REVB, or custom)

  • Gate driver vtable: New driver vtable implemented (if using a new gate driver IC)

  • drv8323_3sh_config.c (or drv8329_1sh_config.c): ADC macro names verified against ti_sdk_dl_config.h

  • drv8323_3sh_config.c: GPIO macros for gate driver EN and CAL pins updated to new board pin names

  • drv8323_3sh_config.c: halGDInst.vTable updated if switching to a different gate driver IC

  • Build succeeds

  • First run: verify current and voltage readings in watch window before enabling motor


Signal Path Diagnostics

After migrating to a new board, use this four-step procedure to validate the complete signal path — from raw ADC counts through current feedback, current control, and finally the speed observer — before attempting closed-loop motor operation.

Note

All variables referenced below are accessible in the CCS Watch Window. halFOCData is the HAL_FOC_Data_Obj instance for motor 1. motorVars_M1 is the MOTOR_Vars_t master object.


Step 1 — Verify ADC and Comparator Offsets

Before enabling the motor, confirm that the ADC offset calibration has produced values in the expected range. Offsets are stored in HAL_FOC_Data_Obj.adcData after HAL_RunOffsetCalStep() completes.

Topology

Field to inspect

Expected value

3-shunt

halFOCData.adcData.offset_I_ad[0], [1], [2]

≈ 2048 (mid-scale of 12-bit ADC)

1-shunt (DRV8329A)

halFOCData.adcData.offset_I_ad[0]

≈ 511 (quarter-scale, unipolar sensing)

Comparator DAC offsets are stored in halFOCData.compOffsetData[0..2]. These represent the hardware over-current trip-point calibration. Verify they are non-zero and within the range defined by OVER_CURRENT_FAULT_A in the gate driver header.

Watch window variables:

halFOCData.adcData.offset_I_ad[0]   /* Phase A (or DC-link for 1-shunt) */
halFOCData.adcData.offset_I_ad[1]   /* Phase B (3-shunt only) */
halFOCData.adcData.offset_I_ad[2]   /* Phase C (3-shunt only) */
halFOCData.compOffsetData[0]        /* CMPSS comparator DAC offset, phase A */
halFOCData.compOffsetData[1]        /* CMPSS comparator DAC offset, phase B */
halFOCData.compOffsetData[2]        /* CMPSS comparator DAC offset, phase C */

Pass criteria: Offset values within ±10 % of the expected mid-scale value. Values near 0 or near full-scale (4095) indicate a wiring or SysConfig error — recheck ADC channel assignments and the IDC_OFFSET_AD macro in the gate driver header.


Step 2 — Align Debug: Validate ADC Current Feedback (Voltage Mode)

Enable align-debug mode to inject a known DC voltage vector and observe the resulting phase currents. This validates ADC channel assignment, current scaling, and sign convention without running the current controller.

Enable flags (set in MOTOR_InputCtrl_t):

motorVars_M1.motorCtrl.flagEnableAlignDebug = 1
motorVars_M1.motorCtrl.flagEnableContAlign  = 1

With both flags set the motor is held continuously in the align state. The applied voltage is V_q = I_align × Rs (voltage-mode, open-loop — no current feedback used).

Procedure:

  1. Set flagEnableAlignDebug = 1 and flagEnableContAlign = 1.

  2. Enable the motor (flagEnableRunAndIdentify = 1). The rotor will lock to the align angle.

  3. Vary the align angle via motorVars_M1.motorSetVars.alignAngle_rad across 0 → 2π.

  4. Monitor the phase currents and the d/q projections:

motorVars_M1.motorOutVars.Iabc_A.value[0]   /* Phase A current, amperes */
motorVars_M1.motorOutVars.Iabc_A.value[1]   /* Phase B current, amperes */
motorVars_M1.motorOutVars.Iabc_A.value[2]   /* Phase C current, amperes */
motorVars_M1.motorOutVars.Id_A              /* d-axis current */
motorVars_M1.motorOutVars.Iq_A              /* q-axis current */

Pass criteria:

  • Iabc_A values are smooth and symmetric as the align angle rotates.

  • Id_A tracks the commanded align current; Iq_A stays near zero.

  • No phase reads a constant zero (would indicate an open ADC channel or wrong pin mapping).

If the feedback looks wrong: Recheck ADC channel-to-phase mapping in SysConfig and verify USER_M1_CURRENT_SF in user_mtr1.h. Adjust current loop gains (Kp, Ki) in motorVars_M1.motorSetVars or re-run TiTune / InstaSPIN parameter identification.


Step 3 — Continuous Align: Validate Closed-Loop Current Control

Disable align-debug mode while keeping continuous align active. The current controller is now closed and regulates Id to the align current setpoint. This step validates current loop tuning independently of the speed observer.

Enable flags:

motorVars_M1.motorCtrl.flagEnableAlignDebug = 0   /* disable voltage-mode align */
motorVars_M1.motorCtrl.flagEnableContAlign  = 1   /* keep continuous align active */

Procedure:

  1. Clear flagEnableAlignDebug (leave flagEnableContAlign = 1).

  2. Step through several align angles and observe Id_A and Iq_A.

  3. Id_A should tightly track the commanded align current with minimal overshoot.

  4. Iq_A should remain near zero at all angles.

Watch window variables:

motorVars_M1.motorOutVars.Id_A              /* should equal alignCurrent_A setpoint */
motorVars_M1.motorOutVars.Iq_A              /* should be ≈ 0 */
motorVars_M1.motorSetVars.alignCurrent_A    /* commanded align current */
motorVars_M1.motorSetVars.Kp_Id             /* d-axis proportional gain */
motorVars_M1.motorSetVars.Ki_Id             /* d-axis integral gain */

Pass criteria: Id_A settles to within 5 % of alignCurrent_A within a few PWM cycles. Oscillation or steady-state error indicates incorrect Kp/Ki — re-run parameter identification or manually tune the current loop gains.


Step 4 — Open-Loop Debug: Validate the Speed Observer

Enable open-loop debug mode to run the motor under closed-loop current control with an open-loop speed ramp. The speed observer runs in parallel but does not yet close the speed loop. This lets you verify that the observer locks to the rotor before switching to full sensorless closed-loop operation.

Enable flag:

motorVars_M1.motorCtrl.flagEnableOpenLoopDebug = 1

Procedure:

  1. Clear flagEnableContAlign and set flagEnableOpenLoopDebug = 1.

  2. Enable the motor. The firmware ramps speed open-loop to motorSetVars.speedStart_Hz.

  3. Monitor the observer output speed and angle:

motorVars_M1.motorStatusVars.speedObs_Hz    /* observer estimated speed */
motorVars_M1.motorStatusVars.angleObs_rad   /* observer estimated angle */
motorVars_M1.motorSetVars.speedStart_Hz     /* open-loop ramp target speed */

Pass criteria:

  • speedObs_Hz converges to and tracks speedStart_Hz (the open-loop ramp target).

  • angleObs_rad advances smoothly without large jumps.

  • Observer lock is confirmed when speedObs_Hz is within ±5 % of the commanded speed.

If the observer does not lock:

  • Verify motor parameters (Rs, Ld, Lq, flux) in motor_params.c.

  • Check that USER_M1_MOTOR_NUM_POLE_PAIRS is correct.

  • Reduce speedStart_Hz to a lower value and retry.

  • Re-run InstaSPIN or TiTune identification to obtain accurate motor parameters.

Transition to Closed-Loop:

Once the observer locks reliably in open-loop debug mode, clear flagEnableOpenLoopDebug and proceed with normal closed-loop sensorless FOC operation.