Abstract
Smart energy management systems (SEMS) are increasingly used to coordinate photovoltaic (PV) generation, battery energy storage, and flexible loads in grid-connected and islandable microgrids. However, most reported SEMS are validated only through software simulations, leaving controller timing, converter nonlinearities, and communication delays largely unverified. This paper presents a hierarchical SEMS combining a receding-horizon model predictive control (MPC) secondary/tertiary economic dispatch layer with a primary droop-controlled inverter layer. The control problem is formulated as a convex quadratic program (QP) incorporating battery state-of-charge (SOC) dynamics, inverter power constraints, and a coincident-peak-aware cost objective. First-order optimality (KKT) conditions provide a shadow-price interpretation of battery dispatch, while recursive feasibility, input-to-state stability, and small-signal analysis establish closed-loop stability and exponential elimination of droop-induced steady-state error. The proposed controller is validated using a Controller-Hardware-in-the-Loop (CHIL) platform, where the physical EMS controller operates in real time against a real-time simulated microgrid. For a 24-hour PV–battery–load case study, the SEMS reduces coincident peak grid import by 22% and day-ahead energy cost by 8% compared with a fixed-threshold reactive controller. During islanding transitions, the secondary control restores voltage and frequency within regulatory limits in under 3 s. Across 5000 test cycles, execution time remains below the 100 ms real-time deadline, with a mean of 51.3 ± 0.3 ms. Sensitivity analysis of the MPC prediction horizon (R² = 0.984) quantifies the trade-off between computational effort and economic performance, demonstrating the practicality of the proposed SEMS for real-time deployment and future multi-microgrid applications.