A Terminal Sliding Mode Controller for Electric Spring

: This paper mainly designs a terminal sliding mode controller (SMC) that can optimize the dynamic and static performance of the electric spring (ES) under the complex load environment on the user side, and improve the anti-interference ability of the ES. Firstly, the user-side ES-containing supply and distribution network (SDN) was modelled and analyzed, and then, the sliding surface and control rate was designed. Next, a reference voltage generation method was introduced, the stabilization conditions of the ES-containing SDN were identified, and the principles of parameter setting for the SMC were expounded. Finally, the proposed terminal SMC was proved feasible through simulations and dSPACE-based physical experiments and found to outperform the linear SMC in adaptability and dynamic and static performance.


INTRODUCTION
Renewable energy sources (RESs) are taking up a growing proportion of the energy supply system. However, the RESs are inherently unsustainable and intermittent, causing power quality problems to the grid (e.g. Guo et al. [1] mentioned that voltage dips and swells, and frequency fluctuates).
To curb the RESs-induced power supply fluctuations, Hui et al. [2] introduced the physical concept of spring into the power electronics, creating a novel concept called electric spring (ES) to apply into microgrids [3]. Drawing on Hooke's law, these scholars analyzed the voltage and current of the ES under different working conditions, such that the ES could stabilize the fluctuating voltage of the bus as a spring, and constructed an experimental platform to verify the feasibility of the ES.
Compared with traditional circuit compensation devices (e.g. static reactive power compensator), Luo et al. [4] verified the ES boasts a small capacity and performs excellently in compensation. Besides, the distributed operation of the ES on the user side, Yan et al. [5] made the consumption more reliable and the supply more stable.
Traditionally, the RESs fluctuations are stabilized by controlling user-side loads [6] or setting real-time prices [7]. By contrast, the ES does not hinder the normal consumption on the user side, as long as the supply fluctuates in a certain range. This improves consumption comfort.
The initial topology of the ES only supports reactive power compensation. Recent studies [8,9] have shown that the various new topologies of the ES are capable of stabilizing frequency and correcting the power factor.
The ES initially adopts linear controllers, such as Areedand Abido [10] proposed proportional-integral (PI) controller for ES-1 topology, and Wang et al. [11] proposed quasi-proportional-resonant (QPR) controller for ES-2 topology. The application of linear controllers is backed up by mature theories and abundant practices. However, linear controllers have a limited effect in the ES, especially in topologies that emerge later than ES-1, for the ES is a nonlinear system with variable structure.
Many attempts have been made to make traditional linear controllers more robust and adaptable. For example, Ma et al. [12] designed a control strategy that adjusts the parameters of the PI controller in real time, using a fuzzy algorithm and particle swarm optimization (PSO). Javaid et al. [13] compared the fuzzy controller, fuzzy PI controller, and a traditional PI controller, and proved that the fuzzy controller has the best dynamic performance and robustness.
Since the ES is a user-side device with the distributed operation, the ES controller must have the following three features: (1) the structure should be simple enough for the user to debug; (2) the anti-interference ability should be sufficiently strong to ensure normal operation in a complex load environment; (3) the controller should be able to adapt to most user loads.
With a variable structure, the sliding mode controller (SMC) is a suitable nonlinear controller for inverter structure and generator [14,15]. This controller is more robust and reliable than the traditional linear controllers [16] and adapts well to changes in system parameters. Compared with traditional linear SMC, the terminal SMC converges fast and applies to an environment with complex interference.
This paper firstly sets up the model and state equation of the ES-containing supply and distribution network (SDN) and introduces a reference voltage generation method. On this basis, the sliding surface function and control rate was designed, and the principles of parameter setting for the SMC was established. Finally, MATLAB simulations were carried out on an ES-containing SDN at 220 V and 30 V, respectively, and a physical experiment was conducted at 30 V, revealing that terminal SMC can control supply voltage fluctuations and sudden load change. Besides, the proposed terminal SMC was found to outperform the linear SMC in robustness and dynamic and static performance.

STRUCTURE AND PRINCIPLES OF ES-CONTAINING SDN
The structure of the ES-containing SDN is illustrated in Fig. 1. The red dotted frame stands for the power supply, which consists of the large grid and the RES. The RES is converted into electrical energy and connected in parallel with the large grid to provide power to the user side via the bus. Z 0 , Z 1 and Z 2 are transmission line impedances.
On the left to the power supply is the user side, which is composed of critical loads (CLs), non-critical loads (NCLs), and the ESs. The CLs are electrical loads that are sensitive to voltage changes, such as patient monitoring equipment and high-precision equipment in medical treatment. If the voltage fluctuates out of the allowable range, the CLs might be damaged and even accidents might occur. The NCLs are electrical equipment that works under a wide voltage range, namely, refrigerators, and air conditioners. Whether an ES participates in the regulation of the bus depends on the corresponding switch Q. If Q is disconnected, the ES and the corresponding NCL will be connected in series, forming a smart load (SL). The SL regulates the bus voltage by adjusting the output power. The topologies and key functions of ES-1 to ES-7 are fully introduced by Wang et al. [17] Subramani and Ramanand [18]. This paper selects the ES-2 topology as the object. Unlike the ES-1, Yan et al. [19] show that ES-2 is enabled by the direct current (DC)-side battery to achieve power compensation, which is greatly expanding the application scope of the ES. The circuit structure and control system of the ES-2 is detailed in Fig, 2, where U g is the supply voltage (corresponding to the power supply in Fig. 1), R + jX is the transmission line impedance, i bus is the total bus current, Z cl is CL impedance, U cl is CL Voltage, i 2 is CL current, Z ncl is NCL impedance, U ncl is NCL voltage, i 3 is NCL current, and Tri is the control signal of switch Q.
The red dotted frame stands for the ES circuit, where V in is the DC-side voltage, S 1 -S 4 are switch tubes, L is the inductance of LC low-pass filter, C is the capacitance of LC low-pass filter, and U es is the ES output voltage.
The black dotted frame stands for the control system, where U ref is the reference voltage. The generation module of U ref is described in Fig. 3. As shown in Fig. 3, the U ref generation module works under the following principles: When the supply side and all equipment are normal, the control signal Tri is set to 1, switch Q in Fig. 2 is connected, and the switch in Fig. 3 is set to 1. Then, the phase-locked loop extracts the phase of the CL voltage. But the ES is not involved in circuit regulation. When the ES is needed, the control signal Tri is set to 0, switch Q in Fig. 2 is disconnected, and the switch in Fig.  3 is set to 2. Then, the phase of U cl is locked by the time delay module. The delay time t is an integer multiple of power frequency cycles. After that, the phase-amplitude of the CL voltage remains the same, whatever the changes in the power supply. The locked phase generates U ref based on the sin module and fixed gain m.
For avoiding periodic interference caused by switch changing 1 to 2, in the physical experiment, there are two trigger signals, the first one was used to control selector switch in Fig. 3, and the second one was used to control switch Q. Significantly, two switch signals were triggered simultaneously in simulation because the simulation environment was perfect, but in the physical experiment, to suppress the influence caused by hardware equipment and signal transmission, first trigger signal was generated firstly and second trigger signal was generated subsequently.
On the upside, the U ref generation method in Fig. 3 improves the robustness of the ES, as it reduces the dependence on the parameters of the external circuit, acquires supply-side parameters without remote communication, saves control cost, and ensures the stability of U cl . On the downside, the generation method cannot maintain the optimal state of the SL, failing to fully exploit the compensation ability of the ES.

DESIGN OF TERMINAL SMC 3.1 Variable Structure Model of the ES
The circuit structure and control system of the ES-2 can be simplified as Figs. 4 and 5, respectively. The control system has two inputs and one output, adding to the difficulty of analysis. To overcome the difficulty, the general approach is to treat one input as an error. Here, the incoming current i 1 from the bus is considered as interference.
Treating current i 1 as interference, Eq. (1) can be rewritten as: where,

Design of Sliding Surface and Control Rate
The linear sliding surface [16] is generally a linear combination of system state variables: Linear SMC can meet the control requirements of general control systems. If the control system is complex and nonlinear, linear SMC will take an infinitely long time to converge, exhibiting poor performance.
To design the terminal SMC, the sliding surface was viewed as a nonlinear combination of system state variables [20]. Once arriving at the sliding surface, the system state will converge to the origin in a limited time. Hence, terminal SMC is better than linear SMC in dynamic performance and robustness. The terminal SMC can be expressed as: 0; and are positive odd nu e 2 mb rs; When the system state moves on the sliding surface, S equals zero. Then, the system state can be described as: The convergence time t of system state can be calculated by: According to Eqs. (7) and (8), the system state has little to do with system parameters during the sliding phase, and only depends on control parameters β, q and p. This means the SMC is highly robust and insensitive to circuit parameters.
The design of the sliding surface S(x) ensures that the system state can converge to the origin within a limited time during the sliding phase. Meanwhile, the quality of the approaching phase can be improved by setting up the control rate u ± (x). This paper designs the control rate based on equivalent control: where u eq is the equivalent control term of the system. Equivalent control forces the system to move in a manner that is equivalent to moving on the sliding surface. Through equivalent control, the system state will reach the sliding mode area and slide along the sliding surface to the origin. Since 0 S S    at the origin, the equivalent control term u eq can be computed by Eqs. (3) and (6): where u vss is the switching control term. In general, the switching control term makes the system move towards the sliding mode area, despite uncertainties like external interference and parameter perturbation. This term offsets the effect of interference i 1 in Eq. (1).
To realize the SMC condition 0 SS   , the switching control is generally implemented by the sign function sign (S). In ideal cases, after reaching the sliding surface, the system state will gradually slide to the origin and stabilize along the sliding surface. In actual control, however, the system contains multiple factors brought by the lag effect of devices, including inertia, unmodeled dynamics, control system samples, and analysis output.
The system state always has the speed of moving in the other direction, as it reaches the sliding surface. As a result, the system state will move back and forth across the sliding surface, pushing up the control frequency. This phenomenon is known as system chattering, which increases the energy loss of the system. In severe cases, chattering will cause the entire system to oscillate, affecting system stability. The bottleneck of this phenomenon seriously restricted the development of SMC.
To suppress chattering, the sign function sign (S) was replaced by the saturation function sat (S): The saturation function reduces the speed of the system state upon arriving at the sliding surface, suppresses the chattering of the system state near the surface, and optimizes the steady-state performance of the controller.
It is calculated that k = 1/Δ in Eq. (11). When the Δ value is small, the saturation function is close to the sign function, leading to fast dynamic response but serious chattering. When the Δ value is large, the chattering is limited, but the stabilization is slow, i.e. the dynamic performance is poor. To optimize the SMC, it is important to choose a rational Δ value.

Sliding Mode Area and Stabilization Conditions
The equivalent control term u eq falls in the range of u eq ∈[−1, 1]. From Eq. (10), it can be derived that: Ideally, the system has 0 S S    in the sliding phase, and e = 0 during stabilization. To ensure that the system equilibrium point (origin) falls into the sliding mode area, F(x, t) was substituted into Eq.
Eq. (13) gives the stability conditions of the ES control system. Since U ref remains constant, the system can be stabilized by selecting circuit parameters V in , L, C, Z cl and Z ncl . Because Eq. (13) is inequality, the system can be stabilized, as long as the circuit parameters fall within a certain range. This demonstrates the strong adaptability of the SMC to changes in circuit parameters.

Parameter Design of Terminal SMC
The control system in Fig. 2 can be optimized as Fig.  6. The system output can be obtained by substituting circuit parameters and system error into the control rate calculation module.
In the simulation, the Control Rule module was built by variable mathematical operation modules, such as addition, subtraction, constant value module, and so on. Required circuit parameters and computational formula in the Control Rule module were shown in Eqs. (9), (10), and (11).
Based on the output, the control signal can be generated in the sine pulse width modulation (SPWM) module. Then, the logical module will process the control signal and produce four pulse signals to control S 1 -S 4 . The selection of parameters β, p, q in the control rate design affects the dynamic and static performance of the system.

Circuit Parameters
Control Rule Figure 6 The block diagram of the terminal SMC When β is constant, the larger the error, the larger the error change rate, and the faster the system state changes. When the error is fixed, the larger the β, the faster the system stabilizes and the faster the system state reaches the sliding surface. If the β value is too large, the system will oscillate and lose stability. If the β value is reasonable, the system will reach an equilibrium state quickly and smoothly.  Fig. 7 provides the step response curves of the secondorder system at different β values of terminal SMC. When β = 100, the system took an excessively long time to converge. When β = 10 000, the overshoot was too large, and the system oscillated slightly during the stabilization. When β = 1000, the system exhibited good dynamic performance: fast response, small overshoot, and rapid convergence. The above results demonstrate the positive effect of a rational β value on the performance of the control system. When q/p = 5/9, the system overshoot was maximized, the adjustment time was long, and the system oscillated slightly during stabilization. When q/p = 5/7, the system overshoot was small, the adjustment time was short, and the system reached equilibrium rapidly. Hence, a reasonable q/p helps to optimize the dynamic performance of the system.
For different subjects, to get the best control performance, there are different controller parameters.
In the ES system, the reference signal is sinusoidal, so the object was controlled and cannot follow the reference signal completely in theory. The parameters of Terminal SMC were set through long-time adjusting.
Based on the ES-containing SDN, the terminal SMC parameters were configured as Tab. 1 for MATLAB simulations and physical experiments.

MATLAB SIMULATIONS 4.1 Simulation at 220 V
The first simulation was carried out at the 220 V, the voltage level of the mains supply. The parameters of the simulation circuit are listed in Tab. 2. The simulation circuit was constructed based on the circuit in Fig. 2, except that the bus current i bus was set to zero (the supply side only powers one load). The parasitic resistance on the inductor was considered during the simulation. For the U ref generation module (Fig. 3), the delay time, gain m and sampling time was set as 0.02 s, 220√2 and 5e −6 s, respectively.
The parameters of the terminal SMC are given in Tab. 1. The frequency of carrier wave in SPWM is 1e 4 Hz. To visualize its performance, the terminal SMC was compared with a linear SMC during the simulation. For the linear SMC, the sliding surface was designed by Eq. (5), the control rate was configured by Eq. (14) with k 1 = 1 and k 2 = 8000, and the other parameters are the same as the terminal SMC.

Ucl Comparison under Supply-Side Fluctuations
First, the two SMCs were compared under supply-side fluctuations: supply voltage dip and supply voltage swell. After debugging, it is learned that the user-side load voltage is 220 V, only if the supply voltage U g is 262 V. Then, the supply voltage was increased and decreased by 15%, that is, the U g dipped to 222.7 V and swelled to 301.3 V, respectively. The dip and swell both lasted 0.3 s. Tab. 3 presents the time variations in U g and Tri. It can be seen that the supply voltage remained normal in 0-0.2 s and started to fluctuate after 0.2 s. The ES did not participate in circuit regulation until 0.1 s.  It can be observed that, after the ES suddenly cut into the circuit at 0.1 s, U cl stabilized after a cycle of slight fluctuation. When the supply voltage did not fluctuate in 0.1-0.2 s, the two SMCs had errors in U cl , due to their steady-state errors. After the supply voltage began fluctuating in 0.2 s, the U cl stabilized after a cycle of slight fluctuation under both SMCs. Comparatively, the U cl fluctuation was smoother and the steady-state error was smaller under the terminal SMC than under the linear SMC. These results reflect the superiority of the terminal SMC. Figs. 11 and 12 show the effective values and phase changes of U ncl in the terminal SMC. The blue dotted line in Fig. 12 is the reference axis of the phase. It can be observed that, after the supply voltage started to fluctuate at 0.2 s, the U ncl decreased and increased significantly. The phase lead occurred during a supply voltage dip, and phase lag took place during supply voltage swell. The main reason is that, when the supply voltage fluctuates, the ES alters the current amplitude and phase of the SL by adjusting the output voltage and current. In this way, the supply-side fluctuations are transferred to the NCL.
The supply-side fluctuations within a certain range can be fully compensated for by the ES. If the fluctuations exceed the range, the compensation will fail, and the system will become unstable. The compensation range of the ES mainly depends on four factors: DC-side voltage and output power; NCL stable operating range; U ref generation algorithm; CL to NCL impedance ratio. The next step is to compare the U cl before and after the ES is activated to control supply-side fluctuations. The variations in U g and Tri were configured as Tab. 4, such that the ES is activated after supply-side fluctuations. On this basis, the U cl variations during supply voltage dip and sag were obtained (Figs. 13 and 14).  As shown in Figs. 13 and 14, after the ES was activated in 0.2 s, U cl changed similarly as U g when the supply voltage fluctuated at 0.1 s. After the activation of the ES, the U cl was stabilized, as its effective value returned to near the reference voltage. From the enlarged view, it is learned that the U cl had very small error under both SMCs. Comparatively, the terminal SMC achieved a smaller steady-state error of U cl than the linear SMC and realized better static performance. This agrees with the results in Figs. 11 and 12.

Ucl Comparison under Sudden Load Changes
Next, the U cl values of the two SMCs were compared as the CL resistance suddenly changes in size and nature. Keeping the supply voltage U g in the normal state, the size and nature of the CL resistance were adjusted as Tab. 5.  4 20 Ω + 10 mH 0.4 -0. 5 20 Ω + 50 μF Then, the ES was activated at 0.04 s, and the variations in U cl under the two SMCs were obtained (Fig. 15). It can be seen that, after the activation of the ES at 0.04 s, the U cl under both controllers fluctuated for a short period and resumed stable. Thus, both controllers can meet control requirements under various load conditions. Of course, the terminal SMC had smaller U cl fluctuation and error than linear SMC, evidence of the strong robustness and adaptability of the terminal SMC. Figure 15 The Ucl of the two SMCs under sudden load changes

Simulation at 30 V
The DC supply of 360 V in the first simulation cannot be realized in the physical experiment. During the experiment, the DC voltage was provided by multiple batteries in series.
To make the simulation results comparable to experimental results, another MATLAB simulation was carried out at a low voltage. The circuit and controllers were designed the same as that in the first simulation. The circuit parameters are given in Tab. 6. On account of the fact that controlled object is unchanged, the parameters of terminal SMC are consistent with the simulation at 220 V. The ES-containing SDN at 30 V was also simulated under supply-side fluctuations and sudden load changes, with linear SMC as the control sample.

Ug Comparison under Supply-Side Fluctuations
After debugging, it is learned that the user-side load voltage remains at 30 V, only if the ES is not activated, and the supply voltage U g is 35.69 V. Then, the supply voltage was increased and decreased by 15%, that is, the U g dipped to 30.34 V and swelled to 41.03 V, respectively. The dip and swell both lasted 0.3 s. Tab. 7 presents the time variations in U g and Tri. Figs. 16 and 17 compare the effective values of U cl of the two SMCs under supply voltage dip and swell, respectively. During 0-0.1 s, the supply side ran normally, the switch Q was connected, and the ES was not connected to the bus. In this case, the U cl value stabilized at 30 V.
After Q was disconnected at 0.1 s, the U cl value stabilized after a slight fluctuation of about one cycle. From 0.1 s to 0.2 s, the U cl value was not completely stable at the given supply voltage of 30 V, owing to the steady-state error of the ES participation in regulation. The steady-state error of the linear SMC was slightly smaller than that of the terminal SMC, because of the difference in the control method.
After the sudden change of U g at 0.2 s, both SMCs stabilized U cl within a certain error range in one cycle. Compared with the linear SMC, the terminal SMC achieved small overshoot, limited steady-state error, and fast response.
The above results are consistent with those of the simulation at 220 V. This further proves that the terminal SMC is more superior than the linear SMC in dynamic and static performance.

Ucl Comparison under Sudden Load Changes
The U cl values of the two SMCs under sudden load changes were simulated, using the same parameters as Subsection 4.1.2. During the 0.5 s -long simulation, the supply voltage U g was kept normal; the Tri signal was set to 1 from 0 s to 0.06 s, and to 0 for the rest of the simulation period. The variations in the resistance and nature of the CL are shown in Tab. 5. The variations in the effective value of U cl and the ES output voltage U es under terminal SMC are displayed in Figs. 18 and 19, respectively.
From the two figures, it can be observed that the U cl fluctuated briefly and then stabilized after the Tri signal disappeared at 0.06 s. The U es remained zero before 0.06 s, because the ES did not participate in circuit regulation until that moment. When the resistance and nature of the CL changed suddenly at 0.2 s, 0.3 s and 0.4 s, the terminal SMC witnessed a smoother variation in U cl , and a smaller steady-state error than the linear SMC. During the sudden load changes, the U cl changed greatly under the linear SMC, which is unfavorable to U cl stabilization. By contrast, the U cl changed smoothly with a small steadystate error, reflecting the excellence of the terminal SMC in dynamic and static performance.
Through Fourier analysis of the U cl waveforms, the harmonic contents in the U cl were calculated as 0.98% and 1.01%, under the linear SMC and terminal SMC, respectively. The harmonic contents meet the output requirements. Figure 18 The Ucl of the two SMCs under sudden load changes Figure 19 The Ues of the terminal SMC under sudden CL changes The above simulations demonstrate that the terminal SMC can be applied to the ES-containing SDN, and can achieve great dynamic and static performance in that network. After that, the terminal SMC will be verified through the physical experiment on the dSPACE platform.

PHYSICAL EXPERIMENT
The parameters of the circuit elements were configured the same as those in the simulation at 30 V (Tab. 2). The experimental platform is illustrated in Fig.  20.
Four batteries (12 V, 24 Ah) were connected in series to simulate the DC 48 V power supply; the supply voltage of the grid was simulated by a voltage regulator, with the effective value of U ref as 30 V; the controller was partly designed with dSPACE (model: DS1202); the CL and NCL were simulated by an adjustable resistor. The control parameters of dSPACE were kept the same as the simulations. The only difference is that the sampling step of the physical experiment was slightly higher (5e −5 s). To prevent short-circuiting, the dead zone of the pulse width modulation (PWM) signal output by each controller was set as one sampling cycle. First, the controller response to supply voltage swell and sag was tested. The effective U cl values were collected by an oscilloscope. Figs. 21 and 22 record the U cl variations of the two controllers under supply voltage swell and sag, respectively. The U cl variation of the terminal SMC is colored in blue, and that of the linear SMC is colored in purple.
As shown in Figs. 21 and 22, the supply voltage swelled/sagged at t 1 by 13%, and the ES was activated at t 2 . It can be observed that U cl changed significantly right before t 2 and returned to near the normal value after that moment. Compared with the linear SMC, the terminal SMC had a small steady-state error and a smooth U cl change trend. The results echo with those of simulations. The U ncl signals under the terminal SMC were collected at supply voltage swell/dip. Then, the variation in the effective value of U ncl was plotted (Fig. 23). It can be seen that the U ncl value was normal before t 1 because the supply side did not fluctuate. After t 1 , the supply voltage swelled/dipped, causing the U ncl to decline in t 1 -t 2 . But the decline is not significant, for the ES was not activated. In this period, U cl and U ncl changed in the same trend. After the ES started to work at t 2 , U ncl increased/decreased more significantly, as the ES transferred the supply-side changes to the NCL. Figs. 24 and 25 show the U cl variations of the two SMCs when the resistance of the CL changed from 40 Ω to 10 Ω or the nature of the CL suddenly changed from 40 Ω to 40 Ω + 10 mH at t 1 . The U cl variation was gentler with a smaller steady-state error under the terminal SMC than under the linear SMC. As shown in Fig. 25, the U cl values slightly oscillated under both controllers, after the sudden change of CL nature, due to the sudden activation of the inductive load. For directly observing U cl while CL nature is changing suddenly, Fig. 26 provides the sinusoidal varying waveform of the U cl variations in Fig. 25.
It can be seen that the U cl values slightly oscillated as the CL nature suddenly changed and they were all stabilized in a very short time. The experimental results generally agree with the simulation results, revealing the feasibility and good dynamic and static performance of the terminal SMC.

CONCLUSIONS
The ES is a nonlinear tool with variable structure, multiple-input, and a single output. This paper mainly designs a terminal SMC to enhance the anti-interference ability of the ES in a complex load environment, and optimize the dynamic and static performance of the ES at changes of system state. The ES-containing SDN was modelled, and the terminal SMC control system was designed. Finally, the feasibility of the proposed terminal SMC was proved through MATLAB simulations and physical experiments. Compared with the linear SMC, the terminal SMC has higher robustness, and excellent static performance, when supply voltage and load suddenly change.
Future research will try to improve the adaptability of the terminal SMC and optimize the ES performance in harsh environments by coupling the terminal SMC with other optimization algorithms. Also, the ES topology will be improved to broaden its application scope and enhance its adaptability.