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.

RTOS/TIDEP0025: 33.3kHz PWM frequency in TIDEP0025 demo

Genius 5840 points
Part Number: TIDEP0025

Tool/software: TI-RTOS

Hello.

I set up the TIDEP0025 demo and it runs well with Endat encoder.

Currently, TIDEP0025 demo runs over 10kHz PWM frequency.

I would like to run the TIDEP0025 demo over 33.3kHz PWM frequency like the benchmark setup described in tidu701.pdf.

So I modified as below, but motor didn't rotate and D15 LED lighted up.

#define PWM_PERIOD 30000 //30us for 33.3KHz
//#define PWM_PERIOD 40000 //40us for 25 KHz - Does not work
//#define PWM_PERIOD 50000 //50us for 20KHz
//#define PWM_PERIOD 100000 //100us for 10KHz

1.Could you tell me how to run the TIDEP0025 demo properly over 33.3kHz PWM frequency?

2.Could you tell me why 25kHz PWM frequency does not work?

3.Is it possible to run the TIDEP0025 demo at 47kHz PWM frequency with my current hardware setup?

Regards,

U-SK

 

  • I am looking into the PWM_PERIOD definition issue and will let you know what I find.

    One thing to note on the PWM frequency is that the AM437x ePWMs are clocked with a 100MHz clock. The minimum granularity is 10ns. This will need to be taken into account when you are evaluating PWM cycle times.

    What is the resolution you would like to achieve on your PWMs at 47kHz? With a 100MHz clock, ~11 bits of precision should be possible at 47kHz.

    Jason Reeder
  • Hi Jason,

    Thank you for your reply.
    I understand that ~11 bits of precision should be possible at 47kHz.
    I am not thinking about requesting resolution at present, so I will let you know as soon as I find out.

    Would you please let me know answers to question 1 and 2 if you find ?

    Regards,
    U-SK
  • Hi Jason,

    Please let me tell you additional information.
    The demo at 20kHz PWM cycles works well with Endat Encoder.

    When I changed CPU frequency to 300MHz, then, motor didn't rotate and D15 LED lighted up.

    Is it due to the processing of focloop not being in time for the next PWM update?

    Regards,
    U-SK
  • Sorry for the delay. I'm still looking into this one and trying to replicate.
  • It appears like the initialization of the PWM signals may have something to do with this. I made a change on my local setup to only enable the PWM clocks at the end of the PWM initialization and it corrected the issue for me. Can you try to following change and let me know if it works for you as well?

    Create the following function in the foc_pwm.c file:

    void CtrlPwmssTimebaseClkDisable(void)
    {
         /*CTRL_PWMSS - PWM3 syncin from PIN (eHRPWM3), timebase clock disable for all*/
         HWREG(SOC_CONTROL_MODULE_REG + CTRL_PWMSS) = CTRL_PWMSS_PWM_SYNCSEL_MASK;
    }

    Call that function at the BEGINNING of the Drv_PWM_Init() function (in the foc_pwm.c file) in order to disable the clock to the PWMs while the initiializations is happening.

    Now, at the END of the Drv_PWM_Init() function (in the foc_pwm.c file) you need to add a barrier instruction (to make sure all of the configurations have landed in the registers) and then re-enable all of the PWM clocks at the exact same time:

    HW_SYNC_BARRIER();
    
    CtrlPwmssTimebaseClkEnable();

    After all of these changes the function should look something like this:

    void Drv_PWM_Init(PWMGEN *p)
    {
        Int32 Tm;
        Tm = (Int32)p->PeriodMax;
        Int16 MPeriod;
        Int32 Tmp;
    
        CtrlPwmssTimebaseClkDisable();
    
        ...
        Initialization of PWMs
        ...
    
        HW_SYNC_BARRIER();
    
        CtrlPwmssTimebaseClkEnable();
    }
    

    This solved the issue for me both when running the CPU at 300MHz and when trying to run the PWM cycle at 25kHz (with the CPU at 600MHz).

    Let me know if this fixes your issue.

    Jason Reeder

  • Hi Jason,

    Thank you for your reply.
    I understand your motor is rotated properly 20kHz PWM cycles with 300MHz CPU frequency and 25kHz PWM cycles with 600MHz CPU frequency.
    How about 33kHz PWM cycles with 600MHz CPU frequency and 25kHz PWM cycles with 300MHz CPU frequecy?

    I measured focloop() turn around time using gpio, the result is as follows:

    5.8~7us at 600MHz CPU frequency
    10.2~13us at 300MHz CPU frequency

    So I think running the demo with the above condition is possible even though considering interrupt delay and ADC processing time.
    I would like to achieve 33kHz PWM cycles with 300MHz CPU frequency, but I think focloop() processing is little bit too long.

    Regards,

    U-SK
  • Hi,

    Can you confirm which versions of the Industrial Drives package that you are using? I've found that version 01.00.02.03 has an optimization when writing the three PWM values that the 01.00.02.00 version does NOT have. If you are using version 01.00.02.00 you need to replace the three calls to the CSL_epwmCounterComparatorCfg() at the bottom of your Drv_PWM_Update() function (in the foc_pwm.c file) with the following code:

        HWREGH(SOC_PWMSS3_REG + PWMSS_EPWM_OFFSET + PWMSS_EPWM_CMPA) = (uint16_t)p->PWM1out;
        HWREGH(SOC_PWMSS4_REG + PWMSS_EPWM_OFFSET + PWMSS_EPWM_CMPA) = (uint16_t)p->PWM2out;
        HWREGH(SOC_PWMSS5_REG + PWMSS_EPWM_OFFSET + PWMSS_EPWM_CMPA) = (uint16_t)p->PWM3out;
    
        HW_SYNC_BARRIER();

    Once I did this in my CiA402 motor control setup, my FOC loop timing (at 300MHz A9 frequency) changed from ~11.7us to ~8.8us.

    I think if you have the following 3 changes you should be able to achieve 33kHz at either 300MHz or 600MHz (using TIDEP0025 demo (EnDat and CiA402)):

    1. The Drv_PWM_Init() function update already listed previously in this E2E thread (to sync the PWMs at the beginning of the demo)
    2. The Drv_PWM_Update() function change mentioned in this post (to reduce timings by nearly 3us at 300MHz)
    3. Change the iep_endat_start offset to (PWM_PERIOD >> 1) - 400. This will move the EnDat position capture to the middle of the PWM cycle and will ensure that the EnDat trigger occurs at 25kHz and 33kHz PWM cycle times.
      1. To achieve this, make the iep_endat_start line in the foc.c file look like the below (change 20000 to 400):
        1.     p_mem_foc_params->iep_endat_start = (PWM_PERIOD >> 1) - 400;

    Let me know if these three changes make your TIDEP0025 demo run correctly at 33kHz while the Arm is running at 300MHz.

    Jason Reeder