SPRACM9B June   2019  – November 2020 F29H850TU , F29H859TU-Q1 , TMS320F28384D , TMS320F28384S , TMS320F28386D , TMS320F28386S , TMS320F28388D , TMS320F28388S , TMS320F28P650DH , TMS320F28P650DK , TMS320F28P650SH , TMS320F28P650SK , TMS320F28P659DH-Q1 , TMS320F28P659DK-Q1 , TMS320F28P659SH-Q1

 

  1.   Trademarks
  2. Introduction
    1. 1.1 Acronyms Used in This Document
  3. Benefits of the TMS320F2838x MCU for High-Bandwidth Current Loop
  4. Current Loops in Servo Drives
  5. Outline of the Fast Current Loop Library
  6. Fast Current Loop Evaluation
    1. 5.1 Evaluation Setup
      1. 5.1.1 Hardware
      2. 5.1.2 Software
      3. 5.1.3 FCL With T-Format Type Position Encoder
        1. 5.1.3.1 Connecting T-Format Encoder to IDDK
        2. 5.1.3.2 T-Format Interface Software
        3. 5.1.3.3 T-Format Encoder Latency Considerations
      4. 5.1.4 SDFM
      5. 5.1.5 Incremental System Build
  7. Incremental Build Level 1
    1. 6.1 SVGEN Test
    2. 6.2 Testing SVGEN With DACs
    3. 6.3 Inverter Functionality Verification
  8. Incremental Build Level 2
    1. 7.1 Setting the Overcurrent Limit in the Software
    2. 7.2 Current Sense Method
    3. 7.3 Voltage Sense Method
    4. 7.4 Setting Current Regulator Limits
    5. 7.5 Verification of Current Sense
    6. 7.6 Position Encoder Feedback
      1. 7.6.1 Speed Observer and Position Estimator
      2. 7.6.2 Verification of Position Encoder Orientation
  9. Incremental Build Level 3
    1. 8.1 Observation One – PWM Update Latency
      1. 8.1.1 From the Expressions Window
      2. 8.1.2 From the Scope Plot
  10. Incremental Build Level 4
    1. 9.1 Observation
  11. 10Incremental Build Level 5
  12. 11Incremental Build Level 6
    1. 11.1 Integrating SFRA Library
    2. 11.2 Initial Setup Before Starting SFRA
    3. 11.3 SFRA GUIs
    4. 11.4 Setting Up the GUIs to Connect to Target Platform
    5. 11.5 Running the SFRA GUIs
    6. 11.6 Influence of Current Feedback SNR
    7. 11.7 Inferences
      1. 11.7.1 Bandwidth Determination From Closed Loop Plot
      2. 11.7.2 Phase Margin Determination From Open Loop Plot
      3. 11.7.3 Maximum Modulation Index Determination From PWM Update Time
      4. 11.7.4 Voltage Decoupling in Current Loop
    8. 11.8 Phase Margin vs Gain Crossover Frequency
  13. 12Incremental Build Level 7
    1. 12.1 Run the Code on CPU1 to Allocate ECAT to CM
    2. 12.2 Run the Code on CM to Setup ECAT
    3. 12.3 Setup TwinCAT
    4. 12.4 Scanning for EtherCAT Devices via TwinCAT
    5. 12.5 Program ControlCard EEPROM for ESC
    6. 12.6 Running the Application
  14. 13Incremental Build Level 8
    1. 13.1 Run the Code on CPU1 to Allocate ECAT to CM
    2. 13.2 Run the Code on CM to Setup ECAT
    3. 13.3 Running the Application
  15. 14References
  16. 15Revision History

Outline of the Fast Current Loop Library

The major challenge in digital motor control systems is the influence of sample and hold, as well as transportation lag inside the loop that slows down the system, impacting its performance at higher frequencies and running speeds. Fixing this problem will improve the current loop bandwidth. However, to achieve this without losing out on DC bus utilization, the following are necessary:

  • High computational power
  • The correct set of control peripherals
  • Superior control algorithm

While the TMS320F2838x provide the necessary hardware support for higher performance, TI's FCL library, which runs on this real-time controllers, provide the necessary algorithmic support. The source code is available from MC SDK v2.01.00.00 and onward.

In order to make the current loop faster and to improve the operational range of current loops, the latency between feedback sampling and the PWM update must be as small as possible. This is depicted in Figure 4-1. Basically, it shows a PWM carrier cycle where system sampling is done at the carrier peak and the corresponding PWM update resulting from its control action is happening after a time TPWM_update. This substantially reduces the transportation lag and improves the bandwidth. However, the down side is the loss of active PWMing time window that is spent in computing the new values of PWM duty cycles for the inverter. This is called the blanking window. The lower this blanking window, the higher the DC bus utilization and the operating speed range of motor.

GUID-808C2125-BE6D-4B0C-AE85-843C199C1336-low.jpg Figure 4-1 Time Lapse Between Feedback Sampling and PWM update

Typically, a latency of 2 µs or less is considered acceptable in many applications where the carrier frequency is 10 KHz. Traditionally, this task is implemented using a combination of high-end FPGAs, external ADCs, and MCUs. However, due to the availability of hardware support such as trigonometric math unit (TMU), CLA, high speed ADC or SDFM, single cycle ADC read and PWM write, it is possible to implement this control on this MCU without FPGAs or external ADCs.

GUID-1B21744E-56BC-47B5-808C-E738B3578C44-low.gif Figure 4-2 Fast Current Loop Library Block Diagram

The FCL library uses the following features in the F2838x MCU:

  • TMU
  • Four high-speed 12- or 16-bit ADCs, or Sigma-Delta Filter Module (SDFM)
  • Additional processing blocks such as CLA

Figure 4-2 shows the block diagram of the FCL library with its inputs and outputs. The FCL library partitions the algorithm across the CPU, CLA, and TMU to bring down the latency to under 1.0 µs compared to the acceptable 2.0 µs. Further optimization is possible if the algorithm is written in assembly.

The FCL library supports two types of current regulators, a standard PI controller and a complex controller. The complex controller can provide additional bandwidth over the standard PI controller at higher speeds. Both current regulators are provided for user evaluation. In the example project, the current regulator can be selected by setting the FCL_CNTLR macro appropriately and studying how they compare.

Table 4-1 lists the FCL API functions and their descriptions.

Table 4-1 Summary of FCL Interface Functions
API Function Description
uint32_t FCL_getSwVersion(void) Function that returns a 32-bit constant, and for this version the value returned is 0x00000007.
void FCL_runComplexCtrl(void) Function that performs the complex control as part of the FCL with QEP encoder and hallsensor using ADC
FCL_runSDFMComplexCtrl(void) Function that performs the complex control as part of the FCL with QEP encoder and shunt resistor using SDFM
void FCL_runAbsEncComplexCtrl(void) Function that performs the complex control as part of FCL with typical absolute encoders and hall sensor using ADC
void FCL_runSDFMAbsEncComplexCtrl(void) Function that performs the complex control as part of FCL with typical absolute encoders and shunt resistor using SDFM
void FCL_runPICtrl(void) Function that performs the PI control as part of the FCL with QEP encoder and hall sensor using ADC
void FCL_runSDFMPICtrl(void) Function that performs the PI control as part of the FCL with QEP encoder and shunt resistor using SDFM
void FCL_runAbsEncPICtrl(void) Function that performs the PI control as part of the FCL with typical absolute encoders and hall sensor using ADC
void FCL_runSDFMAbsEncPICtrl(void) id)Function that performs the PI control as part of the FCL with typical absolute encoders and shunt resistor using SDFM
void FCL_runPICtrlWrap(void) Wrap up function to be called by the user application at the completion of FCL in PI control mode before exiting ISR when QEP is the position sensor
void FCL_runAbsEncPICtrlWrap(void) Wrap up function to be called by the user application at the completion of FCL in PI control mode before exiting ISR, when using abs encoders
void FCL_runQEPWrap(void) Function to be called by the user application to wrap up the QEP feedback procedure. This function is used only in FCL_LEVE2
void FCL_runComplexCtrlWrap(void) Wrap up function to be called by the user application at the completion of FCL in complex control mode before exiting ISR when QEP is the position sensor
void FCL_runAbsEncComplexCtrlWrap(void) Wrap up function to be called by the user application at the completion of FCL in complex control mode before exiting ISR, when using absolute encoders
void FCL_initPWM(uint32_t basePhaseU, uint32_t basePhaseV, uint32_t basePhaseW) Function to initialize PWMs for the FCL operation, this will be called by the user application during the initialization or setup process
void FCL_resetController(void) This function is called to reset the FCL variables and is useful when you want to stop the motor and restart the motor
void FCL_initQEP(uint32_t baseA) This function initializes the eQEP peripheral for connecting to the QEP

void FCL_initADC(uint32_t resultBaseA, ADC_PPBNumber baseA_PPB, uint32_t resultBaseB, ADC_PPBNumber baseB_PPB, uint32_t adcBasePhaseW)

This function initializes the ADCs that are used to sense the motor phase currents

For more information on the library, see the Fast Current Loop MotorControl SDK Library User's Guide available at:

\ti\c2000\C2000Ware_MotorControl_SDK_2_01_00_00\libraries\fcl\docs.

The source code for FCL is available at

\ti\c2000\C2000Ware_MotorControl_SDK_2_01_00_00\libraries\fcl\source

Note: The library is written in a modular format and is able to port over to user platforms using F2838x devices if the following conditions are met:
  • Motor phase current feedbacks are read into variables internal to the library. However, D axis and Q axis current feedbacks are available.
  • PWM modules controlling motor phase A, B, and C are linked to the library.
  • A QEP module connecting to the QEP sensor is linked to the library.
  • CLA tasks one through four are used by the library. This must be accommodated in the user application.
  • Separate, but similar, control functions are written to work with high latency T-format position encoder
  • Similar control functions are written to work with SDFM current sensing