## 3 Design and Implementation of Emulators in Hardware in the Loop
### Photovoltaic Panel
Since the \(e^{x}\) function only admits input values between \(-1\) and \(1\), the following methodology was followed for the calculation of the exponential function greater than \(1\) or less than \(-1\). If \(x>1\) and is denoted by \(int(x)\) to the integer part of \(x\) and by \(fra(x)\) to the fractional part, the exponential function is calculated as shown in Equation (8). In this way, the term \(e^{int(x)}\) can be calculated in a for loop, successively multiplying the value of the number \(e\) by itself \(int(x)\)-times. While \(e^{int(x)}\) can be calculated with the available function, this because of \(fra(x)<1\); this algorithm is shown in Figure 8.  
\[n^{x}=e^{\ln{(n)x}} \tag{7}\] \begin{table}
\begin{tabular}{c c c c c c} \hline \hline
**Parameter** & **Maximum Observed** & **Minimum Observed** & **Type of Data Selected** & \begin{tabular}{c} **Maximum According to the Type of Data** \\ **selected** \\ \end{tabular} & \begin{tabular}{c} **Resolution** \\ **to the Data** \\ \end{tabular} & \
\begin{tabular}{c} **According to** \\ **Selected** \\ \end{tabular} &
\begin{tabular}{c} **According to** \\ **the Data** \\ \end{tabular} \\ \hline \(V_{\infty}\) & 61.97 V & 22.42 V & +9,6 & 63.875 V & 0.125 V \\ \(V_{mpp}\) & 49.67 V & 17.69 V & +9,6 & 63.875 V & 0.125 V \\ \(I_{sc}\) & 9.35 A & 0.29 A & +7,4 & 15.875 A & 0.125 A \\ \(I_{mpp}\) & 8.86 A & 0.27 A & +7,4 & 15.875 A & 0.125 A \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Data obtained from the analysis of the photovoltaic panels (PVPs) for the model parameters. \begin{table}
\begin{tabular}{c c c c} \hline \hline
**Variable** & **Data Type Selected** & \
\begin{tabular}{c} **Maximum According to** \\ **the Type of Data** \\ \end{tabular} &
\begin{tabular}{c} **Resolution** \\ **According to the Type of Data** \\ \end{tabular} \\ \hline \(R_{s}\) & +10,2 & 3.996094 & 0.00390625 \\ \(a\) & +8,0 & 0.996094 & 0.00390625 \\ \(N\) & +15,7 & 63.996094 & 0.00390625 \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Weights assigned to the variables \(R_{s}\), \(a\) and \(N\). Figure 7: Behavior of the values \(R_{s}\), \(a\) and \(N\). Subsequently, if \(x<-1\) then \(-x>1\), and if the integer part of \(-x\) is denoted with \(int(-x)\) and with \(fra(-x)\) to the fractional part, the exponential function is calculated as shown by Equation (9). In this way, the term \(e^{int(-x)}\) can be calculated in a for loop as in the previous case, while \(e^{fra(-x)}\) can be calculated with the available function because \(fra(-x)<1\). The algorithm used to describe this expression is shown in Figure 9.  
\[e^{x}=e^{-(-x)}=\frac{1}{e^{-x}}=\frac{1}{e^{int(-x)+fra(-x)}}=\frac{1}{e^{int (-x)*e^{fra(-x)}}} \tag{9}\]  
The available \(\ln(x)\) function only admits values between \(\frac{1}{e}\) and \(1\), in this case the scaling of the argument of the logarithm is proposed as shown in Equation (10). In this way, what is sought is that the product \(x^{*}c\) is in a valid range for the function and since the constant is known, its logarithm will also be known. Figure 10 shows the code to calculate the logarithm of a variable \(x\) that takes values between the reciprocal of the square of \(e\) and the unit. With the proposed algorithms it is possible to calculate the functions \(n^{x}\) and \(\ln(x)\) using a high-level language, this allows the development of complex applications for non-expert users [29]. \[\ln(x)=\ln\!\left(x*\frac{c}{c}\right)=\ln\!\left(x*c\right)-\ln\!\left(c \right)\ ;\quad c=cte \tag{10}\]  
Figure 8: Algorithm to calculate power of \(\mathrm{e}\) less than \(-1\). Figure 10: Algorithm used to calculate the natural logarithm. Figure 9: Algorithm to calculate powers of \(\mathrm{e}\) less than \(-1\).