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.

Small issue in ePWM module in F28335



Hi,

 I have a small question which is silly one.

i have generated a PWM signal at 20KHz ,60% Duty Cycle.I have to vary the duty cycle in my application for that i written the following code :

 

EPwm1Regs.TBCTL.bit.CTRMODE = TB_FREEZE;  // Disable the timer
EPwm1Regs.TBCTL.bit.HSPCLKDIV = 1; //default
EPwm1Regs.TBCTL.bit.CLKDIV = 0; //default
EPwm1Regs.TBCTL.bit.CTRMODE= TB_COUNT_UPDOWN;
EPwm1Regs.TBCTL.bit.PHSEN = TB_DISABLE; // phase is disabled
EPwm1Regs.TBCTL.bit.SYNCOSEL =0; //syn is disabled
EPwm1Regs.TBPRD =3750;// calculted timebase period value for 20KHz,60% duty cycle
EPwm1Regs.TBCTR = 0;


// setup compare values
EPwm1Regs.CMPA.half.CMPA =1125; 

// Setup shadowing
EPwm1Regs.CMPCTL.bit.SHDWAMODE=CC_SHADOW;
EPwm1Regs.CMPCTL.bit.LOADAMODE= CC_CTR_ZERO;

// Set actions
EPwm1Regs.AQCTLA.bit.CAU = AQ_SET;
EPwm1Regs.AQCTLA.bit.CAD = AQ_CLEAR;

EPwm1Regs.DBCTL.bit.OUT_MODE = 0; // Deadband disabled
EPwm1Regs.PCCTL.bit.CHPEN = 0;  // PWM chopper unit disabled , completion of generating PWM wave supplied to MOSFET.

EALLOW;
SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 1;
EDIS;

My question is how to calculate the duty cycle ?

for this appliction  i have to change the duty cycle continuously how to do that ?

please help me

and also please provide sample code for Maximum power point tracking for photovltaic systems

 

Thanks & Regards,

Naveen Rangu

  

 

  • Hi Naveen,

    I'm not very shure about your question. I think your PWM signal is part of a control loop, right? You might have an output value from your controller which you must relate to your PWM signal. How to do the detailed calculus should be under your control.

    Concerning your second question. I am not specialist in solar applications, but I believe asking for detailed MPPT code, is as easy as asking google to reveal their internet search algorithm.... If I were in your situation I would read the literature available and try to gather the knowledge, instead of copying any code lying around...

    Best regards,


    Andreas

  • first of all sorry for the way i explained my question

    here i am giving some more detail

    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;

    Tst2 = ECapRegs.CAP2;

    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

     

  • Naveen,

    EPwm1Regs.TBPRD =3750;// if running at 150 MHz, this is a 40 KHz frequency (1 / (3750 * 6.666))

    EPwm1Regs.CMPA.half.CMPA =1125;   // this is 40% duty cycle.  You are on from 2x ((3750/2)-1125)

    EPwm1Regs.AQCTLA.bit.CAU = AQ_SET;

    EPwm1Regs.AQCTLA.bit.CAD = AQ_CLEAR;