Your SlideShare is downloading. ×
Process Control SystemsProcess Control SystemsProcess Control SystemsProcess Control Systems
with a PLCwith a PLCwith a PL...
Saxion University of Applied Sciences
J.W. van Dijk
Version 1.0.2
September 2013
© Saxion. All rights reserved. Nothing fr...
Process Control Systems with a PLC
1
ContentsContentsContentsContents
AbbreviationsAbbreviationsAbbreviationsAbbreviations...
Process Control Systems with a PLC
2
AbbreviationsAbbreviationsAbbreviationsAbbreviations
ADC Analogue to Digital Converte...
Process Control Systems with a PLC
3
1111 IntroductionIntroductionIntroductionIntroduction
Presently a Programmable Logic ...
Process Control Systems with a PLC
4
2222 Three layer model of a factoryThree layer model of a factoryThree layer model of...
Process Control Systems with a PLC
5
2.12.12.12.1 Enterprise ControlEnterprise ControlEnterprise ControlEnterprise Control...
Process Control Systems with a PLC
6
2.22.22.22.2 Factory controlFactory controlFactory controlFactory control
The factory...
Process Control Systems with a PLC
7
Manufacturing Execution Systems are an essential component of operations in today's c...
Process Control Systems with a PLC
8
DisDisDisDispatching Production Units:patching Production Units:patching Production U...
Process Control Systems with a PLC
9
2.32.32.32.3 Automation and shopAutomation and shopAutomation and shopAutomation and ...
Process Control Systems with a PLC
10
3333 TraditionalTraditionalTraditionalTraditional control versus PLC controlcontrol ...
Process Control Systems with a PLC
11
For a PLC program written in ST this will look like:
In FBD this function will look ...
Process Control Systems with a PLC
12
4444 PLC controlPLC controlPLC controlPLC control
A PLC is very often used to contro...
Process Control Systems with a PLC
13
4.14.14.14.1 AnalogAnalogAnalogAnalogueueueue inputsinputsinputsinputs
Analogue inpu...
Process Control Systems with a PLC
14
This equation scales the integer-input ‘i_speed’ of the PLC and assigns it to the in...
Process Control Systems with a PLC
15
Figure 4.6: Scaling of an Analogue output (0-12000 → 0-65535)
This scaling can be do...
Process Control Systems with a PLC
16
When the value to be scaled is between 2 values both not equal to 0, the equation wi...
Process Control Systems with a PLC
17
The following ST program gives an example of a moving average filter of 4 samples.
E...
Process Control Systems with a PLC
18
4.44.44.44.4 PID control with a PLCPID control with a PLCPID control with a PLCPID c...
Process Control Systems with a PLC
19
The theory behind PID control goes beyond the scope of PLC programming, however it i...
Process Control Systems with a PLC
20
notes
Upcoming SlideShare
Loading in...5
×

Process control systems with a plc 1.0.2

1,605

Published on

Published in: Education, Business, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,605
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
56
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Process control systems with a plc 1.0.2"

  1. 1. Process Control SystemsProcess Control SystemsProcess Control SystemsProcess Control Systems with a PLCwith a PLCwith a PLCwith a PLC
  2. 2. Saxion University of Applied Sciences J.W. van Dijk Version 1.0.2 September 2013 © Saxion. All rights reserved. Nothing from this publication may be copied, stored in an automated information file, or made public, in any form or in any manner, either electronic, mechanical, through photocopying, recording or any other way, without previous written permission from the publisher.
  3. 3. Process Control Systems with a PLC 1 ContentsContentsContentsContents AbbreviationsAbbreviationsAbbreviationsAbbreviations ....................................................................................................................... 2 1111 IntroductionIntroductionIntroductionIntroduction ......................................................................................................................... 3 2222 Three layer model of a factoryThree layer model of a factoryThree layer model of a factoryThree layer model of a factory ............................................................................................. 4 2.1 Enterprise control .................................................................................................... 5 2.2 Factory control ......................................................................................................... 6 2.3 Automation and shop-floor control ......................................................................... 9 3333 TraditionalTraditionalTraditionalTraditional control versus PLC controlcontrol versus PLC controlcontrol versus PLC controlcontrol versus PLC control .............................................................................. 10 4444 PLC controlPLC controlPLC controlPLC control ....................................................................................................................... 12 4.1 Analogue inputs ................................................................................................... 13 4.2 Analogue outputs ................................................................................................ 15 4.3 Filtering of analogue inputs ................................................................................. 15 4.4 PID control with a PLC .......................................................................................... 17
  4. 4. Process Control Systems with a PLC 2 AbbreviationsAbbreviationsAbbreviationsAbbreviations ADC Analogue to Digital Converter B2B Business to Business CAD Computer Aided Design CAM Computer Added Manufacturing CIM Computer Integrated Manufacturing DAC Digital to Analogue Converter DCS Digital Control System ERP Enterprise Resource Planning FBD Function Block Diagram I/O Input/Output ISO International Standardisation Organisation IS Information Systems IT Information Technology LIMS Laboratory Information Management System MES Manufacturing Execution System OSI Open System Interconnection PLC Programmable Logic Controller PID Proportional–Integral–Derivative SCADA Supervisory Control And Data Acquisition SPC Statistical Process Control SQC Statistical Quality Control ST Structured Text VSD Variable Speed Drive
  5. 5. Process Control Systems with a PLC 3 1111 IntroductionIntroductionIntroductionIntroduction Presently a Programmable Logic Controller (PLC) is still the basic component in automation. A PLC can be found in the lower level of the automation and is the basic component for process control systems and automation . Figure 1.1: PLC, the basic component in automation Before we can have a look at the PLC, first a better understanding of the different layers in an industrial environment is essential.
  6. 6. Process Control Systems with a PLC 4 2222 Three layer model of a factoryThree layer model of a factoryThree layer model of a factoryThree layer model of a factory In the current economic climate, doing more for less is often management’s mandate. Plant floor and manufacturing information technology (IT) staffs are under pressure to show quick results and solve problems with increasingly lean budgets. While that’s a tall order, it is not impossible, provided there’s an up- front investment in time to produce detailed, specific goals and to truly understand what’s needed. Focused, cross-functional teams that implement flexible and scalable information systems (IS) can deliver a smooth, lean manufacturing process. When integrating new technology into an existing facility, always three things should be considered: the hard infrastructure, the soft infrastructure, and information flow. Hard infrastructure includes client and server hardware and network infrastructure. Soft infrastructure includes operating systems, existing or legacy software, needed code customisations, and the human resources to run/support the system. Information flow includes how data in the new system interacts with legacy systems and what legacy data the new system will require, as well as who will want to receive/access the information that is held by the system. Tracking the information flow within a manufacturing process involves three main layers of control: the entire enterprise, the factory or facility as a whole, and the shop floor. Figure 2.1: A manufacturer's three control layers
  7. 7. Process Control Systems with a PLC 5 2.12.12.12.1 Enterprise ControlEnterprise ControlEnterprise ControlEnterprise Control The enterprise control layer, Enterprise Resource Planning (ERP), is the management layer and has business-to-business (B2B) tools surrounding it in order to communicate data from one enterprise to other. The B2B tools overlap into the factory control layer because they can enable data exchange among facilities, customers and suppliers. Within the enterprise layer we also find tools for enterprise resource planning, supply chain management, customer response management, and document control. Data communication in this layer can be characterized by: • Large amounts of data, file transfer • Not very frequent, low refresh rate Major suppliers of ERP products are: • Oracle • SAP • Baan Figure 2.2: Suppliers of ERP software
  8. 8. Process Control Systems with a PLC 6 2.22.22.22.2 Factory controlFactory controlFactory controlFactory control The factory control layer controls manufacturing floor processes. Manufacturing Execution System (MES) is a collection of software functions which are distinct from those included in ERP, CAD/CAM and Industrial Controls. The uniqueness of functionality is an added benefit because it complements the functionalities that exist in the other systems. The focus of MES is operations, especially production operations. MES coordinates all manufacturing data related to operations at a plant wide level. Supervisory control and data acquisition, recipe management, and advanced planning and scheduling tools add to the MES functionality by providing tighter factory floor controls. DescriptioDescriptioDescriptioDescriptionnnn "Manufacturing Execution Systems deliver information enabling the optimisation of production activities from order launch to finished goods. Using current and accurate data, MES guides, initiates, responds to, and reports on plant activities as they occur. The resulting rapid response to changing conditions, coupled with a focus on reducing non-value-added activities, drives effective plant operations and processes. MES improves the return on operational assets as well as on-time delivery, inventory turns, gross margin, and cash flow performance. MES provides mission-critical information about production activities across the enterprise and supply chain via bi-directional communications." The concept of MES is widely recognized and used in manufacturing sectors such as automotive, semiconductor, electronics, food processing, pharmaceuticals, aerospace, medical devices, textiles. Elements such as scheduling, maintenance management, quality, and time and attendance fall within the scope of MES and are used in all industries. The figure below shows the place that is being occupied by MES. While other activities of manufacturing enterprises like CAD, Controls, ERP, etc. have been helped by computer-based applications for a long time, the areas related with production operations haven't received so much attention. Figure 2.3: Plant Information Model
  9. 9. Process Control Systems with a PLC 7 Manufacturing Execution Systems are an essential component of operations in today's competitive business environments, which require greater production efficiency and effectiveness. MES focuses on the valuing-adding processes, helping to reduce manufacturing cycle time, improve product quality, reduce or eliminate paperwork between shifts, reduce lead time, and empowering plant operations staff. This section includes an overview of MES and quotes from users. Figure 2.4: MES Functional Model MES is of particular value to operational management. Functions include resource allocation and status, dispatching production units, data collection/acquisition, quality management, maintenance management, performance analysis, operations/detail scheduling, document control, labour management, process management and product tracking and genealogy. These functions are described more fully below. Resource Allocation and Status:Resource Allocation and Status:Resource Allocation and Status:Resource Allocation and Status: Manages resources including machines, tools, labour skills, materials, other equipment, and other entities such as documents that must be available in order for work to start at the operation. It provides detailed history of resources and insures that equipment is properly set up for processing and provides status real time. The management of these resources includes reservation and dispatching to meet operation scheduling objectives. Operations/Detail Scheduling:Operations/Detail Scheduling:Operations/Detail Scheduling:Operations/Detail Scheduling: Provides sequencing based on priorities, attributes, characteristics, and/or recipes associated with specific production units at an operation such as shape, colour sequencing, or other characteristics that, when scheduled in sequence properly, minimize set-up. It is finite and it recognizes alternative and overlapping/parallel operations in order to calculate, in detail, exact time of equipment loading adjusted to shift patterns.
  10. 10. Process Control Systems with a PLC 8 DisDisDisDispatching Production Units:patching Production Units:patching Production Units:patching Production Units: Manages flow of production units in the form of jobs, orders, batches, lots, and work orders. Dispatch information is presented in the sequence in which the work needs to be done and changes in real time as events occur on the factory floor. It has the ability to alter the prescribed schedule on the factory floor. Rework and salvage processes are available, as well as the ability to control the amount of work in process at any point with buffer management. Document Control:Document Control:Document Control:Document Control: Controls records/forms that must be maintained with the production unit, including work instructions, recipes, drawings, standard operation procedures, part programs, batch records, engineering change notices, shift-to-shift communication, as well as the ability to edit "as planned" and "as built" information. It sends instructions down to the operations, including providing data to operators or recipes to device controls. It might also include the control and integrity of environmental, health and safety regulations, and ISO information such as Corrective Action procedures. Storage of historical data is provided. Data Collection/Acquisition:Data Collection/Acquisition:Data Collection/Acquisition:Data Collection/Acquisition: This function provides an interface link to obtain the inter-operational production and parametric data that populate the forms and records that were attached to the production unit. The data may be collected from the factory floor either manually or automatically from equipment in an up-to-the-minute time frame. Labour Management:Labour Management:Labour Management:Labour Management: Provides status of personnel in an up-to-the-minute time frame. It includes time and attendance reporting, certification tracking, as well as the ability to track indirect activities such as material preparation or tool room work as a basis for activity based costing. It may interact with resource allocation to determine optimal assignments. Quality Management:Quality Management:Quality Management:Quality Management: Provides real time analysis of measurements collected from manufacturing to assure proper product quality control and to identify problems requiring attention. It may recommend action to correct the problem, including correlating the symptom, actions and results to determine the cause. May include SPC/SQC tracking and management of off-line inspection operations, and analysis from a laboratory information management system (LIMS) could also be included. Process Management:Process Management:Process Management:Process Management: Monitors production and either automatically corrects or provides decision support to operators for correcting and improving in-process activities. These activities may be inter-operational and focus specifically on machines or equipment being monitored and controlled, as well as intra- operational, which is tracking the process from one operation to the next. It may include alarm management to make sure factory personnel are aware of process changes that are outside acceptable tolerances. It provides interfaces between intelligent equipment and MES, possibly through Data Collection/Acquisition. Maintenance Management:Maintenance Management:Maintenance Management:Maintenance Management: Tracks and directs the activities to maintain the equipment and tools to insure their availability for manufacturing and insure scheduling for periodic or preventive maintenance. Also provides the response (alarms) to immediate problems. It maintains a history of past events or problems to aid in diagnosing problems. Product Tracking and Genealogy:Product Tracking and Genealogy:Product Tracking and Genealogy:Product Tracking and Genealogy: Provides the visibility to where work is at all times and its disposition. Status information may include who is working on it; components, materials by supplier, lot, serial number, current production conditions, and any alarms, rework, or other exceptions related to the product. The on-line tracking function creates a historical record, as well. This record allows trace ability of components and usage of each end product. Performance Analysis:Performance Analysis:Performance Analysis:Performance Analysis: Provides up-to-the-minute reporting of actual manufacturing operations results along with the comparison to past history and expected business results. Performance results include such measurements as resource utilization, resource availability, product unit cycle time, conformance to schedule and performance to standards. It may include SPC/SQC. Performance Analysis draws on information gathered from different functions that measure operating parameters. These results may be prepared as a periodic report or presented on-line as current evaluation of performance.
  11. 11. Process Control Systems with a PLC 9 2.32.32.32.3 Automation and shopAutomation and shopAutomation and shopAutomation and shop----floor controlfloor controlfloor controlfloor control The automation and shop floor control layers are directly responsible for controlling each step in the manufacturing process. Computer-Integrated Manufacturing (CIM) is a vital piece of this layer because it provides in its controlling layers a generic view of the manufacturing process. CIM architectures must be flexible to manage rapid changes on the factory floor. The idea is CIM can make up the difference MES lacks. This level has a variety of clients, including machines, operators, engineers, and supervisors. Here we find Control Panels (e.g. Touch Screens), PLC’s, sensors and actuators. Typical data communication characteristics for this layer are: • High update frequencies • Small amount of data Figure 2.5: Touch-screen Figure 2.6: PLCs Figure 2.7: Sensors and actuators .
  12. 12. Process Control Systems with a PLC 10 3333 TraditionalTraditionalTraditionalTraditional control versus PLC controlcontrol versus PLC controlcontrol versus PLC controlcontrol versus PLC control A traditional scheme to start and stop a motor is given in the figure below. Here a motor can be started by closing ‘S2’. When ‘S2’ is closed the relay ‘K1’ will be activated, its contacts will be closed, and the motor will run. By using a feedback signal, one of the contacts, from the relay ‘K1’ the motor will continue running when the start button ‘S2’ is released. The motor will run until ‘S1’ is pressed, it will be opened, or an over-temperature situation occurs, ‘F3’ is opened. Figure 3.1: Basic scheme for a motor control Note that in the scheme two different types of contacts are used: Normally Open (NO) contact. This type of contact usually is used for a start. Note that in case of a wiring problem the motor can not be started and also will not start automatically (save operation) Normally Closed (NC) contact. This type of contact usually is used for a stop. Note that in case of a wiring problem the motor automatically will be stopped (save operation) The same functionality implemented in a PLC will look like shown in the figure below. Figure 3.2: Basic control with a PLC Note that the feedback of the relay ‘K1’ is not an input for the PLC in the scheme. The feedback now can be done inside the PLC. In the PLC the following function has to be implemented to obtain the same functionality as in figure 3.1: K1 = F3 AND S1 AND (S2 OR K1) PLC S2 F3S1 K1 inputs outputs
  13. 13. Process Control Systems with a PLC 11 For a PLC program written in ST this will look like: In FBD this function will look like: Figure 3.3: FBD program By connecting the PLC to a process computer the start and stop buttons can be omitted or an additional start or stop location is added. Also the status of the motor can be visualised. Figure 3.4: Connecting the PLC to a process computer With this functionality the motor can only be started or stopped. Modern applications however desire very often that the speed of the motor can be controlled at any value between 0 (stopped) and a maximum speed. ≥1 & K1 F3 S1 S2 K1 := F3 AND S1 AND (S2 OR K1);
  14. 14. Process Control Systems with a PLC 12 4444 PLC controlPLC controlPLC controlPLC control A PLC is very often used to control systems with analogue signals, i.e. temperature, motor speed, flow, or pressure. The analogue signals can be divided in inputs, for measurement or setpoints, or outputs, to control and visualize. Inputs are signals coming from the system and going into the PLC, outputs are signals going from the PLC into the system. In the figure below a basic control system with a PLC is given. In this system the PLC controls the speed of a motor. The required speed (setpoint) of the motor is an input for the PLC. The PLC sets its output to a certain value, in accordance with the setpoint. Because the output of the PLC is always a low voltage output this signal is amplified, using a Variable Speed Drive (VSD). The actual speed of the motor is measured with a speed sensor, which output is connected to the input of the PLC. The PLC gives the actual speed as an output, to i.e. a process computer, for visualisation. Figure 4.1: PLC control system of a motor with analogue inputs and outputs In this example the inputs and outputs of the PLC are analogue, continuous voltages between a minimum and a maximum value. Before analogue inputs can be handled by the software (program) they must be converted. Also outputs needs to be converted. Drive PLC MotorSpeed sensor PLC outputPLC input required speed (setpoint) actual_speed
  15. 15. Process Control Systems with a PLC 13 4.14.14.14.1 AnalogAnalogAnalogAnalogueueueue inputsinputsinputsinputs Analogue inputs should be converted to integers before they can be handled by the software. This conversion is done by an Analogue to Digital Converter, ADC. Commonly used input ranges for analogue inputs are: 0 – 10 V -10V – 10V 0 – 20 mA In the IEC61131-3 standard for programming PLCs an analogue input is always converted to an integer value between 0 and 65535. This is the maximum of a 16 bit number (216-1). Example: a tachometer can measure the speed of a motor in the range from 0 rpm – 1200 rpm. The output of the tachometer is in the range of 0 – 10V which is going to the input of the PLC. In the PLC the incoming voltage is converted by the ADC to an integer value in the range from 0 – 65535. Figure 4.2: Analogue inputs In the program an integer value between 0 and 65535 doesn’t have a direct relation with the actual speed, i.e. a speed of 1000 rpm would be in the program a value of 54612. It is much easier if the value in the program would also be in the range from 0 – 1200, so the input in the range from 0 – 65535 should be scaled to a value in the range from 0 – 1200. However by scaling down an incoming value of 65535 to 1200 a lot of information would be lost. It is better to scale 65535 down to 12000 (in fact 1200.0), the accuracy now is ten times better. Figure 4.3: Scaling of an Analogue input (0-65535 → 0-12000) This scaling can be done by implementing the following equation in the PLC: 65535/)12000*_( speedispeed = For a PLC program written in ST this will look like: speed := (i_speed * 12000) / 65535; Tachometer ADC PLC program motor speed 0-1200rpm PLC input 0-10V i_speed 0-65535 PLC
  16. 16. Process Control Systems with a PLC 14 This equation scales the integer-input ‘i_speed’ of the PLC and assigns it to the integer-internal ‘speed’: • When the motor speed is 0 rpm the analogue input of the PLC will be 0 V. This input is converted to the integer-input ‘i_speed’ value of 0 (using a 0 – 10V input). The result of the equation will be also 0, which is assigned to the integer- internal ‘speed’ of the PLC. • When the motor speed is 1200 rpm the analogue input of the PLC will be 10 V. This input is converted to the integer-input ‘i_speed’ value of 65535 (using a 0 – 10V input). The result of the equation will now be 12000, which is assigned to the integer- internal ‘speed’ of the PLC. When the result of the scaling is between 2 values both not equal to 0, the equation will look a bit more complex. I.e. for scaling of 0-65535 to a value between -5000 and 10000, the equation will be: 500065535/)15000*_( −= unscalediscaled Figure 4.4: Scaling of an Analogue input (0-65535 → -5000-10000) 4.24.24.24.2 AnalogAnalogAnalogAnalogueueueue outputsoutputsoutputsoutputs For analogue outputs the integer values coming from the PLC program should be converted to voltages at the outputs of the PLC. This conversion is done by a Digital to Analogue Converter, DAC. Commonly used output ranges for analogue outputs are: 0 – 10 V -10V – 10V 0 – 20 mA In the IEC61131-3 standard the integer values going into the DAC are always in the range from 0 – 65535. Figure 4.5: Analogue outputs The range from 0 - 65535 usually doesn’t have a direct relation with the controlled system, i.e. a motor speed from 0 – 1200 rpm. Therefore, as with analogue inputs, analogue outputs should be scaled. ActuatorDACPLC program motor speed 0-1200rpm PLC output 0-10V o_speed 0-65535 PLC
  17. 17. Process Control Systems with a PLC 15 Figure 4.6: Scaling of an Analogue output (0-12000 → 0-65535) This scaling can be done by implementing the following equation in the PLC: 12000/)65535*(_ speedspeedo = For a PLC program written in ST this will look like: This equation scales the integer-internal ‘speed’ of the PLC to the integer-output ‘o_speed’. • When ‘speed’ is 0 the result of the equation will be that ‘o_speed’ is also 0, the output voltage of the PLC will be 0 V (using a 0 – 10 V output) and the motor speed will be set to 0 rpm. • When ‘speed’ is 12000 the result of the equation will be that ‘o_speed’ is 65535, the output voltage of the PLC will be 10 V (using a 0 – 10 V output) and the motor speed will be set to 1200 rpm. It is essential that the value, going to the DAC, never is smaller that 0 or greater that 65535! So it is wise to limit the output, see the following ST code example: o_speed := (speed * 65535) / 12000; IF o_speed < 0 THEN o_speed := 0; END_IF; IF o_speed > 65535 THEN o_speed := 65535; END_IF; o_speed := (speed * 65535) / 12000;
  18. 18. Process Control Systems with a PLC 16 When the value to be scaled is between 2 values both not equal to 0, the equation will look a bit more complex. I.e. for scaling of values in the range of -5000-10000 to 0 and 65535, the equation will be: 15000/65535*)5000(_ += unscaledscaledo Figure 4.6: Scaling of an Analogue output (-5000-10000 → 0-65535) 4.34.34.34.3 Filtering of analogFiltering of analogFiltering of analogFiltering of analogueueueue inputsinputsinputsinputs Because of external influences analogue signals often are disturbed and should be filtered by an analogue filter (i.e. a RC filter) or a digital filter. The advantage of digital filters is that they are easy to implement in software (the program) and to modify. Every PLC cycle the analogue input is sampled, using an ADC, giving a digitised signal (xk). Now a new digital filtered value yk can be calculated, based upon the most recent input sample, previous input samples and previous calculated output values. The calculated value can be used in the program or send to an output of the PLC, using a DAC. Figure 4.7: Signal processing The general formula of a digital filter is: ∑∑ = − = − += m j jki n i ikik ybxay 10 .. It is essential that the time between the samples (xk .. xk-n) is always the same. In a PLC this can be easily achieved by setting the PLC cycle time to a fixed value. A simple digital filter is a ‘Moving Average Filter’. The formula for a ‘Moving Average Filter’ that calculates the average of the last 4 samples (n = 3, a0 .. a3 = ¼) is given as: 34 1 24 1 14 1 4 1 .... −−− +++= kkkkk xxxxy PLC PLC program
  19. 19. Process Control Systems with a PLC 17 The following ST program gives an example of a moving average filter of 4 samples. Example Suppose the PLC reads succeeding values (samples) for ‘speed’ as given in the table below. The table also shows the succeeding values for ‘x_0’ – ‘x_3’ and ‘speed_maf’. Clearly the filtered value ‘speed_maf’ changes less than the incoming value ‘speed’. With digital filters it is possible to design and implement filters with characteristics which are very difficult to achieve with analogue filters. The theory behind digital filter design goes beyond the scope of PLC programming. However, based on the moving average filter a useful application can be given. Application In industrial automations, because of electromagnetic interferences, 50Hz disturbances on analogue signals are very common. The 50 Hz disturbance is added with the original analogue signal (superposition) and the signal going into the PLC is disturbed. By using a 4 sample moving average filter with a sample time, which is the PLC cycle time, of 5 ms (20ms / 4) the 50 Hz disturbance can be filtered out completely! Figure 4.8: Signal with 50 Hz disturbance In the example given in the figure above the following values will be measured: ….. 260 258 254 256 260 258 254 …….. Now add 4 succeeding values and divide the result by 4. The final result will always be 257, which is the level of the original undisturbed signal. The 50Hz is completely filtered out! x_3 := x_2; (* shift *) x_2 := x_1; (* previous *) x_1 := x_0; (* samples *) x_0 := speed; (* new sample *) y_0 := (x_0 + x_1 + x_2 + x_3)/4; (* 4 samples moving average *) speed_maf := y_0; speed 240 234 250 246 236 247 258 245 238 x_0 240 234 250 246 236 247 258 245 238 x_1 - 240 234 250 246 236 247 258 245 x_2 - - 240 234 250 246 236 247 258 x_3 - - - 240 234 250 246 236 247 speed_maf - - - 242 241 244 247 247 247
  20. 20. Process Control Systems with a PLC 18 4.44.44.44.4 PID control with a PLCPID control with a PLCPID control with a PLCPID control with a PLC In the figure below a basic example is given of a digital control system for controlling the speed of a motor. In this example a PLC is used as the basic component to control the speed. The PLC has two inputs (‘setpoint’ and ‘actual_ speed’) and one output to the Drive of the motor. The actual speed of the motor is measured with a tachometer. Figure 4.9: Basic control system With the ‘setpoint’ a desired speed is given. This speed is compared with the measured ‘actual_speed’, giving an error signal (error := setpoint – actual_ speed) which is used as an input for the PID controller. A proportional–integral–derivative controller (PID controller) is a generic control loop feedback mechanism widely used in industrial control systems. A PID controller attempts to correct the error between a measured process variable and a desired setpoint by calculating and then outputting a corrective action that can adjust the process accordingly. The PID controller calculation (algorithm) involves three separate parameters; the Proportional (P), the Integral (I) and Derivative (D) values. The Proportional value determines the reaction to the current error, the Integral value determines the reaction based on the sum of recent errors, and the Derivative value determines the reaction to the rate at which the error has been changing. The weighted sum of these three actions is used to adjust the process via a control element such as the position of a control valve or the power supply of a heating element. By "tuning" the three constants in the PID controller algorithm, the controller can provide control action designed for specific process requirements. Because the inputs are coming from the outside of the PLC, they should be scaled and filtered. Also the output should be scaled. Figure 4.10: Scaling and filtering added to the inputs and output PID controllerScale + Filter setpoint + - actual_speed Scale PLC Scale + Filter PID controller Motor Tachometer setpoint + - actual_speed Drive PLC error
  21. 21. Process Control Systems with a PLC 19 The theory behind PID control goes beyond the scope of PLC programming, however it is good to see how the basic code will look like. The general equation for a PID controller is: 0 0 )( )()()( u dt tde TKdtte T K teKtu t dp i p p +++= ∫ With: u(t) output e(t) error input Kp Contant (P action) Ti Integrating time (I action) Td Derivative time (D action) For digital controllers (such as microprocessors and PLCs) this can be written as: ( ) ( ))2()1(2)()()1()()1()( −+−−++−−+−= tetete T TK te T TK teteKtutu s dp i sp p With: u(t) new output u(t-1) previous output e(t) actual error input e(t-1) error signal of the previous cycle e(t-2) error signal of two cycles before Kp Contant (P action) Ts Sampling time (= PLC cycle time) Ti Integrating time (I action) Td Derivative time (D action) Note that the PLC cycle time is part is this equation, so when the PLC cycle time is changed also contacts in the equation has to be changed! The given PID equation can now be simplified: ( ) ( ))2()1(2)()()1()()1()( −+−−++−−+−= teteteKteKteteKtutu dip In the example below the basic code for a PID controller is given: Note that the value of the constants KP (proportional), KI (integral) and KD (derivative) should be determined and set according to your system and requirements. (* Code example for a PID controller *) (* IN is the error signal, used as the input for the PID function *) (* OUT is the output of the PID controller *) (* x_0, x_1, x_2, y_0 and y1 are variables to retain previous states *) (* min_v and max_v are values used to limit the output *) (* KP, KI and KD are the PID constants *) x_2 := x_1; x_1 := x_0; x_0 := IN; y_1 := y_0; y_0 := y_1 + (KP*(x_0 – x_1) + KI*x_0 + KD*(x_0 – 2*x_1 + x_2))/1000; (* limit the PID controller between min_v and max_v *) IF y_0 < min_v THEN y_0 := min_v; END_IF; IF y_0 > max_v THEN y_0 := max_v; END_IF; OUT:=y_0;
  22. 22. Process Control Systems with a PLC 20 notes

×