From 754ea3477da8d62812d4690e707e6434e45a0b45 Mon Sep 17 00:00:00 2001 From: Robin Clark Date: Sun, 25 Nov 2012 11:05:30 +0000 Subject: [PATCH] Worked through red pen of PID description --- submission_thesis/CH5_Examples/software.tex | 53 +++++++++++++-------- 1 file changed, 34 insertions(+), 19 deletions(-) diff --git a/submission_thesis/CH5_Examples/software.tex b/submission_thesis/CH5_Examples/software.tex index 127a4c4..b537592 100644 --- a/submission_thesis/CH5_Examples/software.tex +++ b/submission_thesis/CH5_Examples/software.tex @@ -699,9 +699,7 @@ to obtain the output required. \subsection{Design Stage: Implementation on a micro-controller.} When designing a computer program it is often useful to produce a structured analysis `Yourdon' context diagram~\cite{Yourdon:1989:MSA:62004}, see figure~\ref{fig:context_diagram_PID}. -The Yourdon methodology also gives us a guide as to which software -functions should be called to control the process, or in `C' terms be the main function. -% + \begin{figure}[h]+ \centering \includegraphics[width=300pt]{./CH5_Examples/context_diagram_PID.png} @@ -711,11 +709,13 @@ functions should be called to control the process, or in `C' terms be the main f \end{figure} We have two voltage inputs (see section~\ref{sec:Pt100}) from the Pt100 temperature sensor. For the Pt100 sensor, we will need to read the voltages it outputs and for this -we will need and ADC and MUX. -For the output, we can use a Pulse Width Modulator (PWM) output. This is a common module found on micro-controllers -allowing a variable power output. PWM's ADC's and MUX's are commonly built into cheap micro-controllers~\cite{pic18f2523}. -We can now build more detail into the Yourdon diagram, with the afferent flow coming through the MUX and ADC on the micro-controller, and the afferent -channelled through a PWM module, again built into the micro-controller, see figure~\ref{fig:context_diagram2_PID}. +we will need an ADC and MUX. +% +For the output, we can use a Pulse Width Modulator (PWM) (this is a common module found on micro-controllers +allowing a variable power output~\cite{pwm}). PWM's ADC's and MUX's are commonly built into cheap micro-controllers~\cite{pic18f2523}. +We can now build more detail into the Yourdon diagram, with the afferent data flow coming through the MUX and ADC on the micro-controller, and the afferent +channelled through a PWM module, %again built into the micro-controller, +see figure~\ref{fig:context_diagram2_PID}. \begin{figure}[h]+ \centering \includegraphics[width=300pt]{./CH5_Examples/context_diagram2_PID.png} @@ -724,14 +724,25 @@ channelled through a PWM module, again built into the micro-controller, see figu \label{fig:context_diagram2_PID} \end{figure} The Yourdon methodology allows us to zoom into data transform bubbles and analyse them in more -detail. the controlling software requires definition and we now zoom into and define this in terms of software functions. +detail. +% +We define the controlling software, by looking at or zooming into its trafnsform bubble. +We have the inputs and outputs from the software. +We refine the data flow within the software and thus define software functions. +%, and +%this in terms of software functions. +% We follow the data streams through the process, creating transform bubbles as required. In all `bare~metal' software architectures, we need a rudimentary operating system, often referred to as the monitor. PID, because the algorithm depends heavily on integration, is time sensitive -and we therefore need to invoke at at specific intervals. +and we therefore need to invoke at specific intervals. Most micro-controllers feature several general purpose timers~\cite{pic18f2523}. We can use an internal timer in conjunction with the monitor function to call the PID algorithm at a specified interval. +\paragraph{Data flow model to programmatic call tree.} +The Yourdon methodology also gives us a guide as to which software +functions should be called to control the process, or in `C' terms be the main function. +% \begin{figure}[h] \centering \includegraphics[width=300pt]{./CH5_Examples/context_software.png} @@ -739,8 +750,8 @@ to call the PID algorithm at a specified interval. \caption{Context diagram of the software in the PID temperature controller} \label{fig:contextsoftware} \end{figure} -sing figure~\ref{fig:contextsoftware} we can now pick the transform bubble we -want to be the `main' or controoling function in the software. +Using figure~\ref{fig:contextsoftware} we can now pick the transform bubble we +want to be the `main' or controlling function in the software. This can be thought of as picking one bubble and holding it up. The other bubbles hang underneath forming the software call tree hierarchy, see figure~\ref{fig:context_calltree}. \begin{figure}[h]+ @@ -752,16 +763,21 @@ forming the software call tree hierarchy, see figure~\ref{fig:context_calltree}. \end{figure} This is clearly going to be the monitor function. -This will examine the timer value, and call the PID function, which will call first +\paragraph{Software Algorithm.} +The monitor function will orchestrate the control process. +Firstly it will examine the timer value, and when appropriate, call the PID function, which will call first the determine\_set\_point\_error function with that calling convert\_ADC\_to\_T which calls Read\_ADC (the function developed in the earlier example). With the set point error value the PID function will call the output control function with its PID -demand. On returning to the monitor function, it will return the PID demand value. +demand. +On returning to the monitor function, it will return the PID demand value. +The PID demand value will be applied via the PWM. +We now have a rudimentary closed loop control system incorporating both hardware and software. % -Now we have the system design we have all the components, hardware elements and software functions +Using the Yourdon methodology we have the system design: we have all the components, hardware elements and software functions that will be used in the temperature controller. -We can list these and begin, from the bottom-up -applying FMMD analysis. +We list these and begin, from the bottom-up, +to apply FMMD analysis. \clearpage \subsection{FMMD Analysis of PID temperature Controller} @@ -810,7 +826,7 @@ $$ fm(Pt100) = \{ OUT\_OF\_RANGE \} $$ \paragraph{PWM} -The PWM in use is a hardware register written to with an integer value. +The PWM, in use, is a hardware register written to with an integer value. It then applies a mark space ratio proportional to that value providing a means of applying varying amounts of power. When the PWM action is halted the digital output pin associated with it will typically be held in a high or low state. @@ -1014,6 +1030,5 @@ the monitor program....... -TLC tomorrow... %\clearpage