Characterization of analog and digital control loops for bidirectional buck-boost converter using PID/PIDN algorithms

This article presents the characterization of analog and digital control loops using PID and PIDN control algorithms for bidirectional buck and boost converter (BBC). Control loops of BBC are designed and implemented in MATLAB code using transfer functions in time domain with unit step response and in frequency domain with bode plots and pole-zero plots. These transfer functions are obtained by average large signal modeling of BBC. Actions of analog and digital control loops are characterized in order to ensure stability and dynamic response of BBC which is a bottleneck in renewable energy applications. Improvement in dynamic response and stability of BBC with PIDN control algorithm is demonstrated using bode plots, pole-zero plots, and step response. Control loop gain due to transfer functions of power stage and controllers is demonstrated, and it is found stable in both analog and digital control loops. PIDN compensator is proposed to maintain a healthy balance between the stability and transient behavior since both are indirectly proportional. BBC is modeled using average large signal modeling technique, simulated using MATLAB tool, and analysis of dynamic and stability response is done through unit step input, bode plot, and pole-zero plot. Hardware is designed and implemented using TMS320F28335 controller.

power and become unreliable system. This is the basic idea of finding of bidirectional DC-DC converter as power interface between main power and auxiliary energy storage system for efficient utilization power in the above said scenario [4][5][6][7][8]. The general architecture of bidirectional buck-boost converter in hybrid renewable energy system is shown in Fig. 1.
The BBC supposed to do the job of power conditioning among the loads, power storage systems, and DC bus. To do this, BBC has to be controlled in closed-loop system, and therefore, the closed-loop control mechanism needs to be tested with respect to stability and dynamic response.
Bode plots and pole-zero plots are the easiest tools to analyze the stability and dynamic response. Bode plots are used to measure the stability of such power converters in terms of gain margin, phase margin, damping factor, and bandwidth of control loops in frequency domain since time domain analysis is tedious [9]. There are two domains to develop and implement control loops for power converters: One is continuous time control loop as shown in Fig. 2a, and another one is discrete time control loop as shown in Fig. 2b.
When output voltage (V OUT ) is more than required magnitude, than the error voltage is going to be negative, compensator magnitude will increase that results in decreasing the duty cycle generated by the PWM function and the decreased duty cycle in turn results in reducing the output voltage. The same thing goes in opposite when output voltage is lower than the required magnitude. Control loops consist of voltage sensor and error signal generator; compensator and PWM function are having mainly three concerns: (1). Tracking which checks how close is the output to the commanded value, (2). Disturbance rejection which take care of how well does the output return to the proper value if the input voltage changes or the load changes or there is noise in the load signal voltage, and (3). Stability which ensures output signal does not run away.
In digital control loop, digital compensator is implemented. There are various control compensator algorithms like PID, PIDN, fuzzy PID, artificial neural network (ANN) and so on in terms of digital filters like IIR or FIR filters. Digital PWM is implemented with counter/timer/special hardware [10]. There is issue with digital control loop, i.e., delay time. Its time between sampling time and switching time. Delay time to be overcome such that sampling of output signal should happen at the middle of the off-time or middle of the on-time of PWM signal since switching instants are electrically very noisy [11]. Parallel PID/PIDN compensator is as shown in Fig. 2c. It takes the error signal (V ER-ROR ), and it is tuned by adjusting gain terms and generates the tuned signal (V EA ) which is input signal for PWM function. The tuned signal can either increase or decrease its magnitude based on positive or negative values of error signal in order to decide the stability and dynamic response of power stage. This compensator is good for one of the design where power stage characteristics are not well known. The low-pass filter shown in Fig. 2c filter out the high-frequency-noise signal which is amplified by the differentiator. When the low-pass filter with huge value of filter coefficient (N) makes differentiator as pure differentiator, i.e., PID compensator that results in allowing high-frequency noise with control signal for power stage that in turn results in ripple in output signal [12]. When the value of filter coefficient (N) is nominal, i.e., equal to tuned value then the system is known as PID with filter called as PIDN.
The control loop of BBC either in analog or digital domain has gain known as loop gain T(s) which can be determined as shown in Fig. 2d. Each block of control loop has its own transfer function. Gain of a signal which goes around the control loop is usually constant for feedback function K(s) and PWM function G pwm (s). Power stage design sets G VD (s) and designer design compensator gain H EA (s) so that T(s) gives desired dynamic response and stability [13].
For a control loop to be stable, loop gain is supposed to be ≤ 1 at phase shift is ≤ 180°. Also the phase at the crossover frequency indicates stability margin. Dynamic response is also determined with loop gain. Control loop has a faster transient response when the loop gain has higher crossover frequency where the loop gain crosses 0 dB. For fast response, preferred maximum phase shift is 135° at phase margin of 45°.

Bidirectional DC-DC converter
The half bridge non-isolated bidirectional buck-boost converter as shown in Fig. 3 is taken into account in further design (as per the specification given in Table 1), modeling, and simulation and implementation process. It consists of two MOSFET switches with built-in anti-parallel diodes, one inductor, one 'R' load and two capacitors (one is at battery side and another one is at load side or DC bus side). It is a second-order system since two storage elements like inductor and capacitor come into picture when BBC operates in either buck mode or boost mode at given particular point of time. Inductor is common for both the modes; however, consideration of capacitor will change based on mode [14]. Based on the equivalent circuit due to operating mode, mathematical modeling is carried out using average large signal modeling technique. Switch 's2' is operating during boost mode and switch 's1' is non-operating. But in buck mode, it is vice versa. When switch 's2' is on, energy gets stored in the inductor by the virtue of current flowing through it. When 's2' is off, energy stored in inductor constitutes inductor voltage and supply voltage, i.e., battery voltage get added and will be fed to the DC bus through the in-built diode 'D1' of switch 's1' this is called boosting of voltage, and hence it is called boost mode of operation.  Buck mode is coming into picture when switch 's1' is operating and switch 's2' is nonoperating. When switch 's1' is on, load, i.e., battery and source, i.e., DC bus are connected in series through energy storage element, i.e., inductor therefore the output voltage which is fed to the battery is less than the DC bus voltage [15].

Mathematical modeling and control methods
To control the BBC in closed loop through modeling approach in analog and digital domain, PID and PIDN control methods are used and the method which gives best results and trade-off between stability and dynamic response are projected. Using average large signal modeling technique, The BBC shown in Fig. 3 is modeled, and it finds the application right from renewable energy systems to automobile systems. Later transfer functions in S-domain and Z-domain for each mode of operation are obtained based on the specification given in Table 1

Analog domain
Converter and controller models of BBC are designed in S-domain based on mode of operation, either buck mode or boost mode and type of control; either open loop or closed loop. Considering the design specification given in Table 1, the open-loop transfer function of boost mode (TF boost ) is obtained using Eqs. (1) and (2), and it (2)  Fig. 4.
Similarly, comparing Eq. (6a) with Eq. (6), the damping ratio is ζ = 11.11 and natural angular frequency ω n = 2000 rad/s. From this, it is clear that BBC in open-loop system under buck mode is overdamped system, i.e., no oscillations, but it takes more time to reach stability during turn ON and turn OFF of the MOSFET switch (S1) used in buck mode. Since in this mode, battery is the load that offers negligible internal resistance, and hence, system behaves as if it is first-order system in open-loop control, i.e., without PID control, and it is as shown in Fig. 12.
The general equation for second-order closed-loop transfer function is given by (6b).
For boost mode, analog closed-loop controllers are designed with PID control who's transfer function is given in Eq. (7) and PIDN control who's transfer function is given in Eq.     Comparing equivalence of Eq. (11) with general equation of second-order system given in Eq. (6b) obtains ζ = 0.98 and natural angular frequency ω n = 2165.4 rad/s. From this, it is clear that BBC in closed-loop system under boost mode using PID controller is underdamped system, and its step response is as shown in Fig. 8 This response has moderate oscillations compared to the response without PID control and it takes less time to reach stability as shown in Table 2 during turn ON and turn OFF of the MOSFET switch (S2) used in this mode. (7) G Cboost (S) = 76947s 2 +7.874 * 10 6 s+1.77 * 10 9 s 2 +1.703 * 10 6 s .      Equation (12) is a model represents closed-loop control of BBC in boost mode using PIDN controller in analog domain. This model is obtained by utilizing Eq. (5) represents converter being controlled in closed loop using Eq. (8) which represents controller.
Comparing equivalence of Eq. (12) with general equation of second-order system given in Eq. (6b) obtains ζ = 1.46 and natural angular frequency ω n = 565.3 rad/s. From this, it is clear that BBC in closed-loop system under boost mode using PIDN is overdamped system, and its step response is shown in Fig. 8.
Using PIDN controller, rise time and settling time is more compare to PID controller as shown in Table 2. Since the damping factor of PIDN-based closed-loop control of BBC is more than the damping factor of PID controller.
Buck mode models of closed-loop control of BBC are represented by Eqs. (12a) and (12b) using PID and PIDN controllers, respectively.
Converter being controlled in closed loop using Eq. (7) which represents controller. Comparing equivalence of Eq. (12a) with general equation of second-order system given in Eq. (6b) obtains ζ = 2.09 and natural angular frequency ω n = 961.6 rad/s. From this, it is clear that BBC in closed-loop system under buck mode using PID controller is overdamped system, and its step response is shown in Fig. 12.
This response has moderate oscillations compared to the response without PID control, and it takes less time to reach stability as shown in Table 5 during turn ON and turn OFF of the MOSFET switch(S1) used in this mode. Equation (12b) is a model represents closed-loop control of BBC in buck mode using PIDN controller in analog domain. This model is obtained by utilizing Eq. (6) represents converter being controlled in closed loop using Eq. (10) which represents controller.
Comparing the equivalence of Eq. (12b) with general equation of second-order system given in Eq. (6b) obtains ζ = 0.47 and natural angular frequency ω n = 765.179 rad/s. From this, it is clear that BBC in closed-loop system under buck mode using PIDN is underdamped system, and its step response is shown in Fig. 12.
Analog closed-loop control architecture of BBC is shown in Fig. 4. Considering H(s) = unity. Open-loop and closed-loop models are implemented in MATLAB tool. Based on mode of operation, MATLAB code is developed for analog control of boost mode and buck mode of operation of BBC. Using Eqs. (5)-(10) a block diagram of the analog closed-loop control with PID and PIDN controller is obtained, and it is shown in Fig. 4.

Digital domain
There are two basic methods to design a digital control for the system to be controlled. First one is redesign method and other one is direct method. In this work of develop of digital controller for BBC, redesign method is used. Digital control system with digital PID and PIDN controllers is developed separately for BBC [16]. Digital transfer functions of BBC based on modes of operation are shown in Eqs. (13) and (14).These models are obtained using Tustin transformation with sampling time 't' = 01 s, applied to boost mode and buck mode models of continuous systems given in Eqs. (5) and (6), respectively. Digital control system either open-loop or closed-loop control is stable when number of zeros should not be more than number of poles in the model otherwise at high frequencies, the gain of the system would be unbounded. The developed models represented in Eqs. (13)- (22) are not having zeros more than poles hence the developed models are stable digital systems. In addition, stability of these models are verified using bode plot and Z-plane in the coming section.
Transfer function of Digital PID and PIDN controllers for BBC in boost mode control is given in Eqs. (15) and (16), respectively.
Transfer function of Digital PID and PIDN controllers for BBC in buck mode control is given in Eqs. (17) and (18), respectively. Equation (19) is a model represents closed-loop control of BBC in boost mode using PID controller in digital domain. This model is obtained by utilizing Eq. (13) represents converter being controlled in closed loop using Eq. (15) which represents controller. Equation (20) is a model represents closed-loop control of BBC in boost mode using PIDN controller in digital domain. This model is obtained by utilizing Eq. (13) represents converter being controlled in closed loop using Eq. (16) which represents controller.
Equation (21) is a model represents closed-loop control of BBC in buck mode using PID controller in digital domain. This model is obtained by utilizing Eq. (14) represents converter being controlled in closed loop using Eq. (17) which represents controller.

Results and discussion
The  (B). Stability and dynamic response in buck mode.

A. Stability and dynamic response in boost mode
The validation of stability and dynamic response of BBC in boost mode operation is done through bode plots and pole-zero plots by making use of transfer function model given by Eq. (5) plots are developed using MATLAB code for the transfer functions. This feature becomes the base for the 1model to be embedded in design, simulation, and analysis. The approach of computational implementation through code is basically translates mathematical model to discrete programming code with vari-

(i) Dynamic response
Transient response of BBC working in boost mode using unit step input is as shown in Fig. 8. From Fig. 8 various parameters are listed in Table 2. These parameters define the behavior of BBC for unit step input. If it is understood, then it is easy to understand the behavior of BBC for any type of input signal applied to it. PIDN controller has three control actions (proportional, integration and differentiation) along with filter operation which is associated with differentiator. Without filter with differentiator results in more noise termed as ripple in the load signal that will hinder the performance of the whole system. This is the issue with just PID control. The noise comes with sampled load signal gets amplified by differentiator therefore filter is connected in series with it. Better transient response can be obtained with just PID, whereas PIDN controller obtains better trade-off between stability and dynamic response. This is the major requirement of any system design.

(ii) Stability
It is easy to understand the variation of system parameters under frequency domain particularly the stability of closed-loop control of either analog or digital loops for BBC where the output voltage supposed to have a tight regulation for change in input voltage and load. This is possible with perfect control loop. Estimation of stability using various parameters in bode plots and pole-zero plots give the information that how the output voltage varies with the variation of input voltage, duty cycle, and the load with respect to frequency. Also estimation of damping factor from bode plots gives the information about reaction time of the system.
The frequency response of BBC in boost mode in analog domain is shown in Fig. 9 can be determined from transfer function using bode plots which is basically a graph of magnitude and phase of the transfer function as a function of frequency, where magnitude is plotted in decibels and phase in degrees. These plots reveal some key information about the control loop's performance. The first point of interest is the crossover frequency (f c ). Here, BBC in boost mode is showing 9.13 kHz under PIDN control. This is the frequency at which the control loop gain is unity (0 dB) and is also referred to as the loop bandwidth. The second point of interest is the place at which the phase lag reaches 180°. In this case, its infinity under PIDN control. The phase margin (PM) equals 180° minus the phase lag at f c . In this case its 82.6°. The gain margin (GM) is the gain at a phase lag of 180°. In this case, its infinity under PIDN control. The system will be stable if the phase lag at f c is less than 180°. Here in buck mode under PIDN control, its 82.6° therefore it's stable. For most control loops, the engineers aim to achieve a PM greater than 45° and less than 180°. Typically, a phase margin of 45° provides good transient response with good damping. For buck or boost switching system, the gain margin (GM) should be above 10 dB. In this case, GM is infinity. The data which defines the stability of BBC in boost mode with PID and PIDN control loops is extracted from bode plots of analog domain which is as shown in Fig. 9 and is tabulated in Table 3. Similarly, the data which defines the stability of BBC in boost mode with PID and PIDN control loops is extracted from bode plots of digital domain which is as shown in Fig. 10 and is tabulated in Table 4.
Pole-zero plot in analog domain for BBC in boost mode is demonstrated in open loop and closed loop using PID and PIDN as shown in Fig. 11a-       Magnitude ( Fig. 12 Step response of BBC in buck mode for 50% duty cycle Table 5 Step response of BBC with PID and PIDN and without PID in buck mode (i) Dynamic response

System PM (degrees) GM (db) ω g (rad/s) ω p (rad/s) Delay margin (s) Stability state
For BBC, dynamic response is coming into picture during switching of the switch 'S1' for buck mode of operation. To improve the dynamic response of BBC, PID and PIDN controllers are designed for BBC in both analog and digital domain. The dynamic response of BBC in buck mode is as shown in Fig. 12. Table 5 contains the characteristic properties of control loops for step input. Even in buck mode, PIDN gives better tradeoff between stability and dynamic response.

(ii) Stability
It is easy to understand the variation of system parameters under frequency domain particularly the stability of closed-loop control of either analog or digital loops for BBC where the output voltage supposed to have a tight regulation for change in input voltage and load. This is possible with perfect control loop. Estimation of stability using various parameters in bode plots and pole-zero tools gives the information that how the output voltage varies with the variation of input voltage, duty cycle and the load with respect to frequency. Also estimation of damping factor from bode plots gives the information about reaction time of the system.
The frequency response of BBC in buck mode in analog domain is shown in Fig. 13 can be determined from transfer function using bode plots which is basically a graph of magnitude and phase of the transfer function as a function of frequency, where magnitude is plotted in decibels and phase in degrees. These plots reveal some key Information about the control loop's performance. The first point of interest is the crossover frequency (f c ). Here, BBC in buck mode is showing 360 Hz under PIDN control. This is the frequency at which the control loop gain is unity (0 dB) and is also referred to as the loop bandwidth. The second point of interest is the place at which the phase lag reaches 180°. In this case, lag at f c . In this case, its 122°. The gain margin (GM) is the gain at a phase lag of 180°. In this case, its 40.8 dB under PIDN control. The system will be stable if the phase lag at f c is less than 180°. Here in buck mode under PIDN control, its 120°, and therefore, it is stable. For most control loops, the engineers aim to achieve a PM greater than 45° and less than 180°. Typically, a phase margin of 45° provides good transient response with good damping. For buck or boost switching system the gain margin should be above 10 dB. In this case, GM is 40.8 dB. The data which defines the stability of BBC in buck mode with PID and PIDN control loops is extracted from bode plots of analog domain which is shown in Fig. 13 and is tabulated in Table 6. Similarly, the data which defines the stability of BBC in buck mode with PID and PIDN control loops is extracted from bode plots of digital domain which is as shown in Fig. 14 and is tabulated in Table 7. From digital control technology, it is known that delay in control loop is more compare to analog control loop which offers minimum delay in loop, since the delay offered by ADC and DPWM is more in digital control that results in minimum control loop band [17,18]. In hybrid renewable energy harvesting where power control system is used, the closed-loop control bandwidth plays an important role in the determination of sensitivity of power conditioning unit for transients which occur during switching instants [19][20][21]. But for the practical realization of advanced control algorithms cannot be possible with analog control systems. In addition to its environmental issues, it causes aging effects for analog control systems [22][23][24][25].
Using digital control systems, logic as well as input and output parameters can be easily modified as and when required [26]. Based on this knowledge, observing the data taken from analog and digital domain control of BBC through bode plots and listed in Tables 6 and 7. Digital control loop offers more delay margin than analog control loop because of sampling process by ADC and quantization process by DPWM blocks in digital control loop [26]. These issues can be addressed using special type of control techniques like deadbeat digital control technique where sampling takes place for every switching cycle w.r.t. current considered as input to the loop from power stage [27]. There is a one more technique where multi-sampling of current is done by executing the control algorithm at frequency twice that of the converter frequency. This technique reduces DPWM delay for the maximum extent [28] (Fig. 15).  Fig. 16d. From the figure, it is clear that the BBC in buck mode is stable with various damping factors and overshoots in open-loop control as well as in closed-loop control with PIDN but not with PID control. One zero of PID is lying outside the unit circle since PID amplifies ripples along with load signal that will dilute the expected duty cycle of control signal in charging mode(buck mode). This issue is solved by PIDN control.

Conclusion
Control loop gains of BBC in both analog and digital domain are characterized using bode plots and pole-zero plots and found to be less than unity, and it is much better with PIDN control law which filter out the noise due to switching exits in load signal. Loop gain factor indicates that the system is stable with analog and digital control loops that results in good reliability of the system. Mathematical modeling is the key factor to develop stability and dynamic response analysis and correction can be incorporated for desired stability and dynamic response. Transfer functions of power stage are made to develop control loops which are implemented on digital signal processor (DSP) for the control of BBC prototype. Further with same transfer function models of power stage, control algorithms like, adoptive PID, fuzzy logic with PIDN, model predictive control, intermediate control, neuro-FPGA and machine learning can be used to develop digital control loops which makes the control loop as smart control loop in digital control technology for power converters.