# A Two-Grid Interline Dynamic Voltage Restorer Based on Two Three-Phase Input Matrix Converters
## 6 TI-IDVR Control Algorithm
### CSI Control Algorithm  
The voltage in the loads can be compensated for efficiently in the reference frame \(dq\) even in the presence of voltage disturbances in the feeders. The structure of the control and modulation algorithm implemented to govern the switching on and off of the commutation elements of the CSIs is shown in Figure 6.  
The control algorithm for CSI 1 and CSI 2 is the same. For this reason, only the control algorithm for CSI 1 is addressed in this description. The inputs to the control algorithm are load voltage 1 and the reference voltage of load 1. The phase angle information (\(\theta_{L}\) and \(\theta_{ref}\)) of both voltages is obtained by means of a Phase-Locked Loop (PLL). The active component of both voltages (\(d_{L}\) and \(d_{ref}\)) is obtained by performing the \(abc\)-\(dq\) transformation using the phase angle information obtained above. The active components (\(d_{L}\) and \(d_{ref}\)) of the load and reference voltages are compared to determine if the event is a voltage sag or a voltage swell. With this information, the phase angle of the reference voltage is adjusted to obtain the phase angle \(\theta_{a}\). As shown in Figure 4, the angle \(\theta_{a}\) describes the phase orientation of the voltage vectors that are required for disturbance compensation in the complex space. The phase angle \(\theta_{a}\) provides the necessary information to determine the corresponding sextant in the complex space and to calculate the switching functions \(d_{o1}\) and \(d_{o2}\) in each of the sextants using Equation (32). To generate the trigger signals, the switching functions \(d_{o1}\) and \(d_{o2}\) are compared with a sawtooth signal in the CSI PWM. The sextant defined by angle \(\theta_{a}\) determines the switching elements of the CSI that will be turned on and off so that the CSI synthesizes the appropriate line voltages.  
To synchronize the TTI-MC with the CSI, the control algorithm performs two functions that are very important for this purpose: a) it generates the triangular carrier signal for the MCB-PWM of the TTI-MC, and b) it calculates the dc-link virtual voltage of the TI-IDVR. The triangular carrier signal is generated in the PWM of the CSI. The voltage value in the virtual dc-link depends directly on the phase voltages of the reference voltage of the load, the sextant determined by the phase angle \(\theta_{a}\), and the switching functions \(d_{o1}\) and \(d_{o2}\). The voltage in the virtual dc-link is calculated using Equation (33).  
Compared to [12], this paper adds a \"selective control\" based on \"decision rules\" that allows for connecting or disconnecting the feeders to the TT-IDVR according to the present disturbance. This allows for different modes of operation of the TTI-IDVR and to connect the feeders to the TTI-IDVR only when necessary. This has the benefit of more efficient use of the power delivered by the feeders to the TI-IDVR, and no power is taken from the feeder without failure when it is not needed. Furthermore, this is a feature that other IDVRs lack [15; 16; 17; 18; 19; 20; 21; 22]. The inputs to the decision rules are the active powers of the load voltage (\(d_{L}\)) and the load reference voltage (\(d_{ref}\)). The outputs of the decision rules correspond to switches SF1 and SF2 (Figure 2) that connect or disconnect feeders 1 and 2, respectively.  
Figure 6: CSI control algorithm.  
The decision rules for connecting or disconnecting the feeders with respect to the voltages of load 1 are as follows:  
For a swell on feeder 1:  
IF \(d_{L}>1.05^{*}\)\(d_{\textit{ref}}\) THEN SF1 = 1, SF2 = 0; (connects feeder 1 and disconnects feeder 2)  
For a sag on feeder 1:  
IF \(d_{L}<0.95^{*}\)\(d_{\textit{ref}}\) THEN SF1 = 1, SF2 = 1; (connect both feeders)  
The decision rules for connecting or disconnecting the feeders with respect to the voltages of load 2 are similar to those shown for load 1.