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.

ePWM peripheral: DC/DC converter controlled using Phase shift technique

Other Parts Discussed in Thread: CONTROLSUITE

I am using the phase shift technique to control a DC/DC converter.

I have configured PWM1 as a master and PWM2, 3 and 4 as slaves. To control the phase of PWM, I set TBPHS register with the appropiate value.

The problem I am facing is the following:

The delay of PWM3 sometimes is positive and sometimes is negative. When I change the phase from a negative value to a positive value, the peripheric mantains the PWM output in on position for a complete period before it updates the phase of the PWM.

I am adding the peripheral configuration.

Thank you in advance

    // PAREM ELS CLOCKS DELS ePWM
    EALLOW;
    SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 0;
    EDIS;

    // CONFIGURACIÓ REGISTRE TBCTL
     EPwm1Regs.TBCTL.bit.FREE_SOFT = 2;
    EPwm2Regs.TBCTL.bit.FREE_SOFT = 2;
    EPwm3Regs.TBCTL.bit.FREE_SOFT = 2;
    EPwm4Regs.TBCTL.bit.FREE_SOFT = 2;


    EPwm1Regs.TBCTL.bit.PRDLD = TB_SHADOW;          
    EPwm2Regs.TBCTL.bit.PRDLD = TB_SHADOW;
    EPwm3Regs.TBCTL.bit.PRDLD = TB_SHADOW;
    EPwm4Regs.TBCTL.bit.PRDLD = TB_SHADOW;


    EPwm1Regs.TBCTL.bit.SYNCOSEL = TB_CTR_ZERO;
    EPwm2Regs.TBCTL.bit.SYNCOSEL = TB_SYNC_IN;
    EPwm3Regs.TBCTL.bit.SYNCOSEL = TB_SYNC_IN;           
    EPwm4Regs.TBCTL.bit.SYNCOSEL = TB_SYNC_IN;
       EPwm5Regs.TBCTL.bit.SYNCOSEL = TB_SYNC_IN;
 
    EPwm1Regs.TBCTL.bit.PHSEN = TB_DISABLE;     
    EPwm2Regs.TBCTL.bit.PHSEN = TB_ENABLE;    
     EPwm3Regs.TBCTL.bit.PHSEN = TB_ENABLE;     
    EPwm4Regs.TBCTL.bit.PHSEN = TB_ENABLE;  


      // CONFIGURACIÓ REGISTRE TBPHS
    EPwm1Regs.TBPHS.half.TBPHS = 0;               
    EPwm2Regs.TBPHS.half.TBPHS = 0;             
    EPwm3Regs.TBPHS.half.TBPHS = 0;                
    EPwm4Regs.TBPHS.half.TBPHS = 0;                


    // CONFIGURACIÓ DE LA RECARGA DELS REGISTRES DE COMPARACIÓ
    EPwm1Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;          
    EPwm1Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;
    EPwm1Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO;        
    EPwm1Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO;       
                                                     
    EPwm2Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;
    EPwm2Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;
    EPwm2Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO;
    EPwm2Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO;
        
    EPwm3Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;
    EPwm3Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;
    EPwm3Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO;
    EPwm3Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO;

    EPwm4Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;
    EPwm4Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;
    EPwm4Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO;
    EPwm4Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO;


    //CONFIGUREM PERÍODE, MODULADORA
    EPwm1Regs.TBPRD             = T_CONM;           
    EPwm1Regs.TBCTL.bit.CTRMODE = TB_COUNT_UP; 
                                                            
    EPwm2Regs.TBPRD             = T_CONM;              
    EPwm2Regs.TBCTL.bit.CTRMODE = TB_COUNT_UP;     
 
     EPwm3Regs.TBPRD             = T_CONM;              
    EPwm3Regs.TBCTL.bit.CTRMODE = TB_COUNT_UP;     

     EPwm4Regs.TBPRD             = T_CONM;      
    EPwm4Regs.TBCTL.bit.CTRMODE = TB_COUNT_UP;      
 

    // HABILITEM I CONFIGUREM SOC DEL ADC
    EPwm1Regs.ETSEL.bit.SOCAEN  = ENABLE_BIT;         
    EPwm1Regs.ETSEL.bit.SOCASEL = ET_CTR_ZERO;     
    EPwm1Regs.ETPS.bit.SOCAPRD  = ET_1ST;                


    // HABILITEM I CONFIGUREM INTERRUPCIÓ DEL ePWM 1 i 5
    EPwm1Regs.ETSEL.bit.INTSEL  = ET_CTR_PRD;        
    EPwm1Regs.ETSEL.bit.INTEN   = ENABLE_BIT;  
    EPwm1Regs.ETPS.bit.INTPRD   = ET_1ST;       
 
   
    //INICIALITZACIÓ DELS DUTIES
    EPwm1Regs.CMPA.half.CMPA = duty50;           
    EPwm2Regs.CMPA.half.CMPA = duty50;
    EPwm3Regs.CMPA.half.CMPA = duty50;
    EPwm4Regs.CMPA.half.CMPA = duty50;                 

    EPwm1Regs.CMPB = duty50;              
    EPwm2Regs.CMPB = duty50;
    EPwm3Regs.CMPB = duty50;
    EPwm4Regs.CMPB = duty50;    


  // ESPECIFICA CONMUTACIÓ DE LES SORTIDES PWM
  EPwm1Regs.AQCTLB.bit.ZRO = AQ_SET;  
  EPwm1Regs.AQCTLB.bit.CAU = AQ_CLEAR;

  EPwm2Regs.AQCTLB.bit.ZRO = AQ_SET;
  EPwm2Regs.AQCTLB.bit.CAU = AQ_CLEAR;

  EPwm3Regs.AQCTLB.bit.ZRO = AQ_SET;
  EPwm3Regs.AQCTLB.bit.CAU = AQ_CLEAR;

  EPwm4Regs.AQCTLB.bit.ZRO = AQ_SET;
  EPwm4Regs.AQCTLB.bit.CAU = AQ_CLEAR;



                                
  EPwm1Regs.DBCTL.bit.OUT_MODE = DB_FULL_ENABLE; 
  EPwm1Regs.DBCTL.bit.IN_MODE  = DBB_ALL;     
  EPwm1Regs.DBCTL.bit.POLSEL   = DB_ACTV_LOC;   
  EPwm1Regs.DBFED = TEMPS_MORT;        
  EPwm1Regs.DBRED = TEMPS_MORT;    

  EPwm2Regs.DBCTL.bit.OUT_MODE = DB_FULL_ENABLE;   
  EPwm2Regs.DBCTL.bit.IN_MODE  = DBB_ALL;  
  EPwm2Regs.DBCTL.bit.POLSEL   = DB_ACTV_LOC; 
  EPwm2Regs.DBFED = TEMPS_MORT;            
  EPwm2Regs.DBRED = TEMPS_MORT;       

  EPwm3Regs.DBCTL.bit.OUT_MODE = DB_FULL_ENABLE;  
  EPwm3Regs.DBCTL.bit.IN_MODE  = DBB_ALL;    
  EPwm3Regs.DBCTL.bit.POLSEL   = DB_ACTV_LOC;
  EPwm3Regs.DBFED = TEMPS_MORT;               
  EPwm3Regs.DBRED = TEMPS_MORT;  

  EPwm4Regs.DBCTL.bit.OUT_MODE = DB_FULL_ENABLE;
  EPwm4Regs.DBCTL.bit.IN_MODE  = DBB_ALL;
  EPwm4Regs.DBCTL.bit.POLSEL   = DB_ACTV_LOC;
  EPwm4Regs.DBFED = TEMPS_MORT;
  EPwm4Regs.DBRED = TEMPS_MORT;


    EALLOW;
    SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 1;         // Start all the timers synced
    EDIS;

  • Ramon,

    What you are seeing is a result of the way the phase synchronization is implemented in the PWM peripheral.

    Basically, when PWM1 reaches 0, the slaved PWMs timers' are set to their respective TBPHS value and continue counting from there.  This means that you could skip over the CMPA value under certain circumstances.

    Take the instance in which:
    PWM1 and PWM3's Period value is 1000
    CMPA is 500
    Phase shift is -200 and will be switched to +300 (TBPHS from 200 to 700)

    When PWM1's synchronization pulse occurs (when PWM1 timer reaches 0), PWM3 is at TBCTR=200 and will immediately get loaded to 700 (1000-300).  Since the CMPA value, which makes the PWM signal low, was skipped the PWM output will stay high until the next one occurs.  See attached.

    ---

    However, in most cases your PHS is controlled via a control loop, and the PHS will only change in small increments per cycle (ie from -200 to -198 in one cycle, -198 to -200 in the next, or -4 to 4).  As a result, your 'jumps' should be relatively small per cycle and we haven't had an issue when we've done this in several kits.  (\controlSUITE\development_kits\HVPSFB_v1.1\)

    If your particular application requires large jumps to be made, you can preemptively make CMPA smaller (to force the PWM signal low) in the cycle prior to a a phase jump that you know may be problematic.


    Thank you,
    Brett

  • Thank you for the answer Brett,

    In my application, I am using the PHS via control loop and my increments from one cycle to the other are small. For instance, a change of PHS from -4 to 4 would cause the problem I explained in the previous mail.

    The configuration I have programed is very similar to the example 3.7 in the document: sprug04a - ePWM. By now, the unique solution that has worked is to force all the PWM to an OFF state during a cicle when PHS changes from a negative value to a positive value. However, I think that it is not a very polite solution.

    I had a look at the exaple you gave me without finding a solution to my problem but I will check it deeper, it is weird you've never faced this problem, maybe there's still something wrong in my configuration.

    Thank you,

    Ramon 

  • Ramon,

    Make sure that the TBPHS you choose is always between 0 and TBCTR.  Negative phases aren't directly allowed

    (TBPHS=-100 will cause issues, instead you should input it as TBPHS=TBPRD-100)

    Not sure if this is your issue, but it's one thought I have.


    Thank you,
    Brett

  • Hi Brett,

    I have tried to use values between 0 and TBCTR and the problem presists. The peripheral is behaving in the same way as before.

    Thank you

    Ramon

  • Ramon,

    Can you zip up your project and send it to me?


    Thank you,
    Brett

  • Ok,

    I will send you my project in the following days,

    Thank you in advance

    Ramon

  • Hello Brett,

    I send you attached my project with the phase-shift problem.

    In the following figure, you may see the missing pulse. There are two signals corresponding to EPWM1A (orange) and EPWM3A (purple). The EPWM3A misses a pulse when I change the delay from -100 points to +100 points. The same problem happens if I only use positive values.

    I am looking forward your response,

    Thank you in advance

    Ramon

    Soft_a_TI.rar
  • Ramon,

    Thank you, I understand the problem better now.

    What are you looking to have as a min/max phase shift between PWM1 and PWM3?  -180degrees to 180degrees? -90degrees to 90degrees? other?

    One of the better ways around this type of issue is to redefine your phase shift range (ie make it 1-to-179 degrees or 1-to-359 degrees) and change up your AQCTL events accordingly. 

    Hopefully this gives you some idea of how to make it work, but I'll try to add some clarity when you answer the question above.


    Thank you,
    Brett

  • I expect to have a min/max shift between PWM1 and PWM3 from -90degrees to 90degrees.

  • Ramon,

    Your PWM generation is pretty complex (because you're using deadband and having the deadband be sourced from the B channels of the ePWM).  Therefore, I'll just try to explain my thought process and hope that you can implement them.  I haven't tried either of the two specifically for your case, but similar resolutions have worked in similar circumstances.

    The approach I would take is one of the two below:
    1) I don't believe you are using ePWM3's CMPA.  I would set CMPA's AQCTL to do nothing to the PWM output most of the time.  However, in your ISR you can check to figure out if you'll jump from a negative phase to a positive phase.  When you know the jump will occur, you'll set up a CMPA event to happen at "TBPHS - 1" (ie if TBPRD is 3750 and TBPHS is 3650 but will change to 100, set CMPA to 3649 for one cycle) and set CMPA to AQ_SET your PWM.  In this way, you'll preempt the issue.  In the next cycle, (assuming this is possible) you'll then set CMPA's AQCTL back to doing nothing on an event trigger.

    2) Assuming that you're not using ePWM3's CMPA for some kind of trigger, etc:  Set up ePWM3's TBPHS = TBPRD/4.  Set ePWM3's CMPA = TBPRD/4.  Set ePWM3's CMPB = (3*TBPRD)/4.  Set CMPA to AQ_SET and set up CMPB to AQ_CLEAR.  You should now be able to change the TBPHS of ePWM3 from roughly -90 to 90degrees (if TBPRD=3750, TBPHS should be able to range from 1 to 1874 with no issue). 


    Thank you,
    Brett

  • Hi Brett,

    The problem has finally been solved.

    I have used the second resolution but I have changed the trigger of all PWM in order to move the commutation from the period of the timer. Now, the phase-shift range is within the period of the PWM.

    Thank you very much for your help.

    Ramon

  • Hai One and all........

    I am a fresher to 32 bit micro controllers and now I am working with compiler CCS(Code Composer Studio v 6.0.1),

    I want step by step procedure to use pulse width modulation creation, working with the project solar micro grid inverter

    So here PWM for DC  Dc fly back and PWM for DC AC converter is an important one. so kindly give reply as fast as you can

    Thanks and Regards.

    Mahesh

  • Mahesh,

    Sorry for the delay. I don't think anyone realized there was a different question open on this thread. In future, can you make a new post if you have a new question please?

    For an introductory training course on C2000, the best resource is the 1-day hands-on workshop. You can find more information about it here:
    processors.wiki.ti.com/.../C2000_Piccolo_One-Day_Workshop_Home_Page

    For specific information on solar inverter applications, I recommend you look through the kits available on controlSUITE.
    www.ti.com/.../tools_software.page

    There are several solar kits, but for a first-time I recommend the low voltage "Solar Explorer" kit.

    Hope this helps.

    Regards,

    Richard