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.

QUADRATURE PULSE GENERATOR

Other Parts Discussed in Thread: HALCOGEN

I  WANT  TO  USE  PWM  IN MY PROJECT   FOR  QUARATURE  PULSE GENERATOR   FOR  PULSE  PURPOSE  HOW  DO  THAT  , IAM  USING EXAMPLE  CODE  OF  TMS570LS4357  EQAP  , HOW  TO INCLUDE PWM  IN  OUR  PROJECT  WHAT  WILL BE  SET UP AND  CODE

  • Hello jeev,

    Our expert for this topic is out on local holiday and will be back on Wednesday, please wait for their feedback until then, thank you.

    Best Regards,

    Ralph Jacobi

  • Hi Jeev,

    The PWM can be generated in two ways. One way is using ETPWM and the other way is using NHET.

    Using ETPWM:

    To learn this, refer the example codes present in the Help Topics section of HALCoGen

    Using NHET:

    In this method we have to use a special IDE called HET IDE.

    HET IDE User guide spnu483a.pdf

    Refer below threads also:

    (+) Can NHET on TMS570 be used to implement multiple Quadrature Encoders (QEI) [e.g. QEA, QEB, INDEX] - Arm-based microcontrollers forum - Arm-based microcontrollers - TI E2E support forums

    (+) TMS570LC4357: Implementation of Motor Drive for PMSM using FOC - Arm-based microcontrollers forum - Arm-based microcontrollers - TI E2E support forums

    --
    Thanks & regards,
    Jagadish.

  • what u send  image its not  supporting ,can u send in  jpg form,  bro i have example code  quarature pulse  encode  for that input as pulse through PWM , how to include both example code 

    #include "sys_common.h"
    /* USER CODE BEGIN (1) */
    #include "eqep.h"
    #include "sys_core.h"
    /* USER CODE END */
    /* USER CODE BEGIN (2) */
    #define UNIT_POSITION_X 60U
    /* USER CODE END */
    void main(void)
    {
    /* USER CODE BEGIN (3) */
    uint16 deltaT = 0U;
    float velocity = 0U;
    /* EQEP initialization based on GUI Configuration. */
    QEPInit();
    /* Enable Position Counter */
    eqepEnableCounter(eqepREG1);
    /* Enable Unit Timer. */
    eqepEnableUnitTimer(eqepREG1);
    /* Enable capture timer and capture period latch. */
    eqepEnableCapture(eqepREG1);
    while(1)
    {
    /* Status flag is set to indicate that a new value is latched in the QCPRD register. */
    if((eqepREG1->QEPSTS & 0x80U) !=0U)
    {
    /* Elapsed time between unit position events */
    deltaT = eqepREG1->QCPRD;
    /* Calculate Velocity from deltaT and the value of the unit position. */
    /* The value of Unit Position is a sample value and should be changed by the User as per the actual value in the UNIT_POSITION_X macro above. */
    velocity = (float)(UNIT_POSITION_X/deltaT);
    /* Clear the Status flag. */
    eqepREG1->QEPSTS |= 0x80U;
    }
    }
    /* USER CODE END */
    }

    */

    /* USER CODE BEGIN (0) */
    /* USER CODE END */

    /* Include Files */

    #include "HL_sys_common.h"
    #include "HL_system.h"

    /* USER CODE BEGIN (1) */
    #include "HL_etpwm.h"
    #include "HL_adc.h"
    /* USER CODE END */

    /** @fn void main(void)
    * @brief Application main function
    * @note This function is empty by default.
    *
    * This function is called after startup.
    * The user can use this function to implement the application.
    */

    /* USER CODE BEGIN (2) */
    /* USER CODE END */

    uint8 emacAddress[6U] = {0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU};
    uint32 emacPhyAddress = 1U;

    void main(void)
    {
    /* USER CODE BEGIN (3) */
    _enable_interrupt_();
    adcInit();
    etpwmInit();
    adcEnableNotification(adcREG1, adcGROUP0);
    adcStartConversion(adcREG1, adcGROUP0);
    while(1);
    /* USER CODE END */
    }

    /* USER CODE BEGIN (4) */
    void adcNotification(adcBASE_t *adc, uint32 group)
    {
    adcData_t data;
    uint32 count;
    uint16 cmpA;

    count = adcGetData(adcREG1, adcGROUP0, &data);
    cmpA = (etpwmREG1->TBPRD * data.value)/0xFFF;
    etpwmSetCmpA(etpwmREG1, cmpA);
    }
  • Hi Jeev,

    what u send  image its not  supporting ,can u send in  jpg

    --
    Thanks & regards,
    Jagadish.

  • Hi Jeev,

    i have example code  quarature pulse  encode  for that input as pulse through PWM , how to include both example code 

    Combining two codes is easy, you can do something like below:

    #include "sys_common.h"
    /* USER CODE BEGIN (1) */
    #include "eqep.h"
    #include "sys_core.h"
    #include "HL_etpwm.h"
    #include "HL_adc.h"
    /* USER CODE END */
    /* USER CODE BEGIN (2) */
    #define UNIT_POSITION_X 60U
    uint8 emacAddress[6U] = {0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU};
    uint32 emacPhyAddress = 1U;
    /* USER CODE END */
    void main(void)
    {
    /* USER CODE BEGIN (3) */
    uint16 deltaT = 0U;
    float velocity = 0U;
    
    _enable_interrupt_();
    adcInit();
    etpwmInit();
    
    /* EQEP initialization based on GUI Configuration. */
    QEPInit();
    /* Enable Position Counter */
    eqepEnableCounter(eqepREG1);
    /* Enable Unit Timer. */
    eqepEnableUnitTimer(eqepREG1);
    /* Enable capture timer and capture period latch. */
    eqepEnableCapture(eqepREG1);
    
    
    adcEnableNotification(adcREG1, adcGROUP0);
    adcStartConversion(adcREG1, adcGROUP0);
    
    while(1)
    {
    /* Status flag is set to indicate that a new value is latched in the QCPRD register. */
    if((eqepREG1->QEPSTS & 0x80U) !=0U)
    {
    /* Elapsed time between unit position events */
    deltaT = eqepREG1->QCPRD;
    /* Calculate Velocity from deltaT and the value of the unit position. */
    /* The value of Unit Position is a sample value and should be changed by the User as per the actual value in the UNIT_POSITION_X macro above. */
    velocity = (float)(UNIT_POSITION_X/deltaT);
    /* Clear the Status flag. */
    eqepREG1->QEPSTS |= 0x80U;
    }
    }
    
    void adcNotification(adcBASE_t *adc, uint32 group)
    {
    adcData_t data;
    uint32 count;
    uint16 cmpA;
    
    count = adcGetData(adcREG1, adcGROUP0, &data);
    cmpA = (etpwmREG1->TBPRD * data.value)/0xFFF;
    etpwmSetCmpA(etpwmREG1, cmpA);
    }
    /* USER CODE END */
    }

    But the problem is you have to do the proper configurations in HALCoGen right? otherwise the code won't work properly. So please make sure to do proper HALCoGen configurations as well.

    --
    Thanks & regards,
    Jagadish.