# Zero Average Dynamic Controller for Speed Control of DC Motor
## 2 Materials and Methods
### Strategy for Speed Control in a DC Motor  
As this research aims to control the speed \(W_{m}\), so the reference speed \(W_{mref}\) must be followed and applied to the rotating load of the system. To do this in the \(kT\) period, the following error is defined in the form:  
\[e\;(kT)=W_{m}(kT)-W_{mref}(kT) \tag{21}\]  
In this case, the function \(s(x)\)[26] defines a third-order dynamic in the error variable, as expressed in Equation (22)  
\[s(kT)=e(kT)+k_{s1}\frac{de(kT)}{d(kT)}+k_{s2}\frac{d^{2}e(kT)}{d(kT)^{2}}+k_{ s3}\frac{d^{3}e(kT)}{d(kT)^{3}} \tag{22}\]where the constants \(k_{s1},\ k_{s2},\ k_{s3}\) are parameters obtained as a function of the LC filter constant multiplied by factors \(K_{S1},\ K_{S2},\ K_{S3}\) as shown in Equation (23):  
\[ \begin{array}{c}k_{s1}=K_{S1}\sqrt{LC}\\ k_{s2}=K_{S2}LC\\ k_{s3}=K_{S3}LC\sqrt{LC}\end{array}  \tag{23}\]  
In the previous equations, the terms \(K_{S1}\), \(K_{S2}\), and \(K_{S3}\) are parameters of the ZAD. They can be considered to construct dimensional branching diagrams. Their values can be determined to achieve a desired dynamic behavior in a closed-loop system. Now, when \(W_{mref}\) is constant, then Equation (22) can be written as in Equation (24) and its first derivative as Equation (25):  
\[s(kT)=W_{m}(kT)-W_{mref}(kT)+k_{s1}\frac{dW_{m}(kT)}{d(kT)}+k_{s2}\frac{d^{2}W_ {m}(kT)}{d(kT)^{2}}+k_{s3}\frac{d^{3}W_{m}(kT)}{d(kT)^{3}} \tag{24}\]  
\[\dot{s}(kT)=\frac{dW_{m}(kT)}{d(kT)}+k_{s1}\frac{d^{2}W_{m}(kT)}{d(kT)^{2}}+k_ {s2}\frac{d^{3}W_{m}(kT)}{d(kT)^{3}}+k_{s3}\frac{d^{4}W_{m}(kT)}{d(kT)^{4}} \tag{25}\]  
The duty cycle is then calculated as expressed in:  
\[d_{k}(kT)=\frac{2s\ (kT)+T\dot{s}_{-}(kT)}{T\left(\dot{s}_{-}(kT)-\dot{s}_{+}(kT )\right)} \tag{26}\]  
The term \(s\ (kT)\) is calculated with Equation (22) at the beginning of each switching period to finally obtain \(s\ (kT)=s\ (kT)|\ S_{=ON}\). Additionally, \(\dot{s}_{+}(kT)\) is calculated with Equation (25) to obtain \(\dot{s}_{+}(kT)=\dot{s}(kT)|\ S_{=ON}\). The steps necessary to calculate these variables are shown below:  
\[ \begin{array}{c}\frac{d\dot{t}_{I}}{dt}=-\frac{1}{\mathbbm{c}}v_{c}-\frac{( r_{s}+r_{L})}{L}i_{L}+\frac{F}{L}\\ \frac{dv_{c}}{dt}=-\frac{1}{\mathbbm{c}}i_{a}+\frac{1}{\mathbbm{c}}i_{L}\\ \frac{d\dot{t}_{I}}{dt}=-\frac{k_{s}}{L_{s}}W_{m}-\frac{R_{s}}{L_{s}}i_{a}+ \frac{1}{L_{s}}v_{c}\\ \frac{dW_{m}}{dt}=-\frac{B}{l_{q}}W_{m}+\frac{k_{s}}{l_{q}}i_{a}-\frac{(T_{ \mu i}+T_{L})}{l_{q}}\end{array}  \tag{27}\]  
The second derivatives can be obtained with the previous expression and the following expression is obtained:  
\[ \begin{array}{c}\frac{d^{2}v_{c}}{dt^{2}}=-\frac{1}{\mathbbm{c}}\frac{d \dot{s}_{a}}{dt}+\frac{1}{\mathbbm{c}}\frac{d\dot{t}_{I}}{dt}\\ \frac{d^{2}\dot{t}_{a}}{dt^{2}}=-\frac{k_{s}}{L_{s}}\frac{dW_{m}}{dt}-\frac{R_{ s}}{L_{s}}\frac{d\dot{s}_{a}}{dt}+\frac{1}{L_{s}}\frac{d\dot{t}_{I}}{dt}\\ \frac{d^{2}W_{m}}{dt^{2}}=-\frac{B}{l_{q}}\frac{dW_{m}}{dt^{2}}+\frac{k_{s}}{ l_{q}}\frac{d\dot{t}_{I}}{dt}\end{array}  \tag{28}\]  
The new expressions can be obtained from the second derivatives by deriving again, as shown in Equation (28). \[ \begin{array}{c}\frac{d^{2}\dot{t}_{a}}{dt^{3}}=-\frac{k_{s}}{L_{a}}\frac{ d^{2}W_{m}}{dt^{2}}-\frac{R_{s}}{L_{a}}\frac{d\dot{s}_{a}}{dt^{2}}+\frac{1}{L_{s}} \frac{d^{2}v_{c}}{dt^{2}}\\ \frac{d^{2}W_{m}}{dt^{3}}=-\frac{B}{l_{q}}\frac{d^{2}W_{m}}{dt^{2}}+\frac{k_{ s}}{l_{q}}\frac{d^{2}i_{a}}{dt^{2}}\end{array}  \tag{29}\]  
Then, after finding a new derivate, the following expression is found:  
\[\frac{d^{4}W_{m}}{dt^{4}}=-\frac{B}{l_{eq}}\frac{d^{3}W_{m}}{dt^{3}}+\frac{k_ {t}}{l_{eq}}\frac{d^{3}i_{a}}{dt^{3}} \tag{30}\]  
Applying Equations (24) and (25), and replacing with the values given by Equations (27)-(30), then, the values of \(s\ (kT)\), \(\dot{s}(kT)\) and \(\dot{s}_{+}(kT)=\dot{s}(kT)\big{|}\ S_{=ON}\) are obtained, where \(S=ON\)means that the switch is on.