Understanding DC-AC inverter for pure Sine PWM

Go To Last Post
21 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

1. Need to design solar inverter dc to ac using pure sine wave PWM. I am reading a bit and this is what understand. I am using MCU with FPU enabled.

2. Have to change output freq from 1-400Hz(depending on user input)  & output ac voltage from 110Vac-300Vac(depending on user input)

3.  Currently i am understanding how to change freq: 

a) Whatever I have read on internet is using swtiching freq 20Khz or higher for pure sine wave since its outside audible range. So i am using 20Khz here. I dont know if its ok or higher need to be selected, what is criteria for it?
Since I am using IGBT of 10Amps for application, so cannot go above 20Khz, as they have limitation of their own.
With 20Khz , PWM time period = 1/20Khz = 50us.

 

b) Then I read to divide sine wave into equal parts some on intenet used 100, some 200 some 10. What is criteria for it?
I am chosen 100 parts since it will divide 360 degree into 3.6 degree each.So an array of 100 values is made
arr[n] = Sin(n*Pi/180) where n varies from 0 to 99

Is it ok?
Then PWM will start with width variation and after every degree time period, corresponding PWM On time be selected, whereas PWM timer period is fixed at 50Hz so that switching freq is 20Khz always.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Vindhyachal Takniki wrote:
I am chosen 100 parts since it will divide 360 degree into 3.6 degree each

You only need a table of 90 degrees worth of sine values, as it is symmetric, or at most 180 degrees.  Now your resolution is 90/100 or 180/100. 

Make sure you have a bunch of IGBT's, as you will let the smoke out of a few before your done testing!!!

And when working with HV, always keep one hand in your back pocket so you will not get across the circuit by accident.

good luck

jim

 

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Vindhyachal Takniki wrote:
what is criteria for it?

 

You just quoted the criteria yourself:

You wrote:
I have read on internet is using switching freq 20Khz or higher for pure sine wave since it's outside audible range

 

The range of human hearing is usually stated as 20Hz to 20kHz - so a young person with good hearing may well be able to hear it - and be annoyed by it - if you use 20kHz ...

 

Note that 20KHz = 20 * 1024 = 20480 Hz

 

20kHz is 20000 Hz

 

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Vindhyachal Takniki wrote:
I read to divide sine wave into equal parts some on intenet used 100, some 200 some 10. What is criteria for it?

The more steps you have, the smoother the curve.

 

Use your favourite spreadsheet program to experiment and see how the difference looks!

 

A pure sinewave has an infinite number of steps!

 

Of course, having more steps means your micro has to work harder

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Microchip has a number of app notes for various inverters - you might want to search them out as they address probably all of your questions.
Why do you think a FPU is required? This is purely an integer application.
Then again, the variable frequency suggests a motor drive - if this is the case then that can change things significantly. Let’s not play a guessing game.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:
Microchip has a number of app notes

Find them on the Product Page for the chip you're using:

 

https://www.avrfreaks.net/commen...

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:

Note that 20KHz = 20 * 1024 = 20480 Hz

 

20kHz is 20000 Hz

 

Doesn't 20 KiHz = 20 * 1024 Hz?

 

Using a capital "K" prefix to mean 1024 is used only with bytes, and even that usage has been deprecated, due to ambiguity, in favor of the newer (if you can even call "as of the end of 1998" newer) base-1024 prefixes (kibi, mebi, gibi, etc).

 

(Drive makers have been sued in the past because consumers were/are confused over the meaning of "giga". It means 10003, not 10243! Unfortunately, the most prevalent desktop OS still uses the old and deprecated meaning of kilo/mega/giga/tera, 21 years after those meanings were deprecated, which only perpetuates that confusion.)

 

Last Edited: Thu. Mar 12, 2020 - 07:34 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

christop wrote:
Using a capital "K" prefix to mean 1024 is used only with bytes

No, it isn't.

 

Some people, for example use "32KHz" to describe 32768Hz watch crystals.

 

But you are correct that it all gets very ambiguous - which is exactly why the "newer" terms were introduced.

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for responses.
I have one doubt whether to go with fixed PWM period or fixed steps/360 degree.

 

I was reading this: http://www.ocfreaks.com/sine-wav...
Here it is mentioned : "For each division we have a single PWM cycle."  So for number of steps we divide full cycle we will have fixed PWM period.

 

1. Suppose for ease of understanding using 50-400Hz variable.

 

2. I have uploaded excel file with two options: https://drive.google.com/open?id...

Also attached pdf of same excel also
a) fixed steps 360 & keep swtiching freq variable (i.e 1 step per degree)
b) fixed switching freq(20Khz) & keep steps variable (20Khz as this is max freq for most igbt)
I prefer 4 igbt in H bridge configuration. 

 

 

A) Fixed steps & keep PWM period(swtiching freq)  variable:
1. At 50hz, time period = 1/50hz = 20ms
2. If keep 360 steps fixed, then time_per_step = 20ms/360 = 55.55us/step
3. 55.55us means swtiching freq will be 18khz around.
4. But if intial freq is 400Hz, then switching freq by this calculaltions will be 144Khz, which is very high .

B) Fixed switching freq i.,e 20Khz i.w PWM period = 50us & keep steps variable
1. At 50Hz, steps will be = 20Khz/50Hz i.e 400 steps
2. Time period per step = (1/50)*1000000/400 = 50us
3. So for 50hz, need to divide into 400 steps. For 400 steps, each step sine value is calculated as in excel.
4. Now for each step, 50us PWM period is fixed, so on_time varies. As in excel it changes from 0.78us to 50us(o tp 90 degree) & cycle continues.

I am not sure if igbt can work with such low on_times?
Normally igbt have max switching freq of 20Khz mentioned, so I assume this means 25us on time and 25us off time max? 

Are my calculations correct.

I have been able to generate sine wave by measuring directly at PWM output of MCU & connecting low pass filter of cut off 800hz around. Level shifted for negative cycle.

 

 

I am not sure which way is correct? Can anyone tell?
Is my understanding correct or other way to do it?

 

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

It sounds like this is your first electronics project.  If it is, you need to pick something else to work on.  An inverter like this is full of complexity, and dangerous.  It is NOT a first project.

 

What have you previously done with PWM, high voltage, or even the AVR?  You sound like nothing previous was done at all.

 

Work on other things, then try something more advanced like this later.  You don't need to be fiddling with line voltages right now. This is just an opinion, but it is best not to get in over your head, especially with something dangerous like this. 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Sun. Mar 15, 2020 - 04:58 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The ‘usual’ technique is fixed pwm with dds to generate the variable frequency. Effectively you are building two things - inverter to get the 320V DC bus and a VFD. Again, plenty of app notes to reference.
Learn to Google - it is a specific skill.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The choice of PWM intervals per cycle of sine depends on several things:

 

(1) PWM adds high frequency "noise" to the sine. This, in turn, requires filtering to avoid "conducted emissions" that can interfere with other equipment. The higher the PWM frequency, the easier it is to filter (that is, smaller component values). BUT, on the other hand, higher frequency noise has lower amplitude limits (as per standards for CE or FCC marks).

 

(2) Higher frequency PWM means smaller magnetics (transformer). Smaller transformer usually means lighter weight and smaller physical size and often less expensive.

 

(3) PWM frequency above 25KHz or so is generally preferred as some people can hear up to about that frequency. At even moderate power levels, magnetic cores and windings can vibrate at the PWM frequency, producing something that people can hear.

 

There is no "theoretical optimum". Optimum is what ever works best for your application.

 

Jim

 

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

Last Edited: Sun. Mar 15, 2020 - 10:53 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

By keeping fixed PWM freq 20Khz, i.e 50us time period, and variable steps to divide the sine wave i been able to generate it across MCU pin and connecting simple low pass filter, been able to generate sine wave acroos it for 50,100 & 400Hz, as in pic attached.

 

For example:
1. For 50hz, divide 360 degree into 20Khz/50hz = 400 steps
2. For 100hz, divide 360 degree into 20Khz/100hz = 200 steps
3. For 400hz, divide 360 degree into 20Khz/400hz = 50 steps
All caculations will be caried with FPU enabled MCU only, cortex M4.

 

I was reading some article on delta for carieer freq. They have default 4Khz and can go to max 15Khz.

Now I have some doubts:
1. Currenlty i am able to generate sine wave as desired but on MCU only. is it correct way to do that?

 

2. If it is, then next step is to select igbt of 20Khz switching freq. But have doubt that on_time varies from 0 to 50us? Can igbt work when on_time is near zero?
For example for 50Hz, PWM period is fixed 50us(20Khz), on time varies from 0 minimum, then next minimum is 0.78566us. SO can igbt turn on at this low time? Datsheet specify only 20Khz switching freq max. But i dint find minimum allowable on_time/off_time?

 

3. For initial for safety, will start with low voltages like 24Vdc and gradually increases to 220Vmax.

  

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

avrcandies wrote:
  An inverter like this is full of complexity, and dangerous.

Indeed.

 

And you're getting into the areas where a wire is not just a wire; a resistor is not just a resistor; etc, etc, ...

 

So you really do need a solid grasp of the basics before adding all these extra complications

 

  It is NOT a first project.

Absolutely.

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You do not vary the step size in integer increments. As I mentioned before, use DDS. Two lines of C code and you can vary the frequency with sub Hz increments.

I also asked if you were driving motors. Many VFDs use a 4 kHz carrier.

Last Edited: Mon. Mar 16, 2020 - 11:53 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

@kartman, will check how to use DDS.
Currently i am generating PWM from MCU-> IGBT driver->IGBT module.

Will check how to fit DDS into it then.

 

yes need to drive a 3 phase induction motor.

 

Yes u rightly said and as in delta vfd page attached, default carrier is 4Khz only. But why is that so? Wont it create audible noise more?

 

 

With current setup with MCU I am able to genearte sine PWm from 50-400Hz without issue. 

But now i need to vary amplitude also of output from 110Vac-300Vac? How to do that? Will that by same formula for sine wae?

y= Asin(angle) ?? current setup I have taken A=1in formula. 

Will varying A will vary amplitude also?  I have tried it , it seems to work. But  I am not sure if that is ok or not or this is how its done in vfd's??

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Had you done your research, then you wouldn’t be asking such questions!
You have two ways of changing the output voltage - scale the sine value or scale the dc bus voltage.

What does a ‘pure sine’ inverter have to do with a VFD? Again you drip feed us information and waste everyone’s time.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

@kartman, in inverter and vfd bith have input dc high voltage gets converted to ac.

Both need MCU to generate SPWM for h-bridge or 6 igbts?

Many things are overlapping in both.

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Vindy - you’re making an assumption. The load for a VFD is very specific ie an induction motor, whereas for a mains inverter the load can be anything. This affects the design decisions. So the solution might be similar or very different. A specific difference between that comes to mind is the pwm freq - on a VFD the freq is usually around 4kHz and the motor winding inductance is used to average the current. On an ‘inverter’ the switching frequency is higher so the filter components can be smaller. You might also include a transformer. An ‘inverter’ is usually fixed frequency.
So, be more specific with your questions. Don’t drip feed us critical information. At the price of VFDs these days, why would you design one?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


@kartman, you are right abt that, vfd are vrey cheap these days, but have very specfic design constraint for these.  Read abt DDS, they are capable of genearting sine wave with much more accuracy.

Current hardware is MCU_PWM_Pin->IGBT drivers->IGBT  , with DDS I not sure how they will be able to drive IGBT_drivers. PIN pwm may seems to SPWM but still it turn on/off completely between 0 and 1. 

 

 

 

 

I have attached one excel, where 4khz fixed PWM is used and freq varation for 1 to 400Hz s shown. For 50Hz got exact steps i,e 80 & for it 3 phase PWM values are also shown , graph in excel attached.

 

Now one issue is for 4Khz ,when go for other freq like 51Hz, we got steps in odd values like 78.43137255.

How to tackle this is MCU part?Cannot vary 4Khz as this is what user will input as carrier.

 

 

 

 

 

 

 

 

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

uint32_t phase_acc = 0;
uint32_t phase_inc = 0;

uint8_t sin_table[256] = {sine values...};


//
//  do this each pwm cycle
//
        phase_acc += phase_inc;
uint8_t pwm_val = sin_table[phase_acc >> 24];


// for the other two phases, temporarily add 1/3 and 2/3 of 2^32 to the phase_acc value
// vary phase_inc to vary the frequency.

As you can see, DDS is deceptively simple. Fractional increments are averaged over many cycles. You need to research better.