Skip to content

Instantly share code, notes, and snippets.

@radiosilence
Created December 7, 2009 02:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save radiosilence/250545 to your computer and use it in GitHub Desktop.
Save radiosilence/250545 to your computer and use it in GitHub Desktop.
% NOTES:
% * HAVE AXIS LABELS PLOTTED
% * Put all the working stuff in Appendix 2
% * Talk about Wien bridges in Discussion
\documentclass[a4paper,10pt]{memoir}
\raggedbottom
\setlength{\unitlength}{1cm}
\usepackage{url}
\usepackage{graphicx}
\usepackage{epstopdf}
\usepackage{pstricks}
\usepackage{amsmath,amssymb,amsfonts}
\usepackage{cite}
\usepackage{alltt}
\usepackage{color}
\usepackage{fullpage}
\usepackage{textcomp}
\usepackage{times}
\usepackage[T1]{fontenc}
\usepackage[scaled]{beramono}
%\renewcommand*\familydefault{\ttdefault} %% Only if the base font of the document is to be typewriter style
\usepackage[left=2.5cm,top=2.5cm,right=2.5cm,bottom=2.5cm,nohead,nofoot]{geometry}
\usepackage{natbib}
\bibpunct{(}{)}{;}{a}{,}{,}
\usepackage{float}
\usepackage{relsize,listings}
\lstset{ %
language=Matlab, % choose the language of the code
basicstyle=\relsize{-2}\ttfamily, % the size of the fonts that are used for the code
numbers=left, % where to put the line-numbers
numberstyle=\relsize{-2}\ttfamily, % the size of the fonts that are used for the line-numbers
numbersep=5pt, % how far the line-numbers are from the code
showspaces=false, % show spaces adding particular underscores
showstringspaces=false, % underline spaces within strings
showtabs=false, % show tabs within strings adding particular underscores
frame=none, % adds a frame around the code
tabsize=8, % sets default tabsize to 2 spaces
captionpos=b, % sets the caption-position to bottom
breaklines=true, % sets automatic line breaking
breakatwhitespace=false, % sets if automatic breaks should only happen at whitespace
escapeinside={\%*}{*)} % if you want to add a comment within your code
}
\definecolor{string}{rgb}{0.7,0.0,0.0}
\definecolor{comment}{rgb}{0.13,0.54,0.13}
\definecolor{keyword}{rgb}{0.0,0.0,1.0}
\title{Modelling Assignment\\Module CY2A9}
\author{James E. Cleveland\\\textit{Computer Science \& Cybernetics (BSc)}}
\date{December 7th, 2009}
\begin{document}
\begin{titlingpage}
\setlength{\droptitle}{180pt}
\maketitle
\centering
\includegraphics[width=0.4\linewidth]{runi.eps}
\\~\\~\\~
\begin{abstract}
This report has the results and implementation of finding the transfer function for a Wien Bridge Oscillator circuit (used for converting DC current to sinusoidal or AC current).
It also includes the workings and method behind three other systems which support the methods of analysing the Wien Bridge Oscillator circuit.
The complete workings for the first three systems are available in Appendix C. The object of this is so that if any details are missed in the main report, they can be located here to avoid confusion.
\end{abstract}
\end{titlingpage}
%\textit{NOTE: Although the total page count may be higher than the specified maximum, this is likely due to formatting (blank pages, etc), and contents pages necessary in a double-sided report.}
\tableofcontents
%\clearpage
%\listoffigures
\chapter{Introduction}
\input{introduction}
\chapter{Implementation}
This chapter includes the block diagrams and transfer functions and the algebra used to produce the transfer functions for each system.
%\clearpage
\section{System 1: Mass Spring System}
\input{sys1_imp}
%\clearpage
\section{System 2: Electronic Circuit}
\input{sys2_imp}
%\clearpage
\section{System 3a: Feedback Control System}
\input{sys3a_imp}
%\clearpage
\section{System 3b: Feedback Control System}
\input{sys3b_imp}
%\clearpage
\section{System 4: Wien Bridge Oscillator}
\input{sys4_imp}
%\clearpage
\chapter{Results}
This chapter includes the transfer functions found by hand, those found by MATLAB, the simulated and theoretical output response, and the bode plots for each system.
%\clearpage
\section{System 1: Mass Spring System}
\input{sys1_res}
%\clearpage
\section{System 2: Electronic Circuit}
\input{sys2_res}
%\clearpage
\section{System 3a: Feedback Control System}
\input{sys3a_res}
%\clearpage
\section{System 3b: Feedback Control System}
\input{sys3b_res}
%\clearpage
\section{System 4: Wien Bridge Oscillator}
\input{sys4_res}
%\clearpage
\chapter{Discussion}
\input{discussion}
\chapter{Conclusion}
\input{conclusion}
\chapter*{Acknowledgements}
\begin{itemize}
\item David J. Salisbury: Help with LaTeX, Diagraph
\item Carlos Sainz-Martinez: Help with Math
\end{itemize}
\bibliography{partb}{}
\bibliographystyle{plainnat}
\appendix
\chapter{Code Listing}
\input{code_listing}
\chapter{Analysis For Theoretical Step Response}
\input{analysis_step_response}
\section{System 1: Mass Spring System}
\input{sys1}
\section{System 2: Electronic Circuit}
\input{sys2}
\section{System 3a \& 3b: Modelling feedback control systems}
\input{sys3}
\section{System 4: Wien Bridge Oscillator}
\input{sys4}
\end{document}
\subsection{Task 1}
\begin{figure}[H]
\centering
\input{sys3b_1}
\caption{Block diagram for System 3b with values inserted}
\label{fig:sys3bbd1}
\end{figure}
\begin{align*}
\frac{O\left(s\right)}{I\left(s\right)} & = \frac{\frac{12.5}{\left(1+s3\right)\left(1+s4\right)}}{1+\frac{0.08s\times12.5}{\left(1+s3\right)\left(1+s4\right)}}\\
& = \frac{12.5}{\left(1+s3\right)\left(1+s4\right)+s}\\
\end{align*}
\begin{figure}[H]
\centering
\input{sys3b_2}
\caption{Initial block diagram reduction}
\label{fig:sys3bbd2}
\end{figure}
\begin{align*}
\frac{O\left(s\right)}{I\left(s\right)} & = \frac{0.5\left(\frac{1+s6}{1+s}\right)\left(\frac{12.5}{\left(1+s3\right)\left(1+s4\right)+s}\right)}{1+0.5\left(\frac{1+s6}{1+s}\right)\left(\frac{12.5}{\left(1+s3\right)\left(1+s4\right)+s}\right)}\times\frac{1+s}{1+s}\\
& = \frac{0.5\left(1+s6\right)\left(\frac{12.5}{\left(1+s3\right)\left(1+s4\right)+s}\right)}{\left(1+s\right)+0.5\left(1+s6\right)\left(\frac{12.5}{\left(1+s3\right)\left(1+s4\right)+s}\right)}\times\frac{\left(1+s3\right)\left(1+s4\right)+s}{\left(1+s3\right)\left(1+s4\right)+s}\\
& = \frac{6.25\left(1+s6\right)}{\left(1+s\right)\left(\left(1+s3\right)\left(1+s4\right)+s\right)+6.25\left(1+s6\right)}\\
& = \frac{6.25\left(1+s6\right)}{\left(1+s3\right)\left(1+s4\right)\left(1+s\right)+\left(s^2+s\right)+6.25\left(1+s6\right)}\\
\\
\left(1+s3\right)\left(1+s4\right) & = 12s^2+7s+1\\
\left(12s^2+7s+1\right)\left(1+s\right) & = 12s^3 + 19s^2 + 8s + 1\\
\\
\frac{O\left(s\right)}{I\left(s\right)} & = \frac{6.25\left(6s+1\right)}{12s^3+20s^2+9s+1+6.25\left(6s+1\right)}\times\frac{4}{4}\\
& = \frac{25\left(6s+1\right)}{25\left(6s+1\right)+48s^3+80s^2+36s+4}\\
\end{align*}
Factorising $48s^3+80s^2+36s+4$, (Figure~\ref{fig:sys3bldiv})
\setlength{\tabcolsep}{1pt}
\begin{figure}[H]
\centering
\begin{tabular}{lllll}
& $8s^2+$ & $12s+$ & $4$\\
\cline{2-5}
$6s+1 \div$ & $48s^3+$ & $80s^2+$ & $36s+$ & $4$ \\
& $48s^3$ & $8s^2$\\
& & $72s^2+$ & $36s+$ & $4$ \\
& & $72s^2+$ & $12s$\\
& & & $24s+$ & $4$\\
& & & $24s+$ & $4$\\
\end{tabular}
\caption{Long division to factorise $48s^3+80s^2+36s+4$ }
\label{fig:sys3bldiv}
\end{figure}
\begin{align*}
\frac{O\left(s\right)}{I\left(s\right)} & = \frac{25\left(6s+1\right)}{25\left(6s+1\right)+\left(6s+1\right)\left(8s^2+12s+4\right)}\\
& = \frac{25}{8s^2+12s+29}
\end{align*}
This is the transfer function.
\subsection{Task 2}
\begin{figure}[H]
\begin{alltt}
% System 3b: Feedback Control Systems
S=1;
C= 0.5 * tf( [6 1], [1 1] );
L = tf( [0.08 0], 1 );
P = tf( 12.5, [12 7 1] );
M = 1;
sys3b_tf = S * feedback ( C * feedback( P, L ), M );
minreal( sys3b_tf )
Transfer function:
3.125
-------------------
s^2 + 1.5 s + 3.625
\end{alltt}
\end{figure}
This is the same as the transfer function that was derived manually.
\subsection{Task 3}
To get the function $o(t)$, output in the time domain.
\begin{align*}
\frac{O\left(s\right)}{I\left(s\right)}\times\frac{1}{s} & = \frac{1}{s}\times\frac{25}{8s^2+12s+29}\\
& = \frac{25}{s\left(8s^2+12s+29\right)}\\
& = \frac{A}{s} + \frac{Bs+C}{8s^2+12s+29}\\
25 & = A\left(8s^2+12s+29\right) + Bs^2 + C\\
\end{align*}
Let $s = 0$:
\begin{align*}
25 & = 29A\\
A & = \frac{25}{29}
\end{align*}
Let $s = 1$:
\begin{align*}
25 & = \frac{1225}{29} + B + C\\
\end{align*}
Let $s = 2$:
\begin{align*}
25 & = \frac{2124}{29} + 4B + 2C\\
\frac{-500}{29} & = B + C\\
\frac{-1400}{29} & = 4B + 2C\\
B & = \frac{-200}{29}\\
C & = \frac{-300}{29}\\
\end{align*}
These values can then be put back into the origin output function.
\begin{figure}[H]
\begin{align*}
O\left(s\right) & = \frac{25}{29s} + \frac{\frac{-200}{29}s + \frac{-300}{29}}{8s^2+12s+29}\\
& = \frac{\frac{-200}{29}s + \frac{-300}{29}}{8s^2+12s+29}\times\frac{\frac{1}{8}}{\frac{1}{8}}\\
& = \frac{\frac{-25}{29}s + \frac{-37.5}{29}}{s^2+\frac{3}{2}s+\frac{29}{8}}\\
& = \frac{-\frac{25}{29}\left(s+\frac{3}{2}\right)}{\left(s+\frac{3}{4}\right)^2+\frac{49}{16}}\\
& = \frac{-\frac{25}{29}\left(s+\frac{3}{4}\right)}{\left(s+\frac{3}{4}\right)^2+\frac{49}{16}}+\frac{-\frac{25}{29}\times\frac{3}{4}}{\left(s+\frac{3}{4}\right)^2+\frac{49}{16}}\\
\frac{-\frac{25}{29}\times\frac{3}{4}}{\left(s+\frac{3}{4}\right)^2+\frac{49}{16}} & = \frac{-\frac{75}{203}\times\frac{7}{4}}{\left(s+\frac{3}{4}\right)^2+\frac{49}{16}}\\
& = \frac{\frac{7}{4}\left(\frac{3}{7}\times-\frac{25}{29}\right)}{\left(s+\frac{3}{4}\right)^2+\left(\frac{7}{4}\right)^2}\\
\\
O\left(s\right) & = \frac{25}{29s} + \frac{-\frac{25}{29}\left(s+\frac{3}{4}\right)}{\left(s+\frac{3}{4}\right)^2 + \left(\frac{7}{4}\right)^2} + \frac{\frac{7}{4}\left(\frac{3}{7}\times-\frac{25}{29}\right)}{\left(s+\frac{3}{4}\right)^2 + \left(\frac{7}{4}\right)^2}\\
\\
o\left(t\right) & = \frac{25}{29} - \frac{25}{29}e^{-\frac{3}{4}t}\cos{\frac{7}{4}t} - \frac{3}{7}\frac{25}{29}e^{-\frac{3}{4}t}\sin{\frac{7}{4}t}\\
& = \frac{25}{29}\left(1-e^{-\frac{3}{4}t}\cos{\frac{7}{4}t}-\frac{3}{7}e^{-\frac{3}{4}t}\sin{\frac{7}{4}t}\right)\\
\\
& = \frac{25}{29}\left(1-e^{-\frac{3}{4}t}\left(\cos{\frac{7}{4}t}+\frac{3}{7}\sin{\frac{7}{4}t}\right)\right)\\
\end{align*}
\caption{Obtaining the output function in the time domain for System 3b}
\label{fig:sys4outfunc}
\end{figure}
\subsection{Task 4}
\begin{figure}[H]
\centering
\input{sys3b_mat}
\caption{MATLAB code for System 3b}
\label{fig:sys3mlab}
\end{figure}
\begin{figure}[H]
\centering
\includegraphics[height=100mm]{plots_sys3b.eps}
\caption{Graph and Bode Plot for System 3b}
\label{fig:sys3bplots}
\end{figure}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment