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, DRV8301

Tool/software:

I am working with examples from Motorware and want to run the motor without using the GUI method. If possible, I would like clarification on how to operate the examples without relying on the GUI process. Can anyone guide me on how to do this?

  • Please take a look at the InstaSPIN lab guide (instaspin_labs.pdf) in the folder of motorWare, follow the operations to run the related labs within CCS and without using GUI.

    C:\ti\motorware\motorware_1_01_00_18\docs\labs

  • Hi Yanming Luo

    "I imported Project Lab 11 from motorware_1_01_00_18, but I'm encountering some CMD errors. How can I resolve this?"

    Description	Resource	Path	Location	Type
    #10010 errors encountered during linking; "proj_lab11.out" not built	proj_lab11		 	C/C++ Problem
    #10099-D program will not fit into available	F28027.cmd	/proj_lab11	line 124	C/C++ Problem
    #10099-D program will not fit into available	F28027.cmd	/proj_lab11	line 159	C/C++ Problem
    gmake: *** [proj_lab11.out] Error 1	proj_lab11		 	C/C++ Problem
    gmake: Target 'all' not remade because of errors.	proj_lab11		 	C/C++ Problem
    #10210-D creating ".esysmem" section with default size of 0x400; use	proj_lab11		 	C/C++ Problem
    #10247-D creating output section ".cio" without a SECTIONS	proj_lab11		 	C/C++ Problem
    #10247-D creating output section "ramfuncs" without a SECTIONS	proj_lab11		 	C/C++ Problem
    #10247-D creating output section "rom_accessed_data" without a	proj_lab11		 	C/C++ Problem
    

  • Please take a look at the lab user's guide, and try the other labs. You should run the lab02b or lab02c to identify the motor parameters first if you don't know them. Please make sure that you are using the original example labs without any changes before you know how to change it.

  • Hi Yanming Luo

    I was using the Lab 2b example and entered the motor parameters. The motor was running, but then it suddenly stopped when I used the GUI method. After that, I tried running the motor without the GUI method, but it still wouldn’t start.

    #define USER_MOTOR_RES_EST_CURRENT (3.0)
    #define USER_MOTOR_IND_EST_CURRENT (-0.5)
    #define USER_MOTOR_MAX_CURRENT (20.0)
    #define USER_MOTOR_FLUX_EST_FREQ_Hz (20.0)

  • Please follow the lab user's guide to run the example lab within CCS if you want to identify and spin a new motor.

    Please take a look at the InstaSPIN lab guide (instaspin_labs.pdf) in the folder of motorWare, follow the operations to run the related labs.

    C:\ti\motorware\motorware_1_01_00_18\docs\labs

    The motor must be identified without adding the load.

  • Hi Yanming Luo

    I am using the Lab11 example to control a motor through commands. I have added the SCI functions as per the instructions in section 6.7 of the motorware_1_01_00_18/docs/tutorials. I wrote the logic for motor start and stop, but some errors are occurring. How can I solve them?

    Description	Resource	Path	Location	Type
    #10010 errors encountered during linking; "proj_lab11.out" not built	proj_lab11		 	C/C++ Problem
    #10099-D program will not fit into available	F28027.cmd	/proj_lab11	line 124	C/C++ Problem
    #10099-D program will not fit into available	F28027.cmd	/proj_lab11	line 159	C/C++ Problem
    gmake: *** [proj_lab11.out] Error 1	proj_lab11		 	C/C++ Problem
    gmake: Target 'all' not remade because of errors.	proj_lab11		 	C/C++ Problem
    #10210-D creating ".esysmem" section with default size of 0x400; use	proj_lab11		 	C/C++ Problem
    #10247-D creating output section ".cio" without a SECTIONS	proj_lab11		 	C/C++ Problem
    #10247-D creating output section "ramfuncs" without a SECTIONS	proj_lab11		 	C/C++ Problem
    #10247-D creating output section "rom_accessed_data" without a	proj_lab11		 	C/C++ Problem

  • Any errors if you don't make any changes in the example lab? Did you try to run the lab11a?

  • Hi Yanming Luo

    I only ran Example Lab 5b, as SCI now only supports Lab 11. Therefore, I wrote the logic but am unable to run the Lab 11a example.

  • It doesn't matter any example labs if you just want to add SCI. Please take a look at the guide as below.

    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"

  • Hi Yanming Luo

    //Added
    
    // Function to handle motor commands
    void handleMotorCommands(HAL_Handle handle)
    {
       // HAL_Obj *obj = (HAL_Obj *)handle;
    
        // 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
    }
    
    
    // UART Receive Interrupt Service Routine
    // UART Receive Interrupt Service Routine
    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
                }
            }
            else
            {
                // Buffer overflow, reset counter
                counter = 0;
            }
        }
    
        // Clear SCI interrupt flag
        PIE_clearInt(obj->pieHandle, PIE_GroupNumber_9);
    }
    
    // Process received command
    void processCommand(char *command)
    {
        if (strcmp(command, CMD_RX_ON) == 0)
        {
            isMotorOn = true;
            sendResponse("Motor ON");
            handleMotorCommands(halHandle); // Handle the command
        }
        else if (strcmp(command, CMD_RX_OFF) == 0)
        {
            isMotorOn = false;
            sendResponse("Motor OFF");
            handleMotorCommands(halHandle); // Handle the command
        }
        else
        {
            sendResponse("Unknown Command");
        }
    }
    
    // Send response to UART
    void sendResponse(const char *message)
    {
        int length = strlen(message);
        returnBuf[0] = '<';
        strncpy(&returnBuf[1], message, length);
        returnBuf[length + 1] = '>';
        serialWrite(returnBuf, length + 2);
    }
    
    // Write data to UART
    void serialWrite(const char *sendData, int length)
    {
        int i = 0;
        HAL_Obj *obj = (HAL_Obj *)halHandle; // Ensure halHandle is accessible
    
        GPIO_setHigh(obj->gpioHandle, GPIO_Number_12);
        while (i < length)
        {
            if (SCI_txReady(obj->sciAHandle))
            {
                SCI_write(obj->sciAHandle, sendData[i]);
                i++;
            }
        }
        isWaitingTxFifoEmpty = true;
    }
    


    "I added UART commands to control the motor. I've written the logic and placed it above, but I need clarification on whether the logic will run the motor using the commands. However, I am encountering errors in the F28027.cmd file. The errors are listed below. Could you help me figure out how to resolve them?"

    Description	Resource	Path	Location	Type
    #10010 errors encountered during linking; "proj_lab11.out" not built	proj_lab11		 	C/C++ Problem
    #10099-D program will not fit into available	F28027.cmd	/proj_lab11	line 124	C/C++ Problem
    gmake: *** [proj_lab11.out] Error 1	proj_lab11		 	C/C++ Problem
    gmake: Target 'all' not remade because of errors.	proj_lab11		 	C/C++ Problem
    #10247-D creating output section ".cio" without a SECTIONS	proj_lab11		 	C/C++ Problem
    #10247-D creating output section "ramfuncs" without a SECTIONS	proj_lab11		 	C/C++ Problem
    #10247-D creating output section "rom_accessed_data" without a	proj_lab11		 	C/C++ Problem
    
     

  • Any error if you don't make any changes on the original example lab?

  • Hi Yanming Luo

    I imported the lab examples from CCS, but they are still showing the same errors. Even after increasing the heap size, the errors remain unresolved.

  • Please try to use the other labs like lab05b or lab10a as mentioned before.

  • Hi Yanming Luo

    Are there UART commands to run a motor project zip file?

  • Are there UART commands to run a motor project zip file?

    I am not fully understand your questions. Can you explain this? 

    You can send the data via UART to set the target speed, start/stop the motor, you should convert the received data from UART to the data format using the example lab. As mentioned above, the HAL guide has an example for this.

  • 'Hi Yanming Luo

    "I can send data via UART to set the target speed and control the motor. For example, if you send the command RX_ON, the motor will start, and if you send RX_OFF, the motor will stop. i  need to convert the received data from UART into the correct data format."
    Which lab example ?

  • All of the example labs use the IQ24 format, you should convert the speed command to IQ24 format.

    If you want to know more details about the IQ format, please take a look at the user's guide as below

    You might have a look at the link below to understand the _IQmath and _IQ format.

    C28x IQmath Library (https://www.ti.com/lit/sw/sprc990/sprc990.pdf)

     

    Or have a look at the links below about Iqmath as well if you want.

     

    https://e2e.ti.com/support/microcontrollers/c2000/f/171/p/832121/3077993

    https://e2e.ti.com/support/microcontrollers/c2000/f/171/p/596505/2199304

     

     

    https://e2e.ti.com/support/microcontrollers/c2000/f/171/t/539864

    https://e2e.ti.com/support/microcontrollers/c2000/f/171/p/798297/2961406

  • Hi Yanming Luo


    Already there. 

    The errors are still coming. Can I send you my project file as a ZIP? 

  • Hi Kishor,

    Why not consider upgrade very limited memory x27 Launch pad with faster CPU with far more Flash and SRAM code sizes? Then you can realize built in TMU with new SPV drive algorithms. The newer Universal SDK code supports BLDC motors with Hall sensors too. Perhaps Launch x39 or x25 MCU class will support DRV8301, check TI compatibility charts. Other forum users may be able to better help you get SCI command code running on newer launch pad.

    Regards, 

  • Hi Genatco

    "Could you please guide me on how to resolve these errors and implement the SCI command code? I would appreciate your help."

  • Hi Kishor,

    Seem to recall someone posted about getting DRV8301 to run on LaunchXL-39c. Are you perhaps wasting time experimenting older LaunchXL-27c? The x39c MCU class is a good foundation,120MHZ CPU is of interest with USB isolation XDS110 debug probe.

    LAUNCHXL-F280039C Development kit | TI.com

  • Hi Genatco

    Is there any available code using SCI commands to operate a motor?

  • Hi Kishor,

    Simply add bool control flags set (true/false) same flags used in MCSDK debug Jscript monitor tab. Add virtual links (scistdio.c/h) to the project, don't use clib printf(). Call command SCIprintf() use debug virtual COM port serial view with Putty on SCIA. Use SCIB FIFO level (non blocking) R/W inside TX/RX interrupts, two INT sources for each FIFO level interrupt. May have to give main.c fast interrupt priority in both SCI functions depending on how much TX[char*] data while RX[char*] only buffers 15-16 words in single ISR call. Easy way add; EINT, DINT both interrupts. Don't forget to first clear ISR (stops ISR reentry) and group ACK at the end of each ISR call.

    Example: SCIprintf("UserParmsLoaded %c\n");