\documentclass{article}
\usepackage{fancyhdr}
\usepackage[top=3cm, bottom=3cm, left=3cm, right=3cm]{geometry}
\usepackage[pdftex]{graphicx}
\title{6.302 Motor Lab Take-home Writeup}
\author{Tony Hyun Kim}
\date{\today}

\setlength\parindent{0.0in}
\setlength\parskip{0.1in}
\begin{document}

\maketitle

\section{Lab 1A: Mathematical Model of Motor}
The primary objective of Lab 1A was to measure the parameters of the motor model corresponding to our apparatus. Figure \ref{fig:motor_model} shows the theoretical model in circuit notation. The two most important equations relating the electrical ($V_m$, $I_m$) and mechanical domains ($\theta$ and its derivatives) are:
\begin{eqnarray}
	e_m &=& K_e \dot{\theta}\\
	T   &=& K_t I_m
\end{eqnarray} 
where $e_m$ is the back emf of the spinning motor; and $T$ is the torque generated by the motor, which is proportional to the motor drive current $I_m$.
\begin{figure}[ht]
	\begin{center}
		\includegraphics[scale=0.6]{motor_model.PNG}
	\end{center}
	\caption{\label{fig:motor_model}Electrical model of the motor.}
\end{figure}

Based on the above model, motor transfer functions for both current-drive ($\Theta/I_m$) and voltage-drive ($\Theta/V_m$) can be calculated. They are:
\begin{eqnarray}
	\frac{\Theta}{I_m}\left(s\right) &=& \frac{K_t}{J\cdot s^2}\\
	\frac{\Theta}{V_m}\left(s\right) &=& \frac{1}{s}\cdot\frac{1}{\frac{Js}{K_t}\left(sL_m+R_m\right)+K_e}\\
														 &\approx& \frac{1}{s}\cdot\frac{1/K_e}{\frac{JR_m}{K_tK_e}\cdot s +1} \label{eqn:th_vm_approx}
\end{eqnarray}
where each of the relevant parameters is explained in Table \ref{tab:motor_param}. In Eq. \ref{eqn:th_vm_approx}, we have neglected the high-frequency pole arising from the electronics of the motor, which is much faster than the mechanical time-scale of the device, characterized by $\tau_m = \frac{JR_m}{K_tK_e} = 45.2$ ms. (For comparison, the electrical time-constant is: $\tau_{elec} = \frac{L_m}{R_m} = 0.7$ ms.)
\begin{table}[h]
\caption{\label{tab:motor_param}Measured motor parameters}
\begin{center}
\begin{tabular}{c|c|c}
Name of parameter & Description & Measured value\\
\hline
$K_{tach}$ 	& $\dot{\theta}_m = K_{tach} \dot{\theta}$ & $0.0286 \frac{V\cdot s}{rad}$ \\
$R_m$			 	& Armature resistance & $8.6 \Omega$	\\
$L_m$			 	& Armature inductance & $0.0063 H$ \\
$K_e$			 	& $e_m = K_e \dot{\theta}$, $e_m$ is motor back-emf & $0.0227 \frac{V\cdot s}{rad}$ \\
$n$ 				& Gear ratio & $6.75$ \\
$K_p$				& $\theta_p = K_p \theta$ & $3.279 \frac{V}{rad}$ \\
$J_f$				&	Flywheel inertia & $2.75\times 10^{-5} kg \cdot m^2$ \\
$J_m$				& Motor inertia & $4.6\times10^{-6} kg \cdot m^2$ \\
$K_t$				& $T = K_t \cdot I$ & $0.0231 \frac{N\cdot m}{A}$ 
\end{tabular}
\end{center}
\end{table}

These measurements (of motor station \#1) were utilized in all subsequent labs, even though the latter labs were conducted at different stations. Hence, we may ascribe some of the discrepancies between theory and measurement to the variations among the equipment. 

A major omission in our theoretical model is friction. During our experiments, we noted that we needed to exceed some threshold level at the input drive, in order to get the motor moving; such thresholds are a typical signature of (static) frictional forces. But, because our model does not take friction into account, we should expect discrepancies between measurement and theory. We have observed such deviations, in particular, in the steady-state errors. (Generally, all of our steady-state error measurements were an order of magnitude off of the prediction.)

\section{Lab 1B: Velocity Control Loop}

In Lab 1B, we designed a velocity control loop as shown in Figure \ref{fig:velocity_loop}.
\begin{figure}[ht]
	\begin{center}
		\includegraphics[scale=0.6]{velocity_loop.PNG}
	\end{center}
	\caption{\label{fig:velocity_loop}Block diagram of the velocity control loop.}
\end{figure}

We employed a proportional control compensator (i.e. $G_c = 5.6$ is constant) and also a proportional-plus-integral (PI) compensator of the form $G_c = 5.6\cdot \frac{\tau s+1}{\tau s}$. The value of $5.6$ was deduced by a target closed-loop motor constant of $\tau_m = 35$ ms. This was confirmed in the lab, where we obtained a time-constant of $\tau_{m,meas} = 30$ ms.

The primary comparison to be made between the two schemes is in the steady-state error. With the proportional compensator, we obtained a nonzero steady-state error to a step input: $e_{P} = 0.08$ V. On the other hand, with the PI controller, we got a zero steady-state error. Intuitively, this to be expected, since the integral of the error is now used to correct the output. From a Bode-plot perspective, the PI compensator has the same frequency response as the proportional control at high frequencies, but a much higher low-frequency gain due to the additional integrator. It is this integrator that allows for a zero steady-state error.

In this experiment, we also considered a proportional current-drive loop. The main surprise here was that we obtain experimentally a nonzero steady-state error, contradicting the theoretical prediction of zero error. This discrepancy is ascribed to friction in the motor system, which would replace one of the integrators in $\Theta/I_m$: $Js \rightarrow Js+B$, where $B$ is a velocity-proportional friction coefficient. With this replacement, the theoretical calculation for the steady-state error no longer yields zero.

\section{Lab 1C: Position Control Loop}

In Lab 1C, we implemented a simple position control loop as in Figure \ref{fig:position_loop}.
\begin{figure}[ht]
	\begin{center}
		\includegraphics[scale=0.6]{position_loop.PNG}
	\end{center}
	\caption{\label{fig:position_loop}Block diagram of the position control loop.}
\end{figure}

As before, we placed both a proportional ($G_c = 8$) and a frequency-dependent network in the loop. The frequency-dependent compensator was a lead-network of the form $G_c(s) = 8\cdot\frac{\tau s +1}{0.1\tau s + 1}$, where $\tau$ was targeted for the natural frequency of the proportional-compensated loop transfer function.

We begin with a discussion of the proportional-compensated system. At a gain of $G_c = 8$, the closed-loop system is very lightly damped, with a theoretical damping ratio of $\zeta = 0.0372$. In the laboratory, it was difficult to measure a nonzero damping ratio in the time domain, because the overshoot was extremely close to $100\%$ (corresponding to $\zeta = 0$). The frequency-domain measurements of magnitude peaking and peak frequency corroborated these time-domain measurements.

On the other hand, the time-domain behavior was greatly improved using the lead compensator. We measured only a $10\%$ overshoot in the step response, corresponding to $\zeta = 0.5$. 

We can explain the improvement in system behavior using a Bode plot analysis. Figure \ref{fig:pos_bode} shows the Bode plots of the loop transfer functions for both proportional and lead networks. In particular, the lead compensator ``kicks in'' in the vicinity of the original crossover frequency, increasing the phase margin from a paltry $14.5^\circ$ to a respectable $47.9^\circ$. This additional phase margin corresponds to the increased stability of our lead-compensated position-feedback loop.
\begin{figure}[ht]
	\begin{center}
		\includegraphics[scale=0.35]{pos_bode.PNG}
	\end{center}
	\caption{\label{fig:pos_bode}Bode plots of the proportional and lead-compensated loop transfer functions in Lab 1C. The lead-network greatly improves the phase-margin, and hence the stability of the closed-loop system.}
\end{figure}

\section{Lab 1D: Position Control Loop with Minor Loop}

Finally, we again considered a position control loop. This time, the setup included a minor feedback loop, which took account the velocity of the motor. The scheme is shown in Figure \ref{fig:position_min_loop}.
\begin{figure}[ht]
	\begin{center}
		\includegraphics[scale=0.4]{position_min_loop.PNG}
	\end{center}
	\caption{\label{fig:position_min_loop}Block diagram of the improved position control loop involving tachometric (velocity-dependent) feedback.}
\end{figure}

As usual, we are comparing two candidate elements in the (minor) feedback path. We have considered a constant feedback ($H_{min}(s) = K_{tach}$) and also an ``acceleration feedback'' of the form:
\begin{equation}
	H_{min}(s) = K_{tach}\frac{\tau s}{\tau s + 1}
	\label{eqn:accel_fb}
\end{equation}
with $\tau = 0.2$ s. We begin with a discussion of the simpler, proportional feedback.

Through the gains $G_1$ and $G_2$, it is possible to set the damping ratio ($\zeta$) and the natural frequency ($\omega_n$) of the closed-loop system independently. This fact was demonstrated in the pre-lab by showing that the root-locus plots cover the entire complex plane as a function of $(G_1, G_2)$. For this lab, we have used $G_1$ and $G_2$ such that $\omega_n = 28$ rad/sec and $\zeta = 0.5$.\footnote{I never got my pre-lab back, so I don't remember what $G_1$ and $G_2$ were.} This provides similar performance obtained in the lead-compensated loop of Lab 1C. This claim was confirmed in the laboratory, where we measured a $15\%$ overshoot in the step response.

The main advantage of using a minor loop is to decrease the dependence of the closed-loop system response to the parameters of the plant, e.g. the flywheel inertia. However, we did not pursue such line of investigation in the lab, although it would have been (much more) interesting (than what we actually did, i.e. mainly time/frequency domain measurements of $(\omega_n,\zeta)$). 

Instead, we focused on the steady-state errors of the two compensated systems. For reference, note that if we had used a series lead-compensation on a current-drive position loop, the steady-state error (to an input ramp) would be zero, due to the two open-loop poles at the origin. However, the price we pay for minor compensation is that one of the open-loop poles is removed from the origin via $H_{min}(s) = K_{tach}$, and hence we get a nonzero error. This was confirmed in the lab.

The standard remedy to the nonzero error, which we implemented in this lab, is the usage of the acceleration minor feedback as in Eq. \ref{eqn:accel_fb}. This form of the minor feedback inserts an additional pole at the origin, so that the ramp steady-state error is zero. We verified the zero steady-state error experimentally.

Dynamically, we found that the peak overshoot and the time-to-peak ($t_p$) were modified by using acceleration feedback (instead of proportional feedback). Namely, the peaking was reduced to $6\%$ but the response was slowed from $t_{p,prop} = 97$ ms to $t_{p,accel} = 148$ ms. However, we still have independent control of $\omega_n$ and $\zeta$ through $(G_1,G_2)$ even with acceleration feedback. Hence, it is still possible to shape the step-response dynamics, while maintaining zero steady-state error to an input ramp.


\end{document}