DSP, Micros & Memory


Mixed-signal control circuits use microcontroller for flexibility in implementing PID algorithms

22 September 2004 DSP, Micros & Memory Security Services & Risk Management

Ref: z2717154m

Introduction

When a process is controlled (Figure 1), a characteristic of the process, such as a temperature (regulated variable), is compared with the desired value, or setpoint. The difference, or error signal, e(t), is applied to a controller, which uses the error signal to produce a control signal, u(t), that manipulates a physical input to the process (manipulated variable), causing a change in the regulated variable that will stably reduce the error.

A commonly used control operator is a proportional-integral-derivative (P-I-D, or PID) controller. It sums three terms derived from the error: a simple gain, or proportional term; a term proportional to the integral of the error, or integral term; and a term proportional to the rate of change of the error signal, or derivative term. In the closed loop, the proportional term seeks to reduce the error in proportion to its instantaneous value; the integral term-accumulating error-slowly drives the error towards zero (and its stored error tends to drive it beyond zero); and the derivative term uses the rate of change of error to anticipate its future value, speeding up the response to the proportional term and tending to improve loop stability by compensating for the integral term's lag.

The combination of these terms can provide very accurate and stable control. But the control terms must be individually adjusted or 'tuned' for optimum behaviour in a particular system. Because processes with many lags or substantially delayed response are hard to control, a simple PID controller is best used for processes that react readily to changes in the manipulated variable (which often controls the amount or rate-of-flow of energy added to the process). PID control is useful in systems where the load is continually varying and the controller is expected to respond automatically to frequent changes in setpoint-or deviations of the regulated variable (due to changes in ambient conditions and loading).

Figure 1. Control loop employing a PID control function
Figure 1. Control loop employing a PID control function

The parameters of PID controllers for slow processes are usually obtained initially by working with system models scaled up in speed. There are many advanced control strategies, but the great majority of industrial control systems use PID controllers because they are standard, time-tested, well understood industrial components. Moreover, due to process uncertainties, a more-sophisticated control scheme is not necessarily more efficient than a well-tuned PID controller for a given process.

The PID terms were briefly explained above. Here is a more complete explanation of them.

Proportional control

Proportional control applies a corrective term proportional to the error. The proportionality constant (KP) is known as the proportional gain of the controller. As the gain is increased, the system responds faster to changes in setpoint, and the final (steady-state) error is smaller, but the system becomes less stable, because it is increasingly under-damped. Further increases in gain will result in overshoots, ringing, and ultimately, undamped oscillation.

Integral control

Although proportional control can reduce error substantially, it cannot by itself reduce the error to zero. The error can, however, be reduced to zero by adding an integral term to the control function. An integrator in a closed loop must seek to hold its average input at zero (otherwise, its output would increase indefinitely, ending up in saturation or worse). The higher the integral gain constant, KI, the sooner the error heads for zero (and beyond) in response to a change; so to set KI too high is to invite oscillation and instability.

Derivative control

Adding a derivative term - proportional to the time derivative, or rate-of-change, of the error signal - can improve the stability, reduce the overshoot that arises when proportional and/or integral terms are used at high gain, and improve response speed by anticipating changes in the error. Its gain, or the 'damping constant', KD, can usually be adjusted to achieve a critically damped response to changes in the setpoint or the regulated variable. Too little damping, and the overshoot from proportional control may remain; too much damping may cause an unnecessarily slow response. The designer should also note that differentiators amplify high frequency noise appearing in the error signal.

In summary, a proportional controller (P) will reduce the rise time and will reduce, but never eliminate, the steady state error. A proportional-integral (PI) controller will eliminate the steady state error, but it may make the transient response worse. A proportional-integral-derivative controller (PID) will increase the system stability, reduce the overshoot, and improve the transient response. Effects of increasing a given term in a closed-loop system are summarised in Table I.

Table 1
Table 1

The sum of the three terms is

The corresponding operational transfer function is:

In the system of Figure 1, the difference between the setpoint value and the actual output is represented by the error signal e(t). The error signal is applied to a PID controller, which computes the derivative and the integral of this error signal, applies the three coefficients, and performs the above summation to form the signal, u(t).

Digital PID control

The PID algorithm, now widely used in industrial process control, has been recognised and employed for nearly a century, originally in pneumatic controllers. Electronics - first used to model PID controls in control-system design with analog computers in the 1940s and '50s - became increasingly involved in actual process-control loops, first as analog controllers, and later as digital controllers. Software implementation of the PID algorithm with 8-bit microcontrollers is well documented.

In this article we show the basic components of a digital PID controller - and then show how process control can be implemented economically using a MicroConverter, a data-acquisition system on a chip.

One might consider the use of a PID loop, for example, in an airconditioning or refrigeration system to accurately maintain temperature in a narrow range, using continuous monitoring and control (as opposed to thermostatic on-off control). Figure 2 shows a basic block diagram of a control system that regulates temperature by continuously adjusting fan speed, increasing or decreasing the airflow from a low-temperature source.

Figure 2. Example of a PID controller for a temperature-controlled ventilation system using discrete components
Figure 2. Example of a PID controller for a temperature-controlled ventilation system using discrete components

The system is required to maintain the room temperature as close as possible to the user-selected (setpoint) value. To do this, the system must accurately measure the room temperature and adjust the fan speed to compensate.

In the system shown in Figure 2, a precision current source drives a current through a resistive temperature sensor - a thermistor or RTD-in series with a reference resistor, adjusted to represent the desired temperature. The analog-to-digital converter (ADC) digitises the difference between the reference voltage and the thermistor voltage as a measure of the temperature error. An 8-bit microcontroller is used to process the ADC results, and to implement the PID controller. The microcontroller adjusts the fan speed, driving it via the digital-to-analog converter (DAC). External program memory and RAM are required to operate the 8-bit microcontroller and execute the program.

If proportional control (P) on its own were used, the rate at which the fans run would be directly related to the temperature difference from the setpoint. As mentioned earlier, this will leave a steady state error in place.

Adding an integral term (PI) results in the fan speed rising or falling with the ambient temperature. It adjusts the room temperature to compensate for errors due to the ambient rise in temperature through the day and then the temperature fall in the evening. The integral term thus removes the offset, but if the integral gain is too high, oscillation about the setpoint can be introduced. (Note that oscillation is inherent in temperature-control systems employing on-off thermostats.)

This oscillatory tendency can be greatly reduced by adding in a derivative term (PID). The derivative term responds to the rate of change of the error from the setpoint. It helps the system rapidly correct for sudden changes due to a door or window being opened momentarily.

To simplify this system, minimising parts cost, assembly cost, and board area, an integrated system-on-a-chip (SoC) solution can be used, as shown in Figure 3.

Figure 3. System-on-a-chip implementation
Figure 3. System-on-a-chip implementation

The ADuC845 MicroConverter includes 62 Kbytes of flash/EE program memory, 4 Kbytes of flash data memory, and 2 Kbytes of RAM. The flash data memory can be used to store the coefficients for a 'tuned' PID loop, while the single-cycle core provides enough processing power to simultaneously implement the PID loop and perform general tasks.

Depending on which MicroConverter is selected, the resolution of the ADC ranges from 12 to 24 bits. In a system where the temperature needs to be maintained to 0,1°C accuracy, the ADuC845's high performance 24-bit sigma-delta ADC is ideal.

A second type of application where a PID control loop is useful is setpoint (servo) motor control. In this application the motor is required to move to, maintain, and follow an angular position defined by a user input (for example, the rotation of a potentiometer - Figure 4).

Figure 4. Example of a motor control system embodies with discrete components
Figure 4. Example of a motor control system embodies with discrete components

Again, this system can be implemented using many discrete components or, more simply, with an integrated solution. Figure 5 shows a demonstration system built using the MicroConverter. The circuitry on the board causes the pointer to follow the rotation of the setpoint input potentiometer.

Figure 5. Sample motor control system using discrete components
Figure 5. Sample motor control system using discrete components

Figure 6. System-on-a-chip implementation of Figure 4
Figure 6. System-on-a-chip implementation of Figure 4

With the blocks integrated in the compact form of the ADuC842, parts and assembly costs are lower; the computational electronics occupies considerably less space and is more reliable. Figure 6 shows the simplicity of the system hardware using the SoC approach.

Besides the ADuC842, the board includes a potentiometer buffer amplifier, an output power amplifier that drives the motor, a 5 V low-noise regulator for the low-power electronics, and a huskier 5 V regulator (with heatsink) for the motor. The board also includes status LEDs, a RESET button, a serial-data download button, and some passive elements.

Using PC software to simulate the rest of the system, Figure 7 shows responses for different levels of system tuning, and demonstrates the importance of the integral term.

Figure 7. Proportional-integral (P-I) control for three settings of the integral term. Note the offset from 1,0 for K<sub>I</sub> = 0, the lightly damped oscillatory tendency for K<sub>I</sub> = 2000, with oscillations almost eliminated at K<sub>I</sub> = 550
Figure 7. Proportional-integral (P-I) control for three settings of the integral term. Note the offset from 1,0 for KI = 0, the lightly damped oscillatory tendency for KI = 2000, with oscillations almost eliminated at KI = 550

The improvement in overall system step response when implemented with the full PID loop is clearly shown in Figure 8. The response is fast, accurate, and damped, with no offset, oscillation, or overshoot.

Figure 8. Proportional-integral-derivative (PID) control response
Figure 8. Proportional-integral-derivative (PID) control response





Share this article:
Share via emailShare via LinkedInPrint this page

Further reading:

Rewriting the rules of reputation
Technews Publishing Editor's Choice Security Services & Risk Management
Public Relations is more crucial than ever in the generative AI and LLMs age. AI-driven search engines no longer just scan social media or reviews, they prioritise authoritative, editorial content.

Read more...
How can South African organisations fast-track their AI initiatives?
AI & Data Analytics Security Services & Risk Management
While the AI market in South Africa is anticipated to grow by nearly 30% annually over the next five years, tapping into the promise and potential of AI is not easy.

Read more...
Efficient, future-proof estate security and management
Technews Publishing ElementC Solutions Duxbury Networking Fang Fences & Guards Secutel Technologies OneSpace Technologies DeepAlert SMART Security Solutions Editor's Choice Information Security Security Services & Risk Management Residential Estate (Industry) AI & Data Analytics IoT & Automation
In February this year, SMART Security Solutions travelled to Cape Town to experience the unbelievable experience of a city where potholes are fixed, and traffic lights work; and to host the Cape Town SMART Estate Security Conference 2025.

Read more...
KIOXIA pioneer new 3D Flash technology
EBV Electrolink DSP, Micros & Memory
KIOXIA Corporation and Sandisk Corporation have pioneered a state-of-the-art 3D flash memory technology, setting the industry benchmark with a 4,8 Gb/s NAND interface speed, superior power efficiency, and heightened density.

Read more...
Artificial intelligence meets embedded development
Avnet Silica DSP, Micros & Memory
Microchip Technology is leveraging the power of artificial intelligence (AI) to assist software developers and embedded engineers in writing and debugging code with the launch of its MPLAB AI Coding Assistant.

Read more...
Embedded module for AI vision applications
Rugged Interconnect Technologies DSP, Micros & Memory
The TQMa95xxSA supports AI/ML with vision applications through an integrated NPU and an image processor unit.

Read more...
High-speed Flash for SoC applications
NuVision Electronics DSP, Micros & Memory
GigaDevice has unveiled the GD25NE series of dual-power supply SPI NOR Flash chips, designed specifically for 1,2 V system-on-chip (SoC) applications.

Read more...
Super-fast H.264 encoder FPGA core
EBV Electrolink DSP, Micros & Memory
An ITAR-compliant H.264 core designed for AMD FPGAs provides baseline H.264 support and is currently the smallest and fastest FPGA core in the industry.

Read more...
ST MCUs extend ultra-low power innovation
Altron Arrow DSP, Micros & Memory
STMicroelectronics has introduced new STM32U3 microcontrollers with cutting-edge power-saving innovations that ease deployment of smart connected tech, especially in remote locations.

Read more...
Stallion repositions itself as a services provider
News & Events Security Services & Risk Management
Stallion has rebranded as Stallion Integrated Solutions to reflect its expanded capabilities beyond traditional security services to delivering integrated solutions that enhance safety, asset management, and operational efficiency.

Read more...