# Artificial Intelligence-Based Controller for DC-DC Flyback Converter
## 2 Modeling of Flyback Converter  
The block diagram of the complete system, along with the circuit diagram of the FC, is presented in Figure 1. FC behaves like a plant to be controlled. To develop a controller for it, its dynamics must be known. Figure 1 shows the FC circuit consisting of a DC voltage source \"\(E\)\", a power MOSFET \"S\", transformer \"\(T\)\" for isolation purposes, diode \"\(D\)\", capacitor \"\(C\)\", and load and magnetizing inductance of transformer \"\(L_{M}\)\". The DC voltage source can be the output of an uncontrolled rectifier (after filtering) that converts AC to DC. The switching MOSFET S is fed with a PWM at high frequency. The purpose of the transformer is also to provide better matching between input and output voltage and current requirements. The diode \(D\) rectifies the secondary voltage of the transformer \(T\). The capacitor \(C\) is for filtration purposes. For determining FC dynamics in CCM, a state-space averaging technique was employed [5; 24; 28]. Inductor current \(I_{LM}\) and voltage across the capacitor \(V_{C}\) were considered as independent state variables of the state vector \(X\). Thus,  
\[X=\left[ \begin{array}{c}I_{LM}\\ V_{C}\end{array} \right] \tag{1}\]  
Figure 1: Block diagram of the complete system. The independent input vector \(u\) is expressed in Equation (2) with input voltage \(E\) and voltage across the diode \(V_{D}\) as constraints. \[u=\left[ \begin{array}{c}E\\ V_{D}\end{array} \right] \tag{2}\]  
The output vector consists of input current \(I_{S}\) and output voltage \(V_{O}\), since in the modeling procedure, input and output are to be modeled, which are dependent quantities. \[Y=\left[ \begin{array}{c}I_{S}\\ V_{O}\end{array} \right] \tag{3}\]  
CCM operation occurs in two modes:  
Mode 1: When the switching MOSFET \(S\) is in ON state, current flows through the primary side of the transformer with magnitude \(I_{S}\), and the diode is reversed biased at the secondary side. Therefore, no current flows in the secondary of the transformer. The capacitor's stored energy supplies the output voltage. The state conditions for Mode 1 are:  
\[\frac{dl_{LM}}{dt}=\frac{E}{L_{M}}-\frac{I_{S}R_{S}}{L_{M}} \tag{4}\]  
\[\frac{dV_{C}}{dt}=-\frac{V_{C}}{(R+R_{C})C} \tag{5}\]  
\[V_{O}=\frac{V_{C}R}{R+R_{C}} \tag{6}\]  
\[I_{S}=I_{LM} \tag{7}\]  
where \(L_{M}\) is the magnetizing inductance of transformer, \(\frac{dl_{LM}}{dt}\) is the rate of change of current in the primary of the transformer, \(E\) is the supply voltage, \(I_{S}\) is the supply current, \(R_{S}\) is the resistance of the switch \(S\), \(C\) is the capacitance, \(\frac{dV_{C}}{dt}\) is the rate of change of capacitor voltage, \(V_{C}\) is the capacitor voltage, \(R\) is the load resistance, \(R_{C}\) is the internal resistance of capacitor, and \(V_{O}\) is the output voltage. Thus, the state-space representation for Mode 1 is as follows:  
\[\dot{x}=Ax+Bu\Rightarrow\left[ \begin{array}{c}\frac{dl_{LM}}{dt}\\ \frac{dV_{C}^{2}}{dt}\end{array} \right]=\left[ \begin{array}{cc}-\frac{R_{S} }{L_{M}}&0\\ 0&-\frac{1}{C(R+R_{C})}\end{array} \right]\left[ \begin{array}{c}I_{LM}\\ V_{C}\end{array} \right]+\left[ \begin{array}{cc}\frac{1}{L_{M}}&0\\ 0&0\end{array} \right]\left[ \begin{array}{c}E\\ V_{D}\end{array} \right] \tag{8}\]  
\[y=Cx+Du\Rightarrow\left[ \begin{array}{c}I_{S}\\ V_{O}\end{array} \right]=\left[ \begin{array}{cc}1&0\\ 0&-\frac{R}{R+R_{C}}\end{array} \right]\left[ \begin{array}{c}I_{LM}\\ V_{C}\end{array} \right]+\left[ \begin{array}{cc}0&0\\ 0&0\end{array} \right]\left[ \begin{array}{c}E\\ V_{D}\end{array} \right] \tag{9}\]  
where \(x\) is a state vector, \(\dot{x}\) is the state vector derivative with regard to time, \(A\) is the system matrix, \(B\) is the input matrix, \(u\) is the input or control vector, \(y\) is the output vector, \(C\) is the output matrix, and \(D\) is the disturbance matrix. Mode 2: When the switching MOSFET S is in OFF state, current flows through the secondary of the transformer and the diode is forward biased.