*Article* **Machine Learning Approach for Modeling and Control of a Commercial Heliocentris FC50 PEM Fuel Cell System**

**Mohamed Derbeli \*, Cristian Napole \* and Oscar Barambones \***

System Engineering and Automation Department, Faculty of Engineering of Vitoria-Gasteiz, Basque Country University (UPV/EHU), 01006 Vitoria-Gasteiz, Spain

**\*** Correspondence: mderbeli001@ikasle.ehu.eus (M.D.); cristianmario.napole@ehu.eus (C.N.); oscar.barambones@ehu.eus (O.B.)

**Abstract:** In recent years, machine learning (ML) has received growing attention and it has been used in a wide range of applications. However, the ML application in renewable energies systems such as fuel cells is still limited. In this paper, a prognostic framework based on artificial neural network (ANN) is designed to predict the performance of proton exchange membrane (PEM) fuel cell system, aiming to investigate the effect of temperature and humidity on the stack characteristics and on tracking control improvements. A large part of the experimental database for various operating conditions has been used in the training operation to achieve an accurate model. Extensive tests with various ANN parameters such as number of neurons, number of hidden layers, selection of training dataset, etc., are performed to obtain the best fit in terms of prediction accuracy. The effect of temperature and humidity based on the predicted model are investigated and compared to the ones obtained from real-time experiments. The control design based on the predicted model is performed to keep the stack operating point at an adequate power stage with high-performance tracking. Experimental results have demonstrated the effectiveness of the proposed model for performance improvements of PEM fuel cell system.

**Keywords:** machine learning; deep learning; artificial neural network; ANN; PEM fuel cell; modeling; control

### **1. Introduction**

Fuel cells (FC) are conversion devices which transform hydrogen into electrical energy through an electro-chemical process [1]. These are a trending research topic since their efficiency (more than 40%) is higher than other renewable alternatives such as wind turbines (≈25%) or photovoltaic systems (≈6–20%) [2]. As a consequence, several industries used FC for their applications like aviation [3], automotive [4] and maritime [5]. According to Wang et al. [6], the cutting-edge FC technologies that are currently under focus are polymer electrolyte membrane fuel cells (PEMFCs), solid oxide fuel cells (SOFCs), phosphoric acid fuel cells (PAFCs) and molten carbonate fuel cells (MCFCs). Among the several available types, PEMFC stands out due to its high efficiency, power density and durability [7].

A PEMFC is frequently built with membrane electrode assembly (MEA) that holds an anode and a cathode that are isolated by a proton conductive membrane [8]. The continuous hydrogen supply goes into the anode electrode while the cathode receives oxygen. As a consequence, protons and electrons are generated because of an oxidation reaction; the electrolyte exchange membrane allows the path division of these particles. The electrons move to an external electric circuit whereas the protons join the oxygen to output water [9]. To achieve a suitable system design in terms of efficiency, several PEMFC mathematical models had been developed in recent years to understand the main phenomena that can alter the device performance.

According to Fang, Di and Ru, PEMFC models are divided into operational mechanism and experimental data ones [10]. In regards to the first mentioned category, based on the

**Citation:** Derbeli, M.; Napole, C.; Barambones, O. Machine Learning Approach for Modeling and Control of a Commercial Heliocentris FC50 PEM Fuel Cell System. *Mathematics* **2021**, *9*, 2068. https://doi.org/ 10.3390/math9172068

Academic Editor: António M. Lopes

Received: 12 July 2021 Accepted: 25 August 2021 Published: 26 August 2021

**Publisher's Note:** MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations.

**Copyright:** © 2021 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https:// creativecommons.org/licenses/by/ 4.0/).

regime, these are divided into static and dynamic. Saadi et al. [11] studied three well known models used in static analysis such as the Amphlett et al. [12,13], Larminie and Dicks [14] and Chamberlin-Kim [15]. A simulation showed that the three approaches had different outcomes where the Amphlett produced the most accurate results with high complexity implementation as a downside (same disadvantage for Larmini-Dicks). Conversely, Chamberlin-Kim appeared to be the most simple one but with low precision. Contrarily, dynamic models are used in transient regimes where the double layer effect heads this condition. Often, this phenomenon is modelled as with an electrical capacitor that depends on the electrodes and individual stack features [16,17].

On the other hand, experimental methods comprise mechanisms such as fuzzy identification which has been carried by authors of [18]. In this study, the dehydration of a PEMFC was analysed through classification based on the knowledge from an operator over a FC. Results revealed that suitable nonlinearities like electrical features and uncertainties can be mirrored with linguistic rules, an essential feature of this tool [19]. However, one of the main disadvantages of fuzzy logic strategies is the computational requirement when features are increased and thus, rules are expanded [20]. Another different approach was used by authors of [21] where they employed support vector machine (SVM) based on data-driven for fault diagnosis in PEMFC. In spite of the high accuracy obtained, the disadvantages are related to dynamics that can happen in a short period of time such as switches that are unable to be shown by the proposed model. Additionally, in certain cases, SVM required high computational resources which is associated with the accuracy of the model to be trained [22].

Despite the disadvantages of the mentioned strategies, another approach is the usage of trend tools such as artificial neural networks (ANN). This algorithmic scheme is based on a biological approach of human brain neurons which have the capabilities of recognising, acquiring information, and self-adjusting according to past actions (this is also known as neuroplasticity) [23]. Recently, Nanadegani et al. [24] provided a PEMFC study based on ANNs to increase the output power with a multilayer perceptron (MLP). Therefore, in this study, an in-depth investigation was conducted with a commercial PEMFC to generate a spread variety of ANNs with the aim of finding a suitable configuration that can match the behaviour of the real PEMFC. After finding a proper ANN configuration, this was used as a plant for the calibration of neural control algorithm.

The controller used in this research is an artificial neural network proportional-integralderivative (ANN-PID) controller to track a reference current. Differently to conventional PID controllers, ANN-PID can self-tune its own gains with an inner mechanism based on simple ANN linked with Hebbs learning rule [25]. In this research, the ANN-PID has been contrasted with a conventional PID tuned with appropriate gains gathered in previous experiments.

The structure of this paper has been arranged as follows. Section 2 covers further explanation about the ANN methodology applied and its design, the data collection procedure for the ANN training, the precision of the trained ANNs, the control design, and the metric used to show the accuracy of tracking in later tests. Section 3 includes a contrast between the real PEMFC curves and the ones obtained with the chosen ANN with details about the temperature and humidity effect; additionally, this section ends with the control results of the ANN-PID (tuned with an ANN) that was embedded in a dSpace platform and contrasted with a conventional PID. Finally, Section 4 provides a summary of the most significant outcomes obtained along this study as well as future viewpoints of research.

#### **2. Materials and Methods**

#### *2.1. Artificial Neural Networks (ANNs) Model*

#### 2.1.1. Introduction to ANNs

ANNs have been considered as attractive and powerful tools to predict and approximate linear, nonlinear and even complex models, based only on input-output data mapping [26–28]. Actually, an ANN consists of input and output layers and at least one

hidden interconnection layer. A general architecture of ANN with *N*<sup>1</sup> inputs, *N*<sup>2</sup> outputs and *L* hidden layers is depicted in Figure 1.

**Figure 1.** Network graph of *N*<sup>1</sup> input units, *N*<sup>2</sup> output units and *L*-layer perceptron where each hidden layer contains *Mj* hidden units.

ANNs can manipulate information just like the human brain thanks to the computational features of their basic units (also called nodes or neurons) which take a set of inputs, multiply them by weighted values and put them through an activation function. The schematic structure of the *i*th hidden artificial neuron at the *j*th hidden layer can be depicted as Figure 2.

**Figure 2.** Structure of a single artificial neuron in a neural network.

There are several topologies of NNs in deep learning and they can be classified into two groups of algorithms. The first group contains the ones that were used for supervised deep learning problems such as fully-connected feed-forward algorithms (Multi-Layer Perceptron, Radial Basis Network, etc.), recurrent NNs algorithms (long short term memory, gated recurrent unit, gated feed-forward, etc.) and convolutions NNs algorithms (deep convolutional NNs, deep convolutional inverse graphics network, deconvolutional network, etc.). The second group contains the ones that were used for unsupervised deep learning problems such as restricted Boltzmann machine algorithms (deep belief network, deep Boltzmann machine, etc.) and ML auto-encoder algorithms (variational auto-encoder, denoising auto-encoder, sparse auto-encoder, etc.). However, since modelling the fuel cell is a supervised learning problem, different structures of feed-forward neural network perceptron (FFNNP) with back-propagation learning rule have been implemented in Matlab/Simulink*<sup>R</sup>* and Neureal Network ToolboxTM to predict the performance of a commercial fuel cell system (Heliocentris FC50).

2.1.2. Data Collection and Analysis

• **Data collection:** The first and the most important step in the supervised learning process is gathering the data. In other words, to carry out good training, vast amounts of real-world data (Big Data) is required since the more data we provide to the ML system, the faster the model can learn and improve. Besides, the collected dataset should be well distributed throughout the operation range so as to represent the behaviour of the fuel cell in each operating power point. To this end, a continuous triangular signal with a period of 15 s (7.5 s for each positive/negative slop) was built and supplied to the duty cycle of the boost converter so as to vary the stack current from the minimum to the maximum operating value. The selection of the period was made based on the characteristics of the fuel cell data acquisition software since it measures the data each 0.5 s. In other words, 15 samples in different operating current values will be measured fore each positive/negative slop. Figures 3 and 4 show, respectively, the Simulink blocks used to design the triangular signal and the generated signal. The maximum value of this signal (0.8) drives the fuel cell to operate at the highest current value [8–9A] where the minimum value (0.5) drives the fuel cell to operate at the lowest operating current [0.2–0.5A]. These values can be adjusted via the increase/decrease of the output load resistance value. We have avoided operating currents above 9A since the fuel cell used in this study (Heliocentris FC50) is occupied with a security system that turns off the fuel cell in case of higher currents/temperatures [29–31].

**Figure 3.** Triangular signal design.

**Figure 4.** Triangular signal output.

To obtain data for different operating conditions, variations in temperature, humidity, hydrogen and airflow are required. It should be noted that the fuel cell contains an integrated control system that not only controls the supplied hydrogen but also provides an option to set the fans of the fuel cell at the automatic mode. By using the auto mode, the fans will automatically control the temperature, the humidity and the supplied airflow. However, to provide large degrees of freedom, the auto mode option of the fans was not considered. Therefore, a database containing 20,512 samples for different operating current, temperature and fan power were recorded and presented in Figure 5. This latter also shows the influence of the air flow on the fuel cell performance but the effect of temperature is still not well presented. Therefore, a 3D graph that clearly shows the effect of both temperature and air flow on the stack performance is presented in Figure 6. According to this latter, it is shown that at low air flow (fans power = 10%), by varying the temperature from

25 °C to 43 °C the stack performance improves in the beginning, then becomes almost constant and finally, it deteriorates for higher temperatures. At medium air flow (fans power = 50%), the stack performance improves with increasing temperature. However, for higher temperatures only slight improvements occur since the membrane requires an additional amount of water content. Regarding the last case at which the air flow is set at its maximum value (fans power = 100%), the stack performance improves largely with a temperature increase from *T* = 25 °C to over 40 °C. It is noticed that even for higher temperatures, the stack performance is still improving and this is due to the well humidification provided by the fans.

**Figure 5.** *Istack*-*Pstack* and *Istack*-*Vstack* measured data of Heliocentris FC50 fuel cell; (**a**,**d**): polarisation curves when Fans Power = [10%, 20%, 30%] and for different operating temperature; (**b**,**e**): polarisation curves when Fans Power = 50% and for different operating temperature; (**c**,**f**): polarisation curves when Fans Power = 100% and for different operating temperature.

**Figure 6.** The Heliocentris FC50 stack power according to air flow and stack temperature.


#### 2.1.3. Designing the Network

Based on Figure 2, the output of the *h* (*j*) *<sup>i</sup>* hidden layer unit can be calculated as Equation (1) [36].

$$h\_i^{(j)} = f\_{act} \left[ \left( \sum\_{i=0}^{M\_j} w\_{i,j} \mathbf{x}\_{i,j} \right) + b\_i^j \right] \tag{1}$$

where, *j* = [1,2, . . . , *L*] refers to the *j*th hidden layer, *i* = [1,2, . . . , *Mj*] refers to the *i*th neuron in the hidden layer *j*, *Mj* = [*M*1,*M*2,..., *ML*] refers to the number of neurons at each layer, *<sup>x</sup>* <sup>∈</sup> <sup>R</sup>*<sup>m</sup>* are numerical inputs, *<sup>w</sup>* <sup>∈</sup> <sup>R</sup>*<sup>m</sup>* are weights associated with the inputs, *<sup>b</sup>* <sup>∈</sup> <sup>R</sup> are biases. *fact* is the activation function which is used to introduce nonlinearity into the output of the artificial neuron. Actually, this is important since most of data in the real world is nonlinear and the neurons should learn these nonlinear representations. There are many

activation functions that can be used in practice such as sigmoid, tanh, ReLu, etc. [37]. In this work a tansig function which is given in Equation (2) is used.

$$f\_{\text{act}}(\mathbf{x}) = \frac{2}{1 + e^{-2\mathbf{x}}} - 1 \tag{2}$$

By using Equations (1) and (2), the *kth* output layer unit can be calculated as Equation (3).

$$y\_k = f\_{\rm act}^{\rm out} \left[ \left( \sum\_{i=0}^{M\_L} w\_{i,L} h\_i^{(j)} \right) + b\_k \right] \tag{3}$$

where *k* = [1,2, ..., *N*2] and *f out act* is a linear transfer function or also known as *purelin*, its mathematical expression is given in Equation (4)

$$
overline{\bf x}(\mathbf{x}) = \mathbf{x} \tag{4}$$

To train the FFNNP, several optimisation algorithms can be used to minimise the performance function (also known as loss/cost function) [32,38–40]. These algorithms use either the Jacobian of the network errors or the gradient of the network performance. Both Jacobian and gradient are computed via the back-propagation algorithm which is an efficient computational trick for calculating derivatives inside the deep feed-forward NNs. In this work, we made a comparison study among the four major used algorithms including the Levenberg–Marquardt (LM), Bayesian regularization (BR), BFGS quasi-Newton and Scaled conjugate gradient (SCG). For each training algorithm, the following basic system training parameters are used: maximum number of epochs = 5000, learning rate = 0.01, performance goal = 0, time of training = Infinity. All these parameters were checked for different number of neurons and hidden layers as presented in Table 1.

**Table 1.** Mean squared error of different FFNNP structures/algorithms.


The performance of each training algorithm was measured via the mean squared error (*mse*) which is given in Equation (5), where *y*∗ *<sup>i</sup>* is the desired output (target), *yi* is the actual (predicted) output, and *N* is the number of dataset.

$$F = mse = \frac{1}{N} \sum\_{i=0}^{N} (e\_i)^2 = \frac{1}{N} \sum\_{i=0}^{N} (y\_i^\* - y\_i)^2 \tag{5}$$

The best performance, in terms of training time and mean squared error *mse*, of each algorithm is tinted with green colour (Table 1). The predicted output results as well as the error that corresponds to the best performance (green cells) for each training algorithm are respectively shown in Figures 7 and 8.

**Figure 7.** Predicted output results when using SCG, BFG, LM and BR.

**Figure 8.** Obtained training errors when using SCG, BFG, LM and BR.

According to these figures, it is clear that the BR training algorithm with the structure of 3 hidden layers and 30 neurons for each predicts the best output results in terms of accuracy, where the SCG shows the worst predicted results in comparison with the rest of the algorithms. In terms of time, the SCG shows the fastest training since it takes only around 11 s to predict the output while the BR needs around 6930 s. However, although the BR takes around 2 h for the training, it finally provides a highly accurate model which is one of the main goals of this study.

Figure 9 shows the regression plots which were used to validate the performance of the obtained trained model. According to this figure, it is clear that the predicted model is characterised by high accuracy since most of the data points fall along a 45 degree line, where the output is equal to the target. The goodness of the model also can be analysed via the R values which ranged between 0 (lowest accuracy) and 1 (ideal model). In our case, the accuracy of the obtained model is proven by the following R values: training, R = 0.99974, test, R = 0.99735 and all, R = 0.99938.

**Figure 9.** Performance analysis of the predicted model.

#### *2.2. PEMFC Control with ANN-PID*

#### 2.2.1. Control Design

Although PID control is one of the most used controllers in industries, it still suffers from systems sufficient nonlinearity which make its constant parameters not optimal in each operating moment. This is due to the difficulties of determining the parameters which are usually tuned via the conventional trial and error method. As a solution, we have designed a self-adaptive PID based feed-forward artificial neural network (ANN-PID) aiming to avoid parameters manual tuning. The input of the ANN-PID controller is the error *e*(*k*) which is achieved from the difference between the desired and actual PEMFC stack currents, and the output is the duty cycle signal *u*(*k*). The error is discomposed into three variables *xi* (*i* = [1,2,3]) similarly to the conventional PID, but they will be respectively associated with three weights *wi* which are self-tuned via the Hebb supervised learning rule method. The implementation of the of ANN-PID in the hardware system is explained in Figure 10.

**Figure 10.** Implementation of ANN-PID on Heliocentris FC50 hardware system.

The output of the ANN-PID controller Δ*u*(*k*) is given in Equation (6), where *k* is a positive parameter determined by the user, and the values of the three inputs *xi* are given in Equation (7).

$$
\Delta u(k) = k \sum\_{i=1}^{3} \mathbf{x}\_i(k) w\_i(k) = k(\mathbf{x}\_1(k) w\_1(k) + \mathbf{x}\_2(k) w\_2(k) + \mathbf{x}\_3(k) w\_3(k)) \tag{6}
$$

$$\mathbf{x}\_{i}(k) = \begin{cases} \mathbf{x}\_{1}(k) = \Delta \mathbf{e}(k) \\ \mathbf{x}\_{2}(k) = \mathbf{e}(k) \\ \mathbf{x}\_{3}(k) = \Delta \mathbf{e}(k) - \Delta \mathbf{e}(k-1) \end{cases} \tag{7}$$

The biological origin of Hebb's supervised learning was established from a neuroscience perspective: when two neurons are activated simultaneously, the link intensity (also called plasticity) is proportional to the multiplication of their stimulation [41,42]. Therefore, this concept can be translated mathematically for the adjustment of the PID parameters (*kp*, *ki* and *kd*) which can be obtained through a neural settlement of Equation (8) as Equation (8) shows, where *η<sup>i</sup>* are learning rates that correspond to *wi*(*k*) [43].

$$w\_{\bar{i}}(k) = w\_{\bar{i}}(k-1) + \eta\_{\bar{i}} x\_{\bar{i}}(k) u(k-1) \varepsilon(k) \tag{8}$$

Recently, it has been found that the weight values used for PID online regulation are mainly related to *e*(*k*) and Δ*e*(*k*) [44]. Hence, the inputs *xi*(*k*) of Equation (8) can be replaced by *e*(*k*) + Δ*e*(*k*). Finally, the running algorithm of the control law can be expressed as Equation (9).

$$\begin{cases} w\_i(k) = w\_i(k-1) + \eta\_i[\epsilon(k) + \Delta\epsilon(k)]u(k-1)\epsilon(k) \\ w\_i'(k) = \frac{w\_i(k)}{\sum\_{i=1}^3 |w\_i(k)|} \\ u(k) = u(k-1) + K\sum\_{i=1}^3 w\_i'(k)x\_i(k) \end{cases} \tag{9}$$

### 2.2.2. Metrics Used for Control Performance Improvement

To achieve high tracking performance, the minimisation of the integral of the absolute error (IAE), the root mean squared error (RMSE) and the relative root mean squared error (*RRMSE*), which are described by Equation (10), have been used to adjust and tune the gains of the controller, whereas the values can be determined by taking into account the error reduction in real time.

$$\begin{cases} IAE = \sum\_{i=1}^{N} |\varepsilon\_{i}| \Delta t \\ RMSE = \sqrt{\frac{1}{N} \sum\_{i=1}^{N} (\varepsilon\_{i})^{2}} \\ RMSE = \sqrt{\sum\_{i=1}^{N} (\varepsilon\_{i})^{2} / \sum\_{i=1}^{N} (r\_{i})} \times 100\% \end{cases} \tag{10}$$

where *N*, *ei* and *ri* are, respectively, an observation data length time for the calculation, the tracking error and the reference along the *i*-th *sample*.

#### **3. Results and Discussion**

#### *3.1. Comparison between the Experiment and Simulation Results*

The *Istack*-*Vstack* and *Istack*-*Pstack* polarisation curves of the simulated and real model are presented in Figure 11. According to this figure, it is clear that the predicted model succeeded in providing the same results obtained by the real fuel cell system. It should be noted that the temperature in the experiment curves has an error around ±0.5 °C since it is difficult to make experiments at constant temperatures. One other variable factor that also should be taken into account is the input Hydrogen pressure which is controlled by the manufacture. However, although these two variable factors can differ the predicted results from the real ones, only slight deviations occurred.

#### *3.2. Effect of Temperature and Humidity on the PEM Fuel Cell Stack Performance*

The effects of the operation temperature on the polarisation curves for a low, medium and high humidification (fans power are set at 10%, 50% and 100%) are presented in Figure 11. At low humidification (Figure 11a,b), by varying the temperature from 25 °C to 43 °C the stack performance improves from *T* = 25 °C until *T* = 31 °C and then deteriorates for temperatures up to 31 °C. The improvement of the performance from *T* = 25 °C until *T* = 31 °C can be explained by the enhancement of the conductivity of the membrane which leads to reducing the activation loss. However, for temperatures above 31 °C the membrane starts to dry due to the lack of water content which leads as a consequence to decrease the performance of the stack. At medium humidification (Figure 11c,d), the stack performance improves with increasing temperature. However, for higher temperatures only slight improvements occurred since the membrane requires an additional amount of water content. Regarding the last case at which the membrane is 100% humidified (Figure 11e,f), the stack performance is largely improved with increasing the temperature from *T* = 25 °C until *T* = 39 °C. It is noticed that even for higher temperatures the stack performance is still improving and this is due to the well humidification provided by the fans. It should be noted that although the high humidification has a positive effect on the stack performance for higher temperatures, it also has a negative effect for lower temperatures. Hence, according to Figure 11b,f and for a low temperature equal to 25 °C, it is clear that the stack performance for low humidification (*Pmax* = 33 W) is better than the one obtained by high humidification (*Pmax* = 28 W).

**Figure 11.** Simulation and experiment results (simulation: continuous line; experiment: dashed line); (**a**): *Istack*-*Vstack* polarisation curves when Fans Power = 10%; (**b**): *Istack*-*Pstack* polarisation curves when Fans Power = 10%; (**c**): *Istack*-*Vstack* polarisation curves when Fans Power = 50%; (**d**): *Istack*-*Pstack* polarisation curves when Fans Power = 50%; (**e**): *Istack*-*Vstack* polarisation curves when Fans Power = 100%; (**f**): *Istack*-*Pstack* polarisation curves when Fans Power = 100%.

*3.3. Control Results*

To keep the fuel cell operating at an adequate power point, PID and NN-PID are used. First, the controllers were designed and tested via the the predicted model so as to determine their coefficients. Then, they were implemented on the PEMFC hardware system using the Matlab/SimulinkTM graphical interface. To test the performance of the PID and the NN-PID, two load variations respectively from 20 Ω to 50 Ω and from 50 Ω to 20 Ω are applied during the experiments. The obtained results are clearly presented in Figures 12 and 13.

**Figure 12.** PID and NN-PID experimental results; (**a**–**d**): PEMFC stack current signal; (**e**–**h**): PEMFC stack voltage signal.

The waveforms of the stack current *Istack* and voltage *Vstack* are presented in Figure 12a–d and Figure 12e–h, where (b–d) and (f–h) are respectively the zoom in of a and e. The stack power *Pstack* is shown in Figure 13a–d (b–d are the zoom in of a); whereas the duty cycle and the boost converter output signals (current, voltage and power) are exhibited in Figure 13e–h. According to these graphs, it is clear that both PID and NN-PID succeeded in driving the PEMFC to operate at an adequate power point even when experiencing large load variation. However, although the PID track the reference, slow motion at each load variation occurred. It takes around 6.8 s and 7.25 s to converge to the desired value (response time) respectively for the first and second load variation; whereas the NN-PID requires only 0.75 s and 0.5 s for the same load variations. Regarding the overshoots and undershoots, the PID shows an undershoot current of 2.1 A, an overshoot voltage of 1.11 V and an undershoot power of 10.21 W for the first load variation and an overshoot current of 3.65 A, an undershoot voltage of 1.33 V and an overshoot power of 8.58 W for the second load variation is displayed. On the other hand, the application of the NN-PID performs an undershoot current of 2.38 A, an overshoot voltage of 1.36 A and an undershoot power of 11.18 W for the first load variation and an overshoot current of 4.61 A, an undershoot voltage of 2.31 V and an overshoot power of 7.2 W for the second load variation. It should be noted that both experiments are made at different temperature since it is difficult to keep the fuel cell operating at a constant temperature. Since the stack current is forced via the controllers to follow the reference, the temperature effect of each experiment on the stack performance appears in the stack voltage as presented in Figure 12e–h. The steady state error of current, voltage and power for both PID and

NN-PID are respectively shown in (d) and (h) of Figure 12 and (d) of Figure 13. According to these results, it is clear that the NN-PID provides better results in terms of accuracy since it reduces the amplitude of ripples from 0.1 A to less than 0.01 A. Therefore, although the PID shows slightly lower overshoots in comparison with the NN-PID, this latter provides significantly higher performance in terms of response time and steady state error.

**Figure 13.** PID and NN-PID experimental results; (**a**–**d**): PEMFC stack power signal; (**e**): Duty cycle signal (**f**): Boost converter output current; (**g**): Boost converter output voltage; (**h**): Boost converter output power.

Finally, Table 2 summarises the results of the metrics used to measure the control demeanour. It can be seen that the NN-PID achieved a better outcome in terms of the IAE since it gathered a lower value in comparison to the PID, which represents 62.8% of performance increment. In regards to the accuracy, the trend is still favourable for the NN-PID which is in contrast to the PID of 93.6%. The same situation is seen in the RRMSE since the NN-PID provided a higher improvement as 0.344% was obtained where, in comparison, the PID achieved 5.38%.

**Table 2.** Comparison of the different metrics.


#### **4. Conclusions**

This paper presented an analysis of a commercial Heliocentris FC50 PEM fuel cell system; the objective was to model and control the device via the application of a deep machine learning based artificial neural network. Due to its several input variations, such as stack temperature, humidity and oxygen, which results in nonlinearities and high model complexity, extensive tests with various ANN parameters were required to predict an efficient model.

Since the ANN model requires a large dataset, an efficient automatic method was designed to simplify and facilitate the data collection. This was obtained by generating a triangular signal which varies the duty cycle of the power converter that was inserted between the stack and the load. An experimental dataset composed of 20,512 samples over a wide operating range (different operating current, temperature and fan power) of a commercial stack was recorded and saved for the training process.

Different structures of feed-forward neural network perceptron with backpropagation learning rule were tested to predict the performance of the Heliocentries FC50 fuel cell system. A comparison study including various ANN parameters such as the training algorithm, the number of hidden layers and the number of neurons at each layer was made to obtain the highest accurate model. Finally, an accurate model composed of 3 hidden layers and 90 neurons trained by BR algorithm was used for a comparison study with the real results. On the other hand, the predicted model also was adopted for determining the parameters of the NN-PID control method.

The effect of temperature on the PEM fuel cell stack performance was studied for low, medium and high humidification. At low humidification, it was obtained that the performance of the stack improves for low temperatures (from *T* = 25 °C until *T* = 31 °C) and deteriorates for temperatures up to 31 °C. At medium and high humidifications, it was obtained that the stack performance improves with increasing temperature. However, the effect of temperature is clearly pronounced at higher humidification since the increase of temperature results in a large increase in the stack performance.

At last, two controllers were designed and performed to keep the fuel cell stack operating point at an adequate power stage. Results have demonstrated that both PID and NN-PID have succeeded in driving the stack operation to the desired power point even when experiencing large load variation. However, comparison results have shown high-performance tracking in terms of response time, and steady state error was obtained via the application of the proposed NN-PID control method.

Through this research, future trends for modelling and control of PEM fuel cell systems were analysed and will be the goal of the forthcoming studies. Other types of ANN such as recurrent neural network (RNN) can be an option to improve the performance of the model. Regarding the control method, robust and adaptive controls tuned via neural approach can be also an efficient trend to improve the tracking performance.

**Author Contributions:** Conceptualisation, M.D., C.N. and O.B.; methodology, M.D. and C.N.; software, M.D. and C.N.; validation, M.D.; formal analysis, M.D.; investigation, M.D., C.N. and O.B.; resources, O.B.; writing—original draft preparation, M.D. and C.N.; writing—review and editing, M.D., C.N. and O.B.; supervision, O.B.; project administration, O.B. All authors have read and agreed to the published version of the manuscript.

**Funding:** This research was funded by the Basque Government, Diputación Foral de Álava and UPV/EHU, respectively, through the projects EKOHEGAZ (ELKARTEK KK-2021/00092), CONA-VANTER and GIU20/063.

**Institutional Review Board Statement:** Not applicable.

**Informed Consent Statement:** Not applicable.

**Data Availability Statement:** Not applicable.

**Acknowledgments:** The authors would like to express their gratitude to the UPV/EHU, the Basque Government and the Diputación Foral de Álava.

**Conflicts of Interest:** The authors declare no conflict of interest.

#### **Abbreviations**

The following abbreviations are used in this manuscript:


#### **References**

