**4. Hardware-in-the-Loop Simulation Setup for the Proposed System**

In general, controller and control software are validated by integrating the controller with actual plant hardware. However, in the case of any error in the control system, there are risks of personal injuries, damage to the equipment and delays. Hardware-in-the-Loop (HIL) simulation is a useful tool to avoid such issues. In HIL simulation, instead of a real plant a mathematical model representing the plant loaded in the real-time simulator to act like an actual plant. Through HIL simulations, the response of a controller in real time operation can be validated [19]. The following are the advantages with the HIL simulation: (a) prototype controller software can be developed with minor assumptions about the plant parameters; (b) once the control parameters are calculated with the HIL simulation, it is easy to tune the parameters of the actual system; (c) it saves design cost and time (d) system protections in real time can be analyzed by simulating faults. To validate the control software for the proposed system, HIL simulations were carried out. A plant consisting of a PV array, inverter, battery charger, isolation transformers, grid, battery and contactors was simulated using the Matlab-Simulink software. The simulated model is compiled and loaded into the processor of a real-time digital simulator (RTDS). The simulated plant can be accessed by the external controller cards and other hardware through the I/O channels available in the RTDS. The DSP-based controller is connected as hardware in the loop as shown in Figure 7.

**Figure 7.** Block diagram for hardware-in-the-loop simulation of the proposed grid energy storage system.

The RTDS used for the HIL simulations is the Opal-RT Simulator and the controller hardware is based on a Texas Instruments TMS320F2812 DSP-based controller card. The user interface panel consisting of pushbuttons and potentiometers (POT) is used for user commands and for simulating the faults. Figure 8 shows the hardware setup for the HIL simulations.

**Figure 8.** Hardware-in-the-loop simulation setup for the proposed grid energy storage system for photo voltaic applications.
