**5. Controller Architecture**

The proposed controller is designed to inject AC current for all three modes as described in Section 2. The proposed versatile controllers architecture is shown in Figure 10. The overall proposed closed loop control system consists of references, feedback controller, sensing gain (*H*), feedforward term, estimator, PWM modulation transfer function, *GPWM*, output current transfer function, *Gid*, and voltage transfer function, *Gvi*. The current reference, *I*∗ *out*, is selected based on desired mode of operation and frequency as in (48).

$$I\_{out}^\*(t) = I\_{dc}^\* + I\_{m}^\* \sin(\omega^\* t) \tag{48}$$

where, *I*∗ *dc* is the DC level of the current based on the desired mode, *I*<sup>∗</sup> *<sup>m</sup>* is the desired amplitude of the AC signal, and *ω*∗ is the desired angular frequency of the AC signals.

**Figure 10.** Structure of the proposed controller for AC current injector.

The value of reference current, *I*∗ *out*, is compared with the output current *Iout* and the current error, *Ierr*, is calculated by (49). The error is compensated by a PI feedback controller. The feedback controller gives feedback duty, *df b*, by (50).

$$I\_{err}(t) = I\_{out}^\*(t) - I\_{out}(t) \tag{49}$$

$$d\_{fb}(t) = k\_p I\_{err}(t) + k\_i \int I\_{err}(t)dt\tag{50}$$

The saturation blocks of the proposed controller keep the value of *df b* within the range of −1 to +1. The feedforward duty, *df f* , is calculated in (51) using the estimated open circuit voltage, *Vbat*, and input voltage, *Vin*.

$$d\_{ff}(t) = \frac{\mathcal{V}\_{bat}(t)}{V\_{in}} \tag{51}$$

The feedback and feedforward terms are combined by (52).

$$d = d\_{ff} + d\_{fb} \tag{52}$$

The value of *Vbat* is estimated using an estimator as shown in Figure 11. The estimator takes *Vout* and *Iout* as input. It uses low pass filters to estimate *Vdc* and *Idc*. A high pass filter is used to estimate *<sup>v</sup>ac* and *iac*. From the value of *<sup>v</sup>ac* and *iac*, the magnitude of battery impedance | *Z*| is calculated. The saturation block is used to limit the unexpected values. Using *Idc*, | *Z*| and *Vdc*, the value of *Vbat* is calculated by (53).

$$
\hat{V}\_{\text{bat}} = \hat{V}\_{\text{dc}} - \hat{I}\_{\text{dc}} |\bar{Z}| \tag{53}
$$

**Figure 11.** Proposed estimator for the open circuit voltage of a battery.
