MSPM0G3507: MSPM0G SDK Motorautotune

Part Number: MSPM0G3507
Other Parts Discussed in Thread: DRV8329

Hello,

MSPM0G sdk has Motorautotune.c file, when we use universal motor control drv8329 example code "motorautotune.c" (file path modules->algolib->FOC->source) file not reflect in CCS automaticaly. 

i want to use this file and want to do motor autotuning of rs ls and bemf parameter so my Control card become universal for all motors.

how can i use motorautotune file please guide, also share if any detail documentation available on auto tunning 

thanks 

  • Hi,

    The behavior you are seeing is expected. CCS does not automatically compile every .c file located under the MSPM0 SDK source tree. The imported universal-foc_DRV8329 project builds only the source files and libraries explicitly listed by its project definition. Therefore, the presence of motorautotune.c under modules/algolib/FOC/source does not automatically make it appear in Project Explorer or include it in the build.

    Also, the current Universal FOC documentation does not list motor auto-identification as an integrated application feature. The documented Universal FOC modules include startup, brake, open-loop/closed-loop control, estimators, PI controllers, MTPA, and field weakening, but not the motorautotune module. This indicates that the file is not currently integrated into the supported DRV8329 example flow and cannot be enabled simply by adding the source file.

    First make a workspace copy of the DRV8329 example rather than modifying the original SDK installation.

    Right-click the CCS project and select Add Files.
    Browse to:C:\ti\mspm0_sdk_<version>\source\ti\motor_control_universal_foc\modules\algolib\FOC\source\motorautotune.c
    Select Link to files so the SDK source remains in its original location.
    Add the directory containing the corresponding motorautotune.h file under:
    Project Properties
    → Build
    → Arm Compiler
    → Include Options
    Right-click motorautotune.c, open Resource Configurations → Exclude from Build, and verify that it is enabled for the required build configuration.
    Clean and rebuild the project. The CCS Build Console must contain a line showing that motorautotune.c is being compiled.

    If compilation produces unresolved references, the module depends on additional algorithm source files or interfaces that also need to be added. If the linker reports duplicate symbols, the implementation is already present in a linked algorithm library, and only its public header/API should be used.

    Adding the file is not sufficient

    motorautotune.c needs to be connected to:

    • The motor-control state machine
    • PWM generation
    • ADC current and voltage samples
    • DC-bus voltage measurement
    • Current-sense offset and gain calibration
    • Motor fault handling
    • Safe current and voltage limits
    • The Universal FOC input-register interface

    The DRV8329 example uses a single-shunt current-sensing configuration, in which the DC-bus current is sampled twice during different switching vectors. PWM edges are dynamically shifted to create valid measurement windows. Any resistance or inductance identification routine must use this existing single-shunt sampling mechanism rather than assuming three directly measured phase currents.

    A separate identification state should be added before normal FOC startup:

    MOTOR_IDLE
               ↓
    CURRENT_OFFSET_CALIBRATION
               ↓
    MEASURE_RS
               ↓
    MEASURE_LS
               ↓
    MEASURE_BEMF
               ↓
    VALIDATE_RESULTS
               ↓
    APPLY_PARAMETERS
               ↓
    NORMAL_FOC_STARTUP

    Do not execute auto-identification from the normal FOC ISR without first understanding the APIs and state requirements in motorautotune.h. The identification procedure temporarily overrides normal PWM and current-control operation.

    After identification, the results must be written into the Universal FOC system parameters:

    pUserInputRegs->systemParams.mtrResist =
        identifiedResistance;
    
    pUserInputRegs->systemParams.mtrInductance =
        identifiedInductance;
    
    pUserInputRegs->systemParams.mtrBemfConst =
        identifiedBemfConstant;
    
    /*
     * Request that the application transfer the new register
     * values into the active FOC algorithm structures.
     *
     * Verify the exact member names against the headers from
     * the installed SDK version.
     */
    pUserCtrlRegs->algoDebugCtrl2.updateSysParams = 1U;

    Wait for updateSysParams to return to zero before starting the motor. The Universal FOC application periodically parses the user registers and uses this update command to transfer system parameters into the active FOC variables.

    Use the scaling defined by the exact SDK version:

    • mtrResist: motor phase resistance in milliohms
    • mtrInductance: motor phase inductance in microhenries
    • mtrBemfConst: motor BEMF constant based on the SDK’s mV/Hz scaling

    The current tuning guide notes that the BEMF register value is entered as Ke × 10, so the register definition in the header and the tuning guide for the installed SDK version should be followed rather than assuming that the raw integer equals mV/Hz directly. 

    The main public document is the MSPM0 Universal FOC Tuning User’s Guide, SLAU958A. It provides the supported hardware setup, register map, manual procedures for obtaining resistance, inductance and BEMF, basic motor spinning, estimator tuning, PI-loop tuning, startup configuration, and advanced control features.

    At present, I do not see a released step-by-step TI user guide that documents integrating motorautotune.c into the Universal FOC DRV8329 example. The supported and lower-risk approach is to first use the Universal FOC tuning guide or GUI to characterize several representative motors. Integration of motorautotune.c should be treated as a custom software extension.