Continue to Site

Welcome to

Welcome to our site! is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

digital SPWM using dsPIC30F4011 for single phase inverter

Not open for further replies.


Newbie level 4
Jun 1, 2011
Reaction score
Trophy points
Activity points
Hi All,

I am new to this forum. i am trying to generate digital SPWM from dsPIC30F4011. which i am unable to do as i am not clear.
The hardware part that is power circuit has been designed properly.
Only case is control circuit. i need output of 10k switching frequency.

would really appreciate if someone could help asmy submission days are nearing and my concept of microcontroller are not good enough to handle the coding.

please some guide me through


There are various spwm techniques. The easiest technique in my opinion is centroid pwm technique. just calculate switching angles and configure pwm channels to generate the required angles.
I have done this in dspic33fj32mc204. The centroid pwm technique paper along with matlab code to calculate switching angles is below
**broken link removed****broken link removed**

Read IEEE paper carefully and try to understand matlab code. Then generate an array of switching angles. Change the duty cycle of PWM channel to simulate switching angles.
thanks for your reply. actually i am totally new to electrical concepts and also dsPIC, so bit hard for me to understand. could u pl ellaborate some more. so i can deal well.
yes.. the paper seems promising. and concept is good. but i dont know how to program the same with dsPIC.

could u please guide me with that part.

Thanks ..

One more question. do we get unipolar PWM output or bi polar. i want it for single phase inverter

Unipolar would be preferred for it's smaller ripple current. A dsPIC should be able to generate it.


i require to generate SPWM through dsPIC 30F4011. But i ve no prior experience with programming not sure how to begin with. could u please guide.

Hi Frank,

i ve figured out a way. could atleast tell whether my approach seems resonsable for SPWM generation

Unipolar would be preferred for it's smaller ripple current. A dsPIC should be able to generate it.

How to generate unipolar with dspic??

---------- Post added at 11:10 ---------- Previous post was at 10:50 ----------

Select number of pulses per half cycle. Calculate the switching angles alpha1, alpha2 and alpha n using matlab script attached. Then calculate the duty cycle using following equation approach:

time period=1/f (inverse of switching frequency)
pulse width= α2n - (α2n-1)
duty cycle = "pulse width"/("time period")

calculate N duty cycles using 2N alpha values calculated from matlab script. The create an array of all these duty cycles. Configure dspic PWM module and update duty cycles on every cycle from the array created above.
Not open for further replies.

Part and Inventory Search

Welcome to