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

Porting Reference Code to New C2000 MCU

The Motor Control Universal Lab project can be ported to other FPU and TMU enabled C2000 MCU controllers. Instructions on how to port the lab code are described in detail in the following steps. The F28004x MCU is used as the example for a new target C2000 MCU. To adapt a SysConfig-enabled version of the lab, replace universal_motorcontrol_lab with universal_motorcontrol_syscfg in all below instructions.

  1. Browse to the <install_location>\solutions\universal_motorcontrol_lab folder and select one of the existing device-specific lab folders. The "f28002x" folder will be used in this example, but any can be utilized.
  2. Create a copy of the selected device-specific lab in the same universal_motorcontrol_lab folder, changing the name to "f28004x". <install_location>\solutions\universal_motorcontrol_lab\f28004x will be the location of your final ported lab, and will be referred to as <f28004x_lab_location> below.
  3. The compiler uses cmd files to map the memory of the C2000 MCU. Browse to the <f28004x_lab_location>\cmd folder and update the name of the f28002x_flash_lib_is.cmd files to reflect the new f28004x device. Note that there are several other cmd files present in this folder- these are unused by default and can be ignored.
  4. The Universal Motor Control Lab utilizes the pin definitions present in the C2000Ware device driver files, device.c/h. These must be updated for the new device.
    1. Navigate to the C2000Ware common device support folder for the new C2000 MCU, located at <install_location>\c2000ware\device_support\f28004x. Locate the device.h file in the ...\common\include subfolder.
    2. Copy the device.h file into the <f28004x_lab_location>\drivers\include folder, replacing the existing file.
    3. Navigate back to the C2000Ware common device support folder for the new C2000 MCU. Locate the device.c file in the ...\common\source subfolder.
    4. Copy the device.c file into the <f28004x_lab_location>\drivers\source folder, replacing the existing file.
  5. Browse to the <f28004x_lab_location>\ccs\motor_control folder and use an editor to open the projectspec file. This file is used by CCS to generate the project folder in the user workspace and includes references to device-specific C2000Ware source files.
    1. If the SysConfig-enabled version of the lab is being used, update the bolded text below to indicate the package of your new C2000 MCU. This line of text can be found within the device definition section of the file, which should be the first section.
      sysConfigBuildOptions --product ${C2000WARE_ROOT}/.metadata/sdk.json --device F28002x --package 80QFP --part F28002x_80QFP"
    2. Some C2000 MCUs have different capabilities than others. Update the file to reflect these differences. For example, the F28002x MCU has Fast Integer Division (FINTDIV) support, while the F28004x does not. The relevant processor option is the 'idiv_support' term. Find and delete all instances of "--idiv_support=idiv0" since the F28004x doesn't support this function.
      1. If you are uncertain what changes may need to be made, refer to the TMS320C28x Optimizing C/C++ Compiler v22.6.0.LTS User's Guide, section 2.3 Changing the Compiler's Behavior with Options, table 2-1 Processor Options, which describes in detail what each option is used for.
      2. Determine what differences exist between the that device and the new C2000 MCU that you have chosen. For assistance in this process, refer to the C2000 Real-Time Control Peripheral Reference Guide, which describes the differences between devices and peripheral versions.
      3. Make adjustments as necessary in the projectspec file.
    3. Find and replace all instances of "28002x" with "28004x" in the file.
    4. Find all instances of "280025C" in the file.
      1. The first result should be near the beginning of the file, specifying the project device. Update the text in bold to correctly show the new C2000 MCU chosen for this project.
        <project
            name="universal_motorcontrol_lab_f28004x"
            device="TMS320F280025C"
      2. The final two results should be in the final section of the file. The following excerpts can be found in the 'path' for the ccxml file 'copy file' actions.
        /TMS320F280025C_LaunchPad.ccxml
        /TMS320F280025C.ccxml
      3. Update the text in bold to correctly indicate the generic target configuration files for the new C2000 MCU's family of devices, which can be found in the previously referenced device support folder, in the ...\common\targetConfigs subfolder. For all F28004x devices, the bolded text should be changed to "TMS320F280049C".
      4. All other results for "280025C" should be in comments. Updating these is suggested for documentation accuracy, but is not critical.
  6. Import the "universal_motorcontrol_lab_f28004x" project into CCS.
    1. Note that when the project is imported, CCS may present an error indicating that the f28004x_headers_nonbios.cmd file was not found. This error does not impact performance, although it may increase difficulty in debugging. The memory allocations performed in this file are utilized only by the debug environment watch window, described in Section 3.5.1.2 in the incrememental build stages.
    2. In order to utilize the debug environment watch window fully, follow all instructions in this section related to the f28002x_flash_lib_is.cmd file with the f28002x_headers_nonbios.cmd file as well.
  7. Open the cmd file(s) and change the memory map according to the device chosen. For those entirely unfamiliar with this type of file, refer to the TI Linker Command File Primer for an in-depth introduction and basic usage guide.
    1. It may be easier to adapt one of the generic C2000Ware cmd files, such as the 28004x_generic_flash_lnk.cmd file, than it is to adapt the cmd file for the old device. These files are located in the ...\common\cmd subfolder of the device support folder. In this case, the original cmd file for the project should be used as a reference.
    2. If using the f28004x_headers_nonbios.cmd file, the generic C2000Ware cmd file is located in the ...\headers\cmd subfolder of the device support folder.
  8. Modify the GPIO, PWM, ADC, and CMPSS modules and defines in the hal.h file as described in Section 4.1.2 for the F28004x based hardware kit.
  9. Rebuild the lab project. Any errors or warnings in the project will be displayed in the CCS Console window. Follow the message prompts to fix any errors or warnings. There are a few differences in the driverlib APIs between devices which must be accounted for at this point.
  10. To add functions to configure and use peripherals that are present in the new C2000 MCU that were not present in the original C2000 MCU source for these files, refer to the example functions in C2000Ware or the MotorControlSDK. For example, the F28004x has a Programmable Gain Amplifier (PGA), while the F28002x does not.
  11. Run the project incrementally using the different build levels to test and verify functionality.
  12. If this project will be imported multiple times, it is a good idea to update the project's source files so that these changes will only need to be done once. Navigate to the <f28004x_lab_location> folder.
    1. In the ...\cmd subfolder, replace the f28004x_flash_lib_is.cmd file with the updated file in your imported F28004x project.
    2. In the ...\drivers\source subfolder, replace the hal.c file with the updated file in your imported F28004x project.
    3. In the ...\drivers\include subfolder, replace the hal.h file with the updated file in your imported F28004x project.