Practical Analysis and Design of a Battery Management System for a Grid-Connected DC Microgrid for the Reduction of the Tariff Cost and Battery Life Maximization

This study is focused on two areas: the design of a Battery Energy Storage System (BESS) for a grid-connected DC Microgrid and the power management of that microgrid. The power management is performed by a Microgrid Central Controller (MGCC). A Microgrid operator provides daily information to the MGCC about the photovoltaic generation profile, the load demand profile, and the real-time prices of the electricity in order to plan the power interchange between the BESS and the main grid, establishing the desired state of charge (SOC) of the batteries at any time. The main goals of the power management strategy under study are to minimize the cost of the electricity that is imported from the grid and to maximize battery life by means of an adequate charging procedure, which sets the charging rate as a function of the MG state. Experimental and simulation results in many realistic scenarios demonstrate that the proposed methodology achieves a proper power management of the DC microgrid.


Introduction
Nowadays, the increasing demand for electricity has encouraged the production of local energy by means of the integration of Microgrids (MGs) into the main grid [1]. The MGs are low power distribution systems which have distributed generation (DG), energy storage systems (ESSs) and a variety of loads. The DG is mainly composed by Renewable Energy Sources (RESs) such as PV systems, wind turbines, biomass, etc., whose intermittent nature produces strong power imbalances in the MG that can be compensated by the main grid or by the ESSs operating in the MG. A MG example is shown in Figure 1a, where the term PCC stands for the Point of Common Coupling with the main grid.
ESSs are a fundamental part of MGs, because they allow for a better utilization of the RESs, contributing to the MGs stability and reliability [1,2]. The DC microgrid under study in this work is depicted in Figure 1b. The Battery Energy Storage System (BESS) is formed of: (i) a battery bank, (ii) a Battery Management System (BMS) [3] and (iii) a DC/DC converter. It is important to point out that batteries are considered among the best energy storage devices, due to their quick technological evolution in smart grids and electric vehicles [4]. The essential characteristics of a battery are: the energy storage capacity, the efficiency, the lifetime (expressed in the number of cycles) and the operation temperature. The kind of batteries that are most commonly used in MGs for energy storage applications are Lead Acid (LA) or Valve regulated lead acid (VRLA) and lithium-ion (Li-ion) batteries [5][6][7][8]. In [6], a study was carried out on the most relevant characteristics in the selection process of the suitable battery technology for different applications. The main characteristics of the most widely used battery technologies in MGs are described in Table 1. LA batteries are widely used in MGs, because their implementation cost is the lowest among all usual technologies. In addition, this kind of batteries provides an acceptable performance and a great robustness. Nevertheless, their main drawback is their relatively short cycle life (1500-9000 charge/discharge cycles). On the contrary, Li-ion batteries have a long cycle life (>10,000 cycles) and their efficiency is approximately 95%, but their implementation cost is high (>USD 350/kW·h) [9] Moreover, the BMS of Li-ion batteries is more complex than that of VRLA batteries, due to the need for inner cell protections against overcharges and cell voltage equalization circuits [7,10,11].
Energies 2018, 11, x FOR PEER REVIEW 2 of 31 storage applications are Lead Acid (LA) or Valve regulated lead acid (VRLA) and lithium-ion (Li-ion) batteries [5][6][7][8]. In [6], a study was carried out on the most relevant characteristics in the selection process of the suitable battery technology for different applications. The main characteristics of the most widely used battery technologies in MGs are described in Table 1. LA batteries are widely used in MGs, because their implementation cost is the lowest among all usual technologies. In addition, this kind of batteries provides an acceptable performance and a great robustness. Nevertheless, their main drawback is their relatively short cycle life (1500-9000 charge/discharge cycles). On the contrary, Li-ion batteries have a long cycle life (>10,000 cycles) and their efficiency is approximately 95%, but their implementation cost is high (>USD 350/kW·h) [9] Moreover, the BMS of Li-ion batteries is more complex than that of VRLA batteries, due to the need for inner cell protections against overcharges and cell voltage equalization circuits [7,10,11].
(a) (b)  Regarding the power management in the MGs, one of the crucial challenges is to keep the power balance between the generation and the demand. The power imbalance is a common scenario in MGs, being caused by the discontinuity in the energy generation or by the changes in the power demand. Nowadays, adequate strategies have been developed to manage the power dispatch in the MGs, which can be: centralized, decentralized or distributed [12][13][14][15][16][17][18][19][20][21].
In the decentralized and distributed control strategies the power management and control are integrated in the local controllers of the DGs and ESSs, so that in the case of malfunction of any device, the MG can properly operate after the disconnection of the faulty unit. According to [1], some decentralized control strategies based on the droop method [20] do not need the implementation of a communications system and provide the plug and play function of DG units. Nevertheless, a communication system is necessary for monitoring the power dispatch in the MG so that the power dispatch can be optimized and the status of each power unit can be known [17]. The main limitation of distributed control strategies takes place in environments with large communication delays and measurement errors, which brings about problems in the convergence speed and stability margins of the controls [1,17,18].
Centralized control eases the optimization of the power distribution in the MG by coordinating the power devices by means of a smart centralized system operating through a communication system. A Microgrid Central Controller (MGCC) acquires system data and sets the power to be  • Battery monitoring: This subsystem includes voltage, current, impedance and temperature measurements. The monitoring allows for calculating the battery parameters: SOC, SOL, DOD and State of Health (SOH), yielding an estimation of the battery model. The SOH represents an estimation of the capacity of the battery to store and deliver energy, compared with a new battery [43]. The SOL is similar to the SOH. However, the SOL is defined in literature as the remaining time until the battery needs to be replaced [11]. It is possible to estimate the SOL, saving the data corresponding to the DOD values and the temperatures at which the batteries have been exposed [44]. The BMS of this paper uses the SOH concept. In order to estimate the SOH of the batteries, some studies [35] consider the following expression: SOH (%) = (Q MAX /Q Rated ) 100%; where Q Rated is the rated capacity and Q MAX is the maximum releasable capacity when the battery is fully charged, which will decline with the used time. • Battery protection: Protection can be implemented in both the hardware and the software. This includes protection and diagnosis in the following situations: high temperature, overcharge, overcurrent and the communication loss with the system. • Battery control: This subsystem is responsible for the battery charging procedure. Its goal is to extend the service time of batteries and to allow for a proper energy management in the system.

•
Communication system: This subsystem informs a central controller about the parameters of the batteries in order to manage the power dispatch of the MG. These communications allow for an interface with the user and the interaction with the power management in the MG.
In this paper, the design of a BESS for a DC microgrid is presented. The BESS is based on a BMS that optimizes the energy storage and implements an adequate charge procedure, which changes the charging rate and plans the SOC of the battery depending on the MG scenarios. The BMS has all the elements summarized in Table 2 [45][46][47][48][49][50][51][52][53][54][55][56][57][58][59]. A battery electrical model is described, which allows for determining all the static and dynamic characteristics of the battery. This model is necessary to design the control loops of the power converter of the BESS taking into account all the involved variables. Overall, the batteries can be approximated to a voltage source in series with RC elements (Resistor-Capacitor), where each one represents a specific dynamics for every charging condition [41,60,61].
Hybrid electric vehicles and Electric vehicles [58] - [59] (1) A (•) indicates that it falls in the category specified in the column heading; a (-) indicates that it does not.

Design of the Battery Energy Storage System
The BESS keeps the power balance at the DC bus of the MG. The BESS is composed by: (i) a battery bank, (ii) a BMS and (iii) a DC/DC converter. In this Section, all the power conversion processes have been modeled. The battery model, the BMS and a description of the converter control are shown in the following Subsections.

Selection of the Battery Bank
The capacity of the battery bank is selected to fulfill the following criteria: (i) batteries can be discharged if the available power on the DC bus is lower than that necessary at the MG or when the electricity tariff is high; (ii) batteries must be charged during off-peak times with the surplus of energy which is available from the RES if there is such a surplus. If not, some power from the main grid will be imported for charging the batteries; (iii) the batteries initial cost must be low. However, there's a trade-off between saving money from the electricity tariff, which requires a big battery bank, and obtaining a low cost of the battery system. In order to make both of the goals compatible, a low cost battery technology has been chosen. Furthermore, a value of the DOD (DOD = 65%) close to the maximum recommended [8,29] one has been aimed in the proposed BMS, in order to get a reasonable size of the battery bank. For this study, the power profile of the photovoltaic generation (P PV Profile ), the power consumed by the loads (P Load DC_Profile ) and the tariff costs according to the time of use (TOU) of electricity are taken as reference. This is shown in Figure 2a.
energy which is available from the RES if there is such a surplus. If not, some power from the main grid will be imported for charging the batteries; (iii) the batteries initial cost must be low. However, there's a trade-off between saving money from the electricity tariff, which requires a big battery bank, and obtaining a low cost of the battery system. In order to make both of the goals compatible, a low cost battery technology has been chosen. Furthermore, a value of the DOD (DOD = 65%) close to the maximum recommended [8,29] one has been aimed in the proposed BMS, in order to get a reasonable size of the battery bank. For this study, the power profile of the photovoltaic generation (P Profile PV ), the power consumed by the loads (P DC_Profile Load ) and the tariff costs according to the time of use (TOU) of electricity are taken as reference. This is shown in Figure 2a. The PV generation decreases from 16:00 h to 19:00 h, as can be seen in Figure 2a. At this time, the power demand is higher than PV generation and the TOU price is on peak. At this point, the batteries should have stored enough energy to fulfill the power demand of the MG. Equations (1) and (2) allow for determining the number of batteries that is needed to accomplish this last objective. In (1) and (2), P Available Bat stands for the available power that the batteries should supply during a time interval Δt, supposing that they have been fully charged to a value SOC > 95% before. The time instant when the battery discharge interval starts is called to. V Selected Battery is the rated voltage of the battery.
In this work, a VRLA battery has been selected, model: SUN POWER VRM 12V105 (HOPPECKE, Brilon, Germany). Its characteristics are shown in Table 3 [62]. As it can be seen in Figure 2a, the average power consumed by the load from 16:00 h to 24:00 h (to = 16 h, Δt = 8 h) is 2.7 kW and this average power should be provided by the batteries. P Available Bat ≅ 2.7 kW during that time interval, Δt. The number of batteries of the battery bank is obtained from Equation (2). It is composed of 18 batteries of 12 V connected in series, with a battery bank rated voltage of V Rated Bat = 216 V. The battery bank is charged/discharged from/to the DC bus of the MG by means of a 3 kW bidirectional half-bridge DC/DC converter, as shown in Figure 2b. The LC output filter of the DC/DC converter has an inductance value, L Bat , which has been calculated taking into consideration: (i) the maximum ripple current allowed by the batteries, and (ii) the ripple current through L Bat , ∆I L Bat , should guarantee the continuous current conduction mode if the current is higher than 10% of the maximum current. The value of L Bat is calculated from Equation (3), where VDC is the DC bus voltage and Fsw is the switching frequency of the converter [49]. The values of the input and output capacitances, Ci and Co, can be calculated from (4) and (5), respectively. The PV generation decreases from 16:00 h to 19:00 h, as can be seen in Figure 2a. At this time, the power demand is higher than PV generation and the TOU price is on peak. At this point, the batteries should have stored enough energy to fulfill the power demand of the MG. Equations (1) and (2) allow for determining the number of batteries that is needed to accomplish this last objective. In (1) and (2), P Bat Available stands for the available power that the batteries should supply during a time interval ∆t, supposing that they have been fully charged to a value SOC > 95% before. The time instant when the battery discharge interval starts is called t o . V Battery Selected is the rated voltage of the battery. In this work, a VRLA battery has been selected, model: SUN POWER VRM 12V105 (HOPPECKE, Brilon, Germany). Its characteristics are shown in Table 3 [62]. As it can be seen in Figure 2a, the average power consumed by the load from 16:00 h to 24:00 h (t o = 16 h, ∆t = 8 h) is 2.7 kW and this average power should be provided by the batteries. P Bat Available ∼ = 2.7 kW during that time interval, ∆t. The number of batteries of the battery bank is obtained from Equation (2). It is composed of 18 batteries of 12 V connected in series, with a battery bank rated voltage of V Bat Rated = 216 V. The battery bank is charged/discharged from/to the DC bus of the MG by means of a 3 kW bidirectional half-bridge DC/DC converter, as shown in Figure 2b. The LC output filter of the DC/DC converter has an inductance value, L Bat , which has been calculated taking into consideration: (i) the maximum ripple current allowed by the batteries, and (ii) the ripple current through L Bat , ∆I Bat L , should guarantee the continuous current conduction mode if the current is higher than 10% of the maximum current. The value of L Bat is calculated from Equation (3), where V DC is the DC bus voltage and F sw is the switching frequency of the converter [49]. The values of the input and output capacitances, Ci and Co, can be calculated from (4) and (5), respectively.

Modeling of Battery Bank
The electric model of the battery bank used in this study is similar to that developed in [61], being shown in Figure 3. It has an open-circuit voltage source depending on the SOC, V Bat OCV (SOC), connected in series with a resistor and a second-order R-C circuit that represents the transient response of battery. The impedance of the battery bank is represented by Equation (6) and the battery voltage by Equation (7).
The electric parameters of the chosen VRLA battery bank are shown by Equations (8) to (13) and have been obtained with an identical procedure to that shown in [60,61]. Those Equations are valid for SOC > 0.1. Taking into account that SOC in this work is kept higher or equal than 0. 35,Equations (8) to (13)

Small-Signal Model of the BESS
The small-signal model of the bidirectional half-bridge DC/DC converter is shown in Figure 4. That model has been derived from an averaged model where any electrical value x has a static term at the operation point, X, and a small-signal dynamic term, , being: = + . When the batteries are being charged with a charge current I L(Ch) Bat , the converter works as a Buck converter, as depicted in Figure 4a. When the batteries are being discharged with a discharge current I L(Dis) Bat , the converter works as a Boost converter, see Figure 4b. The transfer functions in Equations (14) and (15) are obtained from Figure 4. They are used to design the controllers in charge mode (Ch) or discharge mode (Dis) of the battery bank.

Control Loops Design of the BESS
The BESS works from a BMS that sets either the charge of the batteries at constant current (CC) or constant voltage (CV), or the discharge of the batteries at a constant current. The block diagram of the current control loop and of the voltage control loop of the BESS are shown in Figure 5.

Small-Signal Model of the BESS
The small-signal model of the bidirectional half-bridge DC/DC converter is shown in Figure 4. That model has been derived from an averaged model where any electrical value x has a static term at the operation point, X, and a small-signal dynamic term, x, being: x = X + x. When the batteries are being charged with a charge current I Bat L(Ch) , the converter works as a Buck converter, as depicted in Figure 4a. When the batteries are being discharged with a discharge current I Bat L(Dis) , the converter works as a Boost converter, see Figure 4b. The transfer functions in Equations (14) and (15) are obtained from Figure 4. They are used to design the controllers in charge mode (Ch) or discharge mode (Dis) of the battery bank.
i Bat

Small-Signal Model of the BESS
The small-signal model of the bidirectional half-bridge DC/DC converter is shown in Figure 4. That model has been derived from an averaged model where any electrical value x has a static term at the operation point, X, and a small-signal dynamic term, , being: = + . When the batteries are being charged with a charge current I L(Ch) Bat , the converter works as a Buck converter, as depicted in Figure 4a. When the batteries are being discharged with a discharge current I L(Dis) Bat , the converter works as a Boost converter, see Figure 4b. The transfer functions in Equations (14) and (15) are obtained from Figure 4. They are used to design the controllers in charge mode (Ch) or discharge mode (Dis) of the battery bank.

Control Loops Design of the BESS
The BESS works from a BMS that sets either the charge of the batteries at constant current (CC) or constant voltage (CV), or the discharge of the batteries at a constant current. The block diagram of the current control loop and of the voltage control loop of the BESS are shown in Figure 5.   Table 4. The BESS control loops are robust to any change in the battery charge/discharge currents, SOC, battery voltage and changes of the DC bus voltage, because the battery model is practically constant when the SOC is higher than 10%, which is a suitable working range for the batteries.  Figure 6a. The controller was designed in the analog domain, taking into account a digital delay of a sampling period, T d = T samp , and discretized in the Z domain by using the Tustin transformation. The sampling frequency was F samp = 16 kHz = 1/T samp, which agrees with the switching frequency, F Sw . The current regulator, G Bat IL (s), is adjusted to get a crossover frequency of the current loop: F ci = 500 Hz < F Sw /20, with a phase margin around 60 deg. The Bode plots of the voltage loop, T Bat V (s), for different values of the SOC are shown in Figure 6b. The voltage regulator G Bat V (s) has been adjusted to get a crossover frequency of the voltage loop: F cv = 12.6 Hz < F ci /20, with a phase margin around 90 deg. The transfer functions of the regulators are summarized in Table 4. The BESS control loops are robust to any change in the battery charge/discharge currents, SOC, battery voltage and changes of the DC bus voltage, because the battery model is practically constant when the SOC is higher than 10%, which is a suitable working range for the batteries.

Design of the BMS
The BMS is designed to fulfill the following objectives: (i) To broadcast the SOC of the batteries to the MGCC (ii) To coordinate the charging/discharging of the batteries depending on the power management strategies that are established by the MGCC and (iii) To adjust the parameters of the battery charge procedure depending on the MG state. The proposed BMS structure for the DC microgrid is shown in Figure 7.

Design of the BMS
The BMS is designed to fulfill the following objectives: (i) To broadcast the SOC of the batteries to the MGCC (ii) To coordinate the charging/discharging of the batteries depending on the power management strategies that are established by the MGCC and (iii) To adjust the parameters of the battery charge procedure depending on the MG state. The proposed BMS structure for the DC microgrid is shown in Figure 7.
The BMS has the following subsystems:  In addition, the batteries can be charged or discharged depending on the cost of the electricity tariff and on the power availability at the RESs of the MG.   Battery Management Algorithm: The battery management algorithm implemented in the BMS is shown in Figure 8 and it is described in the following. Battery Management Algorithm: The battery management algorithm implemented in the BMS is shown in Figure 8 and it is described in the following. The BMS receives three control parameters from the MGCC through RS485 serial communications. These parameters are: (i) the target SOC (SOCref); (ii) the available/necessary power for discharging/charging the batteries (P ref BESS ) to/from the DC bus; and (iii) the time interval tref, during which the BESS must reach SOCref with the available power at the DC bus. The BMS has three inputs that are produced by sensors: the signals from the battery current sensor, from the battery voltage sensor and from the battery temperature sensor, corresponding to I Bat , V Bat and T Bat , respectively.
The SOC of the batteries can be calculated from Equation (16), where a positive (negative) value of I Bat represents a charging (discharging) current of the battery bank. QRated stands for the rated battery bank capacity in A·h. QDis(Ch), expressed by Equation (17), is the expected dis (charge) capacity  The BMS has three inputs that are produced by sensors: the signals from the battery current sensor, from the battery voltage sensor and from the battery temperature sensor, corresponding to I Bat , V Bat and T Bat , respectively.
The SOC of the batteries can be calculated from Equation (16), where a positive (negative) value of I Bat represents a charging (discharging) current of the battery bank. Q Rated stands for the rated battery bank capacity in A·h. Q Dis(Ch) , expressed by Equation (17), is the expected dis (charge) capacity in A·h, which depends on the dis (charge) rate. η Dis(Ch) is the dis (charge) efficiency [10]. The value of Q Dis(Ch) can be obtained by means of a linear interpolation of the curves of the battery capacity provided by the manufacturer [62].
The battery bank charge power is given by the Equation (18) and the power absorbed by the BESS from the DC bus is represented by (19).
Taking into account that P BESS ref stands for the power setpoint to charge the batteries sent by the MGCC to the BESS, the operating mode of the BESS is set as follows: If P BEES_ref > 0, the BESS will work in charge mode ('Mode = 0'), otherwise, the BESS will operate in discharge mode ('Mode = 1').
Note from Figure 8 that there is a ramp function expressed by Equation (20) If 'Mode = 1' (discharge mode). On the contrary, if 'Mode = 0', the BMS calculates the power required (P Bat Required ) to reach the target SOC in the time interval t ref . P Bat Required is given by Equation (22). The charging procedure DIN41773 is carried out. The batteries are charged at CC until a maximum charging voltage is reached. If P Bat Required < P BESS ref (k) , the batteries will be charged with current I Bat  (25) and (26), respectively. Equation (25) provides V Bat (Ch) for charging the battery at a given current according to the charge procedure that was recommended by the manufacturer [62]. The recommended value of V Bat (Ch) may be lower because of the battery temperature (26). Finally, the value of V Bat (Ch) is given by Equation (27). The minimum and maximum values of the charging current suggested by the manufacturer of the chosen batteries are: I C20 = 5 A and I C5 = 20 A, being C20 and C5 the specified battery capacity (measured in A·h) for a discharge time of 20 h and 5 h, respectively.
Once the current that was absorbed by the batteries is lower than a pre-set tail current (I Bat tail ) or after a certain charging time (t Ch ) has elapsed, the battery voltage is kept at a floating voltage value (V Bat Float ) that is expressed by Equation (28). This Equation is obtained from the polynomial interpolation of the floating voltage curves which were provided by the manufacturer [62]. It can be observed that the value of V Bat Float depends on the battery temperature.
If 'Mode = 1' (discharge mode), the BESS operation switches to discharge mode and the discharge current is calculated from Equation (29).

Centralized Power Management Algorithm of the DC Microgrid Tied to the Main Grid
In this Section a centralized power management algorithm for the grid-connected DC Microgrid is described. The DC microgrid consists of: (a) a MGCC; (b) an interlinking converter (ILC) connected to the main grid which regulates the DC bus voltage; (c) two DC/DC converters operating as controlled current sources interchanging their power with the DC bus; (d) four DC loads with their respective electronic switches; (e) an RS485 serial communication system and (f) the MG operator. Figure 9a depicts the placement of the power converters operating in the DC microgrid.
The MGCC receives the information from the MG operator about of the prices of the electricity, of the photovoltaic generation and of the load demand. The MGCC extracts the minimum possible power from the grid to the MG to reduce the electricity bill. If there is an excess of available power at the PV generation and if the SOC of the batteries is adequate, the surplus power can be injected from the MG to the grid under the limit which was determined by the MG operator. As a last resort, the MGCC depending on the SOC, can implement a load shedding functionality to decrease the power which is absorbed from the grid and avoid the batteries undercharging.

The Power Management Algorithm of the MG
The parameters broadcasted among the power converters, MG operator and the MGCC are shown in Table 5. The MGCC establishes the daily planning of the power dispatch in the MG, depending on the reference profiles sent by the MG operator to the MGCC. The evolution in time during a day of the reference profiles (P PV Profile , P Load DC_Profile , P MAX Grid−to−MG , P MAX MG−to−Grid and TOU) is shown in Figure 9b. P PV Profile is the PV power profile, P Load DC_Profile is the profile of the power consumed by the DC loads. P MAX Grid−to−MG is the maximum power that can be imported from the grid to the MG and P MAX MG−to−Grid is the maximum power that can be exported from the MG to the grid.   (1) Control references sent by the MGCC. (2) PGrid is the power injected from the MG to Grid; Po PV is the PV generated power and P Load DC is the power consumed by the DC loads.
The power management algorithm of the MG is shown in Figure 10 and    The power management algorithm of the MG is shown in Figure 10 and it is executed every 1 s (1 Hz), performing the request of the measurements of P BESS , P DC Load , P o PV , P ILC AC and SOC, and transmitting the references to the MG devices. The MGCC selects one of six possible power management cases during the whole day and calculates the reference values, which are transmitted to all the power converters under operation. The cases depend on the scenarios of the MG and are summarized in  Case 0: At the beginning of each day, case 0 is applied. In the Case 0, the MGCC requests to the MG operator the daily reference profiles, which are stored in a data table. Based on this information the MGCC plans the power dispatch at the MG. The maximum powers extracted/injected from/to the grid to/from the MG are established by Equations (30) and (31), respectively. The maximum powers injected/extracted from/to the DC bus to/from the grid by the ILC are calculated by Equations (32) and (33)   Case 0: At the beginning of each day, case 0 is applied. In the Case 0, the MGCC requests to the MG operator the daily reference profiles, which are stored in a data table. Based on this information the MGCC plans the power dispatch at the MG. The maximum powers extracted/injected from/to the grid to/from the MG are established by Equations (30) and (31), respectively. The maximum powers injected/extracted from/to the DC bus to/from the grid by the ILC are calculated by Equations (32) and (33) As it can be seen in Figure 9b, the BESS works in charge mode during off-peak hours (TOU is off-peak), when kW·h is cheaper and when the PV power profile is enough to energize all the DC loads (P Available DC_Profile > 0). The available power profile (P Available DC_Profile ) at the DC bus is given by Equation (34). Table 6. Summary of the cases applied set by the MGCC.

DC Load Output References Mode
Charging Procedure

Case 0
Case 0 is applied at the beginning of each day. The MGCC performs the daily planning of the power dispatch at the MG.
To perform this, it uses the data of the power profiles and TOU sent from the MG operator.

PV = Off
Charge mode CC-CV based on Equation (46) Load shedding funtionality Case 1 indicates that the power management profile predicted for the day has not been correctly fulfilled. This case is applied when there is not power available at the DC bus, the SOC is less than 90% or when the case 0 has failed. In this case, the MGCC complies with the power limit established by the MG operator, without taking into account the electricity tariff in the power management of the MG. The BESS will operate in charge mode, but won't be able to assure the DIN41773 charge procedure.   When the value of P Available DC_Profile starts to be positive, the initial time is detected (t initial ). The final time (t final ) is detected once that P Available DC_Profile changes from positive to negative. With the time interval (t initial < time < t final ) the value of P Available RES is calculated. P Available RES is the available power from the RES for charging the batteries during the time interval (t initial < time < t final ), expressed by the Equation (35). P BESS ref is calculated from Equation (36) and the desired SOC (SOC ref ) which should be reached at t initial is calculated from Equation (37). When P Available DC_Profile < 0 and the TOU is off-peak, the value of P BESS ref is calculated from Equation (38).
If P Available DC_Profile < 0 and the TOU is on-peak, the BESS must supply power to the DC bus from the batteries. The discharge power of the batteries for the time interval (t ref ) is calculated according to Equation (39). P BESS Dis determines the maximum discharge power to avoid battery discharges leading to values of SOC lower than 35%. If P BESS Dis > |P Available DC_Profile |, the P BESS ref is calculated by Equation (40); otherwise, it is calculated by Equation (41).

h < time < t initial
The MGCC begins to execute the strategic planning of case 0 and verifies its compliance. Thus, the MGCC calculates the power flow in the MG every second. The MGCC establishes the PV power limit (P PV Lim_ref ) by means of Equation (42). Note that in Figure 9a, P DC Load stands for the power consumed by the DC loads. Sw ref is a vector with binary variables {0, 1}, indicating which DC loads are connected {1} or disconnected {0}. P DC Load is calculated by Equation (43). Equation (44) stands for the available power at the DC bus (P Available DC ) without taking into account the power absorbed from the main grid. P Available DC−Total is the total available power at the DC bus and is given by Equation (45). If SOC < SOC MIN , the MGCC activates the fault flag and applies Case 1. Case 1 indicates that the power management profile predicted for the day has not been correctly fulfilled. In this case, if the reference profiles do not fit the power measurements, the MGCC will detect that the power generation predicted for the day is not achieved. In that case, if the SOC of the batteries is lower than 35%, the MGCC will establish that the power limit established by the MG operator is imported from the grid, no matter the value of the electricity tariff. If even in that situation the SOC tends to decrease below 35%, the MGCC will set the load shedding functionality. The BESS will operate in charge mode, but will not be able to assure the DIN41773 charge procedure. The batteries are charged at a power according to Equation (46).
If SOC > SOC MIN and the current time of the day is lower than t initial , the MGCC applies case 2. Case 2 is applied at the hours of the day where there is not PV generation and the TOU is off-peak. The MGCC establishes the target SOC (SOC ref = Equation (37) During this time interval the BESS should supply the necessary power to the DC bus, because the TOU is on-peak and the PV power is not enough to feed all the DC loads. If SOC < 90%, the MGCC activates the fault flag and applies case 1.
Otherwise, if SOC >90%, it means that MGCC can perform the initial planning. If P BESS Dis < |P Available DC |, then case 5 is applied. In case 5 the batteries are discharged with a power P BESS ref given by Equation (40). In the opposite case, if P BESS Dis > |P Available DC |, case 6 is applied, because the necessary power at the DC bus is higher than the maximum available discharge power at the batteries. Case 6 avoids discharging the batteries to a SOC lower than SOC MIN . The batteries are discharged with a maximum power P BESS ref given by Equation (41). Figure 11a and b show a block diagram and a picture of the power converters operating in the experimental DC microgrid, respectively. The power converters specifications are shown in Table 7. First, several microgrid scenarios have been studied by means of the of the PSIM™ simulator [63]. After that, the proposed power management algorithm and the BESS have been tested in an experimental MG and compared with the simulated results. The proposed battery charging procedure shown in Section 3 has been verified by simulation #1 and by experiment #1. This procedure has been executed four times, each time with a different charging current: I Bat (Ch) = 15 A, 12 A, 10 A and 5 A. The power management of the MG described in Section 4 has been validated by simulation #2 and by experiment #2. In experiment #3 the response of the MG to an abrupt change of the power flow between the MG and the main grid is studied. Finally, the communication delays between a measurement request from the MGCC and the response of the BESS are shown in experiment #4.

Simulation #1
The DIN41773 compatible charging procedure has been verified by simulation #1, whose results are shown in Figure 12. It is worth pointing out that, in order to check the charging procedure with several values of the charge current in a short simulation time, the value of QRated was downscaled in simulations #1 and #2 to 2 A·h.  Bat is given by Equation (27). A value of T Bat = 25 °C has been considered.
Finally, once the current absorbed by the batteries is lower than a pre-set tail current value (I tail Bat = 1 A), then the battery voltage is set at a constant floating voltage value (V Float Bat ) that is given by Equation (28).

Simulation #1
The DIN41773 compatible charging procedure has been verified by simulation #1, whose results are shown in Figure 12. It is worth pointing out that, in order to check the charging procedure with several values of the charge current in a short simulation time, the value of Q Rated was downscaled in simulations #1 and #2 to 2 A·h. Table 7. Specifications of the power converters operating in the DC microgrid.

Simulation #2
In order to check the proposed power management algorithm described in Section 4, different scenarios with a short simulation time have been analyzed. In order to avoid too long simulation times, the reference profiles were adjusted in this study to a whole equivalent 'daily' period of 2400 s, where 100 s corresponds to one hour of the day. The value of QRated was downscaled for performing the tests #1 and #2 to 2 A·h. The reference profiles that were used to plan the power dispatch in the MG are shown in Table 8. Figure 13 shows the simulation waveforms of the power flow at the DC bus of the MG in one equivalent day. The scenarios under study are: (i) Different values of the TOU tariffs, (ii) variations of the available PV power and (iii) variations of the power consumed by the loads connected to the DC bus. Those variations can be observed in Figure 13, being labeled as TOU, Po PV and P Load DC , respectively. The evolution of the power flow (P DC Available , P DC ILC , P BESS ), the SOC and the batteries current (I Bat ), can be observed in the lower part of Figure 13. The analysis has been performed according to the following time intervals: Interval 1 (0 < time < 40 s) At t = 0 s, it is assumed that the batteries have been discharged the previous day to SOC = 38%. During the duration of the time interval corresponding to case 0, the power dispatch in the MG is done. Depending on the reference profiles of Table 8, the MGCC detects the time intervals where the batteries will be charged only with the available PV power and when the TOU is off-peak. The time values are: tinitial = 900 s, tfinal = 1520 s.

Simulation #2
In order to check the proposed power management algorithm described in Section 4, different scenarios with a short simulation time have been analyzed. In order to avoid too long simulation times, the reference profiles were adjusted in this study to a whole equivalent 'daily' period of 2400 s, where 100 s corresponds to one hour of the day. The value of Q Rated was downscaled for performing the tests #1 and #2 to 2 A·h. The reference profiles that were used to plan the power dispatch in the MG are shown in Table 8. Figure 13 shows the simulation waveforms of the power flow at the DC bus of the MG in one equivalent day. The scenarios under study are: (i) Different values of the TOU tariffs, (ii) variations of the available PV power and (iii) variations of the power consumed by the loads connected to the DC bus. Those variations can be observed in Figure 13, being labeled as TOU, P o PV and P DC Load , respectively. The evolution of the power flow (P Available DC , P ILC DC , P BESS ), the SOC and the batteries current (I Bat ), can be observed in the lower part of Figure 13.
The analysis has been performed according to the following time intervals: Interval 1 (0 < time < 40 s) At t = 0 s, it is assumed that the batteries have been discharged the previous day to SOC = 38%. During the duration of the time interval corresponding to case 0, the power dispatch in the MG is done. Depending on the reference profiles of Table 8, the MGCC detects the time intervals where the batteries will be charged only with the available PV power and when the TOU is off-peak. The time values are: t initial = 900 s, t final = 1520 s.

Interval 2 (40 s < time < 900 s)
This time interval represents the hours of the night and the early hours of the day when the PV power is not enough to energize all the loads and the TOU is off-peak. The MGCC applies case 2. The MGCC sends to the BESS the target SOC, SOC ref = 68% at t ref = 900 s and the reference of the available power at the DC bus to charge the batteries, P BESS ref = Equation (38). However, the BESS only uses the power needed, P BESS = 0.9 kW, to reach the target SOC, which is lower than the power available at the DC bus, P BESS ref ∼ = 3 kW. In this case, the MGCC orders the transfer of the power needed at the DC bus from the grid through the ILC, with a value below the limit imposed by Equation (33). At t = 700 s the value of the power imported from the grid by the ILC is: P ILC DC = −3 kW. Note that at this time interval P BESS takes a constant value (0.9 kW). The BESS complies with the DIN41773 charging procedure.   (36)). In this case, the MGCC can export the excess power from the DC bus to the grid through the ILC. Note that the batteries have reached a value SOC = 97.2% at t = 1520 s.
Interval 4 (1520 s < time < 2400 s) This time interval represents the hours of the day when the TOU is on-peak and the PV power is not enough to energize all the loads. Taking into account that the BESS is charged (SOC ≥ 80%), the MGCC transfers the needed power from the battery bank to the DC bus through the BESS. This interval is divided into three subintervals.   (41). The MGCC orders to import the minimum possible power from the grid. 2300 s < time < 2400 s: The MGCC applies case 5. In this case, the MGCC sends to the BESS the power reference, P BESS ref = Equation (40). The MGCC orders to import the minimum possible power from the grid.

Experiment #1
A 3 kW bidirectional BESS a 2.5 kW PV system and a single-phase 10 kW ILC, have been built and connected to the experimental DC microgrid. Each power converter has its own TMS320F28335 DSP controller to perform its primary control and its serial RS485 communication system. The power converters specifications are the same as those shown in Table 7 2000 s < time < 2300 s: The MGCC applies case 6. In this case, the needed power at the DC bus is higher than the maximum available discharge power at the batteries. The MGCC sends to the BESS the power reference, P ref BESS = Equation (41). The MGCC orders to import the minimum possible power from the grid. 2300 s < time < 2400 s: The MGCC applies case 5. In this case, the MGCC sends to the BESS the power reference, P ref BESS = Equation (40). The MGCC orders to import the minimum possible power from the grid.

Experiment #1
A 3 kW bidirectional BESS a 2.5 kW PV system and a single-phase 10 kW ILC, have been built and connected to the experimental DC microgrid. Each power converter has its own TMS320F28335 DSP controller to perform its primary control and its serial RS485 communication system. The power converters specifications are the same as those shown in Table 7

Experiment #2
The evolution of the powers (P o PV , P BESS , P DC Load , P ILC DC ), currents (I Bat , I PV ), SOC and voltages (V Bat , V PV ) of the DC micrigrid can be observed in Figure 15. Initially, the MGCC applies case 0 and calculates

Experiment #2
The evolution of the powers (Po PV , P BESS , P Load DC , P DC ILC ), currents (I Bat , I PV ), SOC and voltages (V Bat , V PV ) of the DC micrigrid can be observed in Figure 15. Initially, the MGCC applies case 0 and calculates the time intervals where the batteries will be only charged with the power available at the PV system, being the TOU is off-peak, yielding the values: tinitial = 420 s, tfinal = 1300 s. The analysis is performed according to the following time intervals:   At t = 1300 s the TOU changes from off-peak (0.08 €/kW·s) to on-peak (0.16 €/kW·s). This time interval represents the hours of the day when the TOU is on-peak and the PV power is not enough to energize all the loads. Taking into account that the BESS is charged, SOC ≥ 80% (at t = 1300 s, SOC = 94%), the MGCC transfers the necessary power from the battery bank to the DC bus through the BESS. This interval is divided into two subintervals. 1300 s < time < 1780 s: The MGCC applies case 6. In this case, the MGCC calculates the maximum discharge power of the batteries (P BESS Dis ) to discharge the batteries to a level which is higher than SOC MIN (40), ordering to import the minimum possible power from the grid.

Experiment #3
The ILC regulates the voltage of the DC bus in grid connected mode, and performs the synchronization with the main grid. To verify the stability of the DC bus during heavy transients, an abrupt change from −0.8 kW to 1.9 kW (2.7 kW step at t = 9.3 s) of the power flow from the DC bus to the main grid is forced. The experimental waveforms when the MG changes from exporting to importing power to/from the main grid are shown in Figure 16.
Interval 2 (420 s < time < 1300 s) During this time interval, the PV power is enough to energize all the loads. At t = 420 s the MGCC applies case 3. At t = 1300 s the TOU changes from off-peak (0.08 €/kW·s) to on-peak (0.16 €/kW·s). This time interval represents the hours of the day when the TOU is on-peak and the PV power is not enough to energize all the loads. Taking into account that the BESS is charged, SOC ≥ 80% (at t = 1300 s, SOC = 94%), the MGCC transfers the necessary power from the battery bank to the DC bus through the BESS. This interval is divided into two subintervals. 1300 s < time < 1780 s: The MGCC applies case 6. In this case, the MGCC calculates the maximum discharge power of the batteries (P Dis BESS ) to discharge the batteries to a level which is higher than SOCMIN, being SOCref > 35% at tref = 700 s. The MGCC sends the power reference to the BESS, P ref BESS = Equation (41), and orders to import the needed power from the grid.  (40), ordering to import the minimum possible power from the grid.

Experiment #3
The ILC regulates the voltage of the DC bus in grid connected mode, and performs the synchronization with the main grid. To verify the stability of the DC bus during heavy transients, an abrupt change from −0.8 kW to 1.9 kW (2.7 kW step at t = 9.3 s) of the power flow from the DC bus to the main grid is forced. The experimental waveforms when the MG changes from exporting to importing power to/from the main grid are shown in Figure 16. As it can be seen in ZOOM 1 of Figure 16, the DC bus voltage is stable and a small transient deviation occurs of ∆V DC = 38 V, i.e., less of 10% of the DC bus voltage. A low distortion of I Grid can be observed in the transition from exporting to importing power to/from the AC grid.

Experiment #4
In this work, RS485 serial communications are used with the MODBUS protocol. This protocol allows for the exchange of information between the MGCC and the different devices connected to the MG with an adequate performance in MG. The implemented RS485 communications allow for the calculation of the power values in several points of the MG quickly and accurately. The communications delay of the receiving (RX) and transmitting (TX) signals between the MGCC and the BESS can be observed in Figure 17. The RS485 communication bus baud rate is 9600 bps. The time difference between a MGCC request and the BESS response is 18 ms. The proposed power management algorithm is running every second in the MG under study, so that the communication delays are not critical. As it can be seen in ZOOM 1 of Figure 16, the DC bus voltage is stable and a small transient deviation occurs of ΔVDC = 38 V, i.e., less of 10% of the DC bus voltage. A low distortion of IGrid can be observed in the transition from exporting to importing power to/from the AC grid.

Experiment #4
In this work, RS485 serial communications are used with the MODBUS protocol. This protocol allows for the exchange of information between the MGCC and the different devices connected to the MG with an adequate performance in MG. The implemented RS485 communications allow for the calculation of the power values in several points of the MG quickly and accurately. The communications delay of the receiving (RX) and transmitting (TX) signals between the MGCC and the BESS can be observed in Figure 17. The RS485 communication bus baud rate is 9600 bps. The time difference between a MGCC request and the BESS response is 18 ms. The proposed power management algorithm is running every second in the MG under study, so that the communication delays are not critical.

Conclusions
In this paper it has been shown the design and operation of a BESS for a grid-connected DC Microgrid with PV generation. The bidirectional power converter conforming the BESS has been modeled and verified according to any change of the battery charge/discharge currents, the SOC, the battery voltage and variations of the DC bus voltage. The BESS has a BMS that maximizes the battery life time, being compatible with a DIN41773 battery charging procedure and complying with the manufacturer specifications at the same time. The proposed procedure changes the charging parameters of the batteries depending on the MG states.
A MGCC has been used for the power management of the DC microgrid. The MGCC estimates the available power at the DC bus to charge the batteries and a target SOC in the batteries at different hours of the day. The MGCC daily plans the power dispatch in the MG and complies with two objectives: (i) to import the minimum possible power from the grid, and (ii) to charge the batteries during off-peak times and with the surplus of energy is available from the PV resources. These strategies allow for reducing the electricity bill.
The experimental and simulation results show that the implemented method allows for properly planning the power dispatch at the DC microgrid, fulfilling the battery charging procedure recommended by the manufacturer at the same time, expanding battery life.

Conclusions
In this paper it has been shown the design and operation of a BESS for a grid-connected DC Microgrid with PV generation. The bidirectional power converter conforming the BESS has been modeled and verified according to any change of the battery charge/discharge currents, the SOC, the battery voltage and variations of the DC bus voltage. The BESS has a BMS that maximizes the battery life time, being compatible with a DIN41773 battery charging procedure and complying with the manufacturer specifications at the same time. The proposed procedure changes the charging parameters of the batteries depending on the MG states.
A MGCC has been used for the power management of the DC microgrid. The MGCC estimates the available power at the DC bus to charge the batteries and a target SOC in the batteries at different hours of the day. The MGCC daily plans the power dispatch in the MG and complies with two objectives: (i) to import the minimum possible power from the grid, and (ii) to charge the batteries during off-peak times and with the surplus of energy is available from the PV resources. These strategies allow for reducing the electricity bill.
The experimental and simulation results show that the implemented method allows for properly planning the power dispatch at the DC microgrid, fulfilling the battery charging procedure recommended by the manufacturer at the same time, expanding battery life.