## 2 Materials and Methods
### Structure of the Fuzzy Controller
The value of the volatility of the input variable is determined by limits: \(\min(\mathrm{V_{oIV}})=0\) V, \(\max(\mathrm{V_{oIV}})=5\) V, \(\min(\mathrm{V_{oIV}}^{\prime})=0\)\", \(\max(\mathrm{V_{oIV}}^{\prime})=89\)\". The range of output value is equal [0 40] V/V. The maximum value of \(A_{d}\) is related to the minimum voltage value on the measuring shunt, which is 125 uV. The number of rules grows exponentially with the number of variables in the premise of the rule. The number of rules in the fuzzy controller is determined by the formula \(N^{\mathrm{IN}}\) (where \(N\) is number of fuzzy sets and \(IN\) is the number of the input) [24]. The proposed fuzzy model uses two inputs (\(V_{oIV}\)) and its derivative (\(d(V_{oIV})/dt\)) and contains six fuzzy sets (the database contains 64 rules (2\({}^{6}\))). The membership functions selected for the construction of the fuzzy controller are triangles, due to their easy implementation in a microprocessor system. The placement of rules in controller space is a more important parameter influencing the accuracy of the AGC system than their number. Algorithm 1 presents the principle of operation of the AGC for two exemplary activated rules, \(R^{1}\) and \(R^{2}\) (see Equation (1)). The \(V_{oIV}\) data and the derivative \(d(V_{oIV})/dt\) are entered into the AGC system (see Algorithm 1, points 1 and 2). The \(V_{oIV}\) values are checked by conditional statements (see Algorithm 1, points 4 or 14, 15). This data is then entered into the input of the controller as crisp values (\(V_{oIV}(nT)^{*};d(V_{oIV}(nT)^{*}/dt)\) (see Algorithm 1, point 5), where it is subjected to fuzzyication (see Algorithm 1, point 6). The data is assigned to fuzzy sets with a determination of the degree of membership (\(\mu_{A1}(V_{oIV})\), \(\mu_{A2}(V_{oIV})\), \(\mu_{B1}(V_{oIV})\), \(\mu_{B2}(V_{oIV})^{\prime}\)). Operator MIN was used to determine the weight \(w_{j}\) of the rule (see Algorithm 1, point 8). The decision is a fuzzy set \(\mathrm{C}_{j}\) (see Algorithm 1, point 9) whose membership function is determined by equation \(\mu_{oj}(A_{d})=w_{1}^{*}\mu_{G}(A_{d})\). A conclusion from the two rules is given by the equation \(\mu_{oj}(A_{d})=max(w_{1}^{*}\mu_{C1}(A_{d}),w2^{*}\mu_{c2}(A_{d}))\) (see Algorithm 1, point 10). The conditional if statement implements a sub-scope of the AGC system. Algorithm 1 shows the sub-range for the voltages \(V_{oIV}>0.2\) V (see Figure 4) (range: input [0 0.2][0 89] and output[0 20]). Conditional statements (see Algorithm 1, points 4, 14, 15) contain three fuzzy controllers with the same shape of the hyperplane. The main difference between these controllers is the different input voltage and gain ranges (see Algorithm 1, points 14, 15). All of these controllers are built from the same number of rules (64) and types of membership functions (triangular). The center of gravity (COG) (see Algorithm 1, point 12) method was used for defuzzification of the output \(A_{d}\)* signal. The whole algorithm works in the main loop of the microcontroller. The diagram and the structure of the AGC fuzzy controllers implemented in the MCU in the digital section of the current measurement circuit of the power inverter are presented in Figure 4.  
Resistance measuring shunts \(R_{sh}\) (metal alloy with low inductance low and thermal electromotive force EMF < 1 uV/\({}^{\circ}\)C) allow for accurate measurement of DC and AC signals, which vary across the whole measuring range. The input range of the resistance shunt is from 1 A to a maximum of 50 A. The current below 1 A is impossible to measure from the 125 u\(\Omega\) shunt using classical methods and measuring elements. The minimum current value appears when the electric motor connected to the DC/AC power inverter is turned off, while the main power circuit is loaded by the 1 A current device. Two amplifiers operating in non-inverting configuration are connected to the output terminals of the measuring resistor \(R_{sh}\), creating a system with a differential input and output with a voltage gain constant of 800 V/V.