Real-Time Harmonic Optimization in Multilevel Inverter Using Artificial Neural Network (ANN)

— Multilevel inverters (MLIs) are increasingly used in real time applications. Among several pulse width modulation (PMW) techniques currently deployed for the control of MLIs, selective harmonic elimination PWM (SHEPWM) technique arguably gives the best performance due to its direct harmonic mitigation capability. However, real time application of SHEPWM technique is presently infeasible due to the heavy computational cost involved in solving the transcendental nonlinear equations known as selective harmonic elimination (SHE) equations, which characterize the harmonics that are selected for elimination or mitigation. This paper presents a two-stage approach to the online generation of switching angles that mitigate selected lower-order harmonics in multilevel inverters. The first stage involves an offline solution of SHE equations using ant colony optimisation (ACO). In the second stage, ACO computed results are used to train an artificial neural network (ANN) predictive model. The results obtained from the simulation of the proposed method in MATLAB/SIMULINK environment show that the method is highly efficient and accurate.


I. INTRODUCTION
Due to their ability to synthesize an almost sinusoidal output voltage with low harmonic distortion from several dc input voltages, multilevel inverters (MLIs) are widely used in many applications such as distributed generation (DG), flexible ac transmission systems (FACTS), high voltage direct current (HVDC) transmission, adjustable speed drives (ASD) and utility [1]. With the increasing use of MLIs, more stringent operational requirements are made among which is the real time operation of MLIs over a wide range of modulation index. This development is attributable to the advancements made in digital signal processing (DSP) as well as the advent of high-power semiconductor devices with fast switching capability.
Several multilevel inverter topologies such as diode clamped topology, which is based on neutral-point-clamped inverter [2], flying capacitor topology introduced by Meynard and Foch [3], cascaded H-bridge (CHB) topology [4] as well as numerous hybrids of these topologies have been developed to suit various applications. Many of the switching algorithms traditionally used for two-level inverter such as sinusoidal PWM (SPWM), selective harmonics elimination PWM (SHEPWM) and space vector PWM (SVM) have been modified and deployed for multilevel inverter control [5], [6]. Compared with the other PWM techniques, SHEPWM technique at fundamental switching frequency has many advantages among which are: high-quality output spectra, low switching losses and the ability to take advantage of circuit topology by leaving triplen harmonics uncontrolled in three phase systems. In SHEPWM technique, the relation between the modulation index and switching angles is given by the solution of SHE equations, which are transcendental and nonlinear in nature. SHE equations are solved in such a way that the fundamental harmonic is obtained as desired while the selected low order harmonics are eliminated or minimized. The major drawback of the SHEPWM technique is the heavy computational cost in terms of time and memory. This is due to the difficulty involved in solving SHE equations that contain trigonometric terms [7].
Several methods of solving SHE equations that have been reported in the literature can be classified into two groups based on the adopted approach. The approach of the first group is based on the use of the analytical method and it comprises of Newton Raphson (NR) iterative method [8], resultant theory [9] and Walsh function [10]- [12]. These methods are very fast provided that the arbitrarily chosen initial values are sufficiently close to the roots. The approach of the second group is based on the use of nature-inspired algorithms such as genetic algorithm (GA) [13], [14], firefly algorithm [15], ant colony optimization (ACO) [16], particle swarm optimization (PSO) [17], [18], and artificial bee colony (ABC) algorithm [19]. These optimization techniques are able to find available solutions irrespective of the closeness of the initial values to the roots but they are relatively slow.
Presently, real time computation of optimal switching angles for SHEPWM technique is not feasible as none of the existing methods is fast enough to solve SHE equations in real time. However, in order to overcome this limitation, a method known as programmed SHEPWM is increasingly used in multilevel inverter applications that require online generation of switching angles. In this method, the offline solution of SHE equations obtained with either analytical method or nature inspired algorithm are stored in look-up tables [7]. Although programmed SHEPWM is simple to implement, a large amount of memory is required to store all the precalculated switching angles.
This paper presents an artificial neural network (ANN) based predictive model for the real time generation of switching angles in multilevel inverter controlled with SHEPWM technique. The dataset used for the training, testing and validation of the ANN predictive model is the offline solution of SHE equations of an 11-level inverter obtained with SamACO, which is a variant of the ant colony algorithm (ACO). This is a nature-inspired algorithm that is based on the food foraging behavior of ants in a colony. An in-depth review of SamACO can be found in [20] and its application for solving SHE equations is detailed in [21].

A. Cascaded H-bridge Multilevel Inverter Structure
Compared with the other aforementioned topologies, Cascaded H-bridge (CHB) topology is arguably the most widely used due to its fewer components' requirement, modularity and circuit layout flexibility [6]. Additional advantage of CHB is that it has neither the clamping diodes problem experienced in the diode clamped topology nor the voltage-balancing issue that limits the use of flying capacitor topology. In CHB multilevel inverter, Each H-bridge consists of four unidirectional switches usually realized with IGBT and a separate DC source (SDCS) as shown in Fig. 1.  By a different combination of switching states of the unidirectional switches in H-bridge cell, each cell generates three voltage levels as shown in Table I. The synthesized output phase voltage of CHB multilevel inverter is the summation of square wave voltages from the individual H-bridge cells connected together in the same phase with each cell having a different duty cycle [12], [13].
With the increasing number of H-bridges, the synthesized voltage waveform approaches sinusoidal with THD that tends towards zero. For the S-number of H-bridges connected in cascade per phase, the number of output-phase voltage levels is given by (1).

B. Mathematical Model of SHEPWM
In SHEPWM controlled inverters, the switching instances in successive cycles are determined in such a way that the predominant lower order harmonics are either eliminated or minimised while the output voltage is obtained as desired by varying the width of generated pulses. An added advantage of SHEPWM technique is that in a balanced three-phase power system, triplen harmonics can be left uncontrolled as they cancel out in the line-to-line voltages. Due to the quarterwave symmetry in the staircase output voltage waveform, even harmonics also cancel out leaving only the predominant non-triplen odd harmonics to be eliminated.
Using Fourier series expansion [22], the multilevel inverter staircase output voltage waveform shown in Fig. 2 can be resolved into its fundamental component and non-triplen odd harmonic (2).
Where, S is the number of SDCS which is also the number of switching angles and n is the harmonic order. Generally, for S number of switching angles, one switching angle is used for the desired fundamental output voltage V1 and the remaining (S-1) switching angles are used to eliminate the predominant lower order harmonics that are close to the fundamental component in magnitude. From (4), the expression for the fundamental output voltage V1 is given in (5). Where; A parameter that defines the relation between the prevailing fundamental voltage and the maximum obtainable fundamental voltage V1max is called modulation index and it is defined as the ratio of the prevailing fundamental output voltage V1 to the maximum obtainable fundamental voltage V1max.
From (6), the maximum obtainable fundamental voltage is gotten when all the switching angles are zero [8]. Thus, It is found from the literature that 11-level inverter gives optimal performance. Lower level inverters are mostly unable to meet IEEE-519 standard while higher level inverters suffer from narrow range of modulation index, cost and complexity [8], [18]. From (1), five SDCSs are required to develop an 11level cascaded H-bridge inverter. From (4), (6) and (7), SHE equations for obtaining the modulation index and optimal switching angles in an 11-level inverter are given in (8) - (12). V5, V7, V11, and V13 in (8), (9), (10), (11) and (12) are set to zero to in order to eliminate 5 th , 7 th , 11 th and 13 th harmonics respectively.
Generally, the expression for the optimal switching angles in terms of the modulation index can be written as Equation (13) is the compact form of SHE equations. The quality of the multilevel inverter synthesized output voltage is measured in terms of the harmonic content using total harmonic distortion (THD) as the performance evaluation metric. In event of the same modulation index having multiple solution sets, the solution set with the least THD is chosen. The expression for computing THD is given in (14).

C. Artificial Neural Network (ANN)
Artificial neural network (ANN) is a parallel data processing model inspired by the study of biological neurons in human brain. It comprises of nonlinear and adaptive processing units called neurons, which are highly interconnected by adjustable weights [24]. ANNs are able to achieve complex and non-linear input/output mapping without prior knowledge of the mathematical model that relates the input and output data together. ANNs are flexible enough to interpolate and extrapolate results even if the data used for training are incomplete and noisy. This capability of learning and generalization makes them to be suitable in the area of prediction, pattern recognition and classification.
In ANNs, each artificial neuron is represented by a circular node. The inputs to the ANN are supplied through the first layer of nodes called the input layer while the outputs of the ANN are taken from the last layer of nodes called the output layer. These two layers are connected together by a single layer or multiple layers of nodes called hidden layers that are not directly accessible from outside. A typical feedforward multilayer ANN with n-k-p configuration is shown in Fig. 3 where n, k and p are the number of nodes in the input, hidden and output layers, respectively.
There are two basic steps involved in the supervised learning or training process of a typical multilayer feedforward ANN: input/output matching and back propagation of errors. In the first step that is called propagation, there is successive forward matching of the inputs to the corresponding outputs in the training algorithm. In the second step, there is comparison of the processed output value with a target output value. The difference in the compared values is the error signal. Using the error signal, the network then adjusts its weights and bias in accordance with a learning rule. This process is repeated until termination conditions are satisfied.
Each neuron of ANN can be mathematically modeled as shown in Fig. 4. The modeled k-th neuron has m input signals 0 , . . . . 4 that are normally continuous variable. Each of the inputs 0 is multiplied by an associated adjustable scalar weight 0 , which can be positive or negative corresponding to acceleration or inhibition of the flow of signals. The weighted input data signals are then summed with a bias and passed through a nonlinear activation function, which is generally sigmoid, inverse tan, hyperbolic, Gaussian or linear. The activation function either fire or remains inactive depending on the threshold of the signal supplied to it.  The mathematical expressions for the modeled k-th neuron with m inputs are shown in (15) and (16). The error signal of the k-th neutron at instant n is shown in (17).
Where 5 ( ) and 5 ( ) are the desired output and the predicted output of the k-th output neuron, respectively.
The choice of parameters used in ANN is a trade-off between computational cost and performance. The configuration of an ANN has to be chosen in such a way that optimal performance is achieved with an adequate number of neurons and hidden layers. Excessive use of hidden layers and neurons results in overtraining. However, if the number of hidden layers/neurons used is low, there will be an insufficient generalisation. A rule-of-thumb approach to the choice of ANN configuration is the training and evaluation of the performance of ANN with the increasing number of neurons in the hidden layer. Generally, training of ANNs is time-consuming but they are fast to run and can easily be implemented once trained. ANNs have the potential to replace look-up tables in real-time applications since the weights are easily retrievable when stored in the flash memory of the microcontroller, Field Programmable Arrays (FPGAs), or Digital Signal Processor (DSP).

III. IMPLEMENTATION
The dataset used for the training, testing, and validation of the ANN model is the offline solution of the SHE equations in (8) - (12) that was computed with the SamACO algorithm. In order to avoid bias and early termination, the dataset was randomly divided into 70%, 15%, and 15% for the training, testing, and validation of the proposed ANN model, respectively.
The ANN topology chosen for the development of the switching angles prediction model is a multilayer feedforward ANN with a backpropagation learning algorithm. The topological structure of the chosen ANN model consists of a single-neuron input layer, a twentyneuron hidden layer with scalar weights, biases, and tangentsigmoid activation function, and a five-neuron output layer with scalar weights, biases, and a linear activation function. The network was trained using the Fletcher-Reeves variant of the back-propagation algorithm with SamACO as the teacher. The choice of parameters is a trade-off between computational cost and performance, and the parameters were chosen by trial and error. The eventually chosen parameters of the adopted ANN topology are detailed in Table II.
Simulations were performed in MATLAB/Simulink environment using a personal computer (2.11 GHz Intel Core i5 processor with 8.00 GB Random Access Memory and 930 GB Hard disk drive) running MATLAB R2021a on Windows 10.

IV. RESULTS AND DISCUSSION
SamACO computed solution sets and their corresponding THD values at various modulation indices are shown in Fig.  5 and Fig. 6, respectively. As shown in Fig. 5, there are some modulation indices with multiple solution sets. In such cases, the set with the least THD is chosen.
The plot of ANN predicted solution sets at various modulation indices after training is shown in Fig. 7.      Fig. 8 are the regression plots for the training, testing, validation and all of the ANN model.

Shown in
In order to evaluate the performance of the proposed ANN predictive model, simulation of an 11-level single-phase CHB inverter was performed in MATLAB/Simulink environment using ANN predicted solution set at a randomly selected modulation index 0 of 0.9. At the arbitrarily chosen modulation index 0 of 0. 9 Fast Fourier Transform (FFT) of the phase voltage waveforms simulated with ANN predicted solution set was performed and the harmonic spectrum is shown in Fig. 9.
Using (6), the analytical value of the fundamental output voltage V1 at the modulation index 0 of 0.9 is 68.79 (7895) . Thus, there is a close agreement between the analytically computed value of 68.79V and the simulation value of 68.71V that is shown in Fig. 9. As shown in the figure, the 5 ;< , 7 ;< , 11 ;< 13 ;< harmonics that are targeted for elimination are well attenuated.
The THD simulation value of 13.76%. shown in Fig. 9 includes the triplen harmonics, which are present in phase voltage. However, in line-to-line voltage of a balanced threephase system, the triplen harmonics will automatically cancel out and the THD value becomes 3.67%.

V. CONCLUSION
An ANN predictive model is proposed for the real-time generation of optimal solution sets that eliminate targeted lower-order harmonics in multilevel inverters. The approach is based on the mapping of the relationship between modulation index and switching angles in a multilevel inverter using a feedforward artificial neural network. The dataset used for the training of the neural network is the SamACO computed offline solution of the transcendental and nonlinear equations that characterize the selected lower-order harmonics in an 11-level inverter. The trained network successfully generated solution sets for all values of modulation index including modulation indices where solution sets could not be found with the SamACO algorithm, which demonstrates the generalization capability of the ANN predictive model. The viability of the predictive model was demonstrated with the simulation of an eleven-level CHB inverter. Simulation results show that the solution sets predicted by the ANN model are optimal and accurate with the targeted harmonics well attenuated.