Solo disponible en BuenasTareas
  • Páginas : 21 (5137 palabras )
  • Descarga(s) : 0
  • Publicado : 1 de septiembre de 2010
Leer documento completo
Vista previa del texto
Implementing a PID Controller Using a PIC18 MCU
Author: Chris Valenti Microchip Technology Inc. • Disturbances – These are unwanted inputs to the Plant, which can be common. A disturbance would be an open entry door allowing a gust of cold air to blow in, quickly dropping the temperature and causing the heat to come on. • Controller – Intentionally left for last, this is the mostsignificant element of a control system. The Controller is responsible for several tasks and is the link that connects together all of the physical and nonphysical elements. It measures the output signal of the Plant’s Sensors, processes the signal and then derives an error based on the signal measurement and the Setpoint. Once the sensor data has been collected and processed, the result must be used tofind PID values, which then must be sent out to the Plant for error correction. The rate at which all of this happens is dependent upon the Controller’s processing power. This may or may not be an issue depending on the response characteristic of the Plant. A temperature control system is much more forgiving on a Controller’s processing capabilities than a motor control system. Figure 1 shows abasic block diagram of a feedback control system.

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 hascome 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. • Plant – The physical heating and cooling parts of the system. • Sensors – The devices (thermistors measuring temperature) that measure thevariables within the Plant. • Setpoint – This is a value (i.e., 70 degrees), which is converted to a voltage that the process drives towards. • Error Signal – This is the difference between the response of the Plant and the desired response (Setpoint). In a house, the thermostat may be set to 70 degrees, but the temperature is actually 65 degrees, therefore resulting in an error of 5 degrees(Error = Setpoint – Measured).


Controller Output Controller Plant Process Variable




 2004 Microchip Technology Inc.

DS00937A-page 1

The objectives for this application note are to: • discuss in detail the three elements of a PID Controller: Proportional, Integral and Derivative • discuss afirmware 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 PID source code with the PID’s variable declarations. The gains for proportional, integral and derivative all have a rangeof 0 to 15. For resolution purposes, the gains are scaled by a factor of 16 with an 8-bit maximum of 255. A general flow showing how the PID routine would be implemented in the main application code is presented in Figure 2. There were two methods considered for handling the signed numbers. The first method was to use signed math routines to handle all of the PID calculations. The second was to useunsigned math routines and maintain a sign bit in a status register. The latter method was implemented. There are five variables that require a sign bit to be maintained: • • • • • error a_error p_error d_error pid_error

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...
tracking img