## 4 System Control Algorithm  
Figure 5 depicts the electrical connection of the proposed system. The main source of energy is an accumulator. There is no requirement to maintain a constant voltage on the given accumulator, so this source is designated as an unregulated bus. The designed SC module represents the additional energy source of the hybrid energy system. The load voltage (accumulator voltage), load current, SC module current, and voltage were measured to regulate the system. The DSP measures voltages and currents in the system. Based on the values, power is calculated, and then, based on the load power direction, a specific operation mode is selected, as shown in Figure 6. The bidirectional converter current is controlled by the PWM output of the DSP. Figure 4: Final system setup. Figure 7 shows the block scheme of the SC module. Six SC modules are connected in series and six in parallel. Each parallel branch contains a voltage measurement. Therefore, it is possible to measure/observe the voltage distribution on individual branches. The sum of all voltages gives the voltage of the entire SC module. The current measurement from the SC module is connected to the positive clamp. Figure 5: Principle block scheme. Figure 6: Decision-making flowchart diagram. The control of the bidirectional DC/DC converter is divided into three modes, shown in Figure 6. Two of them mean the operation of the converter is in buck mode, and one is in boost mode. The basic principle of the control algorithm is to deliver average power from the accumulator and residual power from the SC module to the load. The control algorithm is dependent on the load power measurement. The load power is calculated based on the battery voltage \(V_{LOAD}\) since the DC bus is common, and the load current \(I_{LOAD}\). If the load power is positive, the load is a consumption device. Another important decisive parameter is the supplied power from the accumulator \(P_{ACCUM}\), which is selectable/adjustable. If the power of the load \(P_{LOAD}\) is greater than the adjustable power from the accumulator \(P_{ACCUM}\), then the differential power is supplied from the SC module, and the inverter works in Mode 1. If the load power is less than the allowable power from the accumulator and at the same time the SOC level of the SC module is less than 90%, then the SC module is recharged with the remaining power from the battery, and thus, the bidirectional converter is in Mode 2. If the SC module is charged (SOC > 90%), then the bidirectional converter is switched off, and only the required power \(P_{LOAD}\) flows from the accumulator. If the load power \(P_{LOAD}\) is negative, the load becomes a source, and all power is supplied to the SC module as long as the SOC is less than 90%. If the SOC of the SC module reaches 90%, the entire recovered power flows into the accumulator, and the bidirectional converter is disabled. The accumulator power value is optional, and then the SC module power is calculated as the difference between load and accumulator power; see Equation (8). The basic scheme of the control algorithm for the boost mode is depicted in Figure 8. The problem is that the current at the output of the DC/DC converter is not measured, so it is impossible to determine the power of the \(P_{DCDC}\) directly. The \(P_{DCDC}\) power represents the output power of the bidirectional DC/DC converter. However, only the voltage and current of the SC module are measured, which represents the SC module/input power of the DC/DC converter \(P_{DCDC\_IN}\) or \(P_{SC}\). Therefore, the output power of the converter is converted to input power \(P_{DCDC\_IN}\) using the measured efficiency characteristic of the converter in boost mode. This value is also understood as the desired power value \(P_{DCDC\_IN}\)'; see Equation (9). Then, the desired \(P_{DCDC\_IN}\)' power is compared to the measured input/SC module power \(P_{SC}\).