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.

is this correct one or not?

Hi ,

my question is there any way that i can change the duty cycle of PWM Signal within the epwm Module or better to go for eCAP ?

 we know that there is a fixed value of CMPA to particular Duty cycle (say 1125 for 60% duty cycle) am i right ? now my doubt is that is there any way to change the CMPA value such that it varies the duty cycle continuously

if I go for eCAP to assign the value of duty cycle variable finding fron caputure mode as below

e.g

 Tst1= ECapRegs.CAP1; //for rising edge of first pulse

 Tst2 = ECapRegs.CAP2; //for falling edge of first pulse

duty cycle = Tst2- Ts1;

 EPwm1regs.CMPA = duty cycle;

is this correct approch (because CAP1 and CAP2 are 32-bit wide)?

please help me

Thanks & Regards

Naveen Rangu

  • Hmmm, it seems you are tackling the problem backwards. In short, the PWM is an "output" module, and the capture is an "input" module.

    To change your output duty cycle in a seemingly continuous manner, you simply need to update your PWMxCMP (A or B) register periodically. In order to do this, you can set a timer interrupt and use it as a time base for your program. Most of the time, we tend to use the PWM timers because it is inherently synchronized with the PWM...

  • Adding to SJU's comments -

    It is possible to use the eCAP module resources to implement a single-channel PWM generator (with 32 bit capabilities) when it is not being used for input captures. The counter operates in count-up mode, providing a time-base for asymmetrical pulse width modulation (PWM) waveforms. The CAP1 and CAP2 registers become the active period and compare registers, respectively, while CAP3 and CAP4 registers become the period and capture shadow registers, respectively.

    This may be the source of confusion. 

    Cheers

    Lori

     

  • Thank you SJU

    yes you are correct. now i understood. instead of timer is it possible to increment  the CMPA value by incrementing as bellow

    EPwm1Regs.CMPA.half.CMPA = CompareA++  ; (I have declared it initially i.e Uint16 CompareA = 1125;)

                      (OR)

    EPwm1Regs.CMPA.half.CMPA = CompareA-- ;

    is this correct approch ?

     

  • Thank you Lori

    may i know what is the advantage of eCAP over ePWM?

    if eCAP is used in APWM mode,then how to change the duty cycle of it? i hope there is no chance to change the duty cycle of the PWM wave using eCAP

    if so,kindly tell me the procedure to do

     

    Regards,

    Naveen

  • Hi Naveen,

    Well, yes, the correct approach would be to let the timer run by itself and adjust the CMP registers to get the desired duty cycle.

    Usually, the new duty cycle is calculated by your controller in order to get the desired operation (current, voltage, power control...), and then you just scale it so that 100% corresponds to your timer period.

    The approach you describe is correct, but all that it will do is increase (or decrease in case of "--") your duty cycle slowly.

    eCAP gives you a 32 bit timer to work with, which could useful for low frequency high resolution PWM. I think it doesn't come will all the good features that the PWM module has, such as deadband, phase shift control, trip, symmetry... I only use them when I run out of PWM pins.

     

  • thank you SJU