Worked through red pen of PID description

This commit is contained in:
Robin Clark 2012-11-25 11:05:30 +00:00
parent 16d41126f4
commit 754ea3477d

View File

@ -699,9 +699,7 @@ to obtain the output required.
\subsection{Design Stage: Implementation on a micro-controller.} \subsection{Design Stage: Implementation on a micro-controller.}
When designing a computer program it is often useful to 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}. 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]+ \begin{figure}[h]+
\centering \centering
\includegraphics[width=300pt]{./CH5_Examples/context_diagram_PID.png} \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} \end{figure}
We have two voltage inputs (see section~\ref{sec:Pt100}) from the Pt100 temperature sensor. 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 For the Pt100 sensor, we will need to read the voltages it outputs and for this
we will need and ADC and MUX. we will need an 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}. For the output, we can use a Pulse Width Modulator (PWM) (this is a common module found on micro-controllers
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 allowing a variable power output~\cite{pwm}). PWM's ADC's and MUX's are commonly built into cheap micro-controllers~\cite{pic18f2523}.
channelled through a PWM module, again built into the micro-controller, see figure~\ref{fig:context_diagram2_PID}. 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]+ \begin{figure}[h]+
\centering \centering
\includegraphics[width=300pt]{./CH5_Examples/context_diagram2_PID.png} \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} \label{fig:context_diagram2_PID}
\end{figure} \end{figure}
The Yourdon methodology allows us to zoom into data transform bubbles and analyse them in more 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. 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. 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 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}. Most micro-controllers feature several general purpose timers~\cite{pic18f2523}.
We can use an internal timer in conjunction with the monitor function We can use an internal timer in conjunction with the monitor function
to call the PID algorithm at a specified interval. 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] \begin{figure}[h]
\centering \centering
\includegraphics[width=300pt]{./CH5_Examples/context_software.png} \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} \caption{Context diagram of the software in the PID temperature controller}
\label{fig:contextsoftware} \label{fig:contextsoftware}
\end{figure} \end{figure}
sing figure~\ref{fig:contextsoftware} we can now pick the transform bubble we Using figure~\ref{fig:contextsoftware} we can now pick the transform bubble we
want to be the `main' or controoling function in the software. 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 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}. forming the software call tree hierarchy, see figure~\ref{fig:context_calltree}.
\begin{figure}[h]+ \begin{figure}[h]+
@ -752,16 +763,21 @@ forming the software call tree hierarchy, see figure~\ref{fig:context_calltree}.
\end{figure} \end{figure}
This is clearly going to be the monitor function. 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 the determine\_set\_point\_error function with that calling convert\_ADC\_to\_T
which calls Read\_ADC (the function developed in the earlier example). 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 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. that will be used in the temperature controller.
We can list these and begin, from the bottom-up We list these and begin, from the bottom-up,
applying FMMD analysis. to apply FMMD analysis.
\clearpage \clearpage
\subsection{FMMD Analysis of PID temperature Controller} \subsection{FMMD Analysis of PID temperature Controller}
@ -810,7 +826,7 @@ $$ fm(Pt100) = \{ OUT\_OF\_RANGE \} $$
\paragraph{PWM} \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 It then applies a mark space ratio proportional to that value providing
a means of applying varying amounts of power. When the PWM 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. 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 %\clearpage