26-01-2012, 11:27 AM
Implementing a PID Controller Using a PIC18 MCU
[attachment=16621]
INTRODUCTION
Continuous processes have been controlled by
feedback loops since the late 1700’s. In 1788, James
Watt used a flyball governor on his steam engine to
regulate its speed. The Taylor Instrument Company
implemented the first fully functional Proportional,
Integral and Derivative (PID) controller in 1940.
Although feedback control has come a long way since
James Watt, the basic approach and system elements
have not changed. There are several elements within a
feedback system; for discussion purposes, we will use
a home heating temperature control system as our
model in the descriptions below.
OBJECTIVES
The objectives for this application note are to:
• discuss in detail the three elements of a PID
Controller: Proportional, Integral and Derivative
• discuss a firmware PID routine on a PIC18 device
• discuss the implementation of a firmware-based
PID that has the flexibility of adapting to different
systems, but is capable of being specifically tuned
later on
• discuss the details of tuning a PID once
implementation has been completed
SOURCE CODE OVERVIEW
Before going further, let’s discuss how the PID source
code is configured. There is no specific way a PID
should be implemented in firmware; the methods
discussed in this application note only touch upon a few
of the many possibilities.
CONCLUSION
As mentioned in the introduction, the Controller’s
processing capabilities will dictate the system’s ability
to respond to the error. Table 3 shows a list of PID functions,
each with the amount of instruction cycles and
time required. In cases where the Plant response is
sluggish, it may be possible to decrease the processor
speed and save on power, but still be able to execute
the PID routine in acceptable time.