A Real-Time and Closed-Loop Control Algorithm for Cascaded Multilevel Inverter Based on Artificial Neural Network

In order to control the cascaded H-bridges (CHB) converter with staircase modulation strategy in a real-time manner, a real-time and closed-loop control algorithm based on artificial neural network (ANN) for three-phase CHB converter is proposed in this paper. It costs little computation time and memory. It has two steps. In the first step, hierarchical particle swarm optimizer with time-varying acceleration coefficient (HPSO-TVAC) algorithm is employed to minimize the total harmonic distortion (THD) and generate the optimal switching angles offline. In the second step, part of optimal switching angles are used to train an ANN and the well-designed ANN can generate optimal switching angles in a real-time manner. Compared with previous real-time algorithm, the proposed algorithm is suitable for a wider range of modulation index and results in a smaller THD and a lower calculation time. Furthermore, the well-designed ANN is embedded into a closed-loop control algorithm for CHB converter with variable direct voltage (DC) sources. Simulation results demonstrate that the proposed closed-loop control algorithm is able to quickly stabilize load voltage and minimize the line current's THD (<5%) when subjecting the DC sources disturbance or load disturbance. In real design stage, a switching angle pulse generation scheme is proposed and experiment results verify its correctness.


Introduction
Multilevel converters have drawn tremendous research interest in recent years and have been implemented in several high-voltage and high-power applications. One of the multilevel topologies is cascaded H-bridges (CHB) configuration which needs several separated DC sources [1].
Various modulation strategies have been developed for CHB converter. Phase shifted PWM (PSPWM) and space vector PWM (SVPWM) are very popular methods in industrial applications [2]. Another important modulation method for CHB converter is the optimal PWM, which includes selective harmonic elimination PWM (SHE-PWM) and harmonic minimization strategies [3]. The main challenge associated with SHE-PWM technique is that a specified number of nonlinear equations must be solved to obtain the appropriate switching angles. Several analytical algorithms have been reported to solve these transcendental equations, such as iterative methods [4], theory of symmetric polynomials [5], and search optimization [6].
The harmonic pollution minimization in multilevel converter with staircase modulation strategy is often defined as a time-limited optimization problem in real-time applications. Modern evolution algorithms have also been used to determine the optimal switching pulses such as genetic algorithms (GA), particle swarm optimization (PSO) [7][8][9], shuffled-frog-leaping algorithm (SFLA), and Bee algorithm (BA) [10,11]. In [12], a generalized formulation for multilevel SHE-PWM converters for any number of levels and any number of switching angles with both equal and unequal DC voltage levels was reported. The limitation of quarterwave symmetrical waveform was relaxed, and half-wave [13] and nonsymmetrical waveforms [14] have also been reported. These papers assumed that the DC source levels do not vary with time. However, the DC voltage levels may vary with time in practice, and calculations methods 2 The Scientific World Journal based on this assumption are very time-consuming. They can only be done by a computer offline. The offline calculated optimal switching angles have to be stored in a look-up table. For every solution in each possible DC voltage level case, a considerable large look-up table would be required. Therefore, the above methods cannot be implemented in realtime manner due to the overhead of computations.
In [15,16], the authors developed a real-time algorithm to calculate the optimal switching angles. Although the resulted voltage THD is minimized, this iterative algorithm was complex. An alternate approach in which artificial neural network (ANN) is implemented was proposed to replace the look-up table and generate optimal switching angles [17]. However, this method still requires large memory to store numerous solutions and only open-loop control of CHB converter was considered.
In order to real-time-control the CHB converter with variable DC sources under staircase modulation strategy, a real-time and closed-loop control algorithm based on ANN for three-phase CHB converter is proposed in this paper. It needs little computation time and memory and has a good control capability of CHB converter. It has two steps. In the first step, HPSO-TVAC algorithm is employed to calculate the optimal switching angles offline. In second step, only 40 samples of optimal switching angles are used to train an ANN and design an ANN to generate optimal switching angles in a real-time manner. The designed ANN is easily embedded into the proposed closed-loop control algorithm. Simulation results demonstrate that the proposed closedloop control algorithm can quickly stabilize load voltage and minimize the line current's THD (<5%) subjecting to DC sources disturbance and load disturbance.
The rest of the paper is arranged as follows. In Section 2, harmonic distortion minimization problem of CHB converter is described. In Section 3, the principle of HPSO-TVAC is introduced and compared with other traditional evolution optimization algorithms. In Section 4, ANN is introduced and designed. The proposed ANN is also compared with previous real-time optimization method. In Section 5, a closed-loop control algorithm for CHB converter is proposed, and the simulation results are given to demonstrate the performance of the proposed method in the presence of DC sources disturbance and load disturbance. In addition, the switching angle pulse generation issue is considered in real design stage. Finally, Section 6 concludes the paper.

Harmonic Minimization Problem
Figure 1(a) shows the structure of a three-phase CHB converter. Each unit has its own separated DC source with a variable voltage level. Figure 1(b) also shows that the ac terminal output phase voltage is synthesized by the sum of H-bridge voltages; that is, V an = V dc1 + V dc2 + ⋅ ⋅ ⋅ + V dc . Each full bridge can generate three different voltage levels: V dc , 0, and −V dc . The number of the levels of output phase voltage in this topology is = 2 +1, where is the number of the DC sources. In the half-cycle waveform, the switching angles set ( 1 , 2 , . . . , ) is symmetrically arranged. The next half-cycle waveform is similar, but with a negative sign.
The Fourier series expansions of the generated output phase voltage V an are Owing to the quarter-wave symmetry of phase voltage, only odd harmonics are presented in V an ( = 0). The amplitude of the th harmonic is expressed only with the first quadrant switching angles 1 , 2 , . . . , where is the number of variables corresponding to switching angles 1 ∼ of the first quadrant; dc is the rated DC voltage level.
In the traditional SHE-PWM method, was assigned as the desired value for fundamental component and equated to zero for the harmonics to be eliminated. Nonlinear transcendental equations were formulated and solved by analytical algorithms. As mentioned, reliability of the results of these nonlinear equations severely depends on the initial guess, and solutions were not available at some points.
In order to avoid these problems, another method is applied to convert the SHE-PWM problem into an optimization problem. In this method, the objective function is to minimize a quality factor such as total harmonic distortion (THD) or distortion harmonic index (DHI). In this study, THD up to the 49th harmonics order is considered as the objective function. The voltage THD is formulated as The voltage THD is considered as the objective function ( ) in the evolution algorithm. Hence, the minimization problem and its constraints can be represented in a mathematical form as follows: Min ( ) = THD% Sub.: 0 < 1 < 2 < ⋅ ⋅ ⋅ < < 2 ; where is the amplitude of the desired fundamental component, 5 , 7 , . . . , 49 are the allowable limits of individual harmonics mandatory required by Grid Standards [18]. The triple harmonics do not exist in three-phase power system. In this study, a novel PSO is employed to optimize the objective function as described in Section 3.
The Scientific World Journal

Self-Organizing Hierarchical Particle Swarm Optimizer with Time-Varying Acceleration Coefficients
In this section, self-organizing hierarchical particle swarm optimizer with time-varying acceleration coefficient (HPSO-TVAC) is introduced [19] and applied to solve the above harmonic minimization problem. In addition, a comparison with traditional evolution optimizers, such as GA, SFLA, and BA, indicates that HPSO-TVAC gives the best solutions in a wide range of modulation index.

Basic PSO.
The basic PSO initiates a random initialization of a population of particles in the search space. Each particle is a potential solution for the optimization problem and tries to search the best position in the total search space. The social behavior of particles that was modeled in the PSO algorithm is used to find the global best solution by simply adjusting each particle's velocity according to its own flying experience and adjusting each particle's position according to the other particles' flying experience. Each particle is described in the -dimensional search space by the position vector = [ 1 , 2 , . . . , ] and the velocity vector In the swarm, the best position of each particle found so far (refer to the optimum fitness function value of each particles) is defined as local best position and is denoted by = [ 1 , 2 , . . . , ], and the global best position of the swarm found so far (refer to the optimum fitness function value of all particles) is denoted by ]. Then, the new velocity of the th particle on the th dimension is updated by using (5) and the position of each particle is updated by using (6): Update position vector x ij as equation (6) v ij (t + 1) = r 4 × V max Calculate new velocity vector v ij as equation (8) Dimensional number j = 1 Update the global best position vector P g and local best position vector P i particle in equation (4) Particles number i = 1 Iter number index = 1 and velocity vector within V max and V min of all particles dimension Particle number n, dimensional number d, maximum iteration number Initialize the switching angles 1 ∼ d randomly between 0 and /2 Iter number = Iter max? iter max , initial and final cogitative and social coefficients 1i / 1f / 2i / 2f Evaluate the cost function F( ) for each where 1 and 2 are constants known as cogitative and social coefficients, respectively; 1 and 2 are random values uniformly distributed within [0, 1]. V ( ) is the previous velocity term. The constriction factor is used to promise the convergence of the algorithm and defined as Typically, is set to 4.1, and the constriction factor is set to 0.729 [20].

Harmonic Minimization Using HPSO-TVAC.
Even though the basic PSO is capable of locating a good solution at a fast rate, its ability to fine tune the global optimum solution is comparatively weak, which is mainly due to lack of diversity at the end of search progress. Thus, HPSO-TVAC is used to solve this problem.
In this novel PSO strategy, the previous velocity term V ( ) in (5) is made zero, and particles rapidly rush towards a local optimum point because of lack of momentum. When a particle stagnates, its local best position remains unchanged for a number of iterations. When all particles stagnate, the algorithm converges prematurely to a local optimal point and global position remains unchanged and V becomes zero. In order to provide the required momentum for particles to find the global optimum solution in this case, the velocity vector of a particle is reinitialized with a random velocity. In this algorithm, the new velocity of the th particle on the th dimension is updated as follows: if V = 0 and 3 < 0.5 1 and 1 are initial and final cogitative coefficients; 2 and 2 are initial and final social coefficients; iter and iter max are current number of iterations and maximum number of iteration; 1 ∼ 5 are randomly numbers between [0, 1]; max is the maximum velocity value.
Thus, a series of particle swarm optimizers are generated inside the main PSO algorithm until the convergence criteria are reached. More details about the HPSO-TVAC were presented in [19]. Appling HPSO-TVAC to the harmonic minimization problem described in above section, the procedure is presented in Figure 2, and the results of optimal switching angles are presented in Figure 3.

Comparison of Traditional Evolution Optimizer.
In order to illustrate the efficiency of the applied approach, a comparison between other three evolution optimizers including GA, SFLA, and BA is performed at five operating points of CHB converter. The parameters of these traditional evolution optimizers are set the same as HPSO-TVAC for fair comparison. The operating point is described by the desired modulation   index * which is defined as normalized value of the desired fundamental component. * is given as follows: * = dc .
(10) Table 1 shows the parameters of HPSO-TVAC and other three evolution optimizers. The number of switching angles is set to five ( = 5) and five equal DC sources ( dc = 20 V) are considered in the case. The inequality constraint limits ( 5 , 7 , . . . , 49 ) in (4) are also shown in Table 1. Table 2 depicts the calculated switching angles 1 ∼ 5 and the resulting THD by each method. THD is computed for harmonics up to 49 orders. Table 3 shows the resulting THD and the variance of THD by each method running 10 times at five operating points ( * = 0.4, 0.5, 0.8, 1.0, 1.1).
According to Tables 2 and 3, HPSO-TVAC method produces the smallest THD and the smallest variance of THD in 10 times running. This means that HPSO-TVAC can provide the most stable solution in a wide range of modulation index. In real-time design application, a stable algorithm  is important to avoid losing solutions in some operating points and to produce a continuous solution trajectory. The applied approach is more stable and more effective than GA, SFLA, and BA optimizer in harmonic pollution minimization problem.

Artificial Neural Networks
ANN is a powerful tool to control a nonlinear system that is very complex in nature. A well-designed ANN can be used to replace the look up table and to generate optimal switching angles in a real-time manner [21].

Structure of ANN.
ANN consists of a number of fundamental elements named neurons that are organized in several layers. Every neuron has an input vector with inputs. The neuron multiples input vector by a weight matrix and is summed with a bias vector . Then a transfer function is applied on the above results, which produces the output vector of the neuron ( + ) [22,23]. A typical two-layer feed-forward network shown in Figure 4 with sigmoid hidden neurons and linear output neurons can fit multidimensional mapping problems arbitrarily well. There are inputs and vectors in an input layer, 1 sigmoid hidden neurons in hidden layer, and 2 linear output neurons in output layer. The weight matrix of th layer with neurons is a × −1 matrix. The bias vector of th layer is a × 1 one and the produced output vector is a × 1 one as well. For the hidden layer, size of 1 is 1 × .
The procedure of determination of the weight and bias matrix is named training. In training's iteration process, weight and bias matrices are updated according to previous matrices and a set of desired outputs for specified inputs. Although there are various training algorithms for training neurons network in literatures, the Levenberg-Marquardt where is the weight and bias variables matrix, ( ) is the error between the desired outputs and the actual outputs of current network, ( ) is the Jacobin matrix that contains the first derivatives of ( ) with respect to , and is the identity matrix. The adaptive parameter is increased by a specified value in [0, 1] until the performance function (mean-squared error) reaches an acceptable value. The original data set is divided into three subsets: training, validation, and testing. The first subset is for the network training and the network is adjusted to its error. The second subject is used to measure network generalization and to halt training when generalization stops improving. The third subset provides an independent measure of network performance during and after training. The proportion of the data sample adopted in this work is 70% for training, 15% for validation, and 15% for testing.

Implementation of ANN.
In order to train ANN, a set of input samples and desired outputs samples are required. In harmonic minimization problem, the inputs are modulation index and the outputs are optimal switching angles obtained by the above HPSO-TVAC. As the modulation index * value is a continuous variable in [0.4, 1.2], a limited number of * in this range are sampled. In this paper, only 40 samples are selected in [0.4, 1.2] at 0.02 interval. An ANN with 10 sigmoid neurons in hidden layer and 1 linear neuron in output layer is established to simulate the interpolation fitting problem.
As Figure 5 illustrates, the mean-squared error (MSE) is below 10 −6 for training, 10 −4 for validation, and 10 −4 for testing with 17 iterations. The regression value which measures the correlation between outputs and targets for training, validation, and testing is 0.99997, 0.99996, and 0.9995, respectively. Table 4 shows the maximum error and the average error between the results generated by ANN and the results calculated by HPSO-TVAC for all angles in different modulation index * . In any modulation index value in [0.4, 1.2], compared with the results using HPSO-TVAC, the maximum and average error for all switching angles using the proposed ANN method are below 10 −3 and are acceptable. It means that the well-designed ANN trained by 40 samples can produce almost the same optimal switching angles as the HPSO-TVAC method in the whole modulation index range. On one hand, when any DC source value varies, HPSO-TVAC algorithm must be implemented again and new switching angles must be calculated and stored in look-up tables. Look-up tables will increase dramatically when more than one DC source value change. However, the proposed ANN method can adaptively produce the optimal switching angles regardless of DC source values change. This feature is shown in the next section.
On the other hand, the computation time to produce optimal switching angles for a well-designed ANN is about 2 ms, while for HPSO-TVAC it is 0.8 s. Hence a well-trained ANN is a superior substitute for look-up tables in real-time control applications.

Compared with Previous Real-Time Algorithm. Liu et al.
in [15] proposed the first real-time THD minimization algorithm for CHB converter with staircase modulation. The flow chart of this algorithm is shown in Figure 6. This method is based on the Newton-Raphson (N-R) iterative algorithm to minimize the voltage THD. There are two steps in this algorithm.
The first step is to determine the parameter by solving the following equation: where is the given modulation index, is the H-bridge number, and DC sources levels are V dc1 ∼ V dc . Using the N-R iterative algorithm, this nonlinear equation can be solved. In the flow chart, is a calculated modulation index during the iteration. If the difference between and is small enough (< ), the iteration will end and the resulting THD will be minimum. is the threshold value 10 −5 .
Taking the above five-stage 11-level CHB converter ( = 5) as an example, the calculated THD of the proposed method and Yu's method is compared and shown in Figure 7. The  calculation time determined by the proposed method and Yu's method is also compared and shown in Figure 8.
It can be seen that the previous real-time algorithm produces almost the same optimal switching pulses and voltage THD value as the proposed method does. However, the previous method is only suitable for a small range of modulation index ([0.65-0.98]). The proposed algorithm is suitable for a wider range of modulation index ([0.4-1.2]).  In addition, the proposed method results in a smaller THD and a lower calculation time, compared with the previous one. The reason is that the N-R iterative algorithm is inherently sensitive to initial values. It may lose solutions in some operating points and cost more time to search for solutions in the iteration process. Table 5 shows the cost time and memory for several methods in one running. The traditional method must store solutions for every possible operating point and the resulting memory is very large. The proposed method is adaptive and the needed memory is small. Therefore, from the point of view of the voltage THD and real-time implementation, the proposed method is better than the previous method.

The Proposed Closed-Loop Algorithm
The closed-loop control algorithm for three-phase CHB converter is always designed at high switching frequency (>5 k) with PSPWM or SVPWM modulation strategy. Although the classical two-loop control structure with PI controller has good dynamic performance, this high frequency method suffers high switching loss and requires many strictly equal DC sources. In this paper, a closed-loop control algorithm based on ANN for CHB converter is proposed.

Closed-Loop Control Algorithm Based on ANN.
As shown in Figure 1(a), the three-phase load is balanced and the load line-voltage V is sampled to keep constant load voltage. The block diagram of proposed closed-loop control algorithm is shown in Figure 9. A Fourier block is used to calculate the fundamental component in load line-voltage V . The error between the desired line-voltage and the calculated one is fed to a simple PI controller. The PI controller is used to adjust the modulation index * and ANN is used to generate optimal switching angles 1 ∼ 5 online. Pulses block is used to generate switching signals to driven H-bridges. In order to investigate the proposed closed-loop control algorithm, a test bench shown in Figure 1(a) is constructed in MATLAB/Simulink software. Table 6 shows the 11-level CHB converter's parameters. Figure 10 shows the CHB converter's steady state output linevoltage 1 1 . Figure 11 shows the three-phase load current. Harmonic analysis shows that THD of the load current is small (0.81%). The above results indicate that the proposed algorithm is effective to minimize load current's THD.

Dynamic Analysis.
In real-time control applications, closed-loop control algorithm must be used to quickly stabilize load voltage and avoid current pollution when subjecting to DC sources disturbance or load disturbance. In this study, two cases are used to test the performance of the proposed closed-loop control algorithm. The proportional gain in PI controller is 1 and integral gain is 100. The sampling frequency is 10 kHz.
In Case 1, load disturbance is applied on CHB converter. The load steps form half load to full load at = 1.0 s. Figure 12 The Scientific World Journal shows the corresponding line-current response. The THD of load current before and after the disturbance is 2.21% and 0.81%. Figure 13 shows the corresponding RMS of linevoltage response. Figure 14 shows the corresponding optimal switching angles response. The transient recovery time is about 0.2 s.
In Case 2, DC sources disturbance is applied on CHB converter. The first DC voltage level V dc1 in each phase changes from 20 V to 30 V at = 0.5 s. The third DC voltage level V dc3 in each phase changes from 20 V to 10 V at = 0.75 s. Figure 15 shows the DC voltage disturbance. Figure 16 shows the corresponding line-current response. Although the multilevel structure is considered asymmetric in this condition, the current is still balanced and has a low THD value (1.69%). Figure 17 shows the corresponding RMS of line-voltage response. Figure 18 shows corresponding optimal switching angles response.
The above results show that the proposed closed-loop control algorithm is effective to stabilize load voltage and minimize the line current's THD when subjecting to dynamic  disturbance, such as DC sources disturbance and load disturbance. Especially, when the multilevel structure is considered asymmetric, the current is still balanced and avoids harmonic pollution. The CHB converter does not need many strictly equal DC sources by this algorithm, avoiding the drawbacks of traditional PSPWM or SVPWM control algorithm. The proposed closed-loop control algorithm has good control capability of CHB converter.

Real Design Issue.
In real design stage, hardware implementation issue of RBF neural network and switching angles pulse generation must be considered. As the modern DSP and FPGA device's computation capability and memory increase, RBF neural network can be implemented on embedded systems. Lots of technique reports proposed various methods to address this issue [24,25]. Thus, this section considers only the switching angles pulse generation issue.
The pulse generation can be implemented by TI DSP 28335's ePWM module. The time-based counter produces a saw-tooth waveform with a period . The voltage's fundamental period is . The switching angle is represented by an interval Δ . The corresponding switching signal 1 ∼ 4 for four power switches 1 -4 in one Hbridge of CHB converter can be generated as shown in Figure 19. The H-bridge's output voltage is V . The high voltage level in ( = 1, 2, 3, 4) means that the corresponding switch is turned on and low voltage level means that the corresponding switch is turned off.
The turn-off time and the turn-on time for 1 are located at 3 th and 4 th saw-tooth in interval , respectively. They can be determined by Δ 3 and Δ 4 given as follows: The turn-off time and turn-on time for 3 are located at 1 th and 2 th saw-tooth in interval , respectively. They can be determined by Δ 1 and Δ 2 given as follows: The signals, 1 and 2 , 3 and 4 , have opposite polarity to avoid simultaneous conduction of the upper and lower switch. As shown in Figure 19, the high level width in V is directly related to switching angle . Thus, five different width pulse voltages can synthesize the ac terminal output phase voltage V an shown in Figure 1(b). When the saw-tooth waveform's period is smaller, the pulse generation is more accurate.
The three-stage 7-level CHB converter's experimental output phase voltage is shown in Figure 20. The five-stage 11level CHB converter's experimental output phase voltage is shown in Figure 21.
is 0.02 s for 50 Hz signal. is 20 s. Although pulses generation principle for only one operating point is given, the switching angles for other operating points can be generated similarly. The experimental results verify the proposed pulse generation scheme.

Conclusion
The contribution of this paper is that a real-time, closedloop control algorithm based on ANN for three-phase CHB inverter is proposed. It costs little computation time and   memory to generate optimal switching angles and has a good control capability of CHB converter. Compared with the previous real-time optimal switching angles method, the proposed one needs little computation time and can produce better solutions in a wide modulation index [0.4-1.2]. Moreover, the proposed algorithm is closed-loop and able to quickly stabilize load voltage and minimize the line current's THD subjecting to DC sources disturbance and load disturbance. In addition, a switching angle pulse generation scheme is proposed and experiment results verify its correctness.