This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS320F28027F: TMS320F28027with DRV8301 to run bldc motor

Part Number: TMS320F28027F
Other Parts Discussed in Thread: MOTORWARE

Tool/software:

Hi

"I have started working on UART commands to run the motor. I am using Lab11 in MotorWare and have added the SCI/UART from section 6.7 in the HAL tutorial. My question is, how do I write the logic for motor start and stop functions? Can someone guide me?"

  • That could be an detailed engineering question. You may just need to convert the command from UART to the control variables in example lab, like gMotorVars.Flag_Run_Identify to start/stop the motor, gMotorVars.SpeedRef_krpm to set the target running speed.

  • Hi Yanming Luo

    "I have written handleMotorCommands in the main.h file. If any modifications are needed, please let me know."

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    In main.h file void handleMotorCommands(void)
    {
    // Start/Stop the motor based on isMotorOn flag
    if (isMotorOn)
    {
    gMotorVars.Flag_Run_Identify = true;
    printf("Motor is ON\n"); // Debug: Print motor state
    }
    else
    {
    gMotorVars.Flag_Run_Identify = false;
    printf("Motor is OFF\n"); // Debug: Print motor state
    }
    // Set the target running speed
    gMotorVars.SpeedRef_krpm = targetSpeed;
    printf("Target speed set to %ld krpm\n", gMotorVars.SpeedRef_krpm); // Debug: Print target speed
    }
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • Looks good. Please let's know if you have any further questions.

  • Hi Yanming Luo

    "I have written in the main.c file. If any modifications are needed, please let me know."

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    In main.c file
    // UART Rx ISR
    interrupt void sciARxISR(void)
    {
    HAL_Obj *obj = (HAL_Obj *)halHandle;
    while (SCI_rxDataReady(obj->sciAHandle))
    {
    char c = SCI_read(obj->sciAHandle);
    if (counter < BUF_SIZE - 1) // -1 to leave space for null terminator
    {
    buf[counter++] = c;
    if (c == '>') // End of command
    {
    buf[counter] = '\0'; // Null-terminate the command string
    processCommand(buf);
    counter = 0; // Reset buffer index
    }
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • If have any further questions about adding SCI,  you may have a look at the HAL user's guide at the folder of the motorWare as below, and refer to chapter "6.7. Adding SCI/UART functionality to a project with InstaSPIN in Motorware.

    motorware_hal_tutorial.pdf at "\ti\motorware\motorware_1_01_00_18\docs\tutorials\motorware_hal_tutorial.pdf"