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 Fault Protection Function

When certain faults occur, such as the fault pin from the motor driver tripping or an overcurrent event detected on the CMSS modules, action is taken to stop the the output PWMs from the MCU. In order to accomplish this, the ePWM muxes and the ePWM trip zones are configured to take appropriate action. The code that accomplishes this is described in this section. Appropriate modification must be made to this code when using a custom motor driver board, using a TI motor driver EVM that is not already supported for the Universal Motor Control Lab, or if configuring the code for a different C2000 MCU. Possible necessary code changes are highlighted in bold. For more detailed information on the X-BAR, see the ePWM X-BAR Mux Configuration Table and OUTPUT X-BAR Mux Configuration Table in the TMS320F28002x Real-Time Microcontrollers Technical Reference Manual.

  1. The below code defines the Motor driver Fault GPIO input. This code is found in the hal.h file.
    //! \brief Defines the gpio for the nFAULT of Power Module
    #define MTR1_PM_nFAULT_GPIO     34
  2. The below defines are used to set up the X-BAR to link the signals from the CMPSS modules and the Fault GPIO to the ePWM trip zone sub module. This code is found in the hal.h file. Notice in the below code that the phase U current X-BAR ePWM mux is configured for CTRIPL and that the phase W current X-BAR ePWM mux is configured for CTRIPH, but the phase V current X-BAR ePWM mux is configured for CTRIPH_OR_L. This is because the phase W and phase U current inputs share the same CMPSS module (module 1), whereas the phase V current input has its own dedicated CMPSS module (module 3) which allows it to be configured to trip both high or low on the same phase current input. If using a C2000 MCU or motor driver board that allows the current inputs to have their own dedicated CMPSS module, then the ePWM mux configuration for phase U and phase W currents need to be changed to CTRIPH_OR_L, similar to how phase V is currently configured.
    #define MTR1_XBAR_TRIP_ADDRL    XBAR_O_TRIP7MUX0TO15CFG
    #define MTR1_XBAR_TRIP_ADDRH    XBAR_O_TRIP7MUX16TO31CFG 
    
    #define MTR1_IDC_XBAR_EPWM_MUX XBAR_EPWM_MUX05_CMPSS3_CTRIPL   // CMPSS3-LP, single shunt only
    #define MTR1_IDC_XBAR_MUX       XBAR_MUX05 // CMPSS3-LP, single shunt only 
    
    #define MTR1_IU_XBAR_EPWM_MUX XBAR_EPWM_MUX00_CMPSS1_CTRIPH // CMPSS1-HP 
    #define MTR1_IV_XBAR_EPWM_MUX XBAR_EPWM_MUX04_CMPSS3_CTRIPH_OR_L // CMPSS3-HP&LP 
    #define MTR1_IW_XBAR_EPWM_MUX XBAR_EPWM_MUX01_CMPSS1_CTRIPL       // CMPSS1-LP
    
    #define MTR1_IU_XBAR_MUX        XBAR_MUX00          // CMPSS1-HP
    #define MTR1_IV_XBAR_MUX        XBAR_MUX04          // CMPSS3-HP&LP
    #define MTR1_IW_XBAR_MUX        XBAR_MUX01 // CMPSS1-LP 
    
    #define MTR1_XBAR_INPUT1 XBAR_INPUT1 
    #define MTR1_TZ_OSHT1 EPWM_TZ_SIGNAL_OSHT1 
    #define MTR1_XBAR_TRIP XBAR_TRIP7 
    #define MTR1_DCTRIPIN EPWM_DC_COMBINATIONAL_TRIPIN7
  3. The below code configures the ePWM X-BAR and the trip signals for the phase currents and motor fault pin. This is done in the HAL_setupMtrFaults() function in the hal.c file. The below code may not need to be modified when modifying the Universal Motor Control Lab, but it is important to ensure that the code in the previous step is properly configured in order to set up the correct mux and trip values.
    void HAL_setupMtrFaults(HAL_MTR_Handle handle) 
    { 
    	... ... 
        // Configure TRIP7 to be CTRIP5H and CTRIP5L using the ePWM X-BAR
        XBAR_setEPWMMuxConfig(MTR1_XBAR_TRIP, MTR1_IU_XBAR_EPWM_MUX);
    
        // Configure TRIP7 to be CTRIP1H and CTRIP1L using the ePWM X-BAR
        XBAR_setEPWMMuxConfig(MTR1_XBAR_TRIP, MTR1_IV_XBAR_EPWM_MUX);
    
        // Configure TRIP7 to be CTRIP3H and CTRIP3L using the ePWM X-BAR
        XBAR_setEPWMMuxConfig(MTR1_XBAR_TRIP, MTR1_IW_XBAR_EPWM_MUX);
    	
    	// Disable all the mux first 
    	XBAR_disableEPWMMux(MTR1_XBAR_TRIP, 0xFFFF); 
    	
    	// Enable Mux 0 OR Mux 4 to generate TRIP 
    	XBAR_enableEPWMMux(MTR1_XBAR_TRIP, MTR1_IU_XBAR_MUX | MTR1_IV_XBAR_MUX | MTR1_IW_XBAR_MUX); 
    	
    	... ... 
    	
    	// configure the input x bar for TZ2 to GPIO, where Over Current is connected 
    	XBAR_setInputPin(INPUTXBAR_BASE, MTR1_XBAR_INPUT1, MTR1_PM_nFAULT_GPIO); 
    	XBAR_lockInput(INPUTXBAR_BASE, MTR1_XBAR_INPUT1); 
    	
        for(cnt=0; cnt<3; cnt++)
        {
            EPWM_enableTripZoneSignals(obj->pwmHandle[cnt],
                                       EPWM_TZ_SIGNAL_CBC6);
    
            //enable DC TRIP combinational input
            EPWM_enableDigitalCompareTripCombinationInput(obj->pwmHandle[cnt],
                                                  MTR1_DCTRIPIN, EPWM_DC_TYPE_DCAH);
    
            EPWM_enableDigitalCompareTripCombinationInput(obj->pwmHandle[cnt],
                                                  MTR1_DCTRIPIN, EPWM_DC_TYPE_DCBH);
    
            // Trigger event when DCAH is High
            EPWM_setTripZoneDigitalCompareEventCondition(obj->pwmHandle[cnt],
                                                         EPWM_TZ_DC_OUTPUT_A1,
                                                         EPWM_TZ_EVENT_DCXH_HIGH);
    
            // Trigger event when DCBH is High
            EPWM_setTripZoneDigitalCompareEventCondition(obj->pwmHandle[cnt],
                                                         EPWM_TZ_DC_OUTPUT_B1,
                                                         EPWM_TZ_EVENT_DCXL_HIGH);
    
            // Configure the DCA path to be un-filtered and asynchronous
            EPWM_setDigitalCompareEventSource(obj->pwmHandle[cnt],
                                              EPWM_DC_MODULE_A,
                                              EPWM_DC_EVENT_1,
                                              EPWM_DC_EVENT_SOURCE_FILT_SIGNAL);
    
            // Configure the DCB path to be un-filtered and asynchronous
            EPWM_setDigitalCompareEventSource(obj->pwmHandle[cnt],
                                              EPWM_DC_MODULE_B,
                                              EPWM_DC_EVENT_1,
                                              EPWM_DC_EVENT_SOURCE_FILT_SIGNAL);
    
            EPWM_setDigitalCompareEventSyncMode(obj->pwmHandle[cnt],
                                                EPWM_DC_MODULE_A,
                                                EPWM_DC_EVENT_1,
                                                EPWM_DC_EVENT_INPUT_NOT_SYNCED);
    
            EPWM_setDigitalCompareEventSyncMode(obj->pwmHandle[cnt],
                                                EPWM_DC_MODULE_B,
                                                EPWM_DC_EVENT_1,
                                                EPWM_DC_EVENT_INPUT_NOT_SYNCED);
    
            // Enable DCA as OST
            EPWM_enableTripZoneSignals(obj->pwmHandle[cnt], EPWM_TZ_SIGNAL_DCAEVT1);
    
            // Enable DCB as OST
            EPWM_enableTripZoneSignals(obj->pwmHandle[cnt], EPWM_TZ_SIGNAL_DCBEVT1);
    
            // What do we want the OST/CBC events to do?
            // TZA events can force EPWMxA
            // TZB events can force EPWMxB
            EPWM_setTripZoneAction(obj->pwmHandle[cnt],
                                   EPWM_TZ_ACTION_EVENT_TZA,
                                   EPWM_TZ_ACTION_LOW);
    
            EPWM_setTripZoneAction(obj->pwmHandle[cnt],
                                   EPWM_TZ_ACTION_EVENT_TZB,
                                   EPWM_TZ_ACTION_LOW);
        }
    	... ... 
    	return; 
    } // end of HAL_setupMtrFaults() function