next up previous contents
Next: The Resolution of the Up: Practical Concerns Previous: Resolution of Output   Contents

The Resolution of $e(t)$ and $K_{p}$

The proportional term is the main component of the output of a PID loop. As a result, $K_{p}$ is an important coefficient, as is the error term itself.

We need to determine the resolution of the error term, $e(t)$. Let us consider a system where the speed can be up to $x$ticks/s. This means the error term can be up to $2x$ because the motor can be spinning full speed backward and ask to spin full speed forward.

The next factor is how often to run the PID loop logic. The frequency of the loop $f$ helps to determine the resolution of the error term. Although the actual error can be up to $2x$ticks/s, between each PID invocation, the difference only be up to $\frac{2x}{f}$. For example, if the top speed of a reversible system is 1200 ticks/s, and the PID loop is invoked at 50Hz, $e(t)$ can only range from -48 to 48, which can be represented by a 7-bit signed integer.

The number of bit required for $e(t)$ is, then,


\begin{displaymath}
r_{e}=\frac{\log{\frac{4x}{f}}}{\log{2}}
\end{displaymath} (9.3)

When $r_{e}$ is close to $r_{k}$, the magnitude of $K_{p}$ is small. This means you need to rely on fractions in $K_{p}$ to fine tune the terms. Instead of using floating point numbers, many small MCUs benefit from the use of more efficient integer/fixed number computations.

For example, even if we know that $K_{p}$ does not exceed 4, we can use 8 bits to represent it. The least significant 6 bits become fractional terms. Given an integral bit pattern of $10110101_{2}$, the actual represented value is $\frac{10110101_{2}}{2^6}$. The division by $2^6$ is inexpensively performed by right shift operations.


next up previous contents
Next: The Resolution of the Up: Practical Concerns Previous: Resolution of Output   Contents
Tak Auyeung 2003-09-29