• 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 » Sinusoidal PWM on Piccolo
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

    Sinusoidal PWM on Piccolo

    This question is not answered
    Elijah Toppo
    Posted by Elijah Toppo
    on Jun 01 2010 18:15 PM
    Prodigy55 points

    Hey guys,

    I am stuck on how to produce SPWM on Piccolo (F28127).

    I have been able to produce Single PWM and Multiple PWM successfully..

    For Multiple PWM i've used an ISR.

    But for Sinusoidal i don't understand when should i change the Compare value.

    I definitely understand the theory for producing SPWM but an stuck in the application using Piccolo.

    Please if someone could guide me on how produce them using Piccolo it would be a great help.

    Please help me out..

    Thanks in advance..

     

    ~Elijah T. Toppo

    Piccolo pwm sinusoidal pwm
    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    All Replies
    • SJU
      Posted by SJU
      on Jun 01 2010 19:12 PM
      Intellectual635 points

      I'm not exactly sure what information you need, but I'll give it a shot...

      What you want to do first is probably setup a timer interrupt (PWM timer works) at a frequency >10x your sine frequency.

      Then you can update your compare value in the ISR with 0.5 * ((A * sin(t)) + 1) * PWM_Timer_period

      Use "A" (0 < A < 1) to vary the amplitude.

      This should give you a sine output with your PWM.

      I hope this helps.

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Arefeen
      Posted by Arefeen
      on Jun 02 2010 07:14 AM
      Genius5170 points

      Most of the motor control system examples if not all utilize SVPWM and should be a good source for you to know more about SVPWM implementation. Please down load any one of those systems to go through the code. One suggestion is ACI3-1.

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • SJU
      Posted by SJU
      on Jun 02 2010 17:57 PM
      Intellectual635 points

      I'd recommend that you first get familiar with sinusoidal PWM before moving on to space vector PWM.

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Elijah Toppo
      Posted by Elijah Toppo
      on Jun 03 2010 14:48 PM
      Prodigy55 points

      Thanks for replying.

      I'll just confirm what i am thinking to do..

      1) set up the pwm counter in up-down mode at say a frequency of 100Hz. (This will act as the carrier signal)

      2) now for the reference sine signal, the compare value has to be set and updated such that it acts as a sine wave (of say 10Hz)

      3) when the counter equals the compare value.. set or reset the epwm pin using action control.

      what i'm stuck at is ..

      1) to update the CMP value an interrupt has to occur. If i set the interrupt to occur when the CMP and CTR equal then what value of should i set the CMP value next.

      After reading your post.. i begin to question is it possible for an interrupt to occur without any action taking place... like if the interrupt was to occur at an constant higher (>10x as u suggested) then following your equation "CMPA = 0.5*((A*sin(t))+1)*PWM_TImer_period" the value could be updated.

      Is it possible to arrange for the ISR to occur without an event happening?

      2) i dont get what does 't' stand for in "CMPA = 0.5*((A*sin(t))+1)*PWM_TImer_period"

       say .. for 10Hz frequency of the sine wave.. t = 2*pi*10*(???).. what should be there.. ? is it CTR? but how can it be CTR.. since PRD is so adjusted to give a higher carrier signal frequency..

       

      Thanks once again.. Please help me out.

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • SJU
      Posted by SJU
      on Jun 03 2010 15:50 PM
      Intellectual635 points

      1) if you're planning on using a scope, you may want to increase your frequencies... 60Hz sine wave with a 1kHz PWM for example.

      2) update compare value at PWM frequency (1kHz)

      3) yes, but you can do it with a one time setup

      You can setup an interrupt at PWM zero or PWM period, that's what is most commonly done.

      You can have your PWM timer run all the time, even when your PWM outputs are not enabled, and have an ISR triggered periodically (after setup).

      "t" stands for time. Basically in your 1kHz interrupt, if you want a 60Hz sine wave, you need to increment by 0.38 rd your internal angle.

      Regards,

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • SJU
      Posted by SJU
      on Jun 03 2010 15:50 PM
      Intellectual635 points

      1) if you're planning on using a scope, you may want to increase your frequencies... 60Hz sine wave with a 1kHz PWM for example.

      2) update compare value at PWM frequency (1kHz)

      3) yes, but you can do it with a one time setup

      You can setup an interrupt at PWM zero or PWM period, that's what is most commonly done.

      You can have your PWM timer run all the time, even when your PWM outputs are not enabled, and have an ISR triggered periodically (after setup).

      "t" stands for time. Basically in your 1kHz interrupt, if you want a 60Hz sine wave, you need to increment by 0.38 rd your internal angle.

      Regards,

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Elijah Toppo
      Posted by Elijah Toppo
      on Jun 15 2010 04:49 AM
      Prodigy55 points

      Sorry for troubling you again with this..

      But can you tell me how to define time 't' in the C code..

       

      what function (if any) am i supposed to use for that.

      please help..

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • SJU
      Posted by SJU
      on Jun 15 2010 11:03 AM
      Intellectual635 points

      "t" is a time base scaled to radians (for sine) that you set with the frequency at which you execute your PWM program.

      In the example I described earlier, I was talking about setting up a 1kHz PWM and updating your duty cycle with f(t).

      We update the PWM duty cycle at the PWM frequency, and we need to get the 60Hz sine wave from that. So "t" is a variable that we increment by "how much angle do we need to add to represent 1ms (from 1kHz) for a 60Hz sine". 

      You can use IQmath to get the sine function (in radians or per unit). You will need to do a small amount of fixed point math to get to where you want to be, and I encourage you to read about the subject.

      Regards,

      SJU

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • SeAn Kinsella
      Posted by SeAn Kinsella
      on Oct 02 2010 11:55 AM
      Intellectual360 points

      SJU,

      A quick one for you - Where is the equation 0.5 * ((A * sin(t)) + 1) * PWM_Timer_period derived from?

      Cheers,

      Seán

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • SeAn Kinsella
      Posted by SeAn Kinsella
      on Oct 18 2010 10:07 AM
      Intellectual360 points

      Hi,

       

      Just wondering if anyone can tell me the derivation for this equation, or where I might find it??

       

      0.5 * ((A * sin(t)) + 1) * PWM_Timer_period

       

      Thanks,

      Seán

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • andreas von kaenel
      Posted by andreas von kaenel
      on Oct 19 2010 00:56 AM
      Genius4285 points

      Hi Séan

      Go to www.wolframalpha.com and type "derivative 0.5 * ((A * sin(t)) + 1) * PWM_Timer_period)" You'll see and be marveled ;-)

      Best regards

      Andreas

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • pradeep kumar ama
      Posted by pradeep kumar ama
      on Aug 06 2012 06:48 AM
      Intellectual685 points

      thanks for giving some information on sine wave but i have some problem same like what to declare the t value and who to declare that i m using tbprd as 2964 and cmpa as 296 so what i need to do now   

      Thanks & regards,
      Pradeep Kumar AMA
      Embedded software Developer
      In
      Solare Energy Pvt. Ltd.
      i m using for 50hz
      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • SJU
      Posted by SJU
      on Aug 06 2012 16:57 PM
      Intellectual635 points

      In your case you are working with fixed point registers and you need to scale the desired output signal to your TBPRD register.

      For example, the largest sinewave you could send out would be something like (2964/2) + (2964/2)*sin(x) where x is a ramp.

      Sounds like you might benefit from reading material about fixed point math. 

      Example: if your sine function output is a q8 number (8 binary digits after decimal point), the math may look like:

      CMP = (Period>>1) + (((Period>>1) * sin_q8(x)) >> 8) which you could further simplify/improve.

      "x" would be generated by incrementing and wrapping a variable at a rate function of your execution period and the desired sin frequency.

      SJU

      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