# Design of a Partially Grid-Connected Photovoltaic Microgrid Using IoT Technology
## 3 Microgrid Modeling and Design
### Battery Array and Bidirectional Converter  
ESS is essential to compensate for energy shortage and power fluctuations in standalone PV systems. In this design, the battery model was implemented as a controlled voltage source [55].  
\[V_{Batt}=\left[V_{0}-k\frac{AH}{AH-\int~{}idt}+Aexp\left(-B\int~{}idt\right) \right]-I_{Batt}R_{o} \tag{19}\]  
where \(V_{0}\) is the open-circuit voltage of a battery, \(AH\) is battery capacity in Ah unit, \(k\) denotes the polarization voltage (\(V\)), \(A\) is the exponential zone amplitude (V), \(B\) is the exponential-zone time-constant inverse (in the unit (Ah)\({}^{-1}\)), \(I_{Batt}\) is the battery current (A), \(R_{o}\) is the battery internal resistance (\(\Omega\)), and the integral \(\int\)\(idt\) is the charge drawn or supplied to the battery. The state-of-charge (\(SOC\)) is a key variable of a rechargeable battery, representing the percentage of the charge level of a battery as compared to its total capacity. Ampere-hour (Ah) counting is a simple and low-complexity method for estimating a battery \(SOC\). To integrate the discharging or charging current and compute the remaining charge in the battery, the Ah counting estimate technique is employed. Therefore, the SOC of a battery is computed as follows [56]:  
\[SOC=SOC_{init}-\int~{}\frac{I_{Batt}\times 100}{\alpha\times 3600}dt \tag{20}\]  
where \(SOC_{init}\) is the initial value of \(SOC\), \(\alpha\) represents the usable capacity of the battery. \(I_{Batt}\) represents the current which is, by definition, negative during charge and positive during the discharge state. The discharge characteristics of a battery bank with a rated capacity of 3 kAh are illustrated in Figure 7. The typical discharge curve includes three distinguished regions. The first region, at the initial time, represents the exponential decay of the battery voltage when the battery is charged. The second one indicates the battery nominal voltage. The third represents the region at which the voltage drops rapidly, and the battery is discharged.  
\begin{table}
\begin{tabular}{l c} \hline \hline
1: & **Initialization**; \(D_{min}\), \(D_{max}\), \(\Delta D\) (duty cycle step), \(D_{k}\)\(V_{k}\), \(I_{k}\), \(P_{k}\) \\
2: & **Read input values of voltage and current \(V_{k+1}\), \(I_{k+1}\)** \\
3: & **Calculate**: \(P_{k+1}=V_{k+1}\)\({}^{*}I_{k+1}\); \(\Delta V=V_{k+1}-V_{k}\); \(\Delta P=P_{k+1}-P_{k}\); \\
4: & **If**\(\Delta P\
eq 0\to\textbf{If}\ \Delta V<0\to\textbf{If}\ \Delta V<0\to D_{k+1}=D_{k}-\Delta D\) \\
5: & **else**\(D_{k+1}=D_{k}+\Delta D\) \\
6: & **else**\(\textbf{\ }  
In the present microgrid architecture, the DC bus is linked to the battery array throughout a buck-boost bidirectional converter circuit, as demonstrated in Figure 8. The controller of that converter is responsible for maintaining a regulated DC bus voltage, in addition to charging and discharging the battery array as required [57]. The design parameters of the bidirectional converter are listed in Table 3. The first proportional-integral (PI) controller was used to obtain a constant DC bus voltage (800 V) as compared to the measured bus voltage. The controller parameters were tuned to be \(k_{p}\) = 10 and \(k_{i}\) = 100 s\({}^{-1}\), and the controller output was limited by the maximum charging/discharging current of the battery. The obtained current was used as a reference value and compared with the monitored battery current (\(I_{Batt}\)). The error signal was fed to another PI controller to obtain the duty-cycle required to complementary drive the two switching transistors (Q1 and Q2). The parameters of the latter PI controller were optimally tuned at \(k_{p}\) = 1 and \(k_{i}\) = 10 s\({}^{-1}\) with duty-cycle limits of 0.1 and 0.9.  
Figure 8: Schematic diagram of bidirectional converter with controller.  
Figure 7: Battery discharge characteristics.