# Current PI Control

Bakez
I have a single phase DC-AC inverter (or H-Bridge) with an inductive load

I want to design a controller that controls the PWM signals to the control side switches that will ensure there is a sinusoidal current through the load. I need to use PI control and implement into a DSP so it has to be a discrete (z-domain).

I am really struggling with this. I have an understanding of how a h-bridge works but little control knowledge. I know the transfer function of the inductive load is:$\frac{1}{sL + R}$. and I know I will have a reference current (which I want to the output through the load) and a measured current that I will feedback into the start to calculate the error.

If anyone has any tips or tutorials in this I would greatly appreciate the help

## Answers and Replies

Antiphon
The PI control has nothing to do with how to control the H-bridge.

You need to understand switching buck converters and that's not very simple to explain using the H-bridge.

Bakez
I know how I am supposed to control the sinusoidal current through the load. I leave the DUT switch duty cycles in open loop and I have to control the PWM to the control switches in order to regulate the difference between the two legs.

What I don't understand is how to make the PI controller that can control the PWM. I can google 'current mode control inverter' and see PI controllers for similar so I know this is common

DragonPetter
The PI control has nothing to do with how to control the H-bridge.

You need to understand switching buck converters and that's not very simple to explain using the H-bridge.

There is a good book explaining volt-seconds balance and how to derive transfer functions for switched inductive circuits called Fundamentals of Power Electronics by Erickson/maksimovic

His website has a lot of the book in pdf slides.

The transfer function is not just the inductor, but also the H-bridge switching. Is this for a motor?

Bakez
No its just an inductive load, I'm using it to simulate one leg of a full 3 phase inverter so I can test the efficiency of the MOSFETs

I think I have done the transfer function and the controller. The transfer function was the load and the gain of the bridge (Vdc) and an exponential term for the delay as it is implemented discretely.

It works for below 10Hz but not for 50Hz which is what I want. I think I have to do something with the phase displacement (see attached bode plot), as I think that the error being calculated is wrong if there is 20degrees phase difference between reference current and the output, any ideas?

#### Attachments

• untitled.jpg
9.9 KB · Views: 525
Hello Bakez -

There are H bridge controllers on a chip - but I think they are all for a "direct" inverter, in this case Fout = Fsw. Typical for DC-DC converter. For motor control - esp 3 Phase, I have not found any "Controller IC" to do this. They are ether DSP or FPGA and the - TI has a wealth of info on this - and they have a library of software to help (try this : http://www.ti.com/tool/TMDS1MTRPFCKIT ).

Starting with an "H" bridge model and converting to 3 phase is not simple - you are ether running 3 x the H bridge ( 12 PWM Signals ) I have only seen this is special application - or the 6 Switch 3 Phase inverter - where - Say Phase A TOP is at the top of the sine in current - Phases B AND C Bottom switches are each carrying 1/2 of the current of Phase A - so the relationships between each switch are much more complicated.

Last edited:
SunnyBoyNY
There are a few things you need to implement current control:

a) current sensor in line with inductance
b) gate driver for each switch
c) pwm generator and mcu to perform calculations

There are three basic modulation methods of driving an H-bridge: unipolar modulation scheme, bipolar modulation scheme and the other is called phase-shifting modulation scheme.

In the first method just one side of the bridge is PWM modulated. The other side is either tied high or low to enable bidirectional current flow. This method applies half the rms voltage across the inductor as opposed to bipolar modulation (inductor voltage is either +Vdc or 0 provided the second leg is tied to ground)

Bipolar modulation method makes the two legs complement each other. If the left leg has duty ratio D, the right leg will have duty ratio D'.

Yet another method is to phase-shift the two legs. Each leg has fixed duty ratio of 50%. Inductor voltage is caused by a phase shift between the two legs.

Gain calculations of the current pi controller is quite simple.

Choose your crossover frequency, which should be 1/10 or less of the switching frequency. Since you have an inductive element (energy storage) and your PI controller also stores energy, you have a second-order system. Make sure that your phase margin is at least 45 degrees, 75 degrees is even safer. This will give you good damping.

PWM pulses and calculations can be done in a cheap MCU such as PIC16F1937 -- you can check out this devkit - http://www.digikey.com/product-detail/en/DV164132/DV164132-ND/2332783

Source: power electronics & controls engineer

Bakez
I think I have simulated my controller with ideal switches and an inductive load in LTSpice. I have 500V DCLink voltage, 50Hz 15A RMS through the inductive load and the switching frequency is 2.5kHz.

Now I have to make an inductor close to the value I used in LTSpice (3.55mH, 2.9mOhms) and then tweak my controller to the exact value that I have made (I also don't know how to make an inductor)

SunnyBoyNY
I think I have simulated my controller with ideal switches and an inductive load in LTSpice. I have 500V DCLink voltage, 50Hz 15A RMS through the inductive load and the switching frequency is 2.5kHz.

Now I have to make an inductor close to the value I used in LTSpice (3.55mH, 2.9mOhms) and then tweak my controller to the exact value that I have made (I also don't know how to make an inductor)

A quick and dirty way of designing magnetic components is to use an application provided by core manufacturers such as (http://www.mag-inc.com/design/software/inductor-design) .

To properly design a power inductor you need to know these values:

* Inductance
* Resistance
* Allowed winding losses
* Allowed core losses
* Allowed current ripple

-> Then you need to select a magnetic code, calculate required length of air gap to store energy, calculate winding number of turns, determine wire size and winding DC resistance, estimate winding loss, and select a different core and repeat if design objectives are not met.

Core losses are dependent on current ripple (which changes the B field magnitude in a core), which is dependent on switching frequency, voltage applied across the inductor, and duty ratio.

Not a completely trivial task.

Once you have everything ready, I suggest you start at 20V dc link at most. Never start at full voltage. Never.

Bakez
Hmm yes I have been trying to use that calculator, I was recommended it.

But it keeps saying that there is no core large enough for my application.

I need to design an inductor so that I have the exact values to simulate in my controller

I will be putting AC current through my inductor, 15A RMS at 50Hz (2.5kHz - 10kHz switching frequencies). Maybe this is why the calculator won't work as its for DC?

Basically I need to design an inductor that I am able to draw a 15A AC current through and small enough to fit on my test circuit. The inductance has to be large enough however to enable the controller to draw a smooth curve. In my controller simulation I used a 3.55mH inductor. I don't know whether this is realistic. I don't have a set required inductance that I need - I just need to make one in that range so I can tune my controller properly now.

Speaking to people today made it sound like it was a trivial task where I just got a core, used an online calculator to calculate how many turns and wire thickness and then measured it to make sure it was correct. It doesn't seem so trivial now.

Is 3.55mH for 15A RMS, with a diameter between 5-15cm realistic?

SunnyBoyNY
But it keeps saying that there is no core large enough for my application.

Inductor size is commanded by current requirements. The more current, the large wire gauge you need. Inductance is proportional to the number of turns squared. Thus, such large core might not exist.

I need to design an inductor so that I have the exact values to simulate in my controller

you can always retune your controller and compensate for lower inductance with higher compensator gains. You should be fine with 200 uH at these voltages/currents.

I will be putting AC current through my inductor, 15A RMS at 50Hz (2.5kHz - 10kHz switching frequencies). Maybe this is why the calculator won't work as its for DC?

You do not really care for the inductance at 50 Hz but at the switching frequency. L = N^2 * S / l * mu, where mu is the local derivative of B with respect to H -> incremental inductance.

Basically I need to design an inductor that I am able to draw a 15A AC current through and small enough to fit on my test circuit. The inductance has to be large enough however to enable the controller to draw a smooth curve.

What is your definition of smooth curve?

Is 3.55mH for 15A RMS, with a diameter between 5-15cm realistic?
Don't think so.

Bakez
OK I was beginning to think this. I will have to ask some more people tomorrow.

What I mean by a smooth curve is this what I have attached. Two pics of the current through the load inductor, both at 2.5kHz switching frequency and the controller has a reference current of 50Hz 15A RMS (green curve is the current). One is with a 3.5mH inductor and the other with a 200u, the 200u one is the unacceptable waveform and it gives a RMS current of more like 50A (I have absolutely no idea why this is happening, apart from that I am very tired right now)... Yet in MATLAB the controller will give the same step response for both...

Originally I was sure it was because there was such a difference between the voltage and current that a large inductor was required, otherwise a slight change/error in the duty cycle for whatever reason induces a huge current swing. So I put the inductance up to 3.5mH.. also I put an arbitary resistance in at 2.9mOhms

What would be a realistic inductance and resistance to design my controller around then for this type of current (bearing in mind the physical size I need to put on the test board)?

#### Attachments

• 3mH.jpg
29.6 KB · Views: 577
• 200u.jpg
20.8 KB · Views: 534
Last edited:
SunnyBoyNY
Okay, let's go back to the linear system theory:

Non-ideal inductor duty ratio to current transfer can be easily found out using basic Kirchoffs:

By averaging:

$v_{dc}.d = v_{l} + v_{r}$

Linearize:

$v_{l} = V_{l} + \tilde{v_{l}} \\ v_{r} = V_{r} + \tilde{v_{r}} \\ v_{dc} = V_{dc} + \tilde{v_{dc}} \\ d_{} = D_{} + \tilde{d_{}}$

Let's plug linearized relations into the averaged equation.

$V_{dc}.\tilde{d} + D.\tilde{v_{dc}} + D.V_{dc} + \tilde{d_{}}.\tilde{v_{dc}} = V_{l} + \tilde{v_{l}} + V_{r} + \tilde{v_{r}}$

$D.V_{dc} = V_{l} + V_{r}$

Where the first term on the right side is zero, which corresponds to the theory (inductor is short at DC)

Perturbation part:

$\tilde{v_{l}} = s . L . \tilde{i_l} \\ v_{r} = R_{l} . \tilde{i_l} \\ \frac{\tilde{i_l}}{\tilde{d}} = \frac{V_{dc}}{s.L+R_{l}}$

Hence you need to compensate this transfer function.

With switching frequency of 2.5 kHz I would suggest to choose 200 Hz crossover frequency. Current command performance might not be acceptable in which case you could switch to control is rotating frame (DQ current command). But that is quite involved.

With regards to inductance selection, 500 Vdc and 2.5 kHz will indeed require large inductance to keep the current ripple to 20% or so -> 15Arms = 21Apk -> 2.1Apk ripple current is allowed.

I would suggest increasing the switching frequency to about 15 kHz and using larger inductance as you say. You can always put more inductors in series to increase the inductance. Such slow switching speed is common for large systems which push hundreds of amperes so that a 50A ripple current is acceptable.

A while ago I did a similar project - Vdc = 400V, Iout = 3A, fsw = 50 kHz, L = 4.7mH * 2 (Pi filter). Also, don't forget that you should have a PI filter at the output to filter out harmonic components. Current can be measured at either point.

Bakez
Thank you for your help.

This circuit is actually being built to test the efficiency of SiC MOSFETS. The test setup is supposed to emulate one leg of a 3-phase converter in a wind turbine application. The inductor is just being used as the load so I can draw the correct current from the test MOSFETs, then I will try to measure efficiency and switching loss etc.

I think one reason I am struggling is the ratio of R to L that is ruining my waveform, as I think I'm correct in saying that in a resistive load the current will drop as soon as the voltage is taken away, whereas an inductor will take time to discharge. Indeed when I increase the resistance to 1ohm even with the 3.55mH inductor the waveform takes a big hit - I can see the waveform dropping fast between each pulse. This then means that the error and then the new duty cycle calculated in my discrete controller is no longer relevant as the current has dropped so much - I need the inductive load to be able to hold the current level steady between pulses while the duty cycle is then updated.

I tried to make the controller better this morning by adding in a derivative component, and in MATLAB the step response is a lot faster, but now I don't think that actually matters as the same problem will still be there unless I either increase the switching frequency massively or get an inductor that is able to hold the current better and I'm now not sure whether it is realistic to build one with the type of values I need.

These MOSFETs are rated at 32A and 1200V so I can't really increase the current. I could parallel some together, and I could put inductors in series, but then it is difficult to turn all these on at the same time - the rise and fall times are under 100ns.

And then if I have inductors in series on my test circuit won't that induce just more losses/leakage/delay? One of the challenges of this project will be to measure the switching losses as just 1ns delay in my measurement devices could skew the results. Increasing the switching frequency is an option, however maybe this will infringe on the objective of the project as increasing the switching frequency to 40kHz is obviously going to reduce the efficiency. Originally I wanted to sweep from 2.5kHz up to say 10 or 15k.

SunnyBoyNY
I think one reason I am struggling is the ratio of R to L that is ruining my waveform, as I think I'm correct in saying that in a resistive load the current will drop as soon as the voltage is taken away, whereas an inductor will take time to discharge.

True. You are looking for continuous current through the power devices. Inductive load achieves that just fine.

Indeed when I increase the resistance to 1ohm even with the 3.55mH inductor the waveform takes a big hit - I can see the waveform dropping fast between each pulse. This then means that the error and then the new duty cycle calculated in my discrete controller is no longer relevant as the current has dropped so much - I need the inductive load to be able to hold the current level steady between pulses while the duty cycle is then updated.

Series resistance is actually an impediment to current regulation as it limits the voltage available to change current across the inductor. It also limits the DC gain of the system as the resistor acts as a pole. That should not be a problem here.

I tried to make the controller better this morning by adding in a derivative component, and in MATLAB the step response is a lot faster, but now I don't think that actually matters as the same problem will still be there unless I either increase the switching frequency massively or get an inductor that is able to hold the current better and I'm now not sure whether it is realistic to build one with the type of values I need.

We do not usually use derivative components in control of power electronics as all measurements contain some sort of noise upon which the controller acts. As you can imagine, derivative of high frequency noise is a large number that will even dwarf the proper control signal.

And then if I have inductors in series on my test circuit won't that induce just more losses/leakage/delay? One of the challenges of this project will be to measure the switching losses as just 1ns delay in my measurement devices could skew the results. Increasing the switching frequency is an option, however maybe this will infringe on the objective of the project as increasing the switching frequency to 40kHz is obviously going to reduce the efficiency. Originally I wanted to sweep from 2.5kHz up to say 10 or 15k.

losses/leakage/delay -- losses where? In inductor? Yes, you will have more series resistance but you don't really care for that. Leakage? Leakage inductance is a parasitic element of transformers but a primary effect of inductors. Delay - this is exactly what you want to achieve. You need a continuous current through the power devices.

Bakez
OK thanks for your help. I have managed to get the inductance down to about 2mH @ 2.5kHz with an acceptable waveform. Any lower and the output current goes much higher than the reference, even though when simulating in MATLAB with just the transfer functions, the step response is still fine (I am simulating the entire circuit in LTSpice) - any ideas why this is?

I think I will have to put 2 or 3 inductors in series.

I will update the thread as I make progress

Bakez
Actually there is no problem realising this inductor. I have one for 20A DC and 6.5mH - it weighs about 10kg. I don't need it to fit on my board.

Actually it is great as I can increase my DC voltage from 500V to perhaps 750V or more and the controller will still work fine - the MOSFETS are rated at 1200V

Now I am trying to build the test setup and trying to work out things like sizing of the DC-Link capacitors etc

geokim
current controller

I have the same dc/ac single phase inverter with RL fiter and grid tie.
I have calibrated a simple PI current control that handles the power factor of the output and controls the Amplitude of the output current.
Has anyone done this for a three phase grid tie inverter?I want to have power factor as best as possible on the output with a simple PI current controller,I want just the Kp and Ki gains if anyone has them.