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
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.
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.
I'd recommend that you first get familiar with sinusoidal PWM before moving on to space vector PWM.
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.
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.
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.
"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.
A quick one for you - Where is the equation 0.5 * ((A * sin(t)) + 1) * PWM_Timer_period derived from?
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
Go to www.wolframalpha.com and type "derivative 0.5 * ((A * sin(t)) + 1) * PWM_Timer_period)" You'll see and be marveled ;-)
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
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.
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.
TI is a global semiconductor design and manufacturing company. Innovate with 100,000+ analog ICs andembedded processors, along with software, tools and the industry’s largest sales/support staff.