Hybrid Control of the DC Microgrid Using Deep Neural Networks and Global Terminal Sliding Mode Control with the Exponential Reaching Law

The direct current (DC) microgrid is one of the key research areas for our advancement toward carbon-free energy production. In this paper, a two-step controller is designed for the DC microgrid using a combination of the deep neural network (DNN) and exponential reaching law-based global terminal sliding mode control (ERL-GTSMC). The DC microgrid under consideration involves multiple renewable sources (wind, PV) and an energy storage unit (ESU) connected to a 700 V DC bus and a 4–12 kW residential load. The proposed control method eliminates the chattering phenomenon and offers quick reaching time by utilizing the exponential reaching law (ERL). In the two-step control configuration, first, DNNs are used to find maximum power point tracking (MPPT) reference values, and then ERL-based GTSMC is utilized to track the reference values. The real dynamics of energy sources and the DC bus are mathematically modeled, which increases the system’s complexity. Through the use of Lyapunov stability criteria, the stability of the control system is examined. The effectiveness of the suggested hybrid control algorithm has been examined using MATLAB simulations. The proposed framework has been compared to traditional sliding mode control and terminal sliding mode control to showcase its superiority and robustness. Experimental tests based on the hardware-in-the-loop (HIL) setup are then conducted using 32-bit TMS320F28379D microcontrollers. Both MATLAB and HIL results show strong performance under a range of environmental circumstances and system uncertainties.


Introduction
Carbon emissions reached their highest level in 2021 after a 6% increase.This is mainly due to the excessive use of fossil fuels to meet our energy demands [1].The utilization of renewable energy resources (RERs) is a promising way to generate clean energy and reduce carbon emissions [2,3].RERs are also becoming a convenient way to provide electricity to rural areas [4].We have seen significant improvements in the technologies related to renewable energy systems (RESs) during the last decade.Solar, hydro, wind, biofuel, and ocean energy are a few of the RERs that are available in abundance [5].
Solar and wind energy systems are the most utilized energy technologies [6,7].However, climatic factors such as solar irradiance, temperature, air density, and wind speed have an impact on the generated power [8].Hence, due to their intermittent nature, a combination of solar and wind to form a hybrid renewable energy system seems to be an effective way to provide reliable power [6,9].Typically, an energy storage unit (ESU), such as a battery, ultracapacitor, or fuel cell, is attached to hybrid systems to store excess power and deliver power when RESs generated power is insufficient [10][11][12].Since most of the RESs and ESU are direct current (DC) devices, the DC microgrid is emerging as one of the key research areas [13][14][15].DC microgrids are efficient and also have the advantage of simple operation and robust control because of the use of semiconductor devices [11].Moreover, RESs and ESU can be connected to the DC system without having to worry about synchronization, DC/AC conversions, or power quality concerns [15,16].
One of the major challenges in the study of DC microgrids is the stability of the DC bus voltage and the transfer of reliable power under varying weather conditions and system dynamics [17,18].Different linear control methods for renewable-based DC microgrids are presented in the literature to stabilize the DC bus voltage.However, linear controllers have their limitations and cannot deal with the uncertainties present in the system [19][20][21][22].A two-step energy management system and proportional-integral-derivative (PID) control for DC microgrid are proposed in [20].The controller is simple and easy to implement but has some limitations such as slow reaching time, a small operating region, and an inability to handle nonlinearities that exist in the framework.A fuzzy-PID controller for wind and PV-based DC microgrid is discussed in [22].Fuzzy logic is a model-free control technique and simple to implement, but since it depends mostly on human insight and expertise, it cannot recognize machine learning and neural networks.In one paper [21], a mathematical model of DC microgrid components and an energy storage system is developed, and model predictive control (MPC) is designed.Although the proposed controller is effective, MPC has a number of drawbacks, including the need for additional sensors and the excessive use of computational power.To overcome these drawbacks, based on higher order sliding mode control theory, several controllers [23,24] have been devised for DC microgrid but these exhibit the chattering phenomenon leading to lower accuracy.
The controllers described so far are based on linear control theory and can only operate in a small region.However, DC microgrids have nonlinear elements and uncertainties.Hence, the next step is to investigate the design of nonlinear controllers for DC microgrids.Nonlinear controllers are robust and have the ability to provide asymptotic stability, fast convergence, and a large region of operation [25].Different nonlinear controllers, such as Lyapunov redesign, sliding mode control, and backstepping control, have been proposed for DC microgrids in the literature [18,[26][27][28][29].A nonlinear controller is designed to integrate PV panels in a DC microgrid setup, and its performance is compared with PI and vectorial control [18].A backstepping-based decentralized nonlinear controller is formulated in [28], and the stability of the DC bus is tested.The controller gives satisfactory performance but suffers from calculation explosion.Furthermore, this reference generation in this control methodology utilizes linear regression which has lower accuracy.In [29], an energy management strategy and integral sliding mode control are proposed for a DC microgrid.The proposed control shows a chattering phenomenon and exhibits steady-state error.
Keeping in mind the preceding arguments, this work studies a DC microgrid comprised of a wind turbine, PV, and battery.A two-step low-level controller is designed with a DNN-based MPPT reference generation for renewable sources and exponential reaching law-based global terminal sliding mode control (ERL-GTSMC) for reference tracking.For reference generation, a DNN model is configured using the TensorFlow open-source Python package, and the data are exported to MATLAB/Simulink 2023a.DNN is utilized because of its sensorless operation, high accuracy, and ease of implementation [30].For the tracking controller, ERL-GTSMC is proposed since it has a fast reaching time and forces the system to the equilibrium point in a finite amount of time, even when the system is not close to a sliding surface [17].Furthermore, the chattering phenomenon found in sliding mode control is significantly reduced by ERL-GTSMC [31].At the high-level control, the energy management algorithm is developed using the battery SOC.No other studies in the literature that the authors are aware of have addressed the ERL-based GTSMC for DC microgrid.The following are the primary contributions of the proposed study: 1.
A two-step low-level controller based on DNN and ERL-GTSMC is developed for the wind/PV/battery DC microgrid.

2.
A TensorFlow open-source Python library is utilized for DNN testing and training.A Pymgrid Python library is used to retrieve PV and load profiles.

3.
Real-world weather profiles and residential building loads are used to test the performance of the controllers.4.
Using TMS320F2837D microcontrollers (Texas Instruments, Dallas, TX, USA) hardware-in-the-loop experiments are conducted to analyze the behavior of a controller in industrial scenarios.
The paper has been structured as follows: In Section 2, the mathematical description of all components of the DC microgrid is presented, and DNN models are discussed.Section 3 illustrates the design technique for the ERL-GTSMC-based tracking controllers.Section 4 discusses the energy management system of the proposed framework.The simulation and HIL results are discussed in Section 5.The article concludes with Section 6.

System Modeling and DNN Design
The overall block diagram of the proposed Wind/PV/Battery DC microgrid is depicted in Figure 1, where PV, wind energy systems, and ESU are linked with the microgrid DC bus via DC-DC power converters.A boost converter is connected to the wind energy system (WES) to control its power and provide MPPT.In addition, the buck-boost bidirectional converter has been utilized to control power flow to the ESU.The PV energy system (PVS) is energized through a two-switch non-inverted buck-boost converter.A varying local DC load is also connected to the microgrid.

Modeling of WES and DNN Design
This research examines WES based on permanent magnet synchronous generators (PMSG) and wind turbines.As seen in Figure 2, a DC-DC boost converter, along with an unregulated rectifier, has been used to link the PMSG with the DC bus.Due to its simplicity, low cost, and ease of management, this study favors PMSG-based wind turbines.By utilizing generators and turbines, WES converts wind energy into electrical energy.The following mathematical equation can be used to express the mechanical power produced by the WES [32]: where v w , ρ, λ, β, and r w represent wind speed, air density, tip speed ratio, blade pitch angle, and turbine radius, respectively.Furthermore, C p represents the power coefficient derived in the form of (λ) and (β).In addition, λ and shaft speed ω r have been related by the expression [33]: where ω r represents the rotor angular velocity.By utilizing Equations ( 1) and ( 2), P mech can be derived as follows, For MPPT of the WES, DNN is used for the reference generation.DNN is employed because of its increased precision and sensorless operation.The DNN consists of one input layer with two neurons, 2 hidden layers with 64 neurons each, and one output layer with one neuron.In this DNN, 54,003 data points for training and testing are utilized.The details of the DNN are given in Figure 3. Data for offline training to learn the characteristics of the wind turbine as a function of inductor current (I w ), shaft speed, and mechanical torque are obtained using a mathematical equation-based OTC.For a specific wind speed, the OTC method operates by regulating PMSG torque to the wind turbine's maximum reference torque T * mech .Under the assumption that the rotor is operating at an ideal tip-speed ratio λ m and maximum power coefficient C p-m , (3) can be modified as, Since P mech-m = ω m T * mech , we can rewrite (4) as: Calculating T * mech from ( 5), the reference current I wre f can be derived as [33]: where the WES power converter's input voltages (V wind ) serve as an apparent load to regulate PMSG rotating speed.The converter is made up of an IGBT switch S 1 , an output filter capacitor C dc , an input inductor L w , and a diode D 1 .Based on literature presented in [17], the mathematical model of WES can be derived using state-space as follows: where i w , µ 1 and v dc are the wind current, switching control, and output voltage, respectively.

Modeling of PVS and DNN Design
The PVS presented in Figure 4 is comprised of PV modules interfaced via a DC-DC non-inverting buck-boost converter.The MPPT operation is carried out by the DC-DC converter, which tracks the DNN-generated MPP voltage reference.The DNN architecture involves an input layer with two neurons, three hidden layers with 128 neurons each, and an output layer with one neuron.630,083 data points are used for the DNN training and testing.Additionally, the offline training data of the MPP reference voltage as a function of temperature and irradiance is obtained using the following equation [34]: The PVS converter is composed of two insulated gate bipolar transistor (IGBT) switches (S 2 , S 3 ), an inductor L pv , a PV input capacitor (C pv ), two diodes (D 2 , D 3 ), and a PV output capacitor C dc .The proposed model also considers the converter's continuous conduction operation.The DC-DC converter has two operating modes.In mode 1, the PV system is disconnected from the load side, D 3 is reverse biased, and the IGBT switches are ON.In mode 2, both IGBT switches are OFF, and a forward-biased diode will connect the load side of the inductor (L pv ) to the circuit.
The governing differential equations of PVS can be expressed as follows: where V pv , µ 2 , and i Lpv , are the input capacitor voltages, control signal, and inductor current of the PV system, respectively.

Modeling of Battery
Standard lead-acid batteries are taken into consideration in this study due to their accessibility and affordability.As shown in Figure 5, a two-switch DC-DC buck-boost converter connects the battery to the DC bus and allows bi-directional current flow.The battery's job is to regulate the DC bus voltage at a specific reference while the power to the load and generation from WES and PVS are changing.The State of Charge (SOC) of the battery can be determined as follows [35]: Figure 5. Battery with ERL-GTSMC controller.
A crucial factor in the Energy Management System (EMS) is the battery's State of Charge (SOC), which measures how much battery power is remaining compared to the maximum amount of power it can store.The EMS needs to receive the battery's SOC to determine whether to charge or discharge the battery based on the amount of load demand.A battery's nominal capacity (Q) and charging current (I bat ) influence the number of amp-hours it can store over a specific time interval (t).The following SOC limitations are necessary for a battery to function safely and have a long lifespan: where SOC min and SOC max represent the lowest and highest permissible states for the safe operation of the battery.Furthermore, the state-space model of the connected converter can be described as follows: where I b , V b are the battery current and voltage.Furthermore, µ 34 represents the switching control that can be defined as follows:

Microgrid Global Modeling
By merging the mathematical models presented in Equations ( 7), ( 9) and ( 12), the proposed DC microgrid global mathematical model based on differential equations can be stated as follows: where x 1 , x 2 , x 3 , x 4 and x 5 represent average values of i w , V pv , i Lpv , i b and v dc , respectively.Moreover, I o represents the load current.

Design of ERL-GTSMC (Low-Level)
Based on ERL-GTSMC multiple controllers have been designed for PV/wind/battery DC microgrid.The centralized control framework for the microgrid has been shown in Figure 6.The core objectives for the switching control laws are: For the ERL-GTSMC controllers design, the error signals have been defined: where I w * , V pv * , I b * , and V dc * represent the reference values generated by the EMS, devised in Section 4. Based on the GTSMC theory, the sliding surface S 1 for the minimization of e 1 to zero has been derived as: where , and both p 1 and q 1 are positive odd numbers.By tuning these control parameters, not only can chattering be reduced but fast tracking can also be achieved.Utilizing (20) and ( 14), the dynamics of the sliding surface ( Ṡ1 ) can be derived by taking the time derivative: It can be observed from ( 21) that the control law comprised of two terms, i.e., the equivalent control u e , which pushes the system toward the sliding surface, and the switching term u s , which maintains the system on the surface under variation in the system parameters and external disturbances.For ease of control design, the control law can be defined as, To derive u e , substituting Ṡ1 = 0 in (21), we obtain: Furthermore, the switching term u s1 can be defined as: where ψ 1 is an exponential reaching law (ERL) and can be given as: where, The ERL increases the effectiveness of the control law by accelerating convergence and reducing chattering.The control law also functions effectively whether the system is far from or close to a sliding surface.The constraints on the parameters defined in (26) are: k 1 > 0, ρ 1 > 0, 0 < α 1 < 1, and 0 < δ 1 < 1. |S 1 | represents the mean value of S 1 .In case the system states are far from the sliding surface, the first term in (26) accelerates the convergence of the states to the sliding surface.Once the system states are near the surface, the latter term ensures quicker convergence at the sliding surface.Thus, ERL enables the system to demonstrate a quick transient response under different scenarios of the reaching process by combining these two concepts.Similar sliding surfaces are defined for the errors e 2 and e 3 as follows: Taking the derivative of sliding surfaces S 2 and S 3 with respect to time yields: Utilizing ( 15)-( 17) and ( 19), the sliding surface dynamics can be yielded as: Based on the aforementioned control design procedure, ERL-GTSMC control laws have been derived for PVS and battery systems.
Similarly, the u s term can be derived as: where ψ 2 and ψ 34 are the ERLs and can be stated as: The constraints on the control parameters defined in ψ 2 and ψ 3 have been elaborated in (26).Furthermore, to provide the asymptotic stability of the proposed wind/PV/battery DC microgrid system, Lyapunov stability criteria have been utilized.According to the Lyapunov stability criteria, the candidate function for the sliding surface (S 1 ) can be defined as: To ensure the asymptotic stability of the system, V(S 1 ) should be positive definite and its time derivative should be negative definite, i.e., V(0) = 0 and V(S 1 ) ≤ 0.
Based on a similar design procedure, the asymptotic stability of S 2 and S 3 can also be achieved.

Energy Management System (High-Level)
An Energy Management System (EMS) has been devised to ensure power balance and provide the required reference values for the battery system.The EMS has two operational modes: surplus mode and shortage mode.The supervisory controller switches to surplus mode when the power produced by PVS and WES is greater than the load demand.On the other hand, a shortage mode is engaged when the produced power is lower than the demand.The objectives of the EMS are: (1) to ensure the smooth operation of the DC microgrid, (2) to extend the lifetime of the battery, and (3) to keep the battery within its designated State of Charge (SOC) range.
Shortage Mode: If P balance > 0, the EMS switches to this mode, and the battery supports PV and wind to cater to the load demands.The process is initiated by checking the battery SOC.If the SOC is greater than SOC min = 20% for steady operation, the battery provides power.The battery will keep providing power until the SOC falls below its threshold.At this point, the battery system will be shut down, and load shedding will be applied to keep the DC microgrid operating steadily.
Surplus Mode: If P balance < 0, the EMS switches to surplus mode.In this mode, the excess power is supplied for battery charging since the load demand is lower than the power produced by solar and wind energy sources.If the battery SOC is less than 80% (SOC < SOC max ), the EMS will charge the battery on a priority basis.If the battery SOC is greater than 80% (SOC > SOC max ), the battery charging will be stopped, and the renewable sources will switch to off-MPPT mode to stop wastage of power, as shown in Figure 7.

Results and Discussion
The robustness of the two-step control design based on DNN and ERL-GTSMC is assessed by running MATLAB simulations and C-HIL tests.The MATLAB/Simulink environment is used to implement the governing system model, which includes the WES, PVS, battery, power converters, and DC load.For accurate analysis, the ode45 solver with a step size of 10 × 10 −5 is used.All the parameters and configuration of the designed DC microgrid and control laws are listed in Tables A1 and A2.The performance of the suggested framework is examined under varying real-world load profiles and weather conditions (wind, temperature, solar irradiance).The load data are imported from OpenEI using the Pymgrid Python library and shown in Figure 8.It shows the 48-h profile of commercial and residential loads ranging from 2 kW to 12 kW.For simulation purposes, the load profile is scaled down to 48 s.A real-time wind profile is used for the MPPT of WES, as shown in Figure 9, to increase the accuracy of controller analysis.Similarly, varying solar irradiance and temperature are used for the MPPT of PVS.The wind speed information is gathered from an anemometer tower at the Jiangsu wind farm, which has a 50 MW capacity.The reference DC voltage value chosen for all simulations is 700 V.
The MPPT references for the WES and PVS are generated using DNN and compared with the linear regression technique, as shown in Figure 10.It can be noticed that DNN predicts the actual value more accurately compared to linear regression in both cases.
To measure efficiency, the mean absolute error (MAE) is used as a comparison parameter.MAE calculates the average amount of error.As a result, the machine learning model with the lowest MAE should be considered a good model.From the comparison given in Figure 11, it can be observed that DNN single input models have lower MAE values of 0.68 and 0.55 compared to 8.33 and 0.76 in the case of linear regression.Similarly, with multiple inputs, DNN models perform better with an MAE of 0.17 and 0.16 compared to 1.54 and 0.39 in the case of linear regression.The effectiveness of the proposed two-step controller in rigorously stabilizing the DC bus voltage against perturbations in load demands and environmental parameters (wind speed, solar irradiance, and temperature) has been shown in Figure 12.From Figure 12, it is clear that over the entire simulated time window, V dc has been regulated to the 700 V reference value.The proposed ERL-GTSMC demonstrates a quick response, reaching the steady state with a settling time of 0.05816 s.The controller also achieves the objective of minimizing chattering and reducing undershoot and overshoot.As shown in Figure 12, the stability of the DC bus voltage was also evaluated in both surplus and shortage modes, and the accurate tracking of the ERL-GTSMC controller was observed with a steady-state error of only 1.1 V.The WES, PVS, and battery system voltage and current levels have been presented in Figure 13.The DNN-based reference generation and the tracking of reference current and voltage by ERL-GTSMC have been shown in Figure 13a,b.From 15 s to 37 s, it can be deduced that the generated current rises with respect to wind speed; however, when the wind speed becomes slow at 37 s, the generated current falls with respect to it.Figure 13c,d depicts the PVS current and voltage curves to achieve MPPT using DNN and ERL-GTSMC.It can be noticed that as the solar irradiance increases from 0 W/m 2 to 386 W/m 2 at 4 s, the generated power also increases.Similarly, the power peaks at 12 s when the solar irradiance is at the highest level of 780 W/m 2 .The current and voltage of the battery are shown in Figure 13e,f.From 0 s to 20 s, the battery discharges to compensate for power shortage, and when the power demand is lower than the generated power, the surplus power is supplied to the battery for charging.Figure 8 depicts the power curves of WES, PVS, the battery, total load generation, and load demand.Initially, the load demand is low, but the renewable sources are also generating very little power.Therefore, the EMS operates in shortage mode, and the battery supports the microgrid by discharging.At 5 s, the load demand starts to gradually rise, but the system is still functioning in shortage mode.To accommodate the increase in load demand, the depletion in the battery system can be seen at 5 s.At 22 s, due to a decrease in load demand and an increase in renewable generation, the EMS switches to surplus mode, and the excess power is used to charge the battery.At 41 s, the load demand once again exceeds the power generated by renewables, so the battery switches to discharging mode and supports renewable generation.
The charging/discharging characteristic of the battery is demonstrated in Figure 14.When the generated power is insufficient to supply the load demand and SOC ≥ SOC min , the battery, along with PVS and WES, provides the energy deficit to meet the load demand.From 20 to 40 s, the battery is charged in accordance with the EMS instructions as shown in Figure 7.

Comparative Analysis with Traditional Control Methods
The designed ERL-GTSMC controller is compared to traditional TSMC and SMC in terms of settling time, chattering phenomenon, steady-state error, and overshoot.To ensure a fair analysis, the same tuning configuration and simulation environment are used.The tracking of DC bus voltage, battery current, WES current, and PVS current is investigated to assess the robustness, reaching speed, and transient response of the controllers.Figure 15 compares the DC bus regulation performance of ERL-GTSMC to that of TSMC and SMC.It can be noticed that ERL-GTSMC has a good settling time of 0.05816 s, but SMC is the fastest with a settling time of 0.0317 s.However, the proposed controller shows a good response to the transients and shows zero overshoot and undershoot, while in the case of SMC and TSMC, an overshot of 1.82% and 0.714% is observed, respectively.Furthermore, ERL-GTSMC has superior tracking accuracy and exhibits a steady-state error (SSE) of 0.0571%, while in the case of SMC and TSMC, it is 0.971% and 0.314%, respectively.Finally, ERL-GTSMC significantly reduces the chattering phenomenon and shows very negligible chattering.However, high chattering is observed in the case of SMC and TSMC.Table 1 depicts the numerical comparison of the proposed ERL-GTSMC to that of TSMC and SMC.The setup for real-time experimental testing of the proposed ERL-GTSMC using the TI LAUNCHXL-F28379D is shown in Figure 16.The TMS320F28379D dual-core processors used in this workbench operate at a frequency of 200 MHz.The development kit is interfaced with the control unit via the C2000 embedded coder package in MATLAB/Simulink.First, the mathematical model of the proposed DC microgrid framework is designed in MATLAB, and then the code is transferred to the F28379D development kit α.In addition, the ERL-GTSMC laws have been executed on development kit β to provide the required PWM signals to the transistor switches of the power converters at a switching frequency of 25 kHz.The development kit β's PWM output ports are connected to development kit α's GPIO ports using the available 12-bit ADC and DAC.A real-time closed-loop system has been established between launchpad α and β.To evaluate the results of C-HIL compared to simulated results, tests are conducted under varying wind speeds and load demands.Figure 17 illustrates the C-HIL platform used to examine ERL-GTSMC controllers under both surplus and shortage modes.During C-HIL, the reference voltage for the DC bus voltage is set to 700 V, and the tuning parameters obtained during computer simulations are used for hardware testing.The DC bus dynamics are shown in Figure 17, and it can be observed that the voltage is strictly maintained during both surplus and shortage modes, with a tracking accuracy of 99.84%.Figure 17b shows the wind current profile under dynamic wind speed.The performance of PVS is depicted in Figure 17c.The charging and discharging state of the battery during surplus and shortage modes are shown in Figure 17d.It can be verified from the aforementioned controller analysis performed in a C-HIL environment that the ERL-GTSMC controllers have adequate tracking and quick response to transients.Furthermore, in every situation, the performance of C-HIL is as robust as the performance of the computer simulation.

Conclusions
DNN-based MPPT reference generation and global terminal sliding model control with the exponential reaching law were presented for a DC microgrid.The DC microgrid bus and its components are mathematically modeled, and control laws are derived.The DC microgrid is extensively tested using real-world weather conditions and various operational modes (surplus mode, shortage mode).The proposed ERL-GTSMC demonstrated a quick response, with a settling time of 0.05816 s, and precise steady-state accuracy, with an SSE of just 0.0571%.Additionally, the proposed control technique exhibits a significant decrease in the chattering phenomenon that typically occurs in slide mode controllers.The proposed ERL-GTSMC was found to be superior in all circumstances compared to TSMC and SMC.The real-time performance of the suggested ERL-GTSMC was validated by the C-HIL process using a low-cost evaluation kit boosting a 200 MHz dual-core processor.Future work will include designing the ERL-GTSMC for a DC microgrid connected to the grid.

Figure 3 .
Figure 3. Configuration of DNN for WES and PVS.

Figure 8 .
Figure 8. Power generation and demand.

Figure 10 .
Figure 10.DNN based MPPT reference generation for WES and PVS.

Figure 11 .
Figure 11.Linear regression and DNN performance analysis.

Figure 12 .
Figure 12.Regulation of DC bus voltage.

Figure 16 .
Figure 16.Configuration of the C-HIL.

Table 1 .
Comparison of proposed ERL-GTSMC with TSMC and SMC.