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

Using External DAC Board

The DAC128S module converts up to 8 software variables into a 12-bit integer value and transmits the data through SPI to the digital-to-analog converter (DAC) on the DAC128S085EVM as shown in Figure 3-27.

 DAC128S Module Block
                    Diagram Figure 3-27 DAC128S Module Block Diagram

The DAC128S085EVM can be connected to the LaunchPad as shown in Figure 3-12 . Key connections of the DAC128S are shown in Figure 3-28.

 DAC128S085EVM Evaluation
                    Board Figure 3-28 DAC128S085EVM Evaluation Board
Table 3-8 Hardware Changes Required for DAC128S085EVM Usage
LaunchPad Device Hardware Changes Required
F28002x, F28003x Jumper wire C2000 SPI_STE (SCS) pin JB-2 to SYNC pin JA-2 on the DAC128S085EVM, as shown in Figure 3-28.
F280013x (1) Device has only 1x SPI module which is shared between Boosterpack site 1 and site 2. This requires populating 0 ohm resistors on the LaunchPad to connect the SPI signals to the Boosterpack site 2, which the DAC128S085EVM connects to. For the specific resistor identifiers, see SPI Routing section in the LAUNCHXL-F2800137 Schematic.
(2) Jumper wire C2000 SPI_STE (SCS) pin to SYNC pin JA-2 on the DAC128S085EVM. The C2000 SPI_STE pin usage will depend on Inverter boosterpack being used:
  1. GPIO19 is used for DRV8323RS, DRV8353RS, DRV8316, & 3-phase GaN inverter EVMs. This will require using the F280013x's Internal Oscillator and making hardware changes. For details, see the Oscillator section of the LAUNCHXL-F2800137 Schematic.
  2. GPIO37 is used for all other inverter EVMs.

Hardware changes required for DAC128S085EVM usage. In order to enable the DAC128S functionality, the predefined symbol DAC_128S_ENABLE must be added in the project properties as shown in Figure 3-19.

The code below shows the declaration of the DAC128S object. This code is located in the sys_main.c file.

DAC128S_Handle   dac128sHandle;        //!< the DAC128S interface handle
DAC128S_Obj      dac128s;              //!< the DAC128S interface object

The DAC128S085 has an eight channel, 12-bit digital-to-analog converter (DAC) , so the user can set the output number between 1 and 8 by changing the value of the DAC_EN_CH_NUM define in the dac128s085.h file. Although the sys_main.c file initializes 8 ptrData[] module inputs to 8 different variable addresses, the number of module inputs that will actually be transmitted and used during the execution of the code will be determined by the value of the DAC_EN_CH_NUM constant that is defined in the dac128s085.h file (shown below). Since most oscilloscopes only have four probes, using 4 out of the 8 DAC128S085 outputs is the default setting in this example. Using 4 outputs is the default setting in this example lab since most of the oscilloscope only has four probes. More outputs will occupy much more ISR time to convert and transmit the data, which can negatively effect the time to spend on other tasks, which is a factor that must be considered if the user desires to use more than 4 outputs.

#define DAC_EN_CH_NUM                       (4)         // 1~8

The code below shows the initialization and setting up of the DAC128S object, handle and parameters. The code configures eight module inputs, ptrData[0] - ptrData[7], to point to the addresses of eight different software variables, but the number of module inputs that will actually be used is determined by the value of the DAC_EN_CH_NUM constant that is defined in the dac128s085.h file. The dac128s data points to different system variables depending on the build level and the control algorithm that is defined. This code can be found in the sys_main.c file.

// initialize the DAC128S
dac128sHandle = DAC128S_init(&dac128s);

// setup SPI for DAC128S
DAC128S_setupSPI(dac128sHandle);
... ...
// Build_Level_2 or Level_3, verify the estimator
dac128s.ptrData[0] = &motorVars_M1.angleGen_rad;                // CH_A
dac128s.ptrData[1] = &motorVars_M1.angleEST_rad;                // CH_B
dac128s.ptrData[2] = &motorVars_M1.anglePLL_rad;                // CH_C
dac128s.ptrData[3] = &motorVars_M1.adcData.I_A.value[0];        // CH_D
dac128s.ptrData[4] = &motorVars_M1.adcData.V_V.value[0];        // CH_E, N/A
dac128s.ptrData[5] = &motorVars_M1.adcData.I_A.value[1];        // CH_F, N/A
dac128s.ptrData[6] = &motorVars_M1.adcData.I_A.value[2];        // CH_G, N/A
dac128s.ptrData[7] = &motorVars_M1.adcData.V_V.value[1];        // CH_H, N/A

dac128s.gain[0] = 4096.0f / MATH_TWO_PI;
dac128s.gain[1] = 4096.0f / MATH_TWO_PI;
dac128s.gain[2] = 4096.0f / MATH_TWO_PI;
dac128s.gain[3] = 2.0f * 4096.0f / USER_M1_ADC_FULL_SCALE_CURRENT_A;
dac128s.gain[4] = 2.0f * 4096.0f / USER_M1_ADC_FULL_SCALE_VOLTAGE_V;
dac128s.gain[5] = 2.0f * 4096.0f / USER_M1_ADC_FULL_SCALE_CURRENT_A;
dac128s.gain[6] = 2.0f * 4096.0f / USER_M1_ADC_FULL_SCALE_CURRENT_A;
dac128s.gain[7] = 2.0f * 4096.0f / USER_M1_ADC_FULL_SCALE_VOLTAGE_V;

dac128s.offset[0] = (uint16_t)(0.5f * 4096.0f);
dac128s.offset[1] = (uint16_t)(0.5f * 4096.0f);
dac128s.offset[2] = (uint16_t)(0.5f * 4096.0f);
dac128s.offset[3] = (uint16_t)(0.5f * 4096.0f);
dac128s.offset[4] = (uint16_t)(0.5f * 4096.0f);
dac128s.offset[5] = (uint16_t)(0.5f * 4096.0f);
dac128s.offset[6] = (uint16_t)(0.5f * 4096.0f);
dac128s.offset[7] = (uint16_t)(0.5f * 4096.0f);

The below code shows the updating of the DAC128S board with the new data over SPI periodically during the execution of the motor1ctrlISR() interrupt. This code is located in the motor1_drive.c file. The number of the DAC outputs that will actually be updated will depend on the value of the DAC_EN_CH_NUM constant.

// Write the variables data value to DAC128S085
DAC128S_writeData(dac128sHandle);