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.

motor control ESC witch eCAP1.

Other Parts Discussed in Thread: MOTORWARE, DRV8305

Good afternoon TI,
In all examples for LaunchPad F28027F in MotorWare the pins are used in the following way: PWM1 > EPWM1,PWM2 > EPWM2,PWM3 > EPWM3.

My question:
I want to use for motor control ESC witch eCAP1.
I want to use for PWM3 > EPWM4.

is it Possible?

Andrew.

  • Andrew,

    I don't follow what you mean by your description....but are you asking if you can change PWM3 to PWM4?  Yes, you need to make the changes in the HAL files. There is a tutorial on the HAL included in MotorWare

    C:\ti\motorware\motorware_1_01_00_14\docs\tutorials

    We are about to release a TI Design for an ESC which includes the use of eCAP1 to decode a pulse train speed command.

  • Thanks, but TI must to remake BOOST-DRV8301.
  • are you saying that you don't have access on the LaunchPad to a free eCAP pin?
  • eCAP pin is used in the BOOST-DRV8301 for PWM. I must cut the PCB. :(
  • ok, I see what you mean.  In the ESC TI Design that will soon be published we used GPIO19 and then moved the SPI line to GPIO33 and updated the SPI read and write functions.  But of course this had custom layout, not hampered by the LaunchPad I/O.

  • Thanks. Do you use for ESC in the eCAP 4 events or 2 events? Maybe share settings for eCAP. I am beginer with C2000. More Thanks.
  • this TI Design should be on the web end of this week I believe. It will have a document covering all the SW changes to make

    // ECAP
    void HAL_setupeCAP(HAL_Handle handle)
    {
    HAL_Obj *obj = (HAL_Obj *) handle;
    CAP_setModeCap(obj->capHandle); // set mode to CAP
    //Disables counter synchronization
    CAP_disableSyncIn(obj->capHandle);
    //Sets the capture event polarity
    CAP_setCapEvtPolarity(obj->capHandle, CAP_Event_1, CAP_Polarity_Rising);
    //Sets the capture event polarity
    CAP_setCapEvtPolarity(obj->capHandle, CAP_Event_2, CAP_Polarity_Falling);
    //Sets the capture event counter reset configuration
    CAP_setCapEvtReset(obj->capHandle, CAP_Event_1, CAP_Reset_Disable);
    //Sets the capture event counter reset configuration (reset counting here)
    CAP_setCapEvtReset(obj->capHandle, CAP_Event_2, CAP_Reset_Enable);
    // continous timer
    CAP_setCapContinuous(obj->capHandle);
    //Set the stop/wrap mode to 2 events
    CAP_setStopWrap(obj->capHandle, CAP_Stop_Wrap_CEVT2);
    //Enables loading of CAP1-4 on capture event
    CAP_enableCaptureLoad(obj->capHandle);
    // Enables Time Stamp counter to running
    CAP_enableTimestampCounter(obj->capHandle);
    //Enables capture (CAP) interrupt source
    CAP_enableInt(obj->capHandle, CAP_Int_Type_CEVT2);
    // enable eCAP interrupt
    PIE_enableInt(obj->pieHandle, PIE_GroupNumber_4, PIE_InterruptSource_ECAP1);
    // enable CPU ECAP Group interrupts
    CPU_enableInt(obj->cpuHandle, CPU_IntNumber_4);
    return;
    } // end of HAL_setupCAP() function
  • Thanks.

    When publish TI  the new MotorWare?

  • MotorWare 15 will release in the next 2-3 days. But this won't have anything new for what you are doing.

    This TI Design (#00643) should release in the next 10 days.
  • Clearly,

    I wait to a TI design. Do You publish the design link here? But I take Reply on e-mail.
    I work on the PCB.

    Thanks.
  • I will make a posting on this forum once it releases. Last I heard it should be next week, but I'm checking on that date.

  • Andrew,
    Do you have solved your problem?I have the same question with that ,could you help me ?

    Jarry Chou.
  • I haven’t finished project yet. I wrote a test program and tested eCAP. I am making PCB. I plan to replace DYMOND Controller. DYMOND works very badly at low turns. Now I have Arduino (Can Open) + MCP2515 + DYMOND. I plan to replace DYMOND through C2000 with ESC, then to add MCP2515 and to work through CAN.
  • Chris,

    Do you have any update on ESC TI Design (#00643) ?

    Thank you,
    Sergiu
  • it was just approved internally so we're hopeful it will be on the web next week. we will be posting a blog and email about it, so you should see something when it's available.
  • Hi Ti.

    Is it possible to publish projects from MotorWare 15 on GitHub? I can share our tests. eCap and SCI.

  • I don't have a problem if you share select .c/.h files that you have created or modified, but you can NOT put the entire MotorWare on a repository as then customers could potentially create working object code without first accepting the MotorWare license.
  • I publish only the changed files. Any remarks are welcomed.
    github.com/.../
  • Thanks for an example. (tiduak1.pdf) Where set you the maximum speed of the motor?
  • Hi Andrew,

    where could download the TI design of ESC?

  • Got that, thanks Chris!
  • Thanks Chris,


    I changed your code for universality.
    -------------------------------------------------------------------------------------------------------------------------------
    in hal.c
    --------------------------------------------------------------------------------------------------------------------------------
    void HAL_setupGate(HAL_Handle handle)
    {
    HAL_Obj *obj = (HAL_Obj *)handle;

    DRV8305_setSpiHandle(obj->drv8305Handle,obj->spiAHandle);
    DRV8305_setGpioHandle(obj->drv8305Handle,obj->gpioHandle);
    DRV8305_setGpioNumber(obj->drv8305Handle,GPIO_Number_4);
    #ifdef CS_GPIO
    DRV8305_setSPI_CS_Number(obj->drv8305Handle,GPIO_Number_19);

    #endif
    } // HAL_setupGate() function

    // SPI_SCS
    #ifdef CS_GPIO
    GPIO_setMode(obj->gpioHandle,GPIO_Number_19,GPIO_19_Mode_GeneralPurpose);
    GPIO_setDirection(obj->gpioHandle, GPIO_Number_19, GPIO_Direction_Output);
    GPIO_setHigh(obj->gpioHandle, GPIO_Number_19);
    #else
    GPIO_setMode(obj->gpioHandle,GPIO_Number_19,GPIO_19_Mode_SPISTEA_NOT);

    #endif

    ----------------------------------------------------------------------------------------------------------------------------------------------
    in dvr8305.c
    ----------------------------------------------------------------------------------------------------------------------------------------------
    #ifdef CS_GPIO
    void DRV8305_setSPI_CS_Number(DRV8305_Handle handle,GPIO_Number_e gpioCS_Number)
    {
    DRV8305_Obj *obj = (DRV8305_Obj *)handle;

    // initialize the gpio interface object
    obj->gpioCS_Number = gpioCS_Number;

    return;
    } // end of DRV8305_setGpioNumber() function

    #endif

    uint16_t DRV8305_readSpi(DRV8305_Handle handle,const DRV8305_Address_e regAddr)
    {
    DRV8305_Obj *obj = (DRV8305_Obj *)handle;
    uint16_t ctrlWord;
    const uint16_t data = 0;
    volatile uint16_t readWord;
    static volatile uint16_t WaitTimeOut = 0;
    volatile SPI_FifoStatus_e RxFifoCnt = SPI_FifoStatus_Empty;

    // build the control word
    ctrlWord = (uint16_t)DRV8305_buildCtrlWord(CtrlMode_Read,regAddr,data);

    // reset the Rx fifo pointer to zero
    SPI_resetRxFifo(obj->spiHandle);
    SPI_enableRxFifo(obj->spiHandle);
    #ifdef CS_GPIO
    // Added: SCS High->Low
    //GPIO_setLow(obj->gpioHandle, GPIO_Number_19);
    GPIO_setLow(obj->gpioHandle,obj->gpioCS_Number);

    #endif
    // write the command
    SPI_write(obj->spiHandle,ctrlWord);

    // wait for the response to populate the RX fifo, else a wait timeout will occur
    while((RxFifoCnt < SPI_FifoStatus_1_Word) && (WaitTimeOut < 0xffff))
    {
    RxFifoCnt = SPI_getRxFifoStatus(obj->spiHandle);
    if(++WaitTimeOut > 0xfffe)
    {
    obj->RxTimeOut = true;
    }
    }

    #ifdef CS_GPIO
    // Added: SCS Low->High
    //GPIO_setHigh(obj->gpioHandle, GPIO_Number_19);
    GPIO_setHigh(obj->gpioHandle,obj->gpioCS_Number);

    #endif
    // Read the word
    readWord = SPI_readEmu(obj->spiHandle);

    return(readWord & DRV8305_DATA_MASK);
    } // end of DRV8305_readSpi() function


    void DRV8305_writeSpi(DRV8305_Handle handle,const DRV8305_Address_e regAddr,const uint16_t data)
    {
    DRV8305_Obj *obj = (DRV8305_Obj *)handle;
    uint16_t ctrlWord;
    uint16_t n;

    // build the control word
    ctrlWord = (uint16_t)DRV8305_buildCtrlWord(CtrlMode_Write,regAddr,data);

    // reset the Rx fifo pointer to zero
    SPI_resetRxFifo(obj->spiHandle);
    SPI_enableRxFifo(obj->spiHandle);
    #ifdef CS_GPIO
    // Added: SCS High->Low
    //GPIO_setLow(obj->gpioHandle, GPIO_Number_19);
    GPIO_setLow(obj->gpioHandle,obj->gpioCS_Number);

    #endif
    // write the command
    SPI_write(obj->spiHandle,ctrlWord);

    // wait for registers to update
    for(n=0;n<0xf;n++)
    asm(" NOP");
    #ifdef CS_GPIO
    // Added: SCS Low->High
    //GPIO_setHigh(obj->gpioHandle, GPIO_Number_19);
    GPIO_setHigh(obj->gpioHandle,obj->gpioCS_Number);

    #endif
    return;
    } // end of DRV8305_writeSpi() function

    -------------------------------------------------------------------------------------------------------------------------------------
    in drv8305.h
    -------------------------------------------------------------------------------------------------------------------------------------

    #ifdef CS_GPIO
    //! \brief Sets the GPIO number in the DRV8305
    //! \param[in] handle The DRV8305 handle
    //! \param[in] gpioHandle The GPIO number to use
    void DRV8305_setSPI_CS_Number(DRV8305_Handle handle,GPIO_Number_e gpioCS_Number);

    #endif

  • good afternoon Chris.

    try you to use function WiteCMD and ReadCMD?
    Very interesting picture with CS.

    Andrew.