## 5 Hierarchical Control Development
### Energy Management System Design  
As supervisory control level, an EMS is included to control the multibus multivoltage DCMG. The main idea to design the EMS is to perform in a similar way to an industrial production system. The EMS is programmed in a central concentrator (CC) hardware; from here, enable signals are generated in order to harness all the energy harvested in PV arrays in various consumption points of the system. In order to reach harmonic performance of the DCMG, a list of loads priorities have to be met:  
1. To supply loads into the building (lighting system and electronics loads)
2. To perform charge EV sequence or inject power to mains
3. To carry out the charge of the ESS batteries  
Once the order of priorities is known, initially, EMS performs a logic startup to define an initial condition of the sistem called initial state of the system (\(\mu_{ko}\)). A first sequential stage takes control of those PEC that can provide power to the system eventually, as a source condition. Another sequential stage controls the system load condition by enabling PECs that may consume power in certain periods of time. In order not to occupy too many resources of the CC, source condition and load condition changes are performed by one finite machine state (FMS) each. The EMS design is based in Petri net theory. Petri nets applications are popular in industrial production items, logistics, resources management and others. In other hand, just a few developments are reported in power systems such as study of protection dynamic behavior [41] and hierarchical restoration after a fail event [42]. Nevertheless, due to discrete nature of the concept, it is possible to use a Petri net to read the new measurements, process them and update the system state of the corresponding transitions (enable signals) \begin{table}
\begin{tabular}{c c c c c} \hline \hline
**Version** & \(K_{\text{P}}\) & \(\tau_{\text{P}}\) & \(K_{i}\) & \(\tau_{i}\) \\ \hline
3.3 kW & 10 & 0.12 s & 0.08 & 0.03 s \\
1.5 kW & 10 & 0.1 s & 0.08 & 0.025 s \\ \hline \hline \end{tabular}
\end{table} 
Table 10: Parameter values for DC–AC full bridge PI controllers. Figure 11: Cascade controller structure. in a fixed period of time. The basic fundamentals of Petri net appear in a summarized way in [43]. EMS proposed consists of three stages: the startup test, source converters perform in closed loop at one tenth of the rated power to know how many and what are the PECs available to work. With the information collected, it is possible to set the DCMG initial state \(\mu_{k_{B}}\). The second stage is a set of FMS to enable-disable source PECs; the most adequate FMS, in the current period, is selected to perform in concordance with the previous state of the system (\(\mu_{k-1}\)). In the same way, the third stage is a set of FMS to enable-disable load PECs, the most adequate FMS; for the current period, it is selected to perform in concordance with the previous state of the system. An EMS block scheme is shown in Figure 12.  
After startup is performed and the initial state (\(\mu_{k_{B}}\)) is defined once, then, the two FMSs are selected to move to a new states (\(\mu_{k}\), \(\mu_{k+1}\), \(\dots\)). Voltage and current measurements are elements of the state vector, which is divided into two: the part associated with sources and the part associated with loads. In order to get the next period of time (\(k+1\)), measurements are evaluated by the EMS and the FMSs activates the necessary enable signals (transitions) to move to a new state or remains in the same state for another period of time. The DCMG as a Petri net appears in Figure 13.  
In Petri nets theory, four basic elements can be identify: place (circle), transition (rectangle), arc (arrow) and token (dot), they are associated with DCMG elements in a specific way.