*4.1. Simulation Results*

Table 3 presents the daily appliance schedule for the simulation according to user behavior in the residence.


**Table 3.** Simulation: Appliance Schedule Runtime.

Therefore, an electrical circuit model was created in PSIM software in order to simulate the power behavior of a residence during an entire day, turning on each appliance according to the scheduled runtime of Table 3.

The simulation collects 256 samples per cycle from current and voltage waveforms and sends them to a Dynamic Link Library (DLL) block. The general DLL block in PSIM allows users to write codes in C or C++, compile them as a Windows DLL, and link them to PSIM using the features of input (from PSIM) and outputs (returning to PSIM). Unlike the simple DLL blocks with a fixed number of inputs and outputs, the general DLL block provides more flexibility and capability in interfacing PSIM with custom DLL files. In this paper, the DLL codes were used to implement the CPT, the KNN and state-machine NILM, according to the algorithms from Figures 5–7. The state machine from Figure 5 is a loop responsible for the event decision when there is power consumption changing. If there is power changing, the state machine flows in steps until it detects the power event and triggers the "ON event" (Figure 6) or the "OFF event" (Figure 7). If an "ON event" is detected, the system runs algorithm Figure 6 responsible for classifying the appliance. After that, the algorithm adds the appliance to the turned-on appliance list and saves the waveform status for future comparisons when a new event is triggered. If an "OFF event" is detected, the system runs algorithm Figure 7 that is responsible for classifying the appliance and removing the appliance from the turned on appliance list and saves the waveform status for comparison when a new event is triggered.

Simultaneously, the PSB takes care of four other characteristics:


Figure 8 presents the simulation results. The state machine with the classifier algorithm accepted all the loads according to Table 3. Figure 8 shows the CPT power decomposition and, consequently, the moments in which the algorithm performed the appliance identification (turn on and turn off triggers).

**Figure 8.** Daily consumption of electricity by household appliances. (**a**) Load disaggregation behavior

in simulation; (**b**) CPT power components behavior in simulation.

Figure 9 shows an example of the operation of the PSB between 09:27 and 10:03 from Figure 8. In this interval, there is the operation of a refrigerator, according to the schedule of Table 3. Following the algorithms of Figures 5–7, the state machine has the following behavior:

	- **–** CPT Features extraction;
	- **–** KNN classifier;
	- **–** Appliance recognition;
	- **–** Recognized appliance added to the appliance list;
	- **–** goto 0;

	- **–** Waveform difference;
	- **–** CPT feature extraction;
	- **–** KNN classifier;
	- **–** Appliance recognition;
	- **–** Recognized appliance removed from the appliance list;
	- **–** goto 0;

• **10:02 to 10:03:** Active power is stable, and there is nothing to be done at this time;

**Figure 9.** Detailed consumption and state-machine behavior between 09:27 and 10:03. (**a**) Load disaggregation behavior between 09:27 and 10:03; (**b**) Active power behavior between 09:27 and 10:03.

Therefore, the PSB worked as expected, and there was no error in the disaggregation process in the simulations. In this study, there was no error because it is used an appliance dataset with high accuracy and the simulated loads operate in a steady state. However, Section 4.2 will present real appliance cases, including power variations.

### *4.2. Experimental Results with Household Appliances*

The PSB operates with a main loop of 15,360 collected samples. Hence, with a fixed fundamental frequency, this loop takes a second to perform. Then, a four-step procedure tracks rapid power variations. Each step updates the average of the active power evaluated with the last block of samples: 0.25 s of total samples.

Therefore, a predefined threshold level compares the active power variation during the time. Then, the procedure uses the difference between the current average active power and the last one used to define the step level direction: when there is the "power on" or "power off" state of the appliance. Figure 10 shows the behavior of the algorithms from Figures 5–7 in this experiment.

In the trigger events—from Figures 6 and 7—the algorithm stores current and voltage waveforms of the last 0.25 s, extracts the current to be considered in the event and calculates the four elements that represent the appliance: active power, power factor, reactive factor, and non-linearity factor. With these elements (attributes), the algorithm uses the classifier algorithm (the KNN) by means of the knowledge dataset from [15]. The classifier returns the label of the appliance, i.e., the algorithm predicts which appliance is turned on (algorithm from Figure 6) or turned off (algorithm from Figure 7). If it is an "ON event" the recognized appliance is added to the appliance list. If it is an "OFF event", the recognized appliance is removed from the appliance list. After this, the system stores the fifteen waveform cycles of the state to use in a new event trigger. Over time, appliances can be identified, as shown in Figure 11.

**Figure 10.** Trigger algorithm validation.

**Figure 11.** Trigger and load disaggregation validation.

Considering such experiments, the PSB reached 95% of accuracy. The main problem encountered in the method corresponds to the loads with several power changes without the existence of a zero-power instant (i.e., a real turn OFF event). Figure 12 shows an example of an air conditioner with an adjustable speed driver (ASD). In this case, the method of load disaggregation carries out the load identification in the ON event trigger and, in the course of the operation, the power changes without the activation of a new trigger. When the device is turned off, the power level is different from the start of the operation, and the classifier may incorrectly identify the turned off appliance. If there is more than one appliance that is turned on, the algorithm may remove the wrong equipment from the list. If there is only one appliance, the algorithm empties the list.

**Figure 12.** Air conditioning with an inverter example.

To solve this problem, the appliance dataset must have a wide range of appliance measuring times and waveforms should consider the last state (in the OFF event trigger). The algorithm from Figure 5 could also be adapted to improve the accuracy in such situations.
