*3.3. Control Architecture*

The EMS operates on three levels. The tertiary level operates in advance, and is responsible for formulating strategies for offerings in various energy markets. It receives as inputs the predicted prices, generation, and the real-time SOC for the intraday market and SE optimization models, which are executed at this control level. It then sends market commitments to the secondary level.

The secondary control level operates in real-time and generates the setpoints for the BESS based on the difference between generation and commitments generated on the third level. The BESS setpoints are calculated as follows:

$$P\_{ESS}(\hbar) = P\_{\text{Com}}(\hbar) - P\_{\text{Gen}}(\hbar),\tag{8}$$

where the following apply:


• *PCom*(*h*): Commitment during hour h (MW).

As shown, when an upward deviation is anticipated, the BESS will receive a setpoint to charge the excess. Conversely, when a downward deviation is expected, a discharging setpoint is generated.

The primary control level manages the energy storage system; it receives charge– discharge setpoints from the secondary level and adjusts them based on the real-time SOC. If the BESS does not have enough energy to cover the missing energy, a downward deviation will occur during that hour. If the BESS is unable to store the excess energy, then an upward deviation will occur.

A sketch of the EMS control architecture is illustrated in Figure 5.

**Figure 5.** EMS control levels.
