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

Run the Code

  1. Set the AC source output to 0 V at 50/60Hz, turn on the AC power supply, slowly increase the input voltage from 0-V to 220-V AC.
  2. The required motor parameters must be defined in the user_mtr1.h header file as shown in the following example code. If the motor parameters are not well know by the user, the motor identification can be used to achieve the motor parameters if the FAST estimator is implemented in the example lab.
    #define USER_MOTOR1_TYPE MOTOR_TYPE_PM
    #define USER_MOTOR1_NUM_POLE_PAIRS (4)
    #define USER_MOTOR1_Rr_Ohm (NULL)
    #define USER_MOTOR1_Rs_Ohm (0.38157931f)
    #define USER_MOTOR1_Ls_d_H (0.000188295482f)
    #define USER_MOTOR1_Ls_q_H (0.000188295482f)
    #define USER_MOTOR1_RATED_FLUX_VpHz (0.0396642499f)
  3. Changes the userParams.flag_bypassMotorId value to "false"in the sys_main.c file to enable the motor identification as the following example code.
    // false->enable identification, true->disable identification
        userParams_M1.flag_bypassMotorId = false;
  4. Set the right identification variables value in the user_mtr1.h file according to the motor specification.
    #define USER_MOTOR1_RES_EST_CURRENT_A       (1.5f)      // A - 10~30% of rated current of the motor
    #define USER_MOTOR1_IND_EST_CURRENT_A       (-1.0f)     // A - 10~30% of rated current of the motor, just enough to enable rotation
    #define USER_MOTOR1_MAX_CURRENT_A           (4.5f)      // A - 30~150% of rated current of the motor
    #define USER_MOTOR1_FLUX_EXC_FREQ_Hz        (40.0f)     // Hz - 10~30% of rated frequency of the motor
  5. Rebuild the project and load the code into the controller, run the project by clicking on button  , or click RunResume in the Debug tab. The systemVars.flagEnableSystem should be set to 1 after a fixed time, that means the offsets calibration have been done and the power relay for inrush is turned on. The fault flags motorVars_M1.faultMtrUse.all should be equal to '0' , if not, the user should check the current and voltage sensing circuit as described in Section 3.5.1.
  6. Set the variable motorVars_M1.flagEnableRunAndIdentify to' 1 in the Expressions window as shown in Figure 3-46, the motor identification will be executed, the whole process will take about 150s. Once motorVars_M1.flagEnableRunAndIdentify is equal to 0 and the motor is stopping, the motor parameters have been identified. Copy the variables value in the watch window to replace the defined motor parameters in the user_mtr1.h file as follows:
    • USER_MOTOR1_Rs_Ohm = motorSetVars_M1.Rs_Ohm’s value
    • USER_MOTOR1_Ls_d_H = motorSetVars_M1.Ls_d_H’s value
    • USER_MOTOR1_Ls_q_H = motorSetVars_M1.Ls_q_H’s value
    • USER_MOTOR1_RATED_FLUX_VpHz = motorSetVars_M1.flux_VpHz’s value
  7. Set userParams_M1.flag_bypassMotorId value to 'true' to disable identification after successfully identify the motors parameters, rebuild the project and load the code into the controller.
  8. The example can support online identify the motor without reloading the code as the following steps.
    1. Set the motorVars_M1.flagEnableRunAndIdentify to' 0' to stop run the motor.
    2. Set the motorVars_M1.flagEnableMotorIdentify to '1' to enable identification.
    3. Set the motorVars_M1.flagEnableRunAndIdentify to' 1' to start identify motor parameters. The motorVars_M1.flagEnableMotorIdentify will be set to '0' automatically that means the identification is in processing.
    4. As described in the step 6 above, the new motor parameters will be identified.
  9. Once complete motor parameters identification or set the correct the motor parameters in the user_mtr1.h file. To start run the motor as the following steps.
    1. Set the variables motorVars_M1.flagEnableRunAndIdentify equal to 1 again to start run the motor.
    2. Set the target speed value to the variable motorVars_M1.speedRef_Hz and watch how the motor shaft speed will follow the setting speed.
    3. To change the acceleration, enter a different acceleration value for the variable motorVars_M1.accelerationMax_Hzps.
    4. Use PWMDAC or DAC128S module to display the monitoring variables as described in Section 3.4.2 or Section 3.4.3. The motor angle and current waveforms are shown in Figure 3-47.
  10. The default proportional gain (Kp) and integral gain (Ki) for the current controllers of the FOC system are calculated in the function setupControllers(). After setupControllers() is called, the global variables motorSetVars_M1.Kp_Id, motorSetVars_M1.Ki_Id, motorSetVars_M1.Kp_Iq, and motorSetVars_M1.Ki_Iq are initialized with the newly calculated Kp and Ki gains. Tune the Kp and Ki value of these four variables in Expressions Watch Window as shown in Figure 3-46 for the current controllers to achieve the expected current control bandwidth and response. The Kp gain creates a zero that cancels the pole of the motor’s stator and can easily be calculated. The Ki gain adjusts the bandwidth of the current controller-motor system. When a speed controlled system is needed for a certain damping, the Kp gain of the current controller will relate to the time constant of the speed controlled system.
  11. The default proportional gain (Kp) and integral gain (Ki) for the speed controllers of the FOC system are also calculated in the function setupControllers(). After setupControllers() is called, the global variables motorSetVars_M1.Kp_spd and motorSetVars_M1.Ki_spd are initialized with the newly calculated Kp and Ki gains. Tune the Kp and Ki value of these two variables in Expressions Watch Window as shown in Figure 3-46 for the speed controllers to achieve the expected current control bandwidth and response. Tuning the speed controller has more unknowns than when tuning a current controller, the default calculated Kp and Ki is just a reference value as a starting point.
  12. Set the variables motorVars_M1.flagEnableRunAndIdentify to '0' to stop run the motor.
  13. Once complete, the controller can now be halted and the debug connection terminated. Fully halting the controller by first clicking the Halt button  on the toolbar or by clicking TargetHalt. Finally, reset the controller by clicking on  or clicking RunReset.
  14. Close CCS debug session by clicking on Terminate Debug Session  or clicking RunTerminate.
 Build Level 4: Variables in
                    Expressions Window Figure 3-46 Build Level 4: Variables in Expressions Window

Use DAC128S085EVM with an oscilloscope to monitor rotor angle of the motor from the FAST estimator, feedback speed of the motor, and a phase current of the motor as shown in Figure 3-47 when the motor is running at forward rotation by setting motorVars_M1.speedRef_Hz to a positive reference value.

 Build Level 4: Rotor Angle
                    with FAST, Phase Current Waveforms at Forward Move Figure 3-47 Build Level 4: Rotor Angle with FAST, Phase Current Waveforms at Forward Move

As illustrated in Section 3.3.2, multiple FOC algorithms can be supported in the example lab. The user can use one or two algorithm for motor control in the lab project as shown in Table 3-7.

The user can implement FAST and eSMO estimators in the project simultaneously by adding the pre-define name 'MOTOR1_FAST' and 'MOTOR1_ESMO' in project properties as described in Section 3.3.1. Rebuild, load and run the project as the operation steps above. The settings will be as shown in Figure 3-46.

  • The systemVars.estType value equals to EST_TYPE_FAST_ESMO that means FAST and eSMO estimators are enabled in this project.
  • The motorVars_M1.estimatorMode equals to ESTIMATOR_MODE_FAST that means the FAST estimator is using for sensorless-FOC, equals to ESTIMATOR_MODE_ESMO that means the eSMO estimator is using for sensorless-FOC.
  • The estimated rotor angles from FAST and eSMO are shown in Figure 3-48. The motor is running with FAST at forward rotation by setting motorVars_M1.speedRef_Hz to a positive value.
  • The estimated rotor angles from FAST and eSMO are shown in Figure 3-52. The motor is running with FAST at reversal rotation by setting motorVars_M1.speedRef_Hz to a negative value.
  • The user can change the value to ESTIMATOR_MODE_ESMO to select the eSMO estimator for sensorless-FOC. And also the user can change the value to switch the using estimator on the fly.

Use DAC128S085EVM with an oscilloscope to monitor rotor angle of the motor from the FAST and eSMO estimator, and a phase current of the motor as shown in Figure 3-48 when the motor is running at forward rotation by setting motorVars_M1.speedRef_Hz to a positive reference value.

 Build Level 4: Rotor Angle
                    with FAST and eSMO, Phase Current Waveforms at Forward Rotation Figure 3-48 Build Level 4: Rotor Angle with FAST and eSMO, Phase Current Waveforms at Forward Rotation

Use DAC128S085EVM with an oscilloscope to monitor rotor angle of the motor from the FAST and eSMO estimator, and a phase current of the motor as shown in Figure 3-49 when the motor is running at reversal rotation by setting motorVars_M1.speedRef_Hz to a negative reference value.

 Build Level 4: Rotor Angle
                    With FAST and eSMO, Phase Current Waveforms at Reversal Rotation Figure 3-49 Build Level 4: Rotor Angle With FAST and eSMO, Phase Current Waveforms at Reversal Rotation

The user can implement FAST and Encoder estimators in the project simultaneously by adding the pre-define name 'MOTOR1_FAST' and 'MOTOR1_ENC' in project properties as described in Section 3.3.1. Rebuild, load and run the project as the operation steps above.

  • The systemVars.estType value equals to EST_TYPE_FAST_ENC that means FAST and Encoder estimators are enabled in this project.
  • The motorVars_M1.estimatorMode equals to ESTIMATOR_MODE_FAST that means the FAST estimator is using for sensorless-FOC, equals to ESTIMATOR_MODE_ENC that means the encoder estimator is using for sensored-FOC.
  • The estimated rotor angles from FAST and Encoder are shown in Figure 3-50. The motor is running with FAST at forward rotation by setting motorVars_M1.speedRef_Hz to a positive value.
  • The user can change the value to ESTIMATOR_MODE_ENC to select the Encoder estimator for sensored-FOC. And also the user can change the value to switch the using estimator on the fly.

Use DAC128S085EVM with an oscilloscope to monitor rotor angle of the motor from the FAST estimator and encoder, and a phase current of the motor as shown in Figure 3-50 when the motor is running at forward rotation by setting motorVars_M1.speedRef_Hz to a positive reference value.

 Build Level 4: Rotor Angle
                    with FAST and Encoder, Phase Current Waveforms at Forward Rotation Figure 3-50 Build Level 4: Rotor Angle with FAST and Encoder, Phase Current Waveforms at Forward Rotation

The user can implement FAST and Hall sensor estimators in the project simultaneously by adding the pre-define name 'MOTOR1_FAST' and 'MOTOR1_HALL' in project properties as described in Section 3.3.1. Rebuild, load and run the project as the operation steps above.

  • The systemVars.estType value equals to EST_TYPE_FAST_HALL that means FAST and Hall sensor estimators are enabled in this project.
  • The motorVars_M1.estimatorMode equals to ESTIMATOR_MODE_FAST that means the FAST estimator is using for sensorless-FOC, equals to ESTIMATOR_MODE_HALL that means the Hall sensor estimator is using for sensored-FOC.
  • The estimated rotor angles from FAST and Hall sensor are shown in Figure 3-51. The motor is running with FAST at forward rotation by setting motorVars_M1.speedRef_Hz to a positive value.
  • The estimated rotor angles from FAST and Hall sensor are shown in Figure 3-51. The motor is running with Hall sensor at reversal rotation by setting motorVars_M1.speedRef_Hz to a negative value.
  • The user can change the value to ESTIMATOR_MODE_HALL to select the Hall sensor estimator for sensored-FOC. And also the user can change the value to switch the using estimator on the fly.

Use DAC128S085EVM with an oscilloscope to monitor rotor angle of the motor from the FAST estimator and Hall sensor, and a phase current of the motor as shown in Figure 3-51 when the motor is running at forward rotation by setting motorVars_M1.speedRef_Hz to a positive reference value.

 Build Level 4: Rotor Angle
                    with FAST and Hall Sensor, Phase Current Waveforms at Forward Rotation Figure 3-51 Build Level 4: Rotor Angle with FAST and Hall Sensor, Phase Current Waveforms at Forward Rotation

Use DAC128S085EVM with an oscilloscope to monitor rotor angle of the motor from the FAST estimator and Hall sensor, and a phase current of the motor as shown in Figure 3-52 when the motor is running at reversal rotation by setting motorVars_M1.speedRef_Hz to a negative reference value.

 Build Level 4: Motor Rotor
                    Angle with FAST and Hall Sensor, Phase Current Waveforms at Reversal
                    Rotation Figure 3-52 Build Level 4: Motor Rotor Angle with FAST and Hall Sensor, Phase Current Waveforms at Reversal Rotation

The user can implement eSMO and Encoder estimators in the project simultaneously by adding the pre-define name 'MOTOR1_ESMO' and 'MOTOR1_ENC' in project properties as described in Section 3.3.1. Rebuild, load and run the project as the operation steps above.

  • The systemVars.estType value equals to EST_TYPE_ESMO_ENC that means eSMO and Encoder estimators are enabled in this project.
  • The motorVars_M1.estimatorMode equals to ESTIMATOR_MODE_ESMO that means the eSMO estimator is using for sensorless-FOC, equals to ESTIMATOR_MODE_ENC that means the encoder estimator is using for sensored-FOC.
  • The estimated rotor angles from eSMO and Encoder are shown in Figure 3-53. The motor is running with eSMO at forward rotation by setting motorVars_M1.speedRef_Hz to a positive value.
  • The user can change the value to ESTIMATOR_MODE_ENC to select the Encoder estimator for sensored-FOC. And also the user can change the value to switch the using estimator on the fly.

Use DAC128S085EVM with an oscilloscope to monitor rotor angle of the motor from the eSMO estimator and encoder, and a phase current of the motor as shown in Figure 3-53 when the motor is running at forward rotation by setting motorVars_M1.speedRef_Hz to a positive reference value.

 Build Level 4: Rotor Angle
                    with eSMO and Encoder, Phase Current Waveforms at Forward Rotation Figure 3-53 Build Level 4: Rotor Angle with eSMO and Encoder, Phase Current Waveforms at Forward Rotation