Filtering for a Inverter PWM Driver

Hi,

I am referring to two app. notes from Microchip -

  1. PICREF-1 2. AN1279

These app.notes deal with making a Un-interruptible Power Supply.

I see that both these app. notes use a (digital) filter (in the control software) to drive the PWM. The PWM is used to generate the sine wave output from the inverter. Here's the flow:

  1. Sample output voltage. 2. Compare with sine PWM reference table. 3. Calculate the error. 4. *Filter the error*. 5. Use the filter output as the PWM pulse width.

I am not able to make out the exact sampling rate used for filter in step 4. But the two possible sampling rates are 32*50 Hz and 64*50 Hz (50 Hz being the desired output frequency). When I do the discrete to continuous conversion (using a "d2c" in Matlab), these two possibilities lead to a gain crossover frequency of 50 Hz or 100 Hz. (Obviously.) (By the gain crossover frequency, I mean the frequency at which the gain of the filter falls to 0 dB.)

My question is, what seems more appropriate? - Does one write a filter for a sine-PWM output with a gain crossover frequency for the desired frequency (50 Hz) or for twice the desired frequency (100 Hz).

Thanks, Anand

Here's the code:

numd=[0.09261 0.09261]; %coefficients from PICREF-1. dend=[1 -1]; ff=50; fs=ff*32; %or 64 Ts=1/fs; sysd=tf(numd,dend,Ts); sysc=d2c(sysd)

and it's result:

Transfer function: 0.09261 s + 296.4 ----------------- s

> 296.4/(2*3.142)

ans =

47.1674
Reply to
Anand P. Paralkar
Loading thread data ...

Without actually looking at the app notes in question (so these comments may be howlingly inappropriate), there's really two different goals you may be wanting to pursue:

One: you're trying to control the harmonics of the output to get a nice clean sine wave. In this case, you'd want a total loop gain with a crossover frequency well above the line frequency (and 2x is not well above).

Two: you're trusting to circuit design (or luck) to control the harmonics, and you're just interested in controlling the RMS voltage out. In this case raising the loop-closure frequency is nice, but not super necessary.

Without knowing the gains in the rest of the system I couldn't say for sure, but the fact that the sampling rate is well above the line frequency points to the possibility that they're trying to control harmonics (even though 64x the line frequency is only going to let them control up to the 6th harmonic with any real reliability).

If you really want to analyze the loop behavior you need to do three things:

1: come up with a difference equation that describes the behavior of the circuit from the PWM command back to the ADC. 2: make a z-domain model of it

3: ditch the discrete-to-continuous approximation, and just do your control design in the z domain. It ain't hard: Bode, Nyquist, Evans root locus and factoring polynomials for stability all work as well in the z domain as in Laplace.

3a: The controller in question started life as a simple analog integrator. Some applications engineer opened a book on digital control systems design to the middle, found the Tustin approximation, and applied it without knowing why, and got H(z) = 0.0463 * (0.5 * (z + 1)/(z - 1)). It doesn't even make sense to do a discrete-to-continuous time conversion of that, as the zero "frequency" maps to infinity.

3b: There's some small possibility that H(z) above is the result of subtle genius and not naive design. I very much doubt it. I once helped hire a guy who had been a Microchip applications engineer, writing app notes for digital control. He had the most superficial knowledge about digital control systems, and had, in fact, recommended an integrator algorithm that is used when you've got a known function you want to integrate, but only adds tons of complexity and delay in a real system. And I'm not knocking the guy: he was an excellent software engineer who I'd hire in a minute for nearly any embedded programming job, but he had no background in digital control.

If Microchip has continued on the path of using good software guys who are out of their depth in digital control, then the H(z) you have would be the exact result of translating an analog circuit into a digital design.

Reply to
Tim Wescott

Hi Tim,

Thanks for looking into this. I was hoping to get your response.

When controlling harmonics, did you mean to say we need the crossover well *below* the 2X frequency? If I understand correctly, we want to exclude, not include the harmonics. (I see that the loop response is that of a low pass filter.)

I forgot to mention, the PWM output is applied to an LC filter so as to change the rectangular waveform to a sine waveform, before the output is given to the load.

I agree that if the intention was to eliminate the harmonics, then I really don't know how setting the crossover frequency to 2X is going to help. (I posted this question because I couldn't figure out where else this filter is helping.)

Do you think this has something to do with stability? Say applying or removing loads? Transient loads? From no load to full load (or vice-versa)?

I really wish someone who has designed a sine-PWM based inverter can throw some light onto this.

Wish you a great day.

Thanks, Anand

Reply to
Anand P. Paralkar

If you want to forcibly generate a clean sine wave, you'll have a sinusoidal look-up table in software, to which you servo the output voltage with a loop with a bandwidth much higher than the line frequency.

Check the values. An LC filter big enough to turn a 50Hz square wave into a 50Hz sine wave is going to be humongous. Are you sure it's not just there to filter out the PWM frequency?

Yes, using feedback here is for the purpose of stabilizing the supply against load changes. Using feedback should make the output much more stable.

Yup. I know theory, but I don't know what all has been done in practice. There's a world of possibilities; by this time maybe most have been tried.

Reply to
Tim Wescott

-snip-

Three: It may want to sync to mains voltage before switching back when mains power resumes

-snip-

Reply to
Andre

Tim,

The LC filter at the inverter output is to filter out anything having a frequency higher than a 50 Hz sine wave. (The output from the voltage inverter is not a 50 Hz square wave, its a sine wave in a PWM format and the PWM has a relatively high switching frequency. So then, the LC filter is not all that large. Yeah, 50 Hz square wave would have been crazy big!)

Indeed, the software has a sine look-up table. Could you please elaborate on "to which you servo the output voltage with a loop with a bandwidth much higher than the line frequency"? I really trying to understand what determines (or what should determine) the loop bandwidth.

Thanks once again, Anand

Reply to
Anand P. Paralkar

Is it to filter out anything higher than 50Hz, or is it to filter out the ripple from the PWM?

In a classic class-D amplifier (which is one way to make a sine wave inverter), the output filter is there to filter out the PWM, and not much else.

Well, it's pretty much what I said. You want to generate a nice clean sine wave, so you design a feedback amplifier (that happens to have a stage with a PWM and an LC filter) and you drive it from a nice clean sine wave command.

In order for the output to be that nice clean sine wave in the face of nonlinear loads, your bandwidth has to be such that the amplifier has low output impedance at frequencies well above the sine wave frequency. In order to get that low impedance, you need a high bandwidth.

What _physically_ determines the loop bandwidth is the component parts: the PWM generator, the H-bridge (or half H-bridge) itself, the LC filter, the ADC, and the control algorithm.

What the loop bandwidth _ought_ to be has innumerable inputs: that decision is part and parcel of the whole systems design, and is impacted by circuit choices in the switching amplifier, the processor capabilities, and (not least) regulatory requirements and the desired performance of the inverter under load.

Reply to
Tim Wescott

You will normally also want to filter out the harmonics of the fundamental PWM frequency. The output will have harmonics and will cause EMI. Running into an inductance or leakage inductance of a transformer, which is common, will cause the waveform current to be a triangle wave. Can't get rid of the harmonics but can certainly help them.

boB

Reply to
boB_K7IQ

Hi Tim,

Thanks for looking into this. I was hoping to get your response.

When controlling harmonics, did you mean to say we need the crossover well *below* the 2X frequency? If I understand correctly, we want to exclude, not include the harmonics. (I see that the loop response is that of a low pass filter.)

I forgot to mention, the PWM output is applied to an LC filter so as to change the rectangular waveform to a sine waveform, before the output is given to the load.

I agree that if the intention was to eliminate the harmonics, then I really don't know how setting the crossover frequency to 2X is going to help. (I posted this question because I couldn't figure out where else this filter is helping.)

Do you think this has something to do with stability? Say applying or removing loads? Transient loads? From no load to full load (or vice-versa)?

I really wish someone who has designed a sine-PWM based inverter can throw some light onto this.

Wish you a great day.

Thanks, Anand

Reply to
Anand P. Paralkar

I wish you had left the context in -- the original exchange had dropped out of my newsreader; I had to go to dsprelated.com to look up the thread.

I meant to say that the loop crossover frequency should be ABOVE any harmonics you want to control. A switching output stage isn't a very high-fidelity amplifier, so if you're going to clean it up you need to do so with feedback. If you don't have significant feedback at a frequency, your cleanup won't work.

But there's a deeper problem here that I only just now noticed. You stated in your original post:

This is incorrect. When you're talking control loops, the gain crossover frequency is the _loop_ gain crossover frequency, which is the gain of the entire loop -- filters, actuators (in this case the switching stage), load and all.

In general, to get good performance in this sort of circuit, you need to make a very clean prototype of your desired sine wave, then you need to design your control loop for the highest possible bandwidth consistent with good stability in all foreseeable circumstances. Bandwidth is roughly equivalent to loop closure frequency, loop closure frequency is a synonym for loop gain crossover frequency, so you want to push that up as high as you can.

Reply to
Tim Wescott

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.