# DC microgrid analysis using state-space representation

This will be a lengthy one so bear with me. I am aiming to describe the following system using differential equations, and then translate that to state-space so that I can design a control scheme that obeys certain specifications mentioned in this question.

The system represents a possible(although simplified) DC microgrid installed in a home. It features an AC source from a standard AC outlet, and a battery used for storage. All the resistors, capacitors and inductors are either parts contained in the converters or are parasitic line impedances. The aim of the system is keep the DC bus voltages at a fixed, predetermined level( $V_2, V_3, V_4$). DC loads such as laptops, mobile phones etc. can be hooked up at the point $V_3$. Ideally, during nighttime there are no loads and the electricity from the AC grid is cheaper than during daytime, so the aim is to store that cheap energy into the batteries during the night. During the day all energy is to be drawn from the battery. However if there is a larger demand for energy(the bus voltages begin to drop) we can use both the battery and the ac in parallel to provide the needed energy. The AC-DC converter is a simple rectifier, and the DC-DC converter at node $V_1$ is a simple buck converter. The dc-dc converter at the battery end is a two way dc-dc converter as shown in the following schematic:

You can see that the inductor $L_4$ and the capacitor $C_3$ are actually parts of the converter but were included in the above microgrid scheme. This was, however possible only if certain transistors in the dc dc converter were constantly on or off, and one of them was used as a switching device(and thus the two way dc-dc behaved as a buck, but more on this later). The inductor $L_1$ and the capacitor $C_1$ are also elements of the buck converter on the left part of the schematic. $R_1$ and $R_2$ were set to zero for the sake of simplicity. This way, I can model the dynamics of the whole system(including the converters).

$\textbf{STATE-SPACE}$

The state variables are as follows: $V_2,V_3,V_4, I_{12},I_{23},I_{34},I_{45}$. $V_1$ and $V_5$ are to be considered as inputs to the system. The differential equations describing the system are as follows:

$C_1 \frac{dV_2}{dt}=I_{12}-I_{23}$

$C_2 \frac{dV_3}{dt}=I_{23}-I_{34}-I_{LOAD}$

$C_3 \frac{dV_4}{dt}=I_{34}-I_{45}$

$V_1-V_2=I_{12}R_1+L_1\frac{dI_{12}}{dt}$

$V_2-V_3=I_{23}R_2+L_2\frac{dI_{23}}{dt}$

$V_3-V_4=I_{34}R_3+L_3\frac{dI_{34}}{dt}$

$V_4-V_5=I_{45}R_4+L_4\frac{dI_{45}}{dt}$

We can write the previous set of equations using matrices:

Since the dc-dc converters feature some sort of switching devices, they both make this system highly nonlinear. Using some sort of state space averaging we get that the mean value of $V_1$ is $D_1 V_{in}$, where $D_1$ is the duty-cycle of the first converter. We can see that from the following schematic:

Supposing that the converter on the right side operates as a buck converter(Q1 constantly ON, Q2 always off, Q4 always OFF, and Q3 is used as a switching device) we get that the mean value of $V_5$ is $D_5 V_{batt}$. We can see that from the following schematic:

We can use the previously mentioned mean values of V1 and V5 if we want to apply state space averaging and use those mean values as inputs in the input matrix in the state space equation. The load current $I_{load}$ is also to be considered as one of the systems inputs. Now what we have done is approximate the nonlinear circuit with a linear one. However I run into problems here when the right hand dc-dc converter operates as a buck converter but this time the voltage of V4 has risen and we are charging the battery (energy flow from left to right). The system has now a completely different topology(Q1-control transistor, Q2 always OFF, Q3 constantly ON, Q4 off). We can see the aforementioned structure in better detail in the schematic below:

Here we have two nonlinear devices, the diode and the transistor between the capacitor and the inductor. What should I do to describe the dynamics of this system? Also, I run into similar problem when the two way dc-dc converter operates as a Boost converter. Any suggestions, literature will be welcome.

• I learned power electronics with the R.W. Erikson book. Chapter 7 may help: ecee.colorado.edu/~ecen5797/notes.html Aug 15, 2017 at 17:40
• Major companies do such things. It's quite resource- wasting work.
– user76844
Aug 18, 2017 at 9:41
• As a side note, have you seen this work: pes.ee.ethz.ch/uploads/tx_ethpublications/… Aug 23, 2017 at 19:00
• Have you considered sweeping the system using a simulation tool such as PLECs in order to obtain the required transfer function? Aug 23, 2017 at 19:02

Ideally, during nighttime there are no loads and the electricity from the AC grid is cheaper than during daytime, so the aim is to store that cheap energy into the batteries during the night.

A battery will cost $300-$1000 per stored kWh. If it can do 3000 cycles, then one stored kWh costs $0.1-$0.3 in battery amortization costs. Thus your scheme is profitable only if the difference between day/night kWh prices from the grid is more than this, which is unlikely, or if the grid is unreliable or intermittent.

Now, back to modeling:

You are modeling your two DC-DC converters as voltage sources. Since their outputs are connected together by a low resistance (ie, wire) any difference in output voltage will result in large currents.

The correct way is to use a current-mode approach.

Both DC-DC converters are now current sources. They will adjust their duty cycle to keep average inductor current constant. In reality, inductor current is a sawtooth with ripple centered on its average, but the result is the same. There are many ways to implement this, for example check LED drivers.

So, you split the problem into several smaller problems. First, design a DC-DC converter which takes a "desired current" as input variable, and regulates its duty cycle to deliver this current independent of voltage variations. Let's call CM the current source on the left (mains-powered) and CB the one connected to batteries. CB's current can be positive or negative since it can both charge and discharge the batteries.

Now you have current sources, so you can parallel them (not so with voltage sources).

Then you implement a control loop, which inputs the load voltage at point V3 on your schematic, and decides the total current I that must be delivered by CM and CB together. This synthetizes an impedance.

Then an algorithm will need to decide how to split this current between CM and CB depending on grid kWh price, battery state of charge, user settings, etc.

FYI I did a similar thing for a bicycle dynamo light: the incoming power source is intermittent. It charges a capacitor. This is then used to power the LEDs. A microcontroller looks at the capacitor voltage, and controls a bidirectional buck-boost current source/sink which charges/discharges a LiIon battery from/to the capacitor. It also adjusts LED current depending on available power.

Differences are that in my case, high ripple on the capacitor is desirable, since it allows to store energy from the generator. In your case ripple is undesirable, so the algorithm would be different.

I chose the battery voltage to be always below the main capacitor rail voltage, so I did not need a 4-switch buckboost, just a standard halfbridge. Current regulation is done by hysteretic control, so frequency varies, but it is dead simple.

The key is to have a current regulation loop which is fast (say your DC-DC runs at 200-500 kHz, then the current loop will react in less than 10 µs), and a capacitor that is large enough (nothing huge though) that the outer control loop does not need to account for the phase shift of the inner current control loop.

None of this needs complicated state space analysis...

This is pretty known engineering problem. It is called a "Hybrid systems" problem, or "switched systems"

The control systems in general are either continuous or discrete. However, when you have an interaction between a continuous and discrete dynamics it is called Hybrid dynamic. In other words, you can say that you have a hybrid system or switched system when the system works in continuous dynamic and you have a discrete transition to another continuous dynamic as shown in fig. .