258
1 A programmable logic controller, PLC, or programmable controller is a digital computer used forautomation of typically industrial electromechanical processes, such as control of machinery on factoryassembly lines, amusement rides, or light fixtures. PLCs are used in many machines, in many industries. PLCs are designed for multiple arrangements of digital and analog inputs and outputs, extended temperature ranges, immunity to electrical noise, and resistance to vibration and impact. Programs to control machine operation are typically stored in battery-backed-up or non-volatile memory. A PLC is an example of a "hard" real- time system since output results must be produced in response to input conditions within a limited time, otherwise unintended operation will result. Before the PLC, control, sequencing, and safety interlock logic for manufacturing

Plc

Embed Size (px)

DESCRIPTION

plc

Citation preview

Aprogrammable logic controller,PLC, orprogrammable controlleris adigital computerused forau

203

Aprogrammable logic controller,PLC, orprogrammable controlleris adigital computerused forautomationof typically industrialelectromechanicalprocesses, such as control of machinery on factoryassembly lines,amusement rides, orlight fixtures. PLCs are used in many machines, in many industries. PLCs are designed for multiple arrangements of digital and analog inputs and outputs, extended temperature ranges, immunity toelectrical noise, and resistance to vibration and impact. Programs to control machine operation are typically stored in battery-backed-up ornon-volatile memory. A PLC is an example of a "hard"real-timesystem since output results must be produced in response to input conditions within a limited time, otherwise unintended operation will result.

Before the PLC, control, sequencing, and safety interlock logic for manufacturing automobiles was mainly composed ofrelays,cam timers,drum sequencers, and dedicated closed-loop controllers. Since these could number in the hundreds or even thousands, the process for updating such facilities for the yearly modelchange-overwas very time consuming and expensive, aselectriciansneeded to individually rewire the relays to change their operational characteristics.

Digital computers, being general-purpose programmable devices, were soon applied to control of industrial processes. Early computers required specialist programmers, and stringent operating environmental control for temperature, cleanliness, and power quality. Using a general-purpose computer for process control required protecting the computer from the plant floor conditions. An industrial control computer would have several attributes: it would tolerate the shop-floor environment, it would support discrete (bit-form) input and output in an easily extensible manner, it would not require years of training to use, and it would permit its operation to be monitored. The response time of any computer system must be fast enough to be useful for control; the required speed varying according to the nature of the process.[1]Since many industrial processes have timescales easily addressed by millisecond response times, modern (fast, small, reliable) electronics greatly facilitate building reliable controllers, especially because performance can be traded off for reliability.

In 1968 GMHydra-Matic(theautomatic transmissiondivision ofGeneral Motors) issued a request for proposals for an electronic replacement for hard-wired relay systems based on a white paper written by engineer Edward R. Clark. The winning proposal came from Bedford Associates ofBedford, Massachusetts. The first PLC, designated the 084 because it was Bedford Associates' eighty-fourth project, was the result.[2]Bedford Associates started a new company dedicated to developing, manufacturing, selling, and servicing this new product: Modicon, which stood forMOdularDIgitalCONtroller. One of the people who worked on that project wasDick Morley, who is considered to be the "father" of the PLC.[3]The Modicon brand was sold in 1977 toGould Electronics, later acquired by German CompanyAEG, and then by FrenchSchneider Electric, the current owner.

One of the very first 084 models built is now on display at Modicon's headquarters inNorth Andover, Massachusetts. It was presented to Modicon byGM, when the unit was retired after nearly twenty years of uninterrupted service. Modicon used the 84 moniker at the end of its product range until the 984 made its appearance.

The automotive industry is still one of the largest users of PLCs

Development[edit]Early PLCs were designed to replace relay logic systems. These PLCs were programmed in "ladder logic", which strongly resembles a schematic diagram of relay logic. This program notation was chosen to reduce training demands for the existing technicians. Other early PLCs used a form ofinstruction listprogramming, based on a stack-based logic solver.

Modern PLCs can be programmed in a variety of ways, from the relay-derived ladder logic to programming languages such as specially adapted dialects ofBASICandC. Another method isstate logic, avery high-level programming languagedesigned to program PLCs based onstate transition diagrams.

Many early PLCs did not have accompanying programming terminals that were capable of graphical representation of the logic, and so the logic was instead represented as a series of logic expressions in some version ofBoolean format, similar toBoolean algebra. As programming terminals evolved, it became more common for ladder logic to be used, for the aforementioned reasons and because it was a familiar format used for electromechanical control panels. Newer formats such as state logic and Function Block (which is similar to the way logic is depicted when using digital integrated logic circuits) exist, but they are still not as popular as ladder logic. A primary reason for this is that PLCs solve the logic in a predictable and repeating sequence, and ladder logic allows the programmer (the person writing the logic) to see any issues with the timing of the logic sequence more easily than would be possible in other formats.

Programming[edit]Early PLCs, up to the mid-1990s, were programmed using proprietary programming panels or special-purpose programmingterminals, which often had dedicated function keys representing the various logical elements of PLC programs.[2]Some proprietary programming terminals displayed the elements of PLC programs as graphic symbols, but plainASCIIcharacter representations of contacts, coils, and wires were common. Programs were stored oncassette tape cartridges. Facilities for printing and documentation were minimal due to lack of memory capacity. The very oldest PLCs used non-volatilemagnetic core memory.

More recently, PLCs are programmed using application software on personal computers, which now represent the logic in graphic form instead of character symbols. The computer is connected to the PLC throughEthernet,RS-232,RS-485, orRS-422cabling. The programming software allows entry and editing of the ladder-style logic. Generally the software provides functions for debugging and troubleshooting the PLC software, for example, by highlighting portions of the logic to show current status during operation or via simulation. The software will upload and download the PLC program, for backup and restoration purposes. In some models of programmable controller, the program is transferred from a personal computer to the PLC through aprogramming boardwhich writes the program into a removable chip such as anEPROMFunctionality[edit]The functionality of the PLC has evolved over the years to include sequential relay control, motion control,process control,distributed control systems, andnetworking. The data handling, storage, processing power, and communication capabilities of some modern PLCs are approximately equivalent todesktop computers. PLC-like programming combined with remote I/O hardware, allow a general-purpose desktop computer to overlap some PLCs in certain applications. Desktop computer controllers have not been generally accepted in heavy industry because the desktop computers run on less stable operating systems than do PLCs, and because the desktop computer hardware is typically not designed to the same levels of tolerance to temperature, humidity, vibration, and longevity as the processors used in PLCs. Operating systems such as Windows do not lend themselves to deterministic logic execution, with the result that the controller may not always respond to changes of input status with the consistency in timing expected from PLCs. Desktop logic applications find use in less critical situations, such as laboratory automation and use in small facilities where the application is less demanding and critical, because they are generally much less expensive than PLCs.[citation needed]Programmable logic relay (PLR)[edit]In more recent years, small products called PLRs (programmable logic relays), and also by similar names, have become more common and accepted. These are much like PLCs, and are used in light industry where only a few points ofI/O(i.e. a few signals coming in from the real world and a few going out) are needed, and low cost is desired. These small devices are typically made in a common physical size and shape by several manufacturers, and branded by the makers of larger PLCs to fill out their low end product range. Popular names include PICO Controller, NANO PLC, and other names implying very small controllers. Most of these have 8 to 12 discrete inputs, 4 to 8 discrete outputs, and up to 2 analog inputs. Size is usually about 4" wide, 3" high, and 3" deep. Most such devices include a tiny postage-stamp-sized LCD screen for viewing simplified ladder logic (only a very small portion of the program being visible at a given time) and status of I/O points, and typically these screens are accompanied by a 4-way rocker push-button plus four more separate push-buttons, similar to the key buttons on a VCR remote control, and used to navigate and edit the logic. Most have a small plug for connecting via RS-232 or RS-485 to a personal computer so that programmers can use simple Windows applications for programming instead of being forced to use the tiny LCD and push-button set for this purpose. Unlike regular PLCs that are usually modular and greatly expandable, the PLRs are usually not modular or expandable, but their price can be twoorders of magnitudeless than a PLC, and they still offer robust design and deterministic execution of the logics.

Features:

The main difference from other computers is that PLCs are armored for severe conditions (such as dust, moisture, heat, cold), and have the facility for extensiveinput/output(I/O) arrangements. These connect the PLC tosensorsandactuators. PLCs readlimit switches, analog process variables (such as temperature and pressure), and the positions of complex positioning systems. Some usemachine vision.[4]On the actuator side, PLCs operateelectric motors,pneumaticorhydrauliccylinders, magneticrelays,solenoids, oranalogoutputs. The input/output arrangements may be built into a simple PLC, or the PLC may have external I/O modules attached to a computer network that plugs into the PLC.

Scan time[edit]A PLC program is generally executed repeatedly as long as the controlled system is running. The status of physical input points is copied to an area of memory accessible to the processor, sometimes called the "I/O Image Table". The program is then run from its first instruction rung down to the last rung. It takes some time for the processor of the PLC to evaluate all the rungs and update the I/O image table with the status of outputs.[5]This scan time may be a few milliseconds for a small program or on a fast processor, but older PLCs running very large programs could take much longer (say, up to 100 ms) to execute the program. If the scan time were too long, the response of the PLC to process conditions would be too slow to be useful.

As PLCs became more advanced, methods were developed to change the sequence of ladder execution, and subroutines were implemented.[6]This simplified programming could be used to save scan time for high-speed processes; for example, parts of the program used only for setting up the machine could be segregated from those parts required to operate at higher speed.

Special-purpose I/O modules may be used where the scan time of the PLC is too long to allow predictable performance. Precision timing modules, or counter modules for use withshaft encoders, are used where the scan time would be too long to reliably count pulses or detect the sense of rotation of an encoder. The relatively slow PLC can still interpret the counted values to control a machine, but the accumulation of pulses is done by a dedicated module that is unaffected by the speed of the program execution.

System scale[edit]A small PLC will have a fixed number of connections built in for inputs and outputs. Typically, expansions are available if the base model has insufficient I/O.

Modular PLCs have a chassis (also called a rack) into which are placed modules with different functions. The processor and selection of I/O modules are customized for the particular application. Several racks can be administered by a single processor, and may have thousands of inputs and outputs. A special high speed serial I/O link is used so that racks can be distributed away from the processor, reducing the wiring costs for large plants.

User interface[edit]See also:User interfaceandList of human-computer interaction topicsPLCs may need to interact with people for the purpose of configuration, alarm reporting, or everyday control. Ahuman-machine interface(HMI) is employed for this purpose. HMIs are also referred to as man-machine interfaces (MMIs) and graphical user interfaces (GUIs). A simple system may use buttons and lights to interact with the user. Text displays are available as well as graphical touch screens. More complex systems use programming and monitoring software installed on a computer, with the PLC connected via a communication interface.

Communications[edit]PLCs have built-in communications ports, usually 9-pinRS-232, but optionallyEIA-485orEthernet.Modbus,BACnet, orDF1is usually included as one of thecommunications protocols. Other options include variousfieldbusessuch asDeviceNet,ProfibusorProfinet. Other communications protocols that may be used are listed in theList of automation protocols.

Most modern PLCs can communicate over a network to some other system, such as a computer running aSCADA(Supervisory Control And Data Acquisition) system or web browser.

PLCs used in larger I/O systems may havepeer-to-peer(P2P) communication between processors. This allows separate parts of a complex process to have individual control while allowing the subsystems to co-ordinate over the communication link. These communication links are also often used forHMIdevices such as keypads orPC-type workstations.

Formerly, some manufacturers offered dedicated communication modules as an add-on function where the processor had no network connection built-in.

Programming[edit]PLC programs are typically written in a special application on a personal computer, then downloaded by a direct-connection cable or over a network to the PLC. The program is stored in the PLC either in battery-backed-upRAMor some other non-volatileflash memory. Often, a single PLC can be programmed to replace thousands ofrelays.[7]Under theIEC 61131-3standard, PLCs can be programmed using standards-based programming languages. A graphical programming notation calledSequential Function Chartsis available on certain programmable controllers. Initially most PLCs utilized Ladder Logic Diagram Programming, a model which emulated electromechanical control panel devices (such as the contact and coils of relays) which PLCs replaced. This model remains common today.

IEC 61131-3 currently defines five programming languages for programmable control systems:function block diagram(FBD),ladder diagram(LD),structured text(ST; similar to thePascal programming language),instruction list(IL; similar toassembly language), andsequential function chart(SFC).[8]These techniques emphasize logical organization of operations.[7]While the fundamental concepts of PLC programming are common to all manufacturers, differences in I/O addressing, memory organization, and instruction sets mean that PLC programs are never perfectly interchangeable between different makers. Even within the same product line of a single manufacturer, different models may not be directly compatible.

Security[edit]Prior to the discovery of theStuxnetcomputer wormin June 2010, security of PLCs received little attention. PLCs generally contain a real-time operating system such asOS-9orVxWorks, and exploits for these systems exist much as they do for desktop computer operating systems such asMicrosoft Windows. PLCs can also be attacked by gaining control of a computer they communicate with.[9]SIMULATION

In order to properly understand the operation of a PLC, it is necessary to spend considerable timeprogramming, testing, anddebuggingPLC programs. PLC systems are inherently expensive, and down-time is often very costly. In addition, if a PLC is programmed incorrectly it can result in lost productivity and dangerous conditions. PLC simulation software such asPLCLogixcan save time in the design of automated control applications and can also increase the level of safety associated with equipment since various "what if" scenarios can be tried and tested before the system is activated.[10]Redundancy[edit]Some special processes need to work permanently with minimum unwanted down time. Therefore, it is necessary to design a system which is fault-tolerant and capable of handling the process with faulty modules. In such cases to increase the system availability in the event of hardware component failure, redundant CPU or I/O modules with the same functionality can be added to hardware configuration for preventing total or partial process shutdown due to hardware failure

PLC compared with other control systems

PLCs are well adapted to a range ofautomationtasks. These are typically industrial processes in manufacturing where the cost of developing and maintaining the automation system is high relative to the total cost of the automation, and where changes to the system would be expected during its operational life. PLCs contain input and output devices compatible with industrial pilot devices and controls; little electrical design is required, and the design problem centers on expressing the desired sequence of operations. PLC applications are typically highly customized systems, so the cost of a packaged PLC is low compared to the cost of a specific custom-built controller design. On the other hand, in the case of mass-produced goods, customized control systems are economical. This is due to the lower cost of the components, which can be optimally chosen instead of a "generic" solution, and where the non-recurring engineering charges are spread over thousands or millions of units.

For high volume or very simple fixed automation tasks, different techniques are used. For example, a consumerdishwasherwould be controlled by an electromechanicalcam timercosting only a few dollars in production quantities.

Amicrocontroller-based design would be appropriate where hundreds or thousands of units will be produced and so the development cost (design of power supplies, input/output hardware, and necessary testing and certification) can be spread over many sales, and where the end-user would not need to alter the control. Automotive applications are an example; millions of units are built each year, and very few end-users alter the programming of these controllers. However, some specialty vehicles such as transit buses economically use PLCs instead of custom-designed controls, because the volumes are low and the development cost would be uneconomical.[11]Very complex process control, such as used in the chemical industry, may require algorithms and performance beyond the capability of even high-performance PLCs. Very high-speed or precision controls may also require customized solutions; for example, aircraft flight controls.Single-board computersusing semi-customized or fully proprietary hardware may be chosen for very demanding control applications where the high development and maintenance cost can be supported. "Soft PLCs" running on desktop-type computers can interface with industrial I/O hardware while executing programs within a version of commercial operating systems adapted for process control needs.[11]Programmable controllers are widely used in motion control, positioning control, and torque control. Some manufacturers produce motion control units to be integrated with PLC so thatG-code(involving aCNCmachine) can be used to instruct machine movements.[citation needed]PLCs may include logic for single-variable feedback analog control loop, aproportional, integral, derivative (PID) controller. A PID loop could be used to control the temperature of a manufacturing process, for example. Historically PLCs were usually configured with only a few analog control loops; where processes required hundreds or thousands of loops, adistributed control system(DCS) would instead be used. As PLCs have become more powerful, the boundary between DCS and PLC applications has become less distinct.

PLCs have similar functionality asremote terminal units(RTU). An RTU, however, usually does not support control algorithms or control loops. As hardware rapidly becomes more powerful and cheaper,RTUs, PLCs, andDCSsare increasingly beginning to overlap in responsibilities, and many vendors sell RTUs with PLC-like features, and vice versa. The industry has standardized on theIEC 61131-3functional block language for creating programs to run on RTUs and PLCs, although nearly all vendors also offer proprietary alternatives and associated development environments.

In recent years "safety" PLCs have started to become popular, either as standalone models or as functionality and safety-rated hardware added to existing controller architectures (Allen Bradley Guardlogix, Siemens F-series etc.). These differ from conventional PLC types as being suitable for use in safety-critical applications for which PLCs have traditionally been supplemented with hard-wiredsafety relays. For example, a safety PLC might be used to control access to a robot cell withtrapped-key access, or perhaps to manage the shutdown response to an emergency stop on a conveyor production line. Such PLCs typically have a restricted regular instruction set augmented with safety-specific instructions designed to interface with emergency stops, light screens, and so forth. The flexibility that such systems offer has resulted in rapid growth of demand for these controllers.

Discrete and analog signals[edit]Discrete signals behave as binary switches, yielding simply an On or Off signal (1 or 0, True or False, respectively). Push buttons,limit switches, andphotoelectric sensorsare examples of devices providing a discrete signal. Discrete signals are sent using eithervoltageorcurrent, where a specific range is designated asOnand another asOff. For example, a PLC might use 24 V DC I/O, with values above 22 V DC representingOn, values below 2VDC representingOff, and intermediate values undefined. Initially, PLCs had only discrete I/O.

Analog signals are like volume controls, with a range of values between zero and full-scale. These are typically interpreted as integer values (counts) by the PLC, with various ranges of accuracy depending on the device and the number of bits available to store the data. As PLCs typically use 16-bit signed binary processors, the integer values are limited between -32,768 and +32,767. Pressure, temperature, flow, and weight are often represented by analog signals. Analog signals can usevoltageorcurrentwith a magnitude proportional to the value of the process signal. For example, an analog 0 to 10V or4-20 mAinput would beconvertedinto an integer value of 0 to 32767.

Current inputsare less sensitive to electrical noise (i.e. from welders or electric motor starts) than voltage inputs.

Example[edit]As an example, say a facility needs to store water in a tank. The water is drawn from the tank by another system, as needed, and our example system must manage the water level in the tank by controlling the valve that refills the tank. Shown is a "ladder diagram" which shows the control system. A ladder diagram is a method of drawing control circuits which pre-dates PLCs. The ladder diagram resembles the schematic diagram of a system built with electromechanical relays. Shown are:

Two inputs (from the low and high level switches) represented by contacts of the float switches

An output to the fill valve, labelled as the fill valve which it controls

An "internal" contact, representing the output signal to the fill valve which is created in the program.

A logical control scheme created by the interconnection of these items in software

In ladder diagram, the contact symbols represent the state of bits in processor memory, which corresponds to the state of physical inputs to the system. If a discrete input is energized, the memory bit is a 1, and a "normally open" contact controlled by that bit will pass a logic "true" signal on to the next element of the ladder.Therefore, the contacts in the PLC program that "read" or look at the physical switch contacts in this case must be "opposite" or open in order to return a TRUE for the closed physical switches.Internal status bits, corresponding to the state of discrete outputs, are also available to the program.

In the example, the physical state of the float switch contacts must be considered when choosing "normally open" or "normally closed" symbols in the ladder diagram. The PLC has two discrete inputs fromfloat switches(Low Level and High Level). Both float switches (normally closed) open their contacts when the water level in the tank is above the physical location of the switch.

When the water level is below both switches, the float switch physical contacts are both closed, and a true (logic 1) value is passed to the Fill Valve output. Water begins to fill the tank. The internal "Fill Valve" contact latches the circuit so that even when the "Low Level" contact opens (as the water passes the lower switch), the fill valve remains on. Since the High Level is also normally closed, water continues to flow as the water level remains between the two switch levels. Once the water level rises enough so that the "High Level" switch is off (opened), the PLC will shut the inlet to stop the water from overflowing; this is an example of seal-in (latching) logic. The output is sealed in until a high level condition breaks the circuit. After that the fill valve remains off until the level drops so low that the Low Level switch is activated, and the process repeats again.

| (N.C. physical (N.C. physical |

| Switch) Switch) |

| Low Level High Level Fill Valve |

|------[ ]------|------[ ]----------------------(OUT)---------|

| | |

| | |

| | |

| Fill Valve | |

|------[ ]------| |

| |

| |

A complete program may contain thousands of rungs, evaluated in sequence. Typically the PLC processor will alternately scan all its inputs and update outputs, then evaluate the ladder logic; input changes during a program scan will not be effective until the next I/O update. A complete program scan may take only a few milliseconds, much faster than changes in the controlled process.

Programmable controllers vary in their capabilities for a "rung" of a ladder diagram. Some only allow a single output bit. There are typically limits to the number of series contacts in line, and the number of branches that can be used. Each element of the rung is evaluated sequentially. If elements change their state during evaluation of a rung, hard-to-diagnose faults can be generated, although sometimes (as above) the technique is useful. Some implementations forced evaluation from left-to-right as displayed and did not allow reverse flow of a logic signal (in multi-branched rungs) to affect the output.

Introduction

Industry has begun to recognize the need for quality improvement and increase in productivity in the sixties and seventies. Flexibility also became a major concern (ability to change a process quickly became very important in order to satisfy consumer needs).

Try to imagine automated industrial production line in the sixties and seventies. There was always a huge electrical board for system controls, and not infrequently it covered an entire wall! Within this board there was a great number of interconnected electromechanical relays to make the whole system work. By word "connected" it was understood that electrician had to connect all relays manually using wires! An engineer would design logic for a system, and electricians would receive a schematic outline of logic that they had to implement with relays. These relay schemas often contained hundreds of relays. The plan that electrician was given was called "ladder schematic". Ladder displayed all switches, sensors, motors, valves, relays, etc. found in the system. Electrician's job was to connect them all together. One of the problems with this type of control was that it was based on mechanical relays. Mechanical instruments were usually the weakest connection in the system due to their moveable parts that could wear out. If one relay stopped working, electrician would have to examine an entire system (system would be out until a cause of the problem was found and corrected).

The other problem with this type of control was in the system's break period when a system had to be turned off, so connections could be made on the electrical board. If a firm decided to change the order of operations (make even a small change), it would turn out to be a major expense and a loss of production time until a system was functional again.

It's not hard to imagine an engineer who makes a few small errors during his project. It is also conceivable that electrician has made a few mistakes in connecting the system. Finally, you can also imagine having a few bad components. The only way to see if everything is all right is to run the system. As systems are usually not perfect with a first try, finding errors was an arduous process. You should also keep in mind that a product could not be made during these corrections and changes in connections. System had to be literally disabled before changes were to be performed. That meant that the entire production staff in that line of production was out of work until the system was fixed up again. Only when electrician was done finding errors and repairing,, the system was ready for production. Expenditures for this kind of work were too great even for well-to-do companies.

2.1 First programmable controllers

"General Motors" is among the first who recognized a need to replace the system's "wired" control board. Increased competition forced auto-makers to improve production quality and productivity. Flexibility and fast and easy change of automated lines of production became crucial! General Motors' idea was to use for system logic one of the microcomputers (these microcomputers were as far as their strength beneath today's eight-bit microcontrollers) instead of wired relays. Computer could take place of huge, expensive, inflexible wired control boards. If changes were needed in system logic or in order of operations, program in a microcomputer could be changed instead of rewiring of relays. Imagine only what elimination of the entire period needed for changes in wiring meant then. Today, such thinking is but common, then it was revolutionary!

Everything was well thought out, but then a new problem came up of how to make electricians accept and use a new device. Systems are often quite complex and require complex programming. It was out of question to ask electricians to learn and use computer language in addition to other job duties. General Motors Hidromatic Division of this big company recognized a need and wrote out project criteria for first programmable logic controller ( there were companies which sold instruments that performed industrial control, but those were simple sequential controllers not PLC controllers as we know them today). Specifications required that a new device be based on electronic instead of mechanical parts, to have flexibility of a computer, to function in industrial environment (vibrations, heat, dust, etc.) and have a capability of being reprogrammed and used for other tasks. The last criteria was also the most important, and a new device had to be programmed easily and maintained by electricians and technicians. When the specification was done, General Motors looked for interested companies, and encouraged them to develop a device that would meet the specifications for this project.

"Gould Modicon" developed a first device which met these specifications. The key to success with a new device was that for its programming you didn't have to learn a new programming language. It was programmed so that same language a ladder diagram, already known to technicians was used. Electricians and technicians could very easily understand these new devices because the logic looked similar to old logic that they were used to working with. Thus they didn't have to learn a new programming language which (obviously) proved to be a good move. PLC controllers were initially called PC controllers (programmable controllers). This caused a small confusion when Personal Computers appeared. To avoid confusion, a designation PC was left to computers, and programmable controllers became programmable logic controllers. First PLC controllers were simple devices. They connected inputs such as switches, digital sensors, etc., and based on internal logic they turned output devices on or off. When they first came up, they were not quite suitable for complicated controls such as temperature, position, pressure, etc. However, throughout years, makers of PLC controllers added numerous features and improvements. Today's PLC controller can handle highly complex tasks such as position control, various regulations and other complex applications. The speed of work and easiness of programming were also improved. Also, modules for special purposes were developed, like communication modules for connecting several PLC controllers to the net. Today it is difficult to imagine a task that could not be handled by a PLC.

2.2 PLC controller components

PLC is actually an industrial microcontroller system (in more recent times we meet processors instead of microcontrollers) where you have hardware and software specifically adapted to industrial environment. Block schema with typical components which PLC consists of is found in the following picture. Special attention needs to be given to input and output, because in these blocks you find protection needed in isolating a CPU blocks from damaging influences that industrial environment can bring to a CPU via input lines. Program unit is usually a computer used for writing a program (often in ladder diagram).

2.3 Central Processing Unit - CPU

Central Processing Unit (CPU) is the brain of a PLC controller. CPU itself is usually one of the microcontrollers. Aforetime these were 8-bit microcontrollers such as 8051, and now these are 16- and 32-bit microcontrollers. Unspoken rule is that you'll find mostly Hitachi and Fujicu microcontrollers in PLC controllers by Japanese makers, Siemens in European controllers, and Motorola microcontrollers in American ones. CPU also takes care of communication, interconnectedness among other parts of PLC controller, program execution, memory operation, overseeing input and setting up of an output. PLC controllers have complex routines for memory checkup in order to ensure that PLC memory was not damaged (memory checkup is done for safety reasons). Generally speaking, CPU unit makes a great number of check-ups of the PLC controller itself so eventual errors would be discovered early. You can simply look at any PLC controller and see that there are several indicators in the form of light diodes for error signalization.

2.4 Memory

System memory (today mostly implemented in FLASH technology) is used by a PLC for an process control system. Aside from this operating system it also contains a user program translated from a ladder diagram to a binary form. FLASH memory contents can be changed only in case where user program is being changed. PLC controllers were used earlier instead of FLASH memory and have had EPROM memory instead of FLASH memory which had to be erased with UV lamp and programmed on programmers. With the use of FLASH technology this process was greatly shortened. Reprogramming a program memory is done through a serial cable in a program for application development.

User memory is divided into blocks having special functions. Some parts of a memory are used for storing input and output status. The real status of an input is stored either as "1" or as "0" in a specific memory bit. Each input or output has one corresponding bit in memory. Other parts of memory are used to store variable contents for variables used in user program. For example, timer value, or counter value would be stored in this part of the memory.

2.5 Programming a PLC controller

PLC controller can be reprogrammed through a computer (usual way), but also through manual programmers (consoles). This practically means that each PLC controller can programmed through a computer if you have the software needed for programming. Today's transmission computers are ideal for reprogramming a PLC controller in factory itself. This is of great importance to industry. Once the system is corrected, it is also important to read the right program into a PLC again. It is also good to check from time to time whether program in a PLC has not changed. This helps to avoid hazardous situations in factory rooms (some automakers have established communication networks which regularly check programs in PLC controllers to ensure execution only of good programs).

Almost every program for programming a PLC controller possesses various useful options such as: forced switching on and off of the system inputs/ouputs (I/O lines), program follow up in real time as well as documenting a diagram. This documenting is necessary to understand and define failures and malfunctions. Programmer can add remarks, names of input or output devices, and comments that can be useful when finding errors, or with system maintenance. Adding comments and remarks enables any technician (and not just a person who developed the system) to understand a ladder diagram right away. Comments and remarks can even quote precisely part numbers if replacements would be needed. This would speed up a repair of any problems that come up due to bad parts. The old way was such that a person who developed a system had protection on the program, so nobody aside from this person could understand how it was done. Correctly documented ladder diagram allows any technician to understand thoroughly how system functions.

2.6. Power supply

Electrical supply is used in bringing electrical energy to central processing unit. Most PLC controllers work either at 24 VDC or 220 VAC. On some PLC controllers you'll find electrical supply as a separate module. Those are usually bigger PLC controllers, while small and medium series already contain the supply module. User has to determine how much current to take from I/O module to ensure that electrical supply provides appropriate amount of current. Different types of modules use different amounts of electrical current.

This electrical supply is usually not used to start external inputs or outputs. User has to provide separate supplies in starting PLC controller inputs or outputs because then you can ensure so called "pure" supply for the PLC controller. With pure supply we mean supply where industrial environment can not affect it damagingly. Some of the smaller PLC controllers supply their inputs with voltage from a small supply source already incorporated into a PLC.

2.7 PLC controller inputs

Intelligence of an automated system depends largely on the ability of a PLC controller to read signals from different types of sensors and input devices. Keys, keyboards and by functional switches are a basis for man versus machine relationship. On the other hand, in order to detect a working piece, view a mechanism in motion, check pressure or fluid level you need specific automatic devices such as proximity sensors, marginal switches, photoelectric sensors, level sensors, etc. Thus, input signals can be logical (on/off) or analogue. Smaller PLC controllers usually have only digital input lines while larger also accept analogue inputs through special units attached to PLC controller. One of the most frequent analogue signals are a current signal of 4 to 20 mA and milivolt voltage signal generated by various sensors. Sensors are usually used as inputs for PLCs. You can obtain sensors for different purposes. They can sense presence of some parts, measure temperature, pressure, or some other physical dimension, etc. (ex. inductive sensors can register metal objects).

Other devices also can serve as inputs to PLC controller. Intelligent devices such as robots, video systems, etc. often are capable of sending signals to PLC controller input modules (robot, for instance, can send a signal to PLC controller input as information when it has finished moving an object from one place to the other.)

2.8 Input adjustment interface

Adjustment interface also called an interface is placed between input lines and a CPU unit. The purpose of adjustment interface to protect a CPU from disproportionate signals from an outside world. Input adjustment module turns a level of real logic to a level that suits CPU unit (ex. input from a sensor which works on 24 VDC must be converted to a signal of 5 VDC in order for a CPU to be able to process it). This is typically done through opto-isolation, and this function you can view in the following picture.Opto-isolation means that there is no electrical connection between external world and CPU unit. They are "optically" separated, or in other words, signal is transmitted through light. The way this works is simple. External device brings a signal which turns LED on, whose light in turn incites photo transistor which in turn starts conducting, and a CPU sees this as logic zero (supply between collector and transmitter falls under 1V). When input signal stops LED diode turns off, transistor stops conducting, collector voltage increases, and CPU receives logic 1 as information.

2.9 PLC controller output

Automated system is incomplete if it is not connected with some output devices. Some of the most frequently used devices are motors, solenoids, relays, indicators, sound signalization and similar. By starting a motor, or a relay, PLC can manage or control a simple system such as system for sorting products all the way up to complex systems such as service system for positioning head of CNC machine. Output can be of analogue or digital type. Digital output signal works as a switch; it connects and disconnects line. Analogue output is used to generate the analogue signal (ex. motor whose speed is controlled by a voltage that corresponds to a desired speed).

2.10 Output adjustment interface

Output interface is similar to input interface. CPU brings a signal to LED diode and turns it on. Light incites a photo transistor which begins to conduct electricity, and thus the voltage between collector and emmiter falls to 0.7V , and a device attached to this output sees this as a logic zero. Inversely it means that a signal at the output exists and is interpreted as logic one. Photo transistor is not directly connected to a PLC controller output. Between photo transistor and an output usually there is a relay or a stronger transistor capable of interrupting stronger signals.

2.11 Extension lines

Every PLC controller has a limited number of input/output lines. If needed this number can be increased through certain additional modules by system extension through extension lines. Each module can contain extension both of input and output lines. Also, extension modules can have inputs and outputs of a different nature from those on the PLC controller (ex. in case relay outputs are on a controller, transistor outputs can be on an extension module).Connecting sensors and execution devicesIntroduction

Connecting external devices to a PLC controller regardless whether they are input or output is a special subject matter for industry. If it stands alone, PLC controller itself is nothing. In order to function it needs sensors to obtain information from environment, and it also needs execution devices so it could turn the programmed change into a reality. Similar concept is seen in how human being functions. Having a brain is simply not enough. Humans achieve full activity only with processing of information from a sensor (eyes, ears, touch, smell) and by taking action through hands, legs or some tools. Unlike human being who receives his sensors automatically, when dealing with controllers, sensors have to be subsequently connected to a PLC. How to connect input and output parts is the topic of this chapter. 3.1 Sinking-Sourcing Concept

PLC has input and output lines through which it is connected to a system it directs. Input can be keys, switches, sensors while outputs are led to different devices from simple signalization lights to complex communication modules.

This is a very important part of the story about PLC controllers because it directly influences what can be connected and how it can be connected to controller inputs or outputs. Two terms most frequently mentioned when discussing connections to inputs or outputs are "sinking" and "sourcing". These two concepts are very important in connecting a PLC correctly with external environment. The most brief definition of these two concepts would be:

SINKING = Common GND line (-)SOURCING = Common VCC line (+)

First thing that catches one's eye are "+" and "-" supply, DC supply. Inputs and outputs which are either sinking or sourcing can conduct electricity only in one direction, so they are only supplied with direct current.According to what we've said thus far, each input or output has its own return line, so 5 inputs would need 10 screw terminals on PLC controller housing. Instead, we use a system of connecting several inputs to one return line as in the following picture. These common lines are usually marked "COMM" on the PLC controller housing.

3.2 Input lines

Explanation of PLC controller input and output lines has up to now been given only theoretically. In order to apply this knowledge, we need to make it a little more specific. Example can be connection of external device such as proximity sensor. Sensor outputs can be different depending on a sensor itself and also on a particular application. Following pictures display some examples of sensor outputs and their connection with a PLC controller. Sensor output actually marks the size of a signal given by a sensor at its output when this sensor is active. In one case this is +V (supply voltage, usually 12 or 24V) and in other case a GND (0V). Another thing worth mentioning is that sinking-sourcing and sourcing - sinking pairing is always used, and not sourcing-sourcing or sinking-sinking pairing.

If we were to make type of connection more specific, we'd get combinations as in following pictures (for more specific connection schemas we need to know the exact sensor model and a PLC controller model).

3.3 Output lines

PLC controller output lines usually can be:

-transistors in PNP connection-transistors in NPN connection-relays

The following two pictures display a realistic way how a PLC manages external devices. It ought to be noted that a main difference between these two pictures is a position of "output load device". By "output load device" we mean some relay, signalization light or similar.

How something is connected with a PLC output depends on the element being connected. In short, it depends on whether this element of output load device is activated by a positive supply pole or a negative supply pole. Architecture of specific PLC controllerIntroduction

This book could deal with a general overview of some supposed PLC controller. Author has had an opportunity to look over plenty of books published up till now, and this approach is not the most suitable to the purposes of this book in his opinion. Idea of this book is to work through one specific PLC controller where someone can get a real feeling on this subject and its weight. Our desire was to write a book based on whose reading you can earn some money. After all, money is the end goal of every business!

4.1 Why OMRON?

Why not? It is a huge company which has high quality and by our standards inexpensive controllers. Today we can say almost with surety that PLC controllers by manufacturers round the world are excellent devices, and altogether similar. Nevertheless, for specific application we need to know specific information about a PLC controller being used. Therefore, the choice fell on OMRON company and its PLC of micro class CPM1A. Adjective "micro" itself implies the smallest models from the viewpoint of a number of attached lines or possible options. Still, this PLC controller is ideal for the purposes of this book, and that is to introduce a PLC controller philosophy to its readers.

4.2 CPM1A PLC controller

Each PLC is basically a microcontroller system (CPU of PLC controller is based on one of the microcontrollers, and in more recent times on one of the PC processors) with peripherals that can be digital inputs, digital outputs or relays as in our case. However, this is not an "ordinary" microcontroller system. Large teams have worked on it, and a checkup of its function has been performed in real world under all possible circumstances. Software itself is entirely different from assemblers used thus far, such as BASIC or C. This specialized software is called "ladder" (name came about by an association of program's configuration which resembles a ladder, and from the way program is written out).

Specific look of CPM1A PLC controller can be seen in the following picture. On the upper surface, there are 4 LED indicators and a connection port with an RS232 module which is interface to a PC computer. Aside from this, screw terminals and light indicators of activity of each input or output are visible on upper and lower sides. Screw terminals serve to manually connect to a real system. Hookups L1 and L2 serve as supply which is 220V~ in this case. PLC controllers that work on power grid voltage usually have a source of direct supply of 24 VDC for supplying sensors and such (with a CPM1A source of direct supply is found on the bottom left hand side and is represented with two screw terminals. Controller can be mounted to industrial "track" along with other automated elements, but also by a screw to the machine wall or control panel.

Controller is 8cm high and divided vertically into two areas: a lower one with a converter of 220V~ at 24VDC and other voltages needed for running a CPU unit; and, upper area with a CPU and memory, relays and digital inputs.When you lift the small plastic cover you'll see a connector to which an RS232 module is hooked up for serial interface with a computer. This module is used when programming a PLC controller to change programs or execution follow-up. When installing a PLC it isn't necessary to install this module, but it is recommended because of possible changes in software during operation.

To better inform programmers on PLC controller status, maker has provided for four light indicators in the form of LED's. Beside these indicators, there are status indicators for each individual input and output. These LED's are found by the screw terminals and with their status are showing input or output state. If input/output is active, diode is lit and vice versa.

4.3 PLC controller output lines

Aside from transistor outputs in PNP and NPN connections, PLC can also have relays as outputs. Existence of relays as outputs makes it easier to connect with external devices. Model CPM1A contains exactly these relays as outputs. There a 4 relays whose functional contacts are taken out on a PLC controller housing in the form of screw terminals. In reality this looks as in picture below.

With activation of phototransistor, relay comes under voltage and activates a contact between points A and B. Contacts A and B can in our case be either in connection or interrupted. What state these contacts are in is determined by a CPU through appropriate bits in memory location IR010. One example of relay status is shown in a picture below. A true state of devices attached to these relays is displayed.

4.4 PLC controller input lines

Different sensors, keys, switches and other elements that can change status of a joined bit at PLC input can be hooked up to the PLC controller inputs. In order to realize a change, we need a voltage source to incite an input. The simplest possible input would be a common key. As CPM1A PLC has a source of direct voltage of 24V, the same source can be used to incite input (problem with this source is its maximum current which it can give continually and which in our case amounts to 0.2A). Since inputs to a PLC are not big consumers (unlike some sensor where a stronger external supply must be used) it is possible to take advantage of the existing source of direct supply to incite all six keys.

4.5 How PLC controller works

Basis of a PLC function is continual scanning of a program. Under scanning we mean running through all conditions within a guaranteed period. Scanning process has three basic steps:

Step 1.Testing input status. First, a PLC checks each of the inputs with intention to see which one of them has status ON or OFF. In other words, it checks whether a sensor, or a switch etc. connected with an input is activated or not. Information that processor thus obtains through this step is stored in memory in order to be used in the following step.

Step 2.Program execution. Here a PLC executes a program, instruction by instruction. Based on a program and based on the status of that input as obtained in the preceding step, an appropriate action is taken. This reaction can be defined as activation of a certain output, or results can be put off and stored in memory to be retrieved later in the following step.

Step 3.Checkup and correction of output status. Finally, a PLC checks up output status and adjusts it as needed. Change is performed based on the input status that had been read during the first step, and based on the results of program execution in step two. Following the execution of step 3 PLC returns to the beginning of this cycle and continually repeats these steps. Scanning time is defined by the time needed to perform these three steps, and sometimes it is an important program feature.

4.6 CPM1A PLC controller memory map

By memory map we mean memory structure for a PLC controller. Simply said, certain parts of memory have specific roles. If you look at the picture below, you can see that memory for CPM1A is structured into 16-bit words. A cluster of several such words makes up a region. All the regions make up the memory for a PLC controller.

Unlike microcontroller systems where only some memory locations have had their purpose clearly defined (ex. register that contains counter value), a memory of PLC controller is completely defined, and more importantly almost entire memory is addressable in bits. Addressability in bits means that it is enough to write the address of the memory location and a number of bits after it in order to manipulate with it. In short, that would mean that something like this could be written: "201.7=1" which would clearly indicate a word 201 and its bit 7 which is set to one.

IR region

Memory locations intended for PLC input and output. Some bits are directly connected to PLC controller inputs and outputs (screw terminal). In our case, we have 6 input lines at address IR000. One bit corresponds to each line, so the first line has the address IR000.0, and the sixth IR000.5. When you obtain a signal at the input, this immediately affects the status of a corresponding bit. There are also words with work bits in this region, and these work bits are used in a program as flags or certain conditional bits.

SR region

Special memory region for control bits and flags. It is intended first and foremost for counters and interrupts. For example, SR250 is memory location which contains an adjustable value, adjusted by potentiometer no.0 (in other words, value of this location can be adjusted manually by turning a potentiometer no.0.

TR region

When you move to a subprogram during program execution, all relevant data is stored in this region up to the return from a subprogram.

HR region

It is of great importance to keep certain information even when supply stops. This part of the memory is battery supported, so even when supply has stopped it will keep all data found therein before supply stopped.

AR region

This is one more region with control bits and flags. This region contains information on PLC status, errors, system time, and the like. Like HR region, this one is also battery supported.

LR region

In case of connection with another PLC, this region is used for exchange of data.

Timer and counter region

This region contains timer and counter values. There are 128 values. Since we will consider examples with timers and counters, we will discus this region more later on.

DM region

Contains data related to setting up communication with a PC computer, and data on errors.

Each region can be broken down to single words and meanings of its bits. In order to keep the clarity of the book, this part is dealt with in Attachments and we will deal with those regions here whose bits are mostly used for writing.

Note:1. IR and LR bits that are not used for their allocated functions can be used as work bits.2. The contents of the HR area, LR area, Counter area, and read/write DM area are backed up by a capacitor. At 25 oC, the capacitor will back up memory for 20 days.3. When accessing a PV, TC numbers are used as word data; when accessing Completing Flags, they are used as bit data.4. Data in DM6144 to DM6655 cannot be overwritten from the program, but they can be changed from a Peripheral Device4.7 Timers and counters

Timers and counters are indispensable in PLC programming. Industry has to number its products, determine a needed action in time, etc. Timing functions is very important, and cycle periods are critical in many processes.

There are two types of timers delay-off and delay-on. First is late with turn off and the other runs late in turning on in relation to a signal that activated timers. Example of a delay-off timer would be staircase lighting. Following its activation, it simply turns off after few minutes.

Each timer has a time basis, or more precisely has several timer basis. Typical values are: 1 second, 0.1 second, and 0,01 second. If programmer has entered .1 as time basis and 50 as a number for delay increase, timer will have a delay of 5 seconds (50 x 0.1 second = 5 seconds).

Timers also have to have value SV set in advance. Value set in advance or ahead of time is a number of increments that timer has to calculate before it changes the output status. Values set in advance can be constants or variables. If a variable is used, timer will use a real time value of the variable to determine a delay. This enables delays to vary depending on the conditions during function. Example is a system that has produced two different products, each requiring different timing during process itself. Product A requires a period of 10 seconds, so number 10 would be assigned to the variable. When product B appears, a variable can change value to what is required by product B.

Typically, timers have two inputs. First is timer enable, or conditional input (when this input is activated, timer will start counting). Second input is a reset input. This input has to be in OFF status in order for a timer to be active, or the whole function would be repeated over again. Some PLC models require this input to be low for a timer to be active, other makers require high status (all of them function in the same way basically). However, if reset line changes status, timer erases accumulated value.

With a PLC controller by Omron there are two types of timers: TIM and TIMH. TIM timer measures in increments of 0.1 seconds. It can measure from 0 to 999.9 seconds with precision of 0.1 seconds more or less.

Quick timer (TIMH) measures in increments of 0.01 seconds. Both timers are "delay-on" timers of a lessening-style. They require assignment of a timer number and a set value (SV). When SV runs out, timer output turns on. Numbers of a timing counter refer to specific address in memory and must not be duplicated (same number can not be used for a timer and a counter).Ladder diagram

Introduction

Programmable controllers are generally programmed in ladder diagram (or "relay diagram") which is nothing but a symbolic representation of electric circuits. Symbols were selected that actually looked similar to schematic symbols of electric devices, and this has made it much easier for electricians to switch to programming PLC controllers. Electrician who has never seen a PLC can understand a ladder diagram.

5.1 Ladder diagram

There are several languages designed for user communication with a PLC, among which ladder diagram is the most popular. Ladder diagram consists of one vertical line found on the left hand side, and lines which branch off to the right. Line on the left is called a "bus bar", and lines that branch off to the right are instruction lines. Conditions which lead to instructions positioned at the right edge of a diagram are stored along instruction lines. Logical combination of these conditions determines when and in what way instruction on the right will execute. Basic elements of a relay diagram can be seen in the following picture.

Most instructions require at least one operand, and often more than one. Operand can be some memory location, one memory location bit, or some numeric value -number. In the example above, operand is bit 0 of memory location IR000. In a case when we wish to proclaim a constant as an operand, designation # is used beneath the numeric writing (for a compiler to know it is a constant and not an address.)

Based on the picture above, one should note that a ladder diagram consists of two basic parts: left section also called conditional, and a right section which has instructions. When a condition is fulfilled, instruction is executed, and that's all!

Picture above represents a example of a ladder diagram where relay is activated in PLC controller when signal appears at input line 00. Vertical line pairs are called conditions. Each condition in a ladder diagram has a value ON or OFF, depending on a bit status assigned to it. In this case, this bit is also physically present as an input line (screw terminal) to a PLC controller. If a key is attached to a corresponding screw terminal, you can change bit status from a logic one status to a logic zero status, and vice versa. Status of logic one is usually designated as "ON", and status of logic zero as "OFF".

Right section of a ladder diagram is an instruction which is executed if left condition is fulfilled. There are several types of instructions that could easily be divided into simple and complex. Example of a simple instruction is activation of some bit in memory location. In the example above, this bit has physical connotation because it is connected with a relay inside a PLC controller. When a CPU activates one of the leading four bits in a word IR010, relay contacts move and connect lines attached to it. In this case, these are the lines connected to a screw terminal marked as 00 and to one of COM screw terminals.

5.2 Normally open and normally closed contacts

Since we frequently meet with concepts "normally open" and "normally closed" in industrial environment, it's important to know them. Both terms apply to words such as contacts, input, output, etc. (all combinations have the same meaning whether we are talking about input, output, contact or something else).

Principle is quite simple, normally open switch won't conduct electricity until it is pressed down, and normally closed switch will conduct electricity until it is pressed. Good examples for both situations are the doorbell and a house alarm.

If a normally closed switch is selected, bell will work continually until someone pushes the switch. By pushing a switch, contacts are opened and the flow of electricity towards the bell is interrupted. Of course, system so designed would not in any case suit the owner of the house. A better choice would certainly be a normally open switch. This way bell wouldn't work until someone pushed the switch button and thus informed of his or her presence at the entrance.

Home alarm system is an example of an application of a normally closed switch. Let's suppose that alarm system is intended for surveillance of the front door to the house. One of the ways to "wire" the house would be to install a normally open switch from each door to the alarm itself (precisely as with a bell switch). Then, if the door was opened, this would close the switch, and an alarm would be activated. This system could work, but there would be some problems with this, too. Let's suppose that switch is not working, that a wire is somehow disconnected, or a switch is broken, etc. (there are many ways in which this system could become dysfunctional). The real trouble is that a homeowner would not know that a system was out of order. A burglar could open the door, a switch would not work, and the alarm would not be activated. Obviously, this isn't a good way to set up this system. System should be set up in such a way so the alarm is activated by a burglar, but also by its own dysfunction, or if any of the components stopped working. (A homeowner would certainly want to know if a system was dysfunctional). Having these things in mind, it is far better to use a switch with normally closed contacts which will detect an unauthorized entrance (opened door interrupts the flow of electricity, and this signal is used to activate a sound signal), or a failure on the system such as a disconnected wire. These considerations are even more important in industrial environment where a failure could cause injury at work. One such example where outputs with normally closed contacts are used is a safety wall with trimming machines. If the wall doors open, switch affects the output with normally closed contacts and interrupts a supply circuit. This stops the machine and prevents an injury.

Concepts normally open and normally closed can apply to sensors as well. Sensors are used to sense the presence of physical objects, measure some dimension or some amount. For instance, one type of sensors can be used to detect presence of a box on an industry transfer belt. Other types can be used to measure physical dimensions such as heat, etc. Still, most sensors are of a switch type. Their output is in status ON or OFF depending on what the sensor "feels". Let's take for instance a sensor made to feel metal when a metal object passes by the sensor. For this purpose, a sensor with a normally open or a normally closed contact at the output could be used. If it were necessary to inform a PLC each time an object passed by the sensor, a sensor with a normally open output should be selected. Sensor output would set off only if a metal object were placed right before the sensor. A sensor would turn off after the object has passed. PLC could then calculate how many times a normally open contact was set off at the sensor output, and would thus know how many metal objects passed by the sensor.

Concepts normally open and normally closed contact ought to be clarified and explained in detail in the example of a PLC controller input and output. The easiest way to explain them is in the example of a relay.

Normally open contacts would represent relay contacts that would perform a connection upon receipt of a signal. Unlike open contacts, with normally closed contacts signal will interrupt a contact, or turn a relay off. Previous picture shows what this looks like in practice. First two relays are defined as normally open , and the other two as normally closed. All relays react to a signal! First relay (00) has a signal and closes its contacts. Second relay (01) does not have a signal and remains opened. Third relay (02) has a signal and opens its contacts considering it is defined as a closed contact. Fourth relay (03) does not have a signal and remains closed because it is so defined.

Concepts "normally open" and "normally closed" can also refer to inputs of a PLC controller. Let's use a key as an example of an input to a PLC controller. Input where a key is connected can be defined as an input with open or closed contacts. If it is defined as an input with normally open contact, pushing a key will set off an instruction found after the condition. In this case it will be an activation of a relay 00.

If input is defined as an input with normally closed contact, pushing the key will interrupt instruction found after the condition. In this case, this will cause deactivation of relay 00 (relay is active until the key is pressed). You can see in picture below how keys are connected, and view the relay diagrams in both cases.

Normally open/closed conditions differ in a ladder diagram by a diagonal line across a symbol. What determines an execution condition for instruction is a bit status marked beneath each condition on instruction line. Normally open condition is ON if its operand bit has ON status, or its status is OFF if that is the status of its operand bit. Normally closed condition is ON when its operand bit is OFF, or it has OFF status when the status of its operand bit is ON.

When programming with a ladder diagram, logical combination of ON and OFF conditions set before the instruction determines the eventual condition under which the instruction will be, or will not be executed. This condition, which can have only ON or OFF values is called instruction execution condition. Operand assigned to any instruction in a relay diagram can be any bit from IR, SR, HR, AR, LR or TC sector. This means that conditions in a relay diagram can be determined by a status of I/O bits, or of flags, operational bits, timers/counters, etc.

5.3 Brief example

Example below represents a basic program. Example consists of one input device and one output device linked to the PLC controller output. Key is an input device, and a bell is an output supplied through a relay 00 contact at the PLC controller output. Input 000.00 represents a condition in executing an instruction over 010.00 bit. Pushing the key sets off a 000.00 bit and satisfies a condition for activation of a 010.00 bit which in turn activates the bell. For correct program function another line of program is needed with END instruction, and this ends the program.

The following picture depicts the connection scheme for this example.

EXAMPLES

Introduction

Programming only related examples make up the first group of examples. They are given as separate small programs that can later be incorporated into larger ones. Second group consists of examples which can be applied to some real problems.

7.1 Self-maintenance

Program allows input to remain at ON status even when the condition that brought it to that status stops. Example in picture below illustrates how use of a key connected to the input IR000.00 changes IR010.01 output status to ON. By letting the key go, output IR010.01 is not reset. This is because IR010.01 output keeps itself at status ON through OR circuit (having IR000.00), and it stays in this status until key at input IR000.01 is pressed. Input IR000.01 is in I connection with the output pin IR010.01 which cancels out a condition, and resets an IR010.01 bit. Example of self-maintenance is quite frequent in specific applications. If a user was connected to IR010.01 output, START and STOP functions could be realized from two keys (without the use of switches). Specifically, input IR000.00 would be a START key, and IR000.01 would be a STOP key.

7.2 Making large time intervals

If it's necessary to make a bigger time interval of 999.9 seconds (9999x0.1s) two linked timers, or a timer and a counter can be used as in this example. Counter is set to count to 2000, and timer is set to 5 seconds which gives a time interval of 10.000 seconds or 2.77 hours. By executing a condition at IR000.00 input, timer begins to count. When it reaches the limit, it sets a flag TIM001 which interrupts the link and simultaneously resets a timer. Once 5 seconds have run out, flag TIM001 changes its status to ON and executes a condition at the counter input CNT002. When a counter numbers 2000 such changes in timer flag status, TIM001 sets its flag CNT002 which in turn executes a condition for IR010.00 to change status to ON. Time that has elapsed from the change of IR000.00 input status to ON and a change of IR010.00 input status to ON comes to 10.000 seconds.

Ladder Diagram:

7.3 Delays of ON and OFF status

Example shows how to make output (IR010.00) delay as opposed to ?(in relation to ?? unclear meaning) input (IR000.00). By executing a condition at IR000.00 input, timer TIM000 begins counting a set value 10 in steps of 0.1 seconds each. After one second has elapsed, it set its flag TIM000 which is a condition in changing output status IR010.00 to ON. Thus we accomplish a delay of one second between ON status of IR000.00 input and ON status IR010.00 input. By changing IR010.00 output status to ON, half of the condition for activation of the second timer is executed. Second half of the timer is executed when IR000.00 input changes status to OFF (normally closed contact). Timer TIM001 sets its flag TIM001 after one second, and interrupts a condition for keeping an output in ON status.

Ladder Diagram:

7.4 Counter over 9999

If you need to count over 9999 (maximum value for a counter), you can use two connected timers. First counter counts up to certain value, and the other one counts flag status changes of the first counter. Thus you get the possibility of counting up to a value which is a result of set values of the first and second counter. In an example at the bottom, first counter counts up to 1000, and second up to 20 which allows you to count to 20000. By executing a condition at IR000.00 input (line whose changes are followed is brought to it), first counter decreases its value by one. This is repeated until counter arrives at zero when it sets its flag CNT001 and simultaneously resets itself (is made ready for a new cycle of counting from 1000 to 0). Each setting of CNT001 influences the other counter which sets its flag after twenty settings of the first counter's flag. By setting CNT002 flag of the second counter, a condition is executed for an IR010.00 output to be activated and to stay in that status through self-maintenance.

Ladder Diagram:

Same effect can be achieved with a modified program below. First change is that there is a "switch" for the whole program, and this is IR000.00 input (program can accomplish its function only while this switch is active). Second change is that the line whose status is followed is brought to IR000.01 input. The rest is the same as in the previous version of the program. Counter CNT002 counts status changes of the CNT001 counter flag. When it numbers them, it changes the status of its flag CNT002 which executes the condition for status change of IR010.00 output. This changes IR010.00 output status after 20000 changes of input IR000.01.

Ladder Diagram:

7.5 Alternate ON-OFF output

Example makes a certain number of impulses of desired duration at PLC controller IR010.00 output. Number of impulses is given in instruction of the counter (here it is a constant #0010 or ten impulses) impulse duration in two timer instructions. First timer defines duration of ON status, and second one duration of OFF status of IR010.00 output bit. In the example these two durations are the same, but through assigning them different parameters they can differ so that duration of ON status can be different from duration of OFF status.

Program starts executing a condition at IR000.00 bit. Since a normally closed contact which refers to counter flag (that isn't set ) is linked with this IR000.00 bit in "I" circuit, this status of IR200.00 bit will change to ON. Bit IR200.00 keeps its status through self-maintenance until counter flag is not set and a condition interrupted.

When an IR200.00 bit is set, timers TIM001 and TIM002 start counting a set interval number at 0.1 s ( in the example, this number is 10 for the first timer, or 20 for the second timer, and this sets the period of one or two seconds). With both timers, a normally closed contact which refers to TIM002 timer flag is connected with IR200.00 bit. When this flag is set which happens every two seconds, both timers are reset. Timer TIM002 resets timer TIM001 and itself, and this starts a new cycle.

At the start of a program, IR010.00 output bit changes status to ON and stays in this status until TIM001 flag changes status to ON (after one second). By changing TIM001 flag status to ON, condition is broken (because it is represented as normally closed contact) and IR010.00 bit changes status to OFF.

IR010.00 output status changes to ON again when time has run out on TIM002 timer. This resets TIM001 timer and its flag which in turn executes a condition for status change of the IR010.00 output. Cycle is thus repeated until a counter numbers 10 changes of TIM001 flag status. With the change of status of CNT000 counter flag, a condition for an assisting bit IR200.00 is broken, and program stops working.

Ladder Diagram:

Expanding the number of input/output lines

IntroductionThis appendix is an answer to the question What if more input or output lines are needed ?. Model detailed in the book carries the mark CPM1A-10CDR-A and is taken as an optimal for its price and features. Alternative models with greater number of lines include CPM1A-20CDR-A, CPM1A-30CDR-A or CPM1A-40CDR-A. The last two can be expanded with three additional modules with 20 extra I/O lines each, totaling 100 I/O lines as a maximum (if this is still insufficient, maybe it is time for you to start using some of more powerful PLC controllers).If not even the most powerful model of CPM1A family satisfies your needs, then extra modules with 20 I/O lines are added. This form of connection reaches 100 input/outputs, which is a significant number in industrial proportions.A.1. Differences and similarities

Taking the other model of PLC controller from CPM1A class basically doesnt change a thing! Everything said for one model also applies to the other. Only thing that changes is the number of screw terminal and the number of bits in IR area connected to that screw terminal. If model with 10 I/O lines (model described in the book) has 6 inputs on addresses IR0000 - IR0005, then the 20 I/O lines model will have 12 inputs on addresses IR0000 - IR0011. Expanding itself should not be a problem. After taking off the cover on the right side, there is a connector which is then connected to the expansion module via flat cable. Still, it requires skill when assigning inputs and outputs because expansion increases the cost of the project. All the models and expansions of CPM1A class carry additional marks defining them more precisely.

DescriptionInput pointsOutput pointsPower SupplyModel Number

10 I/O points6 points4 point Relay Output100 to240 VAC, 50/60 HzCPM1A-10CDR-A

24 VDCCPM1A-10CDR-D

Transistor NPN24 VDCCPM1A-l0CDT-D

Transistor PNP24 VDCCPM1A-10CDT1-D

20 I/O points12 points8 points100 to 240 VAC, 50/60 HzCPMlA-20CDR-A

24 VDCCPM1A-20CDR-D

Transistor NPN24 VDCCPM1A-20CDT-D

Transistor PNP24 VDCCPMlA-20CDT1-D

30 I/O points18 points12 points100 to 240 VAC, 50/60 HzCPM1A-30CDR-A

24 VDCCPM1A-30CDR-D

Transistor NPN24 VDCCPM1A-30CDT-D

Transistor PNP24 VDCCPM1A-30CDT1-D

40 I/O points24 points16 points100 to 240 VAC, 50/60 HzCPM1A-40CDR-A

24 VDCCPM1A-40CDR-D

Transistor NPN24 VDCCPM1A-40CDT-D

Transistor PNP24 VDCCPM1A-40CDT1-D

Notice that PLC controllers with 10 and 20 I/O lines do not have an expansion port. Generally speaking, if there is the slightest possibility for expansion in the project, PLC controller with 30 or 40 I/O lines should be used.A.2. Marking the PLC controllerMarking the controller and the expansion module undergoes three criteria. The first is voltage, the second is the type of input/output and the third is number of I/O lines. The picture below is self-explanatory.

A.3. Specific caseIf two 20 I/O lines expansion modules and one analog module are added to 30 I/O lines model, assigned inputs/outputs will have the addresses from the following table.

UnitAssigned input bitsAssigned output bits

1Central processing unit (CPM2A-30CDX-X)IR 00000-IR 00011 and IR 00100-IR 00105IR 01000-IR 01007 and IR 01100-IR 01103

2Unit for I/O expansion (CPM1A-20EDxxx)IR 00200-IR 02011IR 01200-IR 01207

3Analog I/O unit (CPM1A-MAD01)IR 00300-IR 03015 and IR 00400-IR 00415IR 01300-IR 01315

4Unit for I/O expansion (CPM1A-EDxxx)IR 00500-IR 00511IR 01400-IR 01415

Detailed memory map of PLC controller

IntroductionPurpose of this appendix is to explain certain memory areas in detail. As the following tables cover whole memory, there are options left unused in this book. They should be skipped during the first reading, and used later according to needs.B.1 General explanation of memory areasMemory of PLC controller consists of several areas, some of these having predefined functions.

Data areaWord(s)Bit(s)Function

IR areainput areaIR 000 - IR 009 (10 words)IR 00000 - IR 00915 (160 bits)These bits may be assigned to an external I/O connection. Some of these have direct output on screw terminal (for example, IR000.00 - IR000.05 and IR010.00 - IR010.03 with CPM1A model)

output areaIR 010 - IR 019 (10 words)IR 01000 - IR 01915 (160 bits)

working areaIR 200 - IR 231 (32 words)IR 20000 - IR 23115 (512 bits)Working bits that can be used freely in the program. They are commonly used as swap bits

SR areaSR 232 - SR 255 (24 words)SR23200 - SR25515 (384 bits)Special functions, such as flags and control bits

TR area---TR 0 - TR 7 (8 bits)Temporary storage of ON/OFF states when jump takes place

HR areaHR 00 - HR 19 (20 words)HR0000 - HR1915 (320 bits)Data storage; these keep their states when power is off

AR areaAR 00 - AR 15 (16 words)AR0000 - AR1515 (256 bits)Special functions, such as flags and control bits

LR areaLR 00 - LR 15 (16 words)LR0000 - LR1515 (256 bits)1:1 connection with another PC

Timer/counter areaTC 000 - TC 127 (timer/counter numbers)Same numbers are used for both timers and counters

DM areaRead/writeDM 0000 - DM 0999 and DM 1022 - DM 1023 (1002 words)---Data of DM area may be accessed only in word form. Words keep their contents after the power is off

Error writingDM 1000 - DM 1021 (22 words)---Part of the memory for storing the time and code of error that occurred. When not used for this purpose, they can be used as regular DM words for reading and writing. They cannot be changed from within the program

Read onlyDM 6144 - DM 6599 (456 words)---

PC setupDM 6600 - DM 6655 (56 words)---Storing various parameters for controlling the PC

Note:1. IR and LR bits, when not used to their purpose, may be used as working bits.2. Contents of HR area, LR area, counter and DM area for reading/writing is stored within backup condenser. On 25C, condenser keeps the memory contents for up to 20 days.3. When accessing the current value of PV, TC numbers used for data have the form of word. When accessing the Completing flags, they are used as data bits. 4. Data from DM6144 to DM6655 must not be changed from within the program, but can be changed by peripheral device.B.2. SR memory areaIR area doesnt have predefined memory locations, but is meant for general use in the program. Of all the locations this memory area consists of, only those directly connected to PLC controller input/output lines are of interest for this appendix.

IR area can be divided into 3 parts:

1. Input area is located from word IR000 to IR009, totaling 160 bits. Most important of these are in the word IR000 because they are directly connected to screw terminal of PLC controller. Input IR000.01 is directly connected to screw terminal marked with 01 on the casing of the PLC controller.

2. Output area is located from word IR010 to IR019, totaling 160 bits. Most important of these are in the word IR010 because they are directly connected to screw terminal of PLC controller. Output IR000.00 is directly connected to screw terminal marked with 00 on the casing of the PLC controller.

3. Working area is located from word IR200 to IR231 totaling 512 bits for general use.

As IR memory area does not have predefined memory locations, more detailed explanations are not necessary.

B.3. IR memory areaUnlike IR area, SR area does have predefined memory locations. These bits are usually tied to the PLC controller work or contain current and set values of different functions. Purpose of specific memory locations of SR area is explained in the following table:

WordsBitsFunction

SR 232 - SR 23500 - 15Input area for macro functions. Contains input operands for MCRO(99) (may be used for working bits, when MCRO(99) is not used)

SR 236 - SR 23900 - 15Output area for macro functions. Contains output operands for MCRO(99) (may be used for working bits, when MCRO(99) is not used)

SR 24000 - 15Contains set value SV, when input interrupt 0 is used in counter mode (4 hexadecimal digits) (may be used for working bits, when input interrupt 0 is not used in counter mode)

SR 24100 - 15Contains set value SV, when input interrupt 1 is used in counter mode (4 hexadecimal digits) (may be used for working bits, when input interrupt 1 is not used in counter mode)

SR 24200 - 15Contains set value SV, when input interrupt 2 is used in counter mode (4 hexadecimal digits) (may be used for working bits, when input interrupt 2 is not used in counter mode)

SR 24300 - 15Contains set value SV, when input interrupt 3 is used in counter mode (4 hexadecimal digits) (may be used for working bits, when input interrupt 3 is not used in counter mode)

SR 24400 - 15Contains current value (PV-1), when input interrupt 0 is used in counter mode (4 hexadecimal digits)

SR 24500 - 15Contains current value (PV-1), when input interrupt 1 is used in counter mode (4 hexadecimal digits)

SR 24600 - 15Contains current value (PV-1), when input interrupt 2 is used in counter mode (4 hexadecimal digits)

SR 24700 - 15Contains current value (PV-1), when input interrupt 3 is used in counter mode (4 hexadecimal digits)

SR 248, SR 24900 - 15Contains current value PV of the high-speed counter (may be used for working bits, when high-speed counter is not used)

SR 25000 - 15Analog setting of value 0. Keeps 4 digit BCD value (0000 - 0200) set via analog potentiometer on the PLC controller casing.

SR 25100 - 15Analog setting of value 1. Keeps 4 digit BCD value (0000 - 0200) set via analog potentiometer on the PLC controller casing.

SR 25200Reset of the high-speed counter

01 - 07Not used

08Peripheral port. Switches on for the reset of the peripheral port (this doesn't apply to a case when peripheral device is connected). Bit automatically changes state to OFF after the reset

09Not used

10PLC Setup Reset Bit. When on, it initializes PC setup (DM6600-DM6655). It automatically goes to OFF after the reset. This applies only if the PC is in PROGRAM mode

11Forced Status Hold Bit.OFF: bits used in the operation of forced set/reset are cleared when changing from PROGRAM to MONITOR mode. ON: bits used in the operation of forced set/reset keep their states when changing from PROGRAM to MONITOR mode.

12I/O Hold bit. OFF: IR and LR bits are reset when starting or ending an operation. ON: IR and LR bits keep their states when starting or ending an operation.

13Not used

14Error Log Reset