1 Chapter II Programmable Logic Controller Programmable logic controller hardware parts Based on section 1.4, a PLC is nothing more than a computer (device), tailored specifically for certain control tasks by using sensors and actuators. A basic PLC consists of a power supply, central processing unit and signal module(s). Power supply (PS) provides the PLC with internal supply voltage, which is converted from 120/230 V alternating current (AC) or 24 V direct current (DC). Some PLCs do not need an additional power supply if the central processing unit has 24 V DC input (PLC can be powered over this input). Central processing unit (CPU) is the PLC brain, where the automated process or machine controlling program runs and is stored (built-in program memory). In addition to program processing, the central processing unit assigns parameters to PLC modules, handles communication with the programming devices, with PLC extension modules, with additional PLC(s) and/or other devices (like operator panel for human-machine interface). The processing unit can have a separate power supply, expandable memory slot (like for SD cards) and a field bus communication channel. The central processing unit has a switch or a key switch for the PLC working mode selection. Today s Siemens PLCs have two working modes: the RUN mode, where the user program is executed, and the STOP mode, where the user program is stopped. In both modes the user program can be downloaded to a PLC or uploaded from a PLC to a programming device (PC). The old Siemens PLCs had a third working mode called the RUN-P mode. In this case the user program can be downloaded to the PLC in the STOP or RUN-P mode. In the RUN mode the user program was executed but no program changes could be made. Signal modules (SM) are input/output (I/O) modules for digital (DI, DO) and analogue (AI, AO) signals, which are coming or going to sensors, switches, actuators and other devices in the PLC. The signal module adapts the incoming signal into the internal PLC signals and it acts vice versa with the outgoing signals. Normally 24 V DC and 120/230 V AC are used by digital signal modules. For analogue signal modules DC voltage (like ±10 V, 0 10 V or 1 5 V) and DC current (like 4-20 ma or 0-20 ma) are used. In digital output signal modules optocouplers, transistors and relays are used to change the output signal states. They should protect the signal module against short-circuit, overvoltage and overload. Relays allow us to switch different output voltages (DC and AC) and higher current than transistors. But relay life time (switching count) is shorter than that of transistors. One digital signal module can have up to 8, 16 or 32 inputs and/or outputs of the same type and an analog signal module up to 2, 4, 6 or 8 inputs and/or outputs of the same type.
2 IM-R DI 16xDC 24V DO 16xDC 24V AI 8x12Bit AO 4x12 Bit FIXED SPEED POS. Lean APPLICATION OF PLC IN INDUSTRIAL AUTOMATION However, a PLC can also contain a rack (a rail, on which PLC modules are placed); an interface module (IM) that connects several separately standing racks or rails into one PLC; a function module (FM) that handles complex or time-critical processes independently of the CPU, e.g. fast counting, PID and position control; a communication processor (CP) that connects the PLC into the industrial network, e.g. Industrial Ethernet, PROFIBUS, AS interface, serial point-to-point connection); a human-machine interface (HMI), e.g. operator panel; remote I/Os; fast acting signal modules. Each PLC module has a basic HMI, which is used to display errors and states of communication, battery, I/O, PLC operation etc. For HMI a small liquid crystal display (LCD) or light-emitting diodes (LEDs) are used. DC24V 230 VOLTAGE SELECTOR PS 307 CPU 314 SF SIEMENS DC5V FRCE RUN STOP PUSH SIEMENS SF DC 5V IM361 SM SM SM 331 SF SM 332 SF SF CH1 CH2 FM351 1 I 0 I 1 I 2 I 3 2 I 0 I 1 SF LINK RX/TX RUN STOP CP343-1 RUN STOP I 2 I 3 MRES SIMATIC S7-300 SIMATIC NET SIMATIC S Q 0 Q Q Q Q Q Q Q 3 PS (optional) CPU IM (optional) SM: DI SM: DO Fig A Siemens S7-300 PLC hardware setup SM: AI SM: AO FM: Counting Positioning Closed-loop control CP: Point-to-Point PROFIBUS Industrial Ethernet PROFINET Fig. 0.1 shows a Siemens S7-300 PLC built-up . The PS has to be in the first slot, the CPU in the second slot and the IM in the third slot. Their placing order in the Siemens PLC cannot be changed. These (the slot number counting starts from 4) are followed by the SM, FM and CP modules (together up to 8 separated modules in one rail). Their order is not important; these modules can be mixed, as required. Thus a Siemens S7-300 PLC can be built up from 11 separate modules in one rail and the PLC can have up to 4 separate rails. Some Siemens PLCs do not need a power supply if the automated system has a separate 24 V DC supply, which power output is connected directly into the CPU. Also, there is no need for IM if the PLC is built only on one rail. For some PLCs, the CPU and/or PS module placements are of no significance, like with the Allen-Bradley CompactLogix PLC the PS can be placed in different positions (up to 4 modules can be placed before the PS). But the CPU has to stay in the first place by the CompactLogix controller.
3 PLC types Depending on which device is used as the CPU and how the CPU is connected to other PLC modules, the PLC can be divided into the following types: compact PLC, modular PLC, rack PLC, PLC with an integrated operator panel, industrial PC, slot PLC and soft PLC. The compact PLC combines the CPU, PS, input and output modules in one tight housing. Mostly it has a fixed number of digital I/O (not more than 30), one or two communication channels (one for programming the PLC and the other for field bus connections) and HMI. Occasionally it can have one fast counter input and one or two analog I/O. To increase I/O numbers separate add-on modules can be connected to the compact PLC. The add-on modules are placed in the housing, which look like the compact PLC itself . Compact PLCs are used in automation as replacements of relays. A PLC does not cost more than a handful of relays and the programming is as flexible as wiring. The weak points of this type PLC are low memory for the program and data, low processor performance, low number of PLC timers and counters, and missing data types (like floating point, string) . On the other hand, today s more expensive compact PLCs have the same functionalities as other PLC types, the only flaw is the fixed number of I/Os. Examples of compact PLC are Festo FEC PLC, Siemens Logo and S7-200 PLC (Fig. 0.2). Fig Compact PLC examples. Festo FEC FC660 PLC (left), Siemens Logo (middle) and S7-200 PLC (right) The modular PLC is more powerful and has more functions than the compact PLC. Its parts like CPU, SP, SM, servo motor control modules, positioning modules, CP modules are mostly in separated housings. All modules are placed together on a DIN rail or on a special shape rail and they are communicating with the CPU over a system bus. The system bus can be a part of the CPU, it has a separate housing or consists of a flat cable. The system bus has a limited number of places for modules, but in most cases it is expandable by using separate system bus modules (e.g. IM). Therefore, the modular PLC can be built up according to the requirements of the automated machine or process.
4 Fig Modular PLC example. Siemens S7-300 PLC (left) and Allen-Bradley CompactLogix PLC (right) Compared to a compact PLC, the modular PLC is capable of using a higher number of inputs and outputs, supports larger programs and more data storage and is capable of multitasking. Today the modular PLC is used mainly for the following tasks: controlling, regulating, positioning, calculating, data management, handling, communication, monitoring, web server etc . Examples of modular PLCs are Siemens S7-300 PLC and Allen-Bradley CompactLogix PLC (Fig. 0.3). The rack PLC has almost the same possibilities and functions as the modular PLC. The only difference lies in the rail or the rack in which the PLC modules are placed. The rack has sockets for modules and an integrated system bus for changing information between different modules. Most PLC modules do not have their own housing, but they have only the front panel with HMI. The main advantage of such systems is that these are capable of a faster data transmission rate between modules and have shorter module response times . Fig Rack PLC examples. Siemens S7-400 PLC (left) and Festo CPX PLC (right) Examples of rack PLCs are Siemens S7-400 PLC and Festo CPX PLC (Fig. 0.4). A PLC with an integrated operator panel (OPLC) has a HMI in addition to a PLC for operating and monitoring automated processes or machines. The HMI consists mostly
5 of a display and a keypad or of a touch screen. The display can be text based or graphical. The main advantage of such a system over a PLC with a separate operator panel is that there is no longer a need to program the panel separately. All programming is done in a single software tool, which saves costs of system development. Examples of OPLC are Unitronics M-90 and Vision (Fig. 0.5). Fig Example of an OPLC. Unitronics M-90 The industrial PC is a device which combines a normal PC and a PLC into one. The PLC part can be a hardware-based (slot PLC) or a software-based virtual PLC (soft PLC). The industrial PC is used in medium-sized or larger automation applications where fast process control, fast data collection and exchange with OPC and/or SQL servers (can be integrated into the PC), easy to operate and monitor, and long life span are important. In most cases an industrial PC uses the filed bus to control automated processes and/or machines. Still, it may have also built-in I/Os and other built-in PLC module parts. The drawback of an industrial PC is that after some time replacement components (like memory, processor, video card etc) are not available. This means that these components are not manufactured anymore because new better products have taken their place. Slot PLC is a special card which has all functions of a normal PLC CPU. It is placed into a PC (empty slot on motherboard), which allows direct information exchange within PC existing HMI applications and/or with other software applications. The slot PLC card has at least one communication channel to connect into the field bus (connecting with remote I/Os or with other PLC devices). Soft PLC is a virtual PLC that runs on a PC. To control machines or processes it uses PC communication ports (Ethernet, comport) or special field bus cards (placeable in the PC) to communicate with remote I/Os and with other automation devices. The disadvantage of a soft PLC is the lack of separate memory for data storage . This means that in the case of power loss, all process controlling data is lost. In addition, with an operating system change there is always the risk that the virtual PLC is not compatible with the new system. Furthermore, there is no guarantee that other applications like HMI or OPC servers running at the same time as the soft PLC are working without any problems and that their work does not influence the soft PLC work (like the process control speed is cut down, for some time field bus connection is lost etc.). An example of an industrial PC is the Siemens rack industrial PC (placeabele into rack 19), box industrial PC and panel industrial PC (Fig. 0.6). As a soft PLC, Siemens offers SIMATIC WinAC RTX, which requires a separated field bus card for the PC.
6 Fig Industrial PC examples. Siemens rack industrial PC (left), box industrial PC (middle) and panel industrial PC (right) Signal types for PLC In the automated processes physical quantities like temperature, pressure, electrical voltages are measured. Usually PLC understands and gives out only electrical signals. Therefore, a signal converter is needed in signal modules to receive and send out values of physical quantities. In the PLC three types of signals are distinguished: binary, digital or analogue signals . V 30 V 24 V 11 V 5 V 0V -3V Logic 1 Logic 0 Fig Binary signal logical states by 24 V DC A binary signal is a 1 bit signal, which recognises only two defined values (signal state 0 low, false or signal state 1 high, true). Typical binary signal encoders are a pushbutton and a switch. An actuated normally open contact corresponds to a logic signal 1 and an unactuated one to a logic signal 0. When working with contactless components, this can give rise to certain tolerance bands. For this reason, certain voltage ranges have been defined as logic 0 or logic 1 ranges. IEC defines a value range of V as the logic signal 0, and V as the logic signal 1 (for contactless sensors) by 24 V DC (Fig. 0.7). For 230 V AC the IEC defines a value range of 0 40 V as the logic signal 0 and V as the logic signal 1 . A digital signal is a series of binary signals treated as one. Each position in a digital signal is called a bit. Typical digital signal formats are : tetrad 4 bits (not widely used), byte - 8 bits, word - 16 bits, double word - 32 bits, double long word - 64 bits (not widely used). A typical digital signal encoder is a digit number plate. t
7 Analogue signals have continuous values, so that they consist of infinitely many values (in certain gaps like 0 10 V). Right now the PLCs are not capable of processing the real analogue signals. Therefore incoming analogue signals are converted into digital signals and reversely for outgoing analogue signals. The conversion takes place in the analogue SM. The higher resolution and accuracy of the analogue signal can be achieved by using more bits in a digital signal. For example, a typical 0 10 V analogue signal can have a precision (steps to transform into a digital signal) of 0.1 V, 0.01 V or V according to bit numbers in the digital signal . How does the PLC work? PLC works in a cyclic manner (Fig. 0.8). Each cycle starts with a PLC internal maintenance work like memory management, diagnostic etc . This part of the cycle is performed very fast, so that the user does not notice it. PLC Internal PLC maintenance Automated Process /Machine Input modules Update of input images Sensors/switches PLC cycle Central processing unit Program execution 1 instruction 2 instruction 3 instruction.. Last instruction Binary, digital and analogue signals Output modules Update of output images Actuators Fig A PLC work cycle The next step is the update of the input image. The SM input states are read and converted into binary or digital signals. These signals are sent to the CPU and stored in data memory (input images). Now the CPU executes the user program existing in the memory sequentially (each instruction line individually). Siemens PLC program instructions are processed in the MC7 machine code (resembles Siemens programming language called a statement list) . This means that all the programs written in other programming languages are converted into MC7 instructions. By program execution new output signals (output images) are generated.
8 The last step is the output update. After the last program line has been executed, the output signals (binary, digital or analogue) in the data memory are sent to SM. These signals are then converted into suitable signals for the actuators. If one cycle is over, then the PLC starts a new cycle. A Siemens S7-300 PLC works like that. On the first PLC work cycle Siemens PLC S7-300 executes a start-up program (called a cold start or warm start) if there is one. After the first cycle Siemens PLC will work the main user program. Sometimes the main program execution is interrupted by an event (emergency button has been activated), hardware (one input module is broken) or time-of-day (after some time a shorter program has to be executed) interrupt programs. The PLC goes on with the main program after the interrupt programs have been accomplished. Other company PLC work cycles can be different. For example, in Allen-Bradley CompactLogix PLC the I/Os are updated directly by program execution (not before or after it). Multitasking Today s PLCs have also a multitasking ability. It means that a PLC is capable of working on different tasks (different user programs) simultaneously. In reality the PLC is able to execute only one task at a time. But because of the PLC CPU processors are working very fast and it seems that the PLC executes different tasks at the same time. Standard IEC defines a task as an execution control element which is capable of invoking, either on a periodic basis (called periodic task) or on an event basis (called nonperiodic task), the execution of a set of program organization units (defined programs) . Periodic tasks are executed periodically after some time (after what time it should be executed), which is set by the user. Non-periodic tasks are executed if an event occurs, which is connected to the task. The event and the task are connected by a Boolean variable. By multitasking a task priority block is important because it establishes the scheduling priority of the tasks. The task priority number starts from zero, which marks the highest priority, and goes higher (lower priorities have higher numbers). The task priorities are set by the user. If the PLC tries to execute two or more tasks simultaneously (several tasks are trying to use the CPU processor at the same time), then the tasks priority decides which task will be executed as the first. Normally the task with the highest priority will be executed; the others are in a waiting mode. But if two or more waiting tasks have the same priorities, then the task with the longest waiting time is executed when the CPU process is free (the previous task execution has ended). If some programs have not been included under any tasks, then they have the lowest priority and are executed only when the CPU processor is free (no tasks are executed and computing time is available) . Based on the task execution interruption the multitasking in a PLC is divided into two: nonpreemptive and preemptive multitasking. By the non-preemptive multitasking a task is executed to the end even if a high priority task is activated. After that a task with the longest
9 waiting time and with the highest priority will be executed. In preemptive multitasking a task is executed so long as a higher priority task execution is activated. So the lower priority task execution is suspended so long as the high priority task is completed. In preemptive multitasking the same or lower priority tasks cannot interrupt the executable task. These have to wait the executable task completion. After the interrupted task has been completed a task with the longest waiting time and with the highest priority will be executed. The IEC defines some rules for the determination of the tasks execution rights which the user has to know to use multitasking [5, 11]. 1. A task will be executed if it has been called up (periodically or an event appears, rising edge appears by a specified Boolean variable) and the other rules (below) do not apply. This means the PLC has free computing time to execute a task. 2. If two or more tasks are called up, then the task with the highest priority will be executed. By preemptive multitasking the executive task is suspended if the new activated task has higher priority than the executed one. By non-preemtpive multitasking the new called-up task with higher priority has to wait for the executable task to end before it can be executed. If the called task (by both multitasking types) has the same or lower priority as the executable task, then this task has to wait for the executable task to end. 3. If an active task and a standby task are sharing some program parts (program, function block, function), then this program parts are executed. Other program parts of the standby task are in a waiting mode. 4. If a PLC has standby tasks with equal priorities, then the one with the longest waiting time comes for execution if computing time is available. 5. Programs (parts) which are not assigned to any tasks have the lowest priority. These are called to the execution right after their termination and go to the execution when computing time is available. Some PLC CPUs can have two or more processors in the central processing unit. These PLCs can execute different (two or more) tasks simultaneously (real time multitasking) without time delays. It allows the PLC to respond very fast to process or machine non-regular behaviors if these have been foreseen. Self check 1. The PLC signal modules are... a. input/output modules for digital and analogue signals. b. devices to convert digital signals into analogue signals and vice versa. c. input/output modules of a frequency converter. 2. Which of the following PLC hardware setups corresponds to a Siemens S7-300 series PLC setup?
10 a. a power supply, signal module, central processing unit and communication processor b. a central processing unit, signal module and interface module c. a central processing unit, signal module, power supply and signal module d. a central processing unit, communication processor and signal module 3. A basic PLC consists of... a. a power supply, central processing unit and signal module(s). b. a central processing unit and signal module(s). c. a central processing unit, power supply, signal module(s), HMI module, communication processor and remote input/output module(s). 4. IEC defines logic signal 1 (by 24 V DC) as... a. voltage range 0 40 V. b. voltage range V. c. voltage range V. 5. A OPLC is... a. a PLC which consists of a distributed control system. b. a PLC which in addition to basic PLC modules has also human-machine interfaces. c. a PLC which has also a web server. 6. A Soft PLC is... a. a card PLC placeabele into a PC and controls automated processes through distributed I/Os. b. a virtual PLC, to test written PLC programs. c. a real time software PLC to be installed in a PC and controls automated processes through distributed I/Os. 7. Multitasking means that... a. a PLC is capable of working on different tasks simultaneously. b. the user program is divided into smaller program parts. c. a person can perform more than one task at the same time. 8. Which sentence is true? a. By multitasking at least two tasks are executed at the same time in a PLC. b. By multitasking the task with the lowest priority is executed and the other tasks have to wait its execution end. c. By multitasking the task with the highest priority is executed and the other tasks have to wait its execution end. d. By multitasking the task with the highest priority is executed and the other tasks can interrupt its execution if the new task priority is the lowest.