# Three Phase Inverter PWM generation Question.

#### abdullahab4

Joined Jan 24, 2018
6
Hello Everyone, I am trying to create a three phase inverter using PWM as the input to the gate of the MOSFETs.
I am slightly confused by the theory of inverters. My aim is to control the input PWM signal to control the output speed and amplitude of the sinosoidal signal on my output.
I don't get how the PWM is generated such that it resembeles an output sine wave. I know I know that a comparator is used to compare between a sine signal and a sawtooth signal to generate the PWM. But how exactly does that happen in a Microcontroller? I want to use a microcontroller that is able to generate a sinosoidal pwm, how do i do that? (generally).

#### Alec_t

Joined Sep 17, 2013
14,370
Welcome to AAC!
Suppose you want to create a 50Hz sinewave of peak amplitude A and you have a PWM frequency of 50kHz with amplitude A.
There will be 1000 PWM pulse periods for each cycle of the 50Hz. In each pulse period the average voltage is d*A, where d is the duty cycle.
By increasing/decreasing the duty cycle slightly the average will increase/decrease accordingly. So, by changing the duty cycle from one pulse period to the next, the average voltage per period can be made to follow a sinusoidal curve at the 50Hz rate. A sluggish load such as a motor or incandescent lamp will respond to the average.
The microcontroller uses a stored look-up table of duty cycle values and reads them in turn to set the PWM pulse on and off times. Since the sinewave is symmetrical, the table need only contain enough values (250 in this example) to cover 1/4 of the 50Hz cycle.
The raw PWM looks similar to this.

Last edited:

#### abdullahab4

Joined Jan 24, 2018
6

I understand your point, but what I am struggling with is how to implement that in C programming for example.

Another question I have is that how can i effectively control the output current/voltage. Because I am trying to build a VVVF. I know that the output frequency is controlled by changing the carrier sawtooth frequency, but how does the output VOLTAGE change. In other words, how do i have full control over the output voltage. Do I change the values in the lookup table?

#### tsan

Joined Sep 6, 2014
138
I know that the output frequency is controlled by changing the carrier sawtooth frequency, but how does the output VOLTAGE change. In other words, how do i have full control over the output voltage. Do I change the values in the lookup table?
Don't change the carrier, change the sine wave reference. If you want lower output voltage, reduce amplitude of the sine wave reference. Frequency changes when you change frequency of the reference sine wave.

#### abdullahab4

Joined Jan 24, 2018
6
Don't change the carrier, change the sine wave reference. If you want lower output voltage, reduce amplitude of the sine wave reference. Frequency changes when you change frequency of the reference sine wave.
Fair enough I understand. Forgive me for my naivety but I am relatively new to this. Will I be able to change the sine wave reference using the stored look-up table in the microcontroller? If i have a look up table consisting of several duty cycles. How exactly can I easily control such duty cycles i.e. the sine wave reference to control the output sine wave.

#### Alec_t

Joined Sep 17, 2013
14,370
Will I be able to change the sine wave reference using the stored look-up table in the microcontroller?
You can apply a scaling factor in software to each of the look-up values to change the amplitude of the sinewave.

#### tsan

Joined Sep 6, 2014
138
Will I be able to change the sine wave reference using the stored look-up table in the microcontroller?
If you have a micro controller with hardware pwm units, you can use them to make the carriers. Supply sine wave reference samples with suitable interval to pwm unit and it generates the required pwm. Let's assume that the reference sine wave is made of 40 samples. If you update the sample every 1 ms, frequency is 1/40 ms = 25 Hz. If you update the sample every 500 us, you have 50 Hz.

If i have a look up table consisting of several duty cycles. How exactly can I easily control such duty cycles i.e. the sine wave reference to control the output sine wave.
I don't understand how calculating of duty cycles beforehand would work well. There would be a lot of duty cycles in store. For example with 1% amplitude steps from 0-100% and 0,1 Hz step from 0-60 Hz would make a big table. But if you have it like this, I think it is enough to select duty cycle from the table and control output pin according to that. Pin control might be difficult without adjustable hardware timer interrupt.

#### Janis59

Joined Aug 21, 2017
1,855
RE:""microcontroller that is able to generate a sinosoidal pwm, how do i do that?""
First - I am bit confused what means sinusoidal pwm. Always had been that pwm may only refer to the D-factor, alias gap in between MEANDRIC pulses. But okay, probably You want to say, that Your aim is to create the sin OUTPUT of smps.
Second - If I miss Your aim, and really the aim is sinusoidal three-phase signal, there are very cheap China product (few USD) of four-channel DDS generator. Each channel may be softweare-adjusted by frequency, amplitude, phase shift etc. Thus You need to forget about 4th channel, and first three program for identical f and U but different phase shifts. The output form may be choose between sin, meander, triangular, saw-tooth falling, sawtooth rising.
Third - if software is not Your friend, one may try to do this even in analogue way. For example, the Wilson current mirror creates a stable current what charges one good capacitor. Voltage on that is monitored by extra good comparator. When V comes near to feed voltage, the discharge transistor gets signal to end the sawtooth. And cycle is going by a new, so the near the ideal sawtooth is at the hands. Another high quality comparator monitors the sawtooth current levels, and gives a command to simple logic gates. In my case I was seeking that on one phase but near the GHz (that is why normal pwm tablets was not a solution), but Your case the interest be a much more exact levels, for each phase.
Accordingly each of gates signals comes onto fast optron, gate driver, and powerful mosfet.
But where is the sinus, You may ask. See, by the definition sin(1*f)=1/3 meander(3*f)+1/5 meander(5*f)+1/7 menader(7*f) + ... +.... For most demanding clientele the 7th to 9th harmonic is more than enough, so the frequency will never be too high.
May name some component names capable to work near the 1 GHz frontier steepness.
First comparator ad96687, second (bunch) of comparators adcmp553b, ultrafast logic gate 74as02d, TT trigger sn74lvc2g74, optron iso721m, drivers after optron isl55111.
4) At relatively low frequency of some 100 kHz or less, the job may be done even with more simple solutions. As an example three ne555 in pwm circuit, somehow synchronized through the phase shift (delay). Or (pardon for too much simplification) - bunch of IR2153, what are much more easy to synchronize.
5) So, the digital way, even up to using the ARM processor is absolutely the lightest way to realize the goal (if You are capable to write the appropriate source-code). Because You program all those components and only what is needed is how to implement the 1/3-1/5-1/7 of voltage. Most simple is to use a half-opened transistor, but it is bound to giant heat-fluxes if power is not small. Therefore, three separate voltage sources (probably smps) is the best option, each with own power transistor in output bridge.
And last (6) way of acting is to buy the small 50W three phase Chineese converter and add over it the heavy booster cascade.