• 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 » Problem scoping PWM with frequency 50Hz from F28069
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
  • Problem scoping PWM with frequency 50Hz from F28069

    Problem scoping PWM with frequency 50Hz from F28069

    This question is answered
    Prathamesh dhanpalwar
    Posted by Prathamesh dhanpalwar
    on Apr 20 2012 06:39 AM
    Intellectual410 points

    Hello,

    I am using piccolo F28069 on the experimental kit. I can scope rectangular pulse  at this (PERIOD 40000)                    // 100Hz when PLL is set to 0x10 (80MHz)). But I get nothing when PERIOD 800000                         // 50Hz when PLL is set to 0x10 (80MHz). I dont know what is the problem? Can anyone help me in this regard?

    Thank You.

    Regards-

    Prathamesh

    Piccolo Code Composer Studio Motor Control TMS320C2000 pwm digital motor control f28069
    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    All Replies
    • David M. Alter
      Posted by David M. Alter
      on Apr 20 2012 13:05 PM
      Suggested Answer
      Mastermind23890 points

      Hello Prathamesh,

      First, I think you made a typo in that you said you are setting PERIOD to 800000.  I think you meant 80000.

      The TBPRD register is a 16-bit value.  This means the maximum value you can set it to is (2^16)-1 = 65535.  You are attempting to set it to 80000, which is 0x13880, which gets truncated to 0x3880 by the compiler.  If you look at the build console, you should have a warning from the compiler that says something like "#70-D integer conversion resulted in truncation" assuming the compile is able to pick up the problem (this depends on how you are implementing your test code).

      I suspect you set your compare value in the CMPx register to a value greater than 0x3880.  For example, if you were expecting a 50% duty square wave you probably set CMPx to 40000, which is 0x9C40.  With a period of 0x3880, the compare will never occur and your scope will show flat-line.

      Regards,

      David

      -----------------------------
      David M. Alter
      Senior Member Technical Staff
      Texas Instruments Inc.

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Prathamesh dhanpalwar
      Posted by Prathamesh dhanpalwar
      on Apr 22 2012 03:19 AM
      Intellectual410 points

      Hello David,

         Thank you so  much for your reply.  I have got the error while building, but I declared the type PERIOD by Uint 16, thinking it would exceed the range. The error didnt occur later. But I still cannot get pulse wave at all frequencies.

      Actually I want to generate pulse wave at all frequencies by giving the % of the duty cycle in GUI for a 20 ms wave Therefore, I set my CMPx to 0 initially.

      I would be glad if you help me sole this problem.

      Regards-

      Prathamesh

      100% PWM duty_cycle 1005 duty Cycle
      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • David M. Alter
      Posted by David M. Alter
      on Apr 22 2012 16:19 PM
      Mastermind23890 points

      Prathamesh,

      I'm not understanding exactly what problem you are having.  What are you referring to when you say "GUI?"

      If you set CMPX to zero, you will not see a PWM pulse.  The pin will be either high, or low, all the time (depends on how you have the ePWM module configured).

      Set TBPRD=0xFFFF and CMPRx=0x8000.  This will generate a 50/50 PWM signal at the slowest frequency you can (without scaling the input clock to the ePWM module).  You should see the waveform on the scope.

      - David

      -----------------------------
      David M. Alter
      Senior Member Technical Staff
      Texas Instruments Inc.

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Prathamesh dhanpalwar
      Posted by Prathamesh dhanpalwar
      on Apr 23 2012 06:55 AM
      Intellectual410 points

      Hello David,

      Actually, I need to control a motor that has  pulse duration  from 0.9mS to 2.1mS with 1.5mS as center. The pulse refreshes at 50Hz (20mS). I dont want to used deadband as it gives complimentry outputs. What can I do??

      Regards-

      Prathamesh

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • David M. Alter
      Posted by David M. Alter
      on Apr 23 2012 10:40 AM
      Verified Answer
      Verified by Prathamesh dhanpalwar
      Mastermind23890 points

      Prathamesh,

      Prathamesh dhanpalwar

      Actually, I need to control a motor that has  pulse duration  from 0.9mS to 2.1mS with 1.5mS as center. The pulse refreshes at 50Hz (20mS).

      Use symmetric PWM (counter in up/down count mode).  In this mode, you set the TBPRD register to half the desired number of counts (because you count up, and then down).  For a 50 Hz period with (I assume) a 80 MHz F28069, you would need 800,000 counts (80 MHz / 50 Hz / 2).  This is too large a value for a 16-bit period register, so you need to prescale the clock to the ePWM using the TBCTL.CLKDIV bits.  Smallest prescaler that will work is /16, and set period to 50,000.  Then set the CMPRx as desireds to create your pulse.

      - David

      -----------------------------
      David M. Alter
      Senior Member Technical Staff
      Texas Instruments Inc.

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Prathamesh dhanpalwar
      Posted by Prathamesh dhanpalwar
      on Apr 24 2012 02:07 AM
      Intellectual410 points

      Hello David,

      Thank you for your reply. I have  understood what you suggested. But I can only see the smallest prescalers as 1/4, thats TB_DIV4. How can I set it to 1/16?

      Regards-

      Prathamesh

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • David M. Alter
      Posted by David M. Alter
      on Apr 24 2012 06:02 AM
      Mastermind23890 points

      Prathamesh,

      I'm not seeing where the confusion is.  Look in the F2806x User's Guide, SPRUH18C, p.332, Table 3-29.  Set TBCTL.CLKDIV=100b for /16.

      -----------------------------
      David M. Alter
      Senior Member Technical Staff
      Texas Instruments Inc.

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Prathamesh dhanpalwar
      Posted by Prathamesh dhanpalwar
      on Apr 24 2012 07:26 AM
      Intellectual410 points

      David,

      I have gone through it and I am just worried if  i have done it right.

      EPwm6Regs.TBCTL.bit.CLKDIV = 100 

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • David M. Alter
      Posted by David M. Alter
      on Apr 24 2012 08:38 AM
      Verified Answer
      Verified by Prathamesh dhanpalwar
      Mastermind23890 points

      Prathamesh,

      Prathamesh dhanpalwar

      David,

      I have gone through it and I am just worried if  i have done it right.

      EPwm6Regs.TBCTL.bit.CLKDIV = 100 

      You want to set the bit field to 100b (binary).  This is equal to 4 decimal or 4 hex.  So, the code you want is:

      EPwm6Regs.TBCTL.bit.CLKDIV = 0x4;

      Regards,

      David

      -----------------------------
      David M. Alter
      Senior Member Technical Staff
      Texas Instruments Inc.

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Prathamesh dhanpalwar
      Posted by Prathamesh dhanpalwar
      on Apr 24 2012 09:24 AM
      Intellectual410 points

      David,

      Thank you for bearing with me. I am a newbie to microcontroller programming. 

      Regards-

      Prathamesh 

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Prathamesh dhanpalwar
      Posted by Prathamesh dhanpalwar
      on Apr 26 2012 07:24 AM
      Intellectual410 points

      David,

      I have done the coding for 5 pwms (a,b) for one frequency. Now I want to interface a servo motor which needs the specification I mentioned earlier. I have made the necessary corrections, but I am still getting undesirable output.

      Here are the details:

      // Function based in example code: SymmetricPWM-Main.c
      void InitPWM6mode(void){

      // Setup PWMs in Up-Down-Count, Dual Edge Symmetric Waveform, With Independent
      // Modulation on EPWM2A and EPWM2B
      //
      // - In order to change the PWM frequency, the user should change
      // the value of"period".
      // - The duty-cycles can independently be adjusted by changing compare
      // values (duty_cycle_A & duty_cycle_B) for ePWM2A and ePWM2B.
      // - For further details, please search for the SPRU791.PDF
      // (TMS320x28xx, 28xxx Enhanced Pulse Width Modulator Module) at ti.com


      #define period1 50000 // 50Hz when PLL is set to 0x10 (80MHz)
      // #define period 40000 // 100Hz when PLL is set to 0x10 (80MHz)
      // period 250 // 160kHz when PLL is set to 0x10 (80MHz)
      // period 500 // 80kHz when PLL is set to 0x10 (80MHz)

      // Time-base registers

      EPwm6Regs.TBPRD = period1; // Set timer period, PWM frequency = 1 / period
      EPwm6Regs.TBPHS.all = 0; // Time-Base Phase Register
      EPwm6Regs.TBCTR = 0; // Time-Base Counter Register
      EPwm6Regs.TBCTL.bit.PRDLD = TB_IMMEDIATE; // Set Immediate load
      EPwm6Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN; // Count-updown mode: used for symmetric PWM
      EPwm6Regs.TBCTL.bit.PHSEN = TB_DISABLE; // Disable phase loading
      EPwm6Regs.TBCTL.bit.SYNCOSEL = TB_SYNC_DISABLE;
      EPwm6Regs.TBCTL.bit.HSPCLKDIV = 0x4;
      EPwm6Regs.TBCTL.bit.CLKDIV = 0x4;

      // Setup shadow register load on ZERO

      EPwm6Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;
      EPwm6Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;
      EPwm6Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO; // load on CTR=Zero
      EPwm6Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO; // load on CTR=Zero

      // Set Compare values

      EPwm6Regs.CMPA.half.CMPA = 0; // Set duty 0% initially
      EPwm6Regs.CMPB = 0; // Set duty 0% initially

      // Set actions

      EPwm6Regs.AQCTLA.bit.CAU = AQ_SET; // Set PWM2A on event A, up count
      EPwm6Regs.AQCTLA.bit.CAD = AQ_CLEAR; // Clear PWM2A on event A, down count

      EPwm6Regs.AQCTLB.bit.CBU = AQ_SET; // Set PWM2B on event B, up count
      EPwm6Regs.AQCTLB.bit.CBD = AQ_CLEAR; // Clear PWM2B on event B, down count
      
      
      And here is the case where it calls the PWM6:
      case 'L':                                               //PWM ID
      while(SciaRegs.SCIFFRX.bit.RXFFST == 0){} //Wait for command
      dutyCycle = SciaRegs.SCIRXBUF.all *0.06 * maxDutyCycle_1;
      EPwm6Regs.CMPB = dutyCycle;
      break;
      default:
      I dont know, what is the problem. Thank you.
      
      
      Regards-
      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • David M. Alter
      Posted by David M. Alter
      on Apr 30 2012 07:55 AM
      Mastermind23890 points

      Prathamesh,

      You did not say what the "Undesirable"  PWM behavior is, and honestly I'm not even sure what the PWM specification is that you say you mentioned earlier.  I took a quick look at the code you sent, and I see the following two lines:

          EPwm6Regs.TBCTL.bit.HSPCLKDIV = 0x4;
          EPwm6Regs.TBCTL.bit.CLKDIV = 0x4;

      The first line applies a /16 divider to the PWM input clock.  The second line applies an additional /8 divider to the PWM input clock, giving you a total divider of /128.  Is that what you want?  I thought you wanted /16, which lines up with what your #define for PERIOD1:

           #define    period1   50000         // 50Hz when PLL is set to 0x10 (80MHz)

       

      Regards,

      - David

       

       

      -----------------------------
      David M. Alter
      Senior Member Technical Staff
      Texas Instruments Inc.

      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