Using PLC for Custom-design of a PID/PWM Program to Control a Heater Temperature

This is a practical approach to control a continuous-time process variable (temperature) using a discrete controller (PLC) and a custom-designed software control algorithm and hardware interface, in a closed-loop system. Unlike the conventionally known technique of transforming a digital control action into a proportional analogue one by a D/A converter followed by power amplifier, the control action was formed internally by the PLC as a PID/PWM signal, which was used to trigger the power stage. This approach helped reducing the error due D/A conversion, maximized utilization of the PLC and reduced total cost. The control system is realized by utilizing the heater of the training board (RGT1), manufactured by DL-lorenzo Company and it simulates an analogue heating control system. The PLC is Siemens Simatic S7-214 model. An experimental result has shown that the control algorithm functions perfectly.


INTRODUCTION
The use of a digital signal processor (DSP) to evaluate the actual value of an analogue process output and then compute a correction signal has many advantages. DSP does not suffer from the long-term drift effect that analogue circuits do. Changes to constants can easily be made without the actual physical change to the circuitry and simply modifying the loaded program or loading a new one can radically alter the mode of control. Realizing PWM techniques and other advanced functions is some of the vast power points of digital controllers. Actually, in most cases DSPs are designed to replace the ON-line analogue ones. This explains the continuous approaches to implement digitally the traditional analogue control modes such as PID actions.
Because of the advantages of the PLCs [1] , a PLC type S7-200 was utilized as a DSP. Nowadays most modern sequential control systems are based on PLCs, which are in fact specialized industrial computers. Thus, one of the targets of this work is to design a PLC program for PID control algorithm and to develop it to get at the PLC output a PWM signal proportional to the value at the output of PID controller. In this case there is no need for a DAC IC nor for a specific power amplifier stage. Here the PWM signal with the power static switch emulates the function of a D-type power amplifier. From another side, by using the designed interface board, one can exclude the implementation of a high cost proprietary power interface module, this simplifies the circuit and reduces its cost.
PLC manufacturers very often provide the option of analogue I/O and support instant PID functions for extra cost. Such functions can be used directly by entering the control parameters and constants. Nevertheless, this feature is only usable if the analogue I/O module is installed. Therefore PID algorithm was designed instead of using a ready one. This, also, provides more flexibility to use the program with those PLCs, which do not support ready PID loops. Designed I/O board shown in Fig. 1 satisfies our demands and costs one third of the I/O module's cost approximately.
Because of the limited size of this paper, the design procedure of the I/O interface board is not illustrated. It will be published in a special paper. However, I would like to add that cost is not the only factor. As Johnson [2] wrote: (every engineer has personal preferences as to which flavor of PID algorithm should be used in any particular situation). For example full PID algorithm can only be used when the signal has little noise or where suitable filtering or limiting has been applied. Another example is that the derivative action could be on the process variable only and could be on the system error depending on the severity of change of system error. In our study we make use of the digital values of the PID output to initiate a PWM signal in order to control the timing of the power switch.

PLC application consideration:
Each program cycle: -Store previous error in (VW20). -Store the set point value in (VW10), this value is generated using analog adjustment feature of CPU-214. -Subtract the process variable PV (VW0) from the set point Sp (VW10) and get the result representing ERROR stored in (VW10).
PID control action output: The discrete representation of the PID control loop is given by the equation: Add recent error to (AC1) -Multiply result by Ki and accumulate in (AC1) -Multiply the value of (AC1) by the time period T and store the value in (AC1) -Add the integral part to the overall output in (AC0) Put recent error in accumulator (AC1) -Subtract previous error from (AC1) and store result in (AC1) -Multiply the result by Kd and accumulate in (AC1) -Divide output by T -Add the differential action output to the overall output stored in (AC0) Scaling : This network is necessary for scaling the output to comply with the next steps and give a flexible range of variation for the controller constants. 65535 is the maximum possible 16-bit (word) value.  instructions for logic operations, math operations, data moves and program control functions as calls, interrupts, subroutines and so on. Some functions are of the PLC's advanced features such as the instant PWM, which depends on special memory bytes (SM67, SM68). So, a ready function of PWM is utilized in order to reduce the size of the program, assuming that programming of this function from scratch is straight forward, [3] . The block diagram of the control system is shown in Fig. 2.
The instantaneous temperature value is conveyed by eight parallel lines connected to eight input points of the PLC as given in Table 1.
The desired output of the control loop is a digital level passed to one output point of the PLC, (Q 0.0). Due to programming demands in order to avoid Temp. [C]
[C]   [4] , as illustrated in Fig. 3.  Table 2 contains the PLC program written in ladder diagram and statement list forms and illustrated network by network. Important to note that interrupts and subroutines are not parts of the main program body. They function as independent units when called.

EXPERIMENTAL RESULTS
The control system has been tested with different controller settings of the PID actions. Experiment took place in the process control laboratory by using the heater of the training board (RGTI), [5] . The initial temperature of the heater was equal to room temperature. Figure 4 and Table 3 show the time characteristic of the controlled variable when the controller was in the proportional mode. After temperature has settled in a steady state mode, at the 27 th minute the heater was subjected to an external disturbance for an instant. The figure shows the reaction of the controller and how the variable settled again into a new steady state. The response was obtained with a 20% gain. Consequently the offset is considerably high. When the gain was increased to 60%, a noticeable overshoot occurred and the offset decreased. Note that the curve is not perfectly smooth this is due to external disturbances such as the opening and closure of the doors of the laboratory and the AC unit, which has also participated, in some noisy values included in the reading. Another factor is the small heat capacity of the heater. Figure 5 and Table 4 show system response in the PI mode. The load was disturbed at the 27 th minute and the controller cleared the error and retrieved the previous steady state.

CONCLUSION
* Using PLC a custom design of a software PID/PWM control algorithm was carried out and implemented to control a heater temperature in a closed-loop system. At the same time a PLC analogue input binary output interface board was specifically designed to be compatible with the software program.
* Power interface between the controller output and the load was realized by transforming the PID digital output into a PWM signal in order to trigger the power switch. This helped reducing the error due D/A conversion, maximized utilization of the PLC and reduced the total cost. * The programmed software could be used with other PLCs which do not support PID kit or PLC analogue input binary output interface board.