TIDUF67 April   2024  – December 2024

 

  1.   1
  2.   Description
  3.   Resources
  4.   Features
  5.   Applications
  6.   6
  7. 1System Description
    1. 1.1 Terminology
    2. 1.2 Key System Specifications
  8. 2System Overview
    1. 2.1 Block Diagram
    2. 2.2 Highlighted Products
      1. 2.2.1 AM263x Microcontrollers
        1. 2.2.1.1 TMDSCNCD263
        2. 2.2.1.2 LP-AM263
  9. 3System Design Theory
    1. 3.1 Three-Phase PMSM Drive
      1. 3.1.1 Mathematical Model and FOC Structure of PMSM
      2. 3.1.2 Field Oriented Control of PM Synchronous Motor
        1. 3.1.2.1 The (a, b) → (α, β) Clarke Transformation
        2. 3.1.2.2 The (α, β) → (d, q) Park Transformation
        3. 3.1.2.3 The Basic Scheme of FOC for AC Motor
        4. 3.1.2.4 Rotor Flux Position
      3. 3.1.3 Sensorless Control of PM Synchronous Motor
        1. 3.1.3.1 Enhanced Sliding Mode Observer With Phase Locked Loop
          1. 3.1.3.1.1 Design of ESMO for PMSM
          2. 3.1.3.1.2 Rotor Position and Speed Estimation with PLL
      4. 3.1.4 Hardware Prerequisites for Motor Drive
      5. 3.1.5 Additional Control Features
        1. 3.1.5.1 Field Weakening (FW) and Maximum Torque Per Ampere (MTPA) Control
        2. 3.1.5.2 Flying Start
  10. 4Hardware, Software, Testing Requirements, and Test Results
    1. 4.1 Hardware Requirements
    2. 4.2 Software Requirements
      1. 4.2.1 Importing and Configuring Project
      2. 4.2.2 Project Structure
      3. 4.2.3 Lab Software Overview
    3. 4.3 Test Setup
      1. 4.3.1 LP-AM263 Setup
      2. 4.3.2 BOOSTXL-3PHGANINV Setup
      3. 4.3.3 TMDSCNCD263 Setup
      4. 4.3.4 TMDSADAP180TO100 Setup
      5. 4.3.5 TMDSHVMTRINSPIN Setup
    4. 4.4 Test Results
      1. 4.4.1 Level 1 Incremental Build
        1. 4.4.1.1 Build and Load Project
        2. 4.4.1.2 Setup Debug Environment Windows
        3. 4.4.1.3 Run the Code
      2. 4.4.2 Level 2 Incremental Build
        1. 4.4.2.1 Build and Load Project
        2. 4.4.2.2 Setup Debug Environment Windows
        3. 4.4.2.3 Run the Code
      3. 4.4.3 Level 3 Incremental Build
        1. 4.4.3.1 Build and Load Project
        2. 4.4.3.2 Setup Debug Environment Windows
        3. 4.4.3.3 Run the Code
      4. 4.4.4 Level 4 Incremental Build
        1. 4.4.4.1 Build and Load Project
        2. 4.4.4.2 Setup Debug Environment Windows
        3. 4.4.4.3 Run the Code
    5. 4.5 Adding Additional Functionality to Motor Control Project
      1. 4.5.1 Using DATALOG Function
      2. 4.5.2 Using PWMDAC Function
      3. 4.5.3 Adding CAN Functionality
      4. 4.5.4 Adding SFRA Functionality
        1. 4.5.4.1 Principle of Operation
        2. 4.5.4.2 Object Definition
        3. 4.5.4.3 Module Interface Definition
        4. 4.5.4.4 Using SFRA
    6. 4.6 Building a Custom Board
      1. 4.6.1 Building a New Custom Board
        1. 4.6.1.1 Hardware Setup
        2. 4.6.1.2 Migrating Reference Code to a Custom Board
          1. 4.6.1.2.1 Setting Hardware Board Parameters
          2. 4.6.1.2.2 Modifying Motor Control Parameters
          3. 4.6.1.2.3 Changing Pin Assignment
          4. 4.6.1.2.4 Configuring the PWM Module
          5. 4.6.1.2.5 Configuring the ADC Module
          6. 4.6.1.2.6 Configuring the CMPSS Module
  11. 5General Texas Instruments High Voltage Evaluation (TI HV EVM) User Safety Guidelines
  12. 6Design and Documentation Support
    1. 6.1 Design Files
      1. 6.1.1 Schematics
      2. 6.1.2 BOM
      3. 6.1.3 PCB Layout Recommendations
        1. 6.1.3.1 Layout Prints
    2. 6.2 Tools and Software
    3. 6.3 Documentation Support
    4. 6.4 Support Resources
    5. 6.5 Trademarks
  13. 7About the Author

Adding CAN Functionality

CAN functionality can be added into the lab project to provide the user a communication bus for sending the start/stop command and getting the feedback running states. To utilize this, enable the pre-define symbol CMD_CAN in project build properties as shown in Figure 4-2. PCAN-View is used to simply monitor, transmit, and record CAN data traffic. Different type of command messages can be defined in motor_common.hfile. In this project as an example, sender specifies a starting command and defines a target speed value. The recipient then receives a message containing the target speed.

Please be noted that depending on whether you are using the LaunchPad or EVM in the kit, certain pin mux settings are required. These configurations are achieved using the mcanEnableTransceiver and tca6416ConfigOutput functions, as outlined in the following code:

#if defined(AM263_CC)
void tca6416ConfigOutput(uint16_t port, uint16_t pin, uint16_t level);
#endif // AM263_CC

#if defined(CMD_CAN)
#if defined(AM263_LP)

void mcanEnableTransceiver(void)
{
    uint32_t    gpioBaseAddr, pinNum;

    gpioBaseAddr = (uint32_t)AddrTranslateP_getLocalAddr(MCAN_ENABLE_BASE_ADDR);
    pinNum       = MCAN_ENABLE_PIN;

    GPIO_setDirMode(gpioBaseAddr, pinNum, GPIO_DIRECTION_OUTPUT);

    GPIO_pinWriteLow(gpioBaseAddr, pinNum);
}
#endif // AM263_LP

#if defined(AM263_CC)
/* ========================================================================== */
/*                           Macros & Typedefs                                */
/* ========================================================================== */

/* Input status register */
#define TCA6416_REG_INPUT0              ((UInt8) 0x00U)
#define TCA6416_REG_INPUT1              ((UInt8) 0x01U)

/* Output register to change state of output BIT set to 1, output set HIGH */
#define TCA6416_REG_OUTPUT0             ((uint8_t) 0x02U)
#define TCA6416_REG_OUTPUT1             ((uint8_t) 0x03U)

/* Configuration register. BIT = '1' sets port to input, BIT = '0' sets
 * port to output */
#define TCA6416_REG_CONFIG0             ((uint8_t) 0x06U)
#define TCA6416_REG_CONFIG1             ((uint8_t) 0x07U)

/* ========================================================================== */
/*                          Function Declarations                             */
/* ========================================================================== */
static void SetupI2CTransfer(I2C_Handle handle,  uint32_t targetAddr,
                      uint8_t *writeData, uint32_t numWriteBytes,
                      uint8_t *readData,  uint32_t numReadBytes);

void mcanEnableTransceiver(void)
{
    I2C_Handle      i2cHandle;
    uint8_t         dataToSlave[4];

    i2cHandle = gI2cHandle[CONFIG_I2C0];
    dataToSlave[0] = TCA6416_REG_CONFIG0;
    dataToSlave[1] = 0x0U;
    SetupI2CTransfer(i2cHandle, 0x20, &dataToSlave[0], 1, &dataToSlave[1], 1);
    /* set the P00 to 0 make them output ports. */
    dataToSlave[1] &= ~(0x1U);
    SetupI2CTransfer(i2cHandle, 0x20, &dataToSlave[0], 2, NULL, 0);

    /* Get the port values. */
    dataToSlave[0] = TCA6416_REG_INPUT0;
    dataToSlave[1] = 0x0U;
    SetupI2CTransfer(i2cHandle, 0x20, &dataToSlave[0], 1, &dataToSlave[1], 1);

    /* Set P10 and P11 to 0.
     */
    dataToSlave[0] = TCA6416_REG_OUTPUT0;
    dataToSlave[1] &= ~(0x1);
    SetupI2CTransfer(i2cHandle, 0x20, &dataToSlave[0], 2, NULL, 0);
}

static void SetupI2CTransfer(I2C_Handle handle,  uint32_t targetAddr,
                      uint8_t *writeData, uint32_t numWriteBytes,
                      uint8_t *readData,  uint32_t numReadBytes)
{
    int32_t status;
    I2C_Transaction i2cTransaction;

    /* Enable Transceiver */
    I2C_Transaction_init(&i2cTransaction);
    i2cTransaction.targetAddress = targetAddr;
    i2cTransaction.writeBuf = (uint8_t *)&writeData[0];
    i2cTransaction.writeCount = numWriteBytes;
    i2cTransaction.readBuf = (uint8_t *)&readData[0];
    i2cTransaction.readCount = numReadBytes;
    status = I2C_transfer(handle, &i2cTransaction);
    DebugP_assert(SystemP_SUCCESS == status);
}

#endif // AM263_CC
#endif // CMD_CAN

After launching "PCAN-View", make setup the CAN adaptor as Figure 4-34:

TIDM-02018 PCAN-View Setup Figure 4-34 PCAN-View Setup

Double click to initiate the CAN data transmission as shown in Figure 4-35.

TIDM-02018 CAN Data Transmission
                    Start Figure 4-35 CAN Data Transmission Start

As shown in Figure 4-36, the motorVars_M1.flagEnableRunAndIdentify is configured with a value of 1, and the motorVars_M1.speedRef_Hz is set to 40Hz. This speed value is then transmitted back to the recipient through the CAN communication.

TIDM-02018 CAN Command: Variables in
                    Expressions Window Figure 4-36 CAN Command: Variables in Expressions Window