• Join
  • Sign In with my.TI Login
Texas Instruments
  • Products
  • Applications
  • Tools & Software
  • Support & Community
  • Sample & Buy
  • About TI
Sample & Purchase Cart Sample & Purchase Cart
  • Search
  • Advanced
TI E2E™ Community
  • Support Forums
  • Blogs
  • Groups
  • Videos
  • 简体中文
  • More ...
TI Home » TI E2E Community » Support Forums » Microcontrollers » C2000™ Microcontrollers » C2000 32-bit Microcontrollers Forum » EPWM phase lag
Share
C2000™ Microcontrollers
  • Forums
  • Announcements
  • E2E Wiki
Options
  • Subscribe via RSS
C2000 Resources
  • Product Folder
  • C2000 Training Portal
  • C2000 Technical Training Catalog
  • C2000 Datasheets, App Notes, User Guides
  • C2000 Hardware Design Kits
  • controlSUITE for C2000 Software Library


  • InstaSPIN Resources
  • What is InstaSPIN?
  • Videos and Support


  • InstaSPIN-FOC and InstaSPIN-MOTION Resources
  • What is InstaSPIN-FOC?
  • What is InstaSPIN-MOTION?
  • Product Folder: F28069F, F28068F, F28062F, F28068M, F28069M
  • User’s Guide
  • Technical User’s Manual
  • Tools
  • Forums

    EPWM phase lag

    This question is not answered
    villuribhanu
    Posted by villuribhanu
    on Apr 13 2012 05:21 AM
    Intellectual300 points

    Hi,

     I am using TMS320F28335. I want to generate two pair of PWM's.

    I configured EPWM1 and EPWM2 in cmplementary mode.

    I want to generate a duty cycle in such way that complementary of EPWM1A is EPWM2A.

    code is given below

    Initialization:

     // Period = 15000 TBCLK counts
     EPwm1Regs.TBPRD = EPWM1_TIMER_TBPRD;

     // Set Phase register to zero
     EPwm1Regs.TBPHS.half.TBPHS = 0;

     // Clock ratio to SYSCLKOUT
     EPwm1Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1;      
     EPwm1Regs.TBCTL.bit.CLKDIV = TB_DIV1;

     // Symmetrical mode
     EPwm1Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN;

     // Master module
     EPwm1Regs.TBCTL.bit.PHSEN = TB_DISABLE;
     EPwm1Regs.TBCTL.bit.PRDLD = TB_SHADOW;

     // Sync down-stream module
     EPwm1Regs.TBCTL.bit.SYNCOSEL = TB_CTR_ZERO;
     EPwm1Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;
     EPwm1Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;
     EPwm1Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO; // load on CTR=Zero
     EPwm1Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO; // load on CTR=Zero

     // set actions for EPWM1A
     // Set output to high when TBCTR = CMPA while TBCTR incrementing
     EPwm1Regs.AQCTLA.bit.CAU = AQ_SET;
     // Set output to high when TBCTR = CMPA while TBCTR incrementing
     EPwm1Regs.AQCTLA.bit.CAD = AQ_CLEAR;

     // enable Dead-band module
     EPwm1Regs.DBCTL.bit.OUT_MODE = DB_FULL_ENABLE;

     // Active Hi complementary
     EPwm1Regs.DBCTL.bit.POLSEL = DB_ACTV_HIC;

     // FED = 150 TBCLKs
     EPwm1Regs.DBFED = 300;

     // RED = 150 TBCLKs
     EPwm1Regs.DBRED = 300; 


    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
       
     // EPWM Module 2 config

     // Period = 15000 TBCLK counts
     EPwm2Regs.TBPRD = EPWM1_TIMER_TBPRD;

     // Set Phase register to zero
     EPwm2Regs.TBPHS.half.TBPHS = 0;

     // Clock ratio to SYSCLKOUT
     EPwm2Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1;      
     EPwm2Regs.TBCTL.bit.CLKDIV = TB_DIV1;

     // Symmetrical mode
     EPwm2Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN;

     // Slave module
     EPwm2Regs.TBCTL.bit.PHSEN = TB_ENABLE;
     EPwm2Regs.TBCTL.bit.PRDLD = TB_SHADOW;

     // sync flow-through
     EPwm2Regs.TBCTL.bit.SYNCOSEL = TB_SYNC_IN;
     EPwm2Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;
     EPwm2Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;
     EPwm2Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO; // load on CTR=Zero
     EPwm2Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO; // load on CTR=Zero

     // set actions for EPWM2A

     // Set output to high when TBCTR = CMPA while TBCTR incrementing
     EPwm2Regs.AQCTLA.bit.CAU = AQ_SET; 
     // Set output to Low when TBCTR = CMPA while TBCTR decrementing
     EPwm2Regs.AQCTLA.bit.CAD = AQ_CLEAR;

     // enable Dead-band module 
     EPwm2Regs.DBCTL.bit.OUT_MODE = DB_FULL_ENABLE;
     
     // Active Hi complementary
     EPwm2Regs.DBCTL.bit.POLSEL = DB_ACTV_HIC;

     // FED = 150 TBCLKs
     EPwm2Regs.DBFED = 300;
     // RED = 150 TBCLKs
     EPwm2Regs.DBRED = 300; 

     while(1)
       {
      DutyCycle2 = EPWM1_MAX_CMPA - DutyCycle;
      
      EPwm1Regs.CMPA.half.CMPA = DutyCycle;      // Set compare A value
      
      EPwm2Regs.CMPA.half.CMPA = DutyCycle2;  // Set compare A value
     }

    Now I am getting some phase lag between EPWM1A and EPWM2B.

    Could any one help me in this regard.  

    Regards,

    Bhanu Prakash Villuri 

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    All Replies
    • Daniel Chang
      Posted by Daniel Chang
      on Apr 16 2012 11:00 AM
      Expert4120 points

      Hello,

      It looks like you are using synchronization between the PWM1 and PWM2 modules.  Synchronization has a 2 cycle delay, which is probably the cause of your phase lag.  To compensate,  try using the following in your code:

      EPwm2Regs.TBPHS.half.TBPHS = 2;    // 2 cycle compensate for synchronization delay
      EPwm2Regs.TBCTL.bit.PHSDIR = 1;    // count UP after synchronization event

      Regards,
      Daniel

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    TI E2E™ Community
    • Support Forums
    • Blogs
    • Videos
    • Groups
    • Site Support & Feedback
    • Settings
    TI E2E™ Community Groups
    • TI University Program
    • Make the Switch
    • Microcontroller Projects
    • Motor Drive & Control
    Other Communities
    • Deyisupport
    • Designsomething.org
    • beagleboard.org
    • TI on Element 14
    • TI on TechXchangeSM
    Other Technical & Support Resources
    • WEBENCH® Design Center
    • Product Information Centers
    • Technical Documents
    • TI Design Network
    • TI Technical Articles
    • TI Training

    All content and materials on this site are provided "as is". TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with regard to these materials, including but not limited to all implied warranties and conditions of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with respect to these materials. No license, either express or implied, by estoppel or otherwise, is granted by TI. Use of the information on this site may require a license from a third party, or a license from TI.

    Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms of Use of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms of Use of this site. TI, its suppliers and providers of content reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

    Follow Us Texas Instruments on Facebook Texas Instruments on Twitter Texas Instruments on LinkedIn Texas Instruments on Google+
    TI Worldwide | Contact Us | my.TI Login | Site Map | Corporate Citizenship | mobile m.ti.com (Mobile Version)

    TI is a global semiconductor design and manufacturing company. Innovate with 100,000+ analog ICs and
    embedded processors, along with software, tools and the industry’s largest sales/support staff.

    © Copyright 1995-2013 Texas Instruments Incorporated. All rights reserved.
    Trademarks | Privacy Policy | Terms of Use