SPRUJ26A September   2021  – April 2024

 

  1.   1
  2.   Abstract
  3.   Trademarks
  4. 1Introduction
  5. 2Motor Control Theory
    1. 2.1 Mathematical Model and FOC Structure of PMSM
    2. 2.2 Field Oriented Control of PM Synchronous Motor
    3. 2.3 Sensorless Control of PM Synchronous Motor
      1. 2.3.1 Enhanced Sliding Mode Observer with Phase Locked Loop
        1. 2.3.1.1 Design of ESMO for PMSM
        2. 2.3.1.2 Rotor Position and Speed Estimation With PLL
    4. 2.4 Hardware Prerequisites for Motor Drive
      1. 2.4.1 Motor Phase Voltage Feedback
    5. 2.5 Additional Control Features
      1. 2.5.1 Field Weakening (FW) and Maximum Torque Per Ampere (MTPA) Control
      2. 2.5.2 Flying Start
  6. 3Running the Universal Lab on TI Hardware Kits
    1. 3.1 Supported TI Motor Evaluation Kits
    2. 3.2 Hardware Board Setup
      1. 3.2.1  LAUNCHXL-F280025C Setup
      2. 3.2.2  LAUNCHXL-F280039C Setup
      3. 3.2.3  LAUNCHXL-F2800137 Setup
      4. 3.2.4  TMDSCNCD280025C Setup
      5. 3.2.5  TMDSCNCD280039C Setup
      6. 3.2.6  TMDSCNCD2800137 Setup
      7. 3.2.7  TMDSADAP180TO100 Setup
      8. 3.2.8  DRV8329AEVM Setup
      9. 3.2.9  BOOSTXL-DRV8323RH Setup
      10. 3.2.10 BOOSTXL-DRV8323RS Setup
      11. 3.2.11 DRV8353RS-EVM Setup
      12. 3.2.12 BOOSTXL-3PHGANINV Setup
      13. 3.2.13 DRV8316REVM Setup
      14. 3.2.14 TMDSHVMTRINSPIN Setup
      15.      34
      16.      35
    3. 3.3 Lab Software Implementation
      1. 3.3.1 Importing and Configuring Project
      2.      38
      3.      39
      4. 3.3.2 Lab Project Structure
      5. 3.3.3 Lab Software Overview
    4. 3.4 Monitoring Feedback or Control Variables
      1. 3.4.1 Using DATALOG Function
      2. 3.4.2 Using PWMDAC Function
      3. 3.4.3 Using External DAC Board
    5. 3.5 Running the Project Incrementally Using Different Build Levels
      1. 3.5.1 Level 1 Incremental Build
        1. 3.5.1.1 Build and Load Project
        2. 3.5.1.2 Setup Debug Environment Windows
        3. 3.5.1.3 Run the Code
      2. 3.5.2 Level 2 Incremental Build
        1. 3.5.2.1 Build and Load Project
        2. 3.5.2.2 Setup Debug Environment Windows
        3. 3.5.2.3 Run the Code
      3. 3.5.3 Level 3 Incremental Build
        1. 3.5.3.1 Build and Load Project
        2. 3.5.3.2 Setup Debug Environment Windows
        3. 3.5.3.3 Run the Code
      4. 3.5.4 Level 4 Incremental Build
        1. 3.5.4.1 Build and Load Project
        2. 3.5.4.2 Setup Debug Environment Windows
        3. 3.5.4.3 Run the Code
  7. 4Building a Custom Board
    1. 4.1 Building a New Custom Board
      1. 4.1.1 Hardware Setup
      2. 4.1.2 Migrating Reference Code to a Custom Board
        1. 4.1.2.1 Setting Hardware Board Parameters
        2. 4.1.2.2 Modifying Motor Control Parameters
        3. 4.1.2.3 Changing Pin Assignment
        4. 4.1.2.4 Configuring the PWM Module
        5. 4.1.2.5 Configuring the ADC Module
        6. 4.1.2.6 Configuring the CMPSS Module
        7. 4.1.2.7 Configuring Fault Protection Function
      3. 4.1.3 Adding Additional Functionality to Motor Control Project
        1. 4.1.3.1 Adding Push Buttons Functionality
        2. 4.1.3.2 Adding Potentiometer Read Functionality
        3. 4.1.3.3 Adding CAN Functionality
    2. 4.2 Supporting New BLDC Motor Driver Board
    3. 4.3 Porting Reference Code to New C2000 MCU
  8.   A Appendix A. Motor Control Parameters
  9.   References
  10.   Revision History

Configuring the ADC Module

Similar to the previous PWM section, the ADC connections can also be changed for a custom board or a TI motor control kit or C2000 MCU that is not supported with the universal motor control lab. The HAL module configures the ADC channels to correctly correspond with the motor driver board. As an example, the connection diagram for the LAUNCHXL-F280025C and BOOSTXL-DRV8323RS combination is shown in Figure 4-3. The ADC modules configuration is described in the following steps, with potential board-specific changes highlighted in bold. Steps 1 and 2 are essential for configuring a new motor driver board or a different C2000 MCU to run the motor.

 ADC Connection DiagramFigure 4-3 ADC Connection Diagram

The code below is taken from the hal.h and hal.c files located in the solutions\universal_motorcontrol_lab\f28002x\drivers\include and \source folders.

  1. The below code shows the defines of the base addresses, assigned channels, and SOCs of the ADC modules in the hal.h file. Note that for the SOC number, multiple ADCs can be assotiated with the same SOC number as long as they belong to different ADC modules (in the case below, module A and module C). It is best to try to sample all the currents and all the voltages as close together as possible, so configure the SOC numbers with this in mind.
    #define MTR1_IU_ADC_BASE        ADCA_BASE               // ADCA-A11*/C0
    #define MTR1_IV_ADC_BASE        ADCC_BASE               // ADCC-A14/C4*
    #define MTR1_IW_ADC_BASE        ADCC_BASE               // ADCC-A15/C7*
    #define MTR1_VU_ADC_BASE        ADCA_BASE               // ADCA-A6*
    #define MTR1_VV_ADC_BASE        ADCA_BASE               // ADCC-A3*/C5
    #define MTR1_VW_ADC_BASE        ADCC_BASE               // ADCA-A2/C9*
    #define MTR1_VDC_ADC_BASE       ADCC_BASE               // ADCC-C6*
    #define MTR1_POT_ADC_BASE       ADCA_BASE               // ADCA-A12*/C1
    
    #define MTR1_IU_ADCRES_BASE     ADCARESULT_BASE         // ADCA-A11*/C0
    #define MTR1_IV_ADCRES_BASE     ADCCRESULT_BASE         // ADCC-A14/C4*
    #define MTR1_IW_ADCRES_BASE     ADCCRESULT_BASE         // ADCC-A15/C7*
    #define MTR1_VU_ADCRES_BASE     ADCARESULT_BASE         // ADCA-A6*
    #define MTR1_VV_ADCRES_BASE     ADCARESULT_BASE         // ADCC-A3*/C5
    #define MTR1_VW_ADCRES_BASE     ADCCRESULT_BASE         // ADCA-A2/C9*
    #define MTR1_VDC_ADCRES_BASE    ADCCRESULT_BASE         // ADCC-C6*
    #define MTR1_POT_ADCRES_BASE    ADCARESULT_BASE         // ADCA-A12*/C1
    
    #define MTR1_IU_ADC_CH_NUM      ADC_CH_ADCIN11          // ADCA-A11*/C0
    #define MTR1_IV_ADC_CH_NUM      ADC_CH_ADCIN4           // ADCC-A14/C4*
    #define MTR1_IW_ADC_CH_NUM      ADC_CH_ADCIN7           // ADCC-A15/C7*
    #define MTR1_VU_ADC_CH_NUM      ADC_CH_ADCIN6           // ADCA-A6*
    #define MTR1_VV_ADC_CH_NUM      ADC_CH_ADCIN3           // ADCC-A3*/C5
    #define MTR1_VW_ADC_CH_NUM      ADC_CH_ADCIN9           // ADCA-A2/C9*
    #define MTR1_VDC_ADC_CH_NUM     ADC_CH_ADCIN6           // ADCC-C6*
    #define MTR1_POT_ADC_CH_NUM     ADC_CH_ADCIN12          // ADCA-A12*/C1
    
    #define MTR1_IU_ADC_SOC_NUM     ADC_SOC_NUMBER1         // ADCA-A11*/C10-SOC1-PPB1
    #define MTR1_IV_ADC_SOC_NUM     ADC_SOC_NUMBER1         // ADCC-A14/C4* -SOC1-PPB1
    #define MTR1_IW_ADC_SOC_NUM     ADC_SOC_NUMBER2         // ADCC-A15/C7* -SOC2-PPB2
    #define MTR1_VU_ADC_SOC_NUM     ADC_SOC_NUMBER4         // ADCA-A6*     -SOC4
    #define MTR1_VV_ADC_SOC_NUM     ADC_SOC_NUMBER5         // ADCC-A3*/C5  -SOC5
    #define MTR1_VW_ADC_SOC_NUM     ADC_SOC_NUMBER5         // ADCA-A2/C9*  -SOC5
    #define MTR1_VDC_ADC_SOC_NUM    ADC_SOC_NUMBER6         // ADCC-C6*     -SOC6
    #define MTR1_POT_ADC_SOC_NUM    ADC_SOC_NUMBER6         // ADCA-A12*/C1 -SOC6
    
    #define MTR1_IU_ADC_PPB_NUM     ADC_PPB_NUMBER1         // ADCA-A11*/C10-SOC1-PPB1
    #define MTR1_IV_ADC_PPB_NUM     ADC_PPB_NUMBER1         // ADCC-A14/C4* -SOC1-PPB1
    #define MTR1_IW_ADC_PPB_NUM     ADC_PPB_NUMBER2         // ADCC-A15/C7*- SOC2-PPB2
  2. The below code shows the defines for the interrupt sources for the ISR in the hal.h file.
    // interrupt
    #define MTR1_PWM_INT_BASE       MTR1_PWM_U_BASE         // EPWM1
    
    #define MTR1_ADC_INT_BASE       ADCA_BASE               // ADCA-A14 -SOC4
    #define MTR1_ADC_INT_NUM        ADC_INT_NUMBER1         // ADCA_INT1-SOC4
    #define MTR1_ADC_INT_SOC        ADC_SOC_NUMBER4         // ADCA_INT1-SOC4
    
    #define MTR1_PIE_INT_NUM        INT_ADCA1               // ADCA_INT1-SOC4
    #define MTR1_INT_ACK_GROUP      INTERRUPT_ACK_GROUP1    // ADCA_INT1-CPU_INT1
  3. The ADC modules are set up in the HAL_setupADCs() function that is located in the hal.c file. The setup of the ADC that is used to sample the potentiometer is shown below as an example. If the user desires to use extra ADC channels to sample additional signals, the ADC channels will need to be set up in a similar manner as the code below.
    // POT_M1 ADC_setupSOC(MTR1_POT_ADC_BASE, MTR1_POT_ADC_SOC_NUM, MTR1_ADC_TRIGGER_SOC, MTR1_POT_ADC_CH_NUM, MTR1_ADC_V_SAMPLEWINDOW);
  4. The ADC results are read in the HAL_readMtr1ADCData() function that is located in the hal.h file. The reading of the ADC result from the POT input is shown as an example below. If the user adds additional ADC channels for additional signal sampling, it will be necessary to add code similar to what is shown below to read the results of the added ADC channels. This will also require modification of the HAL_ADCData_t structure in order to store the data.
    // read POT adc value
    pADCData->potAdc = ADC_readResult(MTR1_POT_ADCRES_BASE, MTR1_POT_ADC_SOC_NUM);