Implementing Discrete Model of Photovoltaic System on the Embedded Platform for Real-Time Simulation

: This paper presents the development of a discrete model of a photovoltaic (PV) system consisting of a PV panel, Maximum Power Point Tracking (MPPT), a dual-axis solar tracker, and a buck converter. The discrete model is implemented on a 32-bit embedded system. The goal of the developed discrete PV model is to provide an e ﬃ cient way for evaluating several algorithms and models used by the PV system in real-time fashion. The proposed discrete model perfectly matches the continuous and discrete model simulated with MATLAB-SIMULINK. The real-time performance is tested by running the model to simulate the PV system, where the fastest time sampling of 1 ms is achieved by the buck converter model, while the longest time sampling of 100 ms is achieved by the solar tracker model. Moreover, a novel method is proposed to optimize the net energy, which is calculated by subtracting the energy consumed by the tracker from the PV energy generated. The proposed net energy optimization method varies the operation time interval of the solar tracker under high and low solar irradiation conditions. Based on the real-time simulation of the discrete model, our approach increases the net energy by 29.05% compared to the system without the solar tracking and achieves an increase of 1.08% compared to the existing method.


Introduction
A photovoltaic (PV) system requires several technologies such as Maximum Power Point Tracking (MPPT) and Solar Tracking to improve its energy efficiency. MPPT is a technique that is used to improve the energy efficiency by operating the PV at the maximum power point. This method relies on the non-linear characteristic of the current and voltage relationship of the PV. Basically, the MPPT methods could be divided into two types: conventional methods and intelligent methods. The most popular conventional methods are the Perturb and Observe (P&O) and Incremental Conductance (INC) methods [1]. The most popular intelligent methods are the Fuzzy Logic Controller (FLC) and Artificial Neural Networks (ANN) methods [1].
The P&O method works by perturbing the PV voltage and observing the PV power to achieve the maximum power point [2]. However, the basic algorithm has problems with the response time, oscillation at the maximum power point, and drift under irradiation changes. Therefore, many improved methods have been proposed [3][4][5][6]. The authors in [3][4][5] proposed MPPT methods with a variable step size to deal with the response time and oscillation problems. Several modified algorithms have been proposed in [6,7] to overcome the drift problem.
The INC method was employed to overcome the oscillation problem at the steady state [8][9][10][11]. The INC method decreases/increases the PV voltage according to the value of incremental inductance. This method is based on the fact that the derivative of the power with respect to the voltage at the maximum power point is zero. The speed time and accuracy could be improved by introducing controller. Simulation models for testing the solar tracking system were developed in [19,23,25,26,29,31]. Unlike the MPPT and the solar tracking systems, most of the PV monitoring systems are developed using real PV systems. Only a few PV monitoring systems use the simulation models, such as the one proposed in [42]. In [42], a virtual PV plant is used in developing the PV monitoring system.
In this paper, we propose a discrete model of a PV system with MPPT and solar tracking. Instead of a continuous model simulated using computer software, our discrete model is implemented on the embedded hardware. To the best of our knowledge, no other system similar to this is available. The main contributions of our work are threefold. First, since the discrete model is implemented on the embedded hardware, a real-time simulation can be performed. Second, our model can easily be integrated with an IoT-based PV monitoring system for the real-time monitoring applications. Third, using our proposed system, we may evaluate the solar tracker operation time interval to achieve the optimal energy produced by the PV system. This last contribution deals with energy optimization in the solar tracking system in relation to the energy consumption of the solar tracker operation.
The rest of the paper is organized as follows. Section 2 presents the proposed system consisting of our proposed discrete model of the PV system. The experimental results and discussion are described in Section 3. The conclusion is covered in Section 4.

System Configuration
The configuration of the proposed system is depicted in Figure 1. The proposed discrete PV model (hereinafter called as the PV Dis-Mod) consists of five main components: (a) Solar model; (b) PV panel model; (c) Solar tracker model; (d) Buck converter model; and (e) MPPT. The solar model is used to generate the effective solar irradiance (Geff ) directing to the PV panel. The Geff is the solar irradiation which is perpendicular to the PV panel. It is affected by the solar position and the pan and tilt of the PV panel. In the solar model, the solar azimuth and elevation are calculated using an astronomy algorithm [44][45][46][47] that utilizes the latitude and longitude of the PV site. The solar azimuth and elevation are fed to the solar tracking system for determining the PV pan and tilt. The PV panel model is a mathematical model of the PV proposed in [48][49][50]. In the model, the PV voltage and ambient temperature are considered to be the inputs, while the output is the PV current. The PV panel model is connected to the buck converter model and the MPPT controller. The solar tracker model is a discrete model of the dual-axis solar tracker proposed in [31]. This tracker employs two DC motors to track the solar azimuth and elevation. Proportional Integral Derivative (PID) controllers are used to control the position of the motors. The solar tracker model is used to calculate the pan (azimuth) and tilt (elevation) of the PV panel so that they are perpendicular to the solar azimuth and elevation. The buck converter model adopts the model proposed in [2,31,51]. The buck converter is driven by a pulse width modulation (PWM) signal generated by the MPPT controller. The converter is used to change the PV voltage and current according to the MPPT algorithm, in the case of the P&O technique.

PV Panel Model
The PV panel model [50] is illustrated in Figure 2, which consists of one diode and a photocurrent source. The relationship between the voltage and current can be derived from the following equations [48,50]: where I is the PV current, V is the PV voltage, I PH is the photocurrent, I S is the cell saturation of the dark current, q is an electron charge (q = 1.6 × 10 −19 C), k is Boltzmann's constant (k = 1.38 × 10 −23 J/K), T C is the cell's temperature, A is an ideal factor (A = 1.2), I SC is the cell's short circuit current at the temperature of 25 • C and solar irradiation of 1000 W/m 2 (I SC = 3.25 A), K I is the temperature coefficient of the cell's short circuit current (K I = 0.003), T R is the cell's reference temperature (T R = 298.15 K), G is the solar irradiation (in kW/m 2 ), I RS is the reverse saturation current, E G is the band gap energy (E G = 1.
The effective solar irradiation (Geff in Figure 1) is obtained using the following formula: where Gind is the incident solar irradiation, θ is the PV panel's azimuth angle, and β is the PV panel's tilt angle.

Solar Tracker Model
The continuous model of the solar tracker is depicted in Figure 3. The azimuth tracker and elevation tracker use the same model. In the figure, the right block represents the DC motor, while the left one is the PID controller. In this research, the DC motor's parameters are adopted from [29], where k e is the motor constant (k e = 0.03103), L a is the armature inductance (L a = 0.00866 H), f is the damping coefficient (f = 0.000025 Nms/rad), R a is the armature resistance (R a = 18.2214 Ω), and J is the moment of inertia (J = 0.000090 kgm 2 ). The parameters of the PID controller are the proportional gain (K p = 0.0805), integral gain (K i = 0.0011), and derivative gain (K d = 0.0635). The closed loop transfer function of the actual angle (θ a (s)) to the reference angle (θ r (s)) is defined below: θ a (s) θ r (s) = 0.00197 s 2 + 0.002498 s + 0.00003413 0.0016 s 3 + 0.00337 s 2 + 0.002498 s + 0.00003413 .
The discrete model of the solar tracker is obtained by converting the transfer function in the s-domain, Equation (16), to the z-domain. In this research, the conversion is performed using the MATLAB script, and the discrete transfer function is given below (the time sampling is 100 ms): where θ a (z) and θ r (z) are the actual angle and reference angle in the z-domain, respectively. In order to be implemented on an embedded system, the transfer function in Equation (17) is converted to the following difference equation: , and y[k − 3] are the actual angles at step-k, step-(k − 1), step-(k − 2), and step-(k − 3), respectively, , and x[k − 3] are the reference angles at step-(k − 1), step-(k − 2), and step-(k − 3) respectively, and step-n is the current step.

MPPT
The P&O, the most popular MPPT technique, is adopted in this research. The algorithm is depicted in Figure 4. As shown in the figure, it first calculates the PV power at step-k (P[k]). Then, the change in power (∆P[k]) and change in voltage (∆V[k]) are calculated using the following formulas: where V[k] and I[k] are the PV voltage and current at step-k respectively, and P[k − 1] and V[k − 1] are the power and voltage at step-(k − 1), respectively.

MPPT
The P&O, the most popular MPPT technique, is adopted in this research. The algorithm is depicted in Figure 4. As shown in the figure, it first calculates the PV power at step-k (P[k]). Then, the change in power (∆P[k]) and change in voltage (∆V[k]) are calculated using the following formulas:

P[k] = V[k] I[k]
(19) ). Based on these values, the next action is performed as follows.
where S V is the step size of the perturbation voltage.

Buck Converter Model
The electrical circuit of a buck converter model is depicted in Figure 5 [2]. The model consists of a power switch device (S), a freewheeling diode (FD), an inductor (Ind), and a capacitor (Cap). The relationship between the voltage input (v in ) and the voltage output (v out ) is determined by the following formulas, where the model is expressed in the discrete form: where i L is the inductor current, i S is the input current, Q r is the diode recovered charge (Q r = 100 × 10 −9 C), f s is the switching frequency (f s = 40 kHz), D is the duty cycle, t r is the diode reverse recovery time (t r = 50 × 10 −9 s), T s is the time sampling (T s = 1 ms), v C is the capacitor voltage, C is the capacitance of the capacitor (C = 4.7 mF), i C is the capacitor current, L is the inductance of the inductor (L = 100 µH), R on is the resistance of the power switch device at the ON state (R on = 0.05 Ω), R L is the resistance of the inductor (R L = 0.1 Ω), i load is the load current, and esr is the equivalent series resistance of the capacitor (esr = 0.05 Ω).

Optimization of Solar Tracker Energy
Our proposed solar tracker employs two DC motors to track the solar azimuth and elevation. Since the motors consume energy during their operation, a strategy is required to optimize the operation time of the motors. In [30], the elevation tracker moves up every 10 • (19 s), moves down every 10 • (14 s), and the azimuth tracker moves every 1 • (1.1 s). In [32], the elevation and azimuth motors are operated every 15 • (1 h).
In this research, we evaluate the impact of tracker operation time on the net energy of the PV system, where the net energy is defined by subtracting the energy consumed by the tracker from the energy generated by the PV. Two tracker operation strategies are compared. First, a fixed time interval is used, where the azimuth and elevation trackers move every 1 min. Second, a variable time interval is used, where the time intervals for operating the trackers are varied depending on the time of day as given in Table 1. The latter strategy is based on the fact that the energy consumed by the solar tracker depends only on the time interval, while the energy produced by the PV depends on both the time interval and the solar irradiation. Thus, by setting a longer time interval at noon (with high solar irradiation), the tracker energy is greatly reduced, whereas the high solar irradiation causes the PV power to be high, and prolonging the time interval of the tracker only slightly decreases the PV energy. Therefore, it results in a more efficient net energy. It is worth noting here that the selection of the interval values given in Table 1 is based on the observation of the experimental results that will be discussed in the next section.

PV Panel Model Verification
The PV panel model verification is conducted by comparing the proposed model, which is implemented on the embedded system (Wemos [52], a 32-bit microcontroller) and a model simulated using MATLAB/Simulink. Since the MATLAB model is a common approach to simulate the PV panel model expressed in Equations (1)-(4), it is reasonable to use the Simulink model as the reference model for the verification of our proposed model.
In the experiments, the relationship between the PV voltage and current is evaluated under the three different conditions listed in Table 2. The evaluation results are illustrated in Figure 6   As discussed previously, the closed-loop transfer function of the solar tracker is modeled as a third-order system, where the continuous transfer function, discrete transfer function, and difference equation are defined in Equations (16)-(18), respectively. The response times of the unit steps are plotted in Figure 7, where the line represents the continuous model simulated using MATLAB, the square marker represents the discrete model simulated using MATLAB, and the triangle marker represents the discrete model implemented on Wemos. The evaluation of response time is important when operating the tracker to follow the solar movement, as discussed below. In our proposed system, the time interval of the solar tracker operation is given in Table 1, where the fastest time is 10 min. However, as described previously, we also make a comparison to the solar tracker with a time interval of 1 min. It suggests that the response time of the solar tracker should be less than 1 min. From Figure 7, it is obtained that the settling time of our solar tracker model is approximately 5 s. Thus, the solar tracker model fulfills this requirement.
By comparing the three models in Figure 7, we may conclude that the discrete models using a time sampling of 100 ms are adequate to represent the continuous model, in the sense that the response times of the unit steps are almost matched perfectly. Moreover, our proposed discrete model implemented on Wemos only shows a slight discrepancy compared to the one simulated using MATLAB. Similar to the PV model, this discrepancy is caused by the difference in the precision format of the floating-point numbers.

Buck Converter Response Time
The buck converter is one of the main components in the PV system and is employed by the MPPT to control the PV voltage. Thus, the response time of the buck converter should be fast enough to accommodate the solar irradiation changes and MPPT algorithm. In this work, as discussed in the previous section, the time sampling of the buck converter model expressed by Equations (22)-(27) is set to 1 ms. The response times of the buck converter models are plotted in Figure 8, where the line denotes the continuous model simulated by MATLAB, the square marker denotes the discrete model simulated by MATLAB, and the triangle marker denotes the proposed discrete model implemented on Wemos. From Figure 8, it is obtained that the response times of the three models are almost matched perfectly. Therefore, the proposed discrete model implemented on Wemos is adequate to represent the buck converter model. The settling time of the buck converter is approximately 5 ms, and it is fast enough to be used in the experiments. Similar to the PV model and the solar tracker model, the discrete model implemented on Wemos shows a slight discrepancy with the one simulated by MATLAB due to the difference in the precision format of the floating-point numbers.

MPPT Evaluation
To evaluate the MPPT algorithm (P&O), we run the discrete PV model without the solar tracker on Wemos. The MPPT parameters and environmental conditions are given in Table 3. The response time of the MPPT algorithm is plotted in Figure 9, where the grey line denotes the PV power, and the blue line denotes the solar irradiation. As shown in the figure, it is obtained that for a high solar irradiation (1000 W/m 2 ) and an initial duty cycle of 0.5, the maximum power point is achieved at approximately 200 ms. From the experiment, it is found that the maximum power is 56 W and the duty cycle in the steady state is 0.48. This maximum power complies with the observation of the PV voltage-current characteristic shown in Figure 6. From Figure 9, it is obtained that for a low solar irradiation (300 W/m 2 ) and an initial duty cycle of 0.48 (at a time of 5000 ms), the MPPT algorithm requires approximately 2000 ms to achieve the maximum power. From the experiment, it is found that the maximum power is approximately 15.5 W and the duty cycle in the steady state is 0.27.

Real-Time Simulation
As described previously, the main objective of our discrete model is to simulate the PV system model in real time. The real-time simulation is conducted by running the discrete model implemented on Wemos (PV Dis-Mod) using predefined environmental data. The environmental data consisted of the solar irradiation and PV temperature, where their profiles during a day from 07:00 to 17:59 h are shown in Figure 10. Both the solar irradiation and PV temperature change every hour. The PV model site is at Malang city, Indonesia, with a longitude of 112.621391 • E and latitude of 7.983908 • S. To provide an efficient time during the evaluation process, a real 1 min time is simulated in 5 s on Wemos. Thus, a real 1 h time is simulated in 5 min. Using this method, evaluating the PV model from 07:00 h to 17:59 h only requires 55 min. Therefore, it is suitable to test several algorithms and models for research purposes in the laboratory.
In the experiments, we compare four PV Dis-Mod models, namely  Table 1 (called Mod_TR_Var). It is noted here that the Mod_TR_1m1m is used to represent the fastest time interval that can be applied to our model, as explained in the following. From Figure 9, it is obtained that the longest response time of the MPPT algorithm is approximately 2 s. Since the fastest time interval of the solar tracker is 1 min, it will be simulated in 5 s on Wemos, which is longer than 2 s. Thus, it applies to our proposed model. Mod_TR_15m30m is used to represent the existing method proposed in [30] with some adjustments to our application, where the solar tracker takes 15 min to move 1 0 in the azimuth position, and it takes 30 min to move 10 0 in the elevation position.

Effective Solar Irradiation on PV Model
As given in Equation (15), the effective solar irradiation depends on the solar position and solar tracker. Since the operation times of the solar trackers for the four PV Dis-Mod models are different, the profiles of the effective solar irradiation on each PV model will be different as depicted in Figure 11, where Figure 11a shows the profiles from 07:00 to 17:59 h and Figure 11b shows closer look profiles from 10:00 to 12:00 h. The blue, orange, grey, and yellow lines denote Mod_NT, Mod_TR_1m1m, Mod_TR_15m30m, and Mod_TR_Var, respectively. As shown in Figure 11a, since there is no solar tracker, the effective solar irradiation on Mod_NT is the lowest one compared to the others. The profiles of the effective solar irradiation for Mod_TR_1m1m, Mod_TR_15m30m, and Mod_TR_Var are almost the same. However, from the closer look profiles shown in Figure 11b, we may see their differences. It is clearly shown that the flat profile (highest value) of the effective solar irradiation is achieved by Mod_TR_1m1m. In the cases of As shown in Figure 11a, since there is no solar tracker, the effective solar irradiation on Mod_NT is the lowest one compared to the others. The profiles of the effective solar irradiation for Mod_TR_1m1m, Mod_TR_15m30m, and Mod_TR_Var are almost the same. However, from the closer look profiles shown in Figure 11b, we may see their differences. It is clearly shown that the flat profile (highest value) of the effective solar irradiation is achieved by Mod_TR_1m1m. In the cases of Mod_TR_15m30m and Mod_TR_Var, since the trackers operate in the time interval of 15 min or 20 min, the solar irradiation is the same with the flat one (highest value) at the beginning of the interval and then decreases until the next interval. The decrease in the solar irradiation is caused by the fact that the solar tracker only moves at the beginning and then stops until the next interval.

PV Power
The profiles of the PV power generated by the PV models are depicted in Figure 12, where Figure 12a shows the profiles from 07:00 to 17:59 h, and Figure 12b shows the closer look profiles from 11:00 to 13:00 h. In the figures, the blue, orange, grey, and yellow lines represent Mod_NT, Mod_TR_1m1m, Mod_TR_15m30m, and Mod_TR_Var, respectively.

PV Power
The profiles of the PV power generated by the PV models are depicted in Figure 12, where Figure  12a shows the profiles from 07:00 to 17:59 h, and Figure 12b shows the closer look profiles from 11:00 to 13:00 h. In the figures, the blue, orange, grey, and yellow lines represent Mod_NT, Mod_TR_1m1m, Mod_TR_15m30m, and Mod_TR_Var, respectively. As expected, the profiles of the PV power shown in Figure 12 follow the profiles of the effective solar irradiation shown in Figure 11. The highest PV power is achieved by Mod_TR_1m1m, while the lowest one is achieved by Mod_NT. As shown in the closer look profiles (Figure 12b), the profiles of the PV power generated by Mod_TR_15m30m and Mod_TR_Var fluctuate according to their solar tracker time intervals. As expected, the profiles of the PV power shown in Figure 12 follow the profiles of the effective solar irradiation shown in Figure 11. The highest PV power is achieved by Mod_TR_1m1m, while the lowest one is achieved by Mod_NT. As shown in the closer look profiles (Figure 12b), the profiles of the PV power generated by Mod_TR_15m30m and Mod_TR_Var fluctuate according to their solar tracker time intervals.

PV Energy
The profiles of the PV energy values are depicted in Figure 13, where Figure 13a shows the profiles from 07:00 to 17:59 h, and Figure 13b shows closer look profiles from 15:00 to 17:59 h. In the figures, the blue, orange, grey, and yellow lines represent Mod_NT, Mod_TR_1m1m, Mod_TR_15m30m, and Mod_TR_Var, respectively.

PV Energy
The profiles of the PV energy values are depicted in Figure 13, where Figure 13a shows the profiles from 07:00 to 17:59 h, and Figure 13b shows closer look profiles from 15:00 to 17:59 h. In the figures, the blue, orange, grey, and yellow lines represent Mod_NT, Mod_TR_1m1m, Mod_TR_15m30m, and Mod_TR_Var, respectively. From the figure, it is obtained that the highest to lowest PV energies are achieved by Mod_TR_1m1m, Mod_TR_Var, Mod_TR_15m30m, and Mod_NT. This result could be understood from the fact that by operating the solar tracker in the faster time interval, the effective solar irradiation on the PV panel will be higher, and as consequence, the PV power will be higher. Thus, the generated PV energy will be higher. By observing closer look profiles on Figure 13b, we can see that the PV energy of our proposed method (Mod_TR_Var) is higher than that of the existing method [30] (Mod_TR_15m30m) and slightly lower than that of Mod_TR_1m1m.

Net Energy
The profiles of the energy consumed by the solar tracker from 07:00 to 17:59 h are depicted in Figure 14, where the red, green, and purple lines represent Mod_TR_1m1m, Mod_TR_15m30m, and Mod_TR_Var, respectively. From the figure, it is clearly shown that the solar tracker having the fastest time interval (Mod_TR_1m1m) consumes the highest energy. It is worth noting that our proposed tracker (Mod_TR_Var) consumes much less energy than Mod_TR_1m1m. Moreover, the energy consumed by Mod_TR_Var is slightly greater than that consumed by Mod_TR_15m30m.  Table 4, the net energy of Mod_TR_Var is 29.05% greater than that of Mod_NT. The increase is 1.08% and 6.07% greater than the increases achieved by Mod_TR_15m30m and Mod_TR_1m1m, respectively. The results show that our proposed approach (Mod_TR_Var) provides an efficient way to provide the highest net energy compared to the existing methods. In contrast, although the method with the fastest time interval (Mod_TR_1m1m) generates the greatest PV energy, its solar tracker consumes the most energy. Thus, the net energy is low.  Table 4, the net energy of Mod_TR_Var is 29.05% greater than that of Mod_NT. The increase is 1.08% and 6.07% greater than the increases achieved by Mod_TR_15m30m and Mod_TR_1m1m, respectively. The results show that our proposed approach (Mod_TR_Var) provides an efficient way to provide the highest net energy compared to the existing methods. In contrast, although the method with the fastest time interval (Mod_TR_1m1m) generates the greatest PV energy, its solar tracker consumes the most energy. Thus, the net energy is low.    x min from 07:00 to 17:59 h. V_xm_ym indicates that both the azimuth and elevation trackers move every x min during the low solar irradiation periods (07:00 to 09:59 h and 14:00 to 17:59 h) and every y min during the high solar irradiation period (10:00 to 13:59 h).
A comparison result of the net energy values produced using the seven scenarios is given in Figure 16. In the case of the fixed time interval, increasing the interval from 10 to 15 min increases the net energy; however, when the time interval is increased to 20 min, the net energy will be reduced. It indicates that there is an optimal time interval that should be properly selected to achieve the maximum net energy. In the case of the variable time intervals, the maximum net energy is achieved by V_10m_20m (as adopted in our proposed method given in Table 1). By comparing the four scenarios of the variable time intervals, we can obtain several findings as follows: • Comparing V_10m_15m to V_10m_20m, it is obtained that the net energy will be increased when the time interval during a period of high solar irradiation is increased. • Comparing V_15m_10m to V_20m_10m, it is obtained that the net energy will be decreased when the time interval during a period of low solar irradiation is increased.
From the above findings, it is obtained that increasing the time interval during a period of high solar irradiation yields the opposite effect of doing so during a period of low solar irradiation. It could be analyzed from the fact that increasing the time interval will decrease both the PV energy and the tracker energy, and since the tracker energy is not dependent on the solar irradiation, the effect of increasing the time interval at different solar irradiation levels is determined by the PV energy. By increasing the time interval, the PV energy reduction during the high solar irradiation period is smaller than that during low solar irradiation period. Therefore, prolonging the time interval during a period of high solar irradiation will increase the net energy.

Conclusions
The implementation of the discrete model of the PV system on the embedded platform is developed. The PV system employs the MPPT technique and a dual-axis solar tracking system to improve its energy generation. The proposed discrete model is suitable for running a real-time simulation of the PV system, which is an important task in PV system research studies. In addition to the discrete model, a new approach to control the operation time interval of the solar tracker is also developed. The proposed approach uses different time intervals for different periods: those with the high solar irradiation and low solar irradiation. This approach provides an effective solution to achieve the optimal net energy, which is the subtraction of the PV energy by the consumed solar tracker energy.
In the future, we will extend our discrete model to cover complex models and large PV systems. Furthermore, advanced algorithms for optimizing the net energy will be developed.