Introduction Practical PLC (Programmable Logic Controller) Programming

Textbook, 2017

112 Pages, Grade: a


Table of Contents

Introduction PLC And Automation
1.1 Introduction
1.2 What Is PLC
1.3 History of Programmable Logic Controllers (PLCs):
1.4 Types of PLC
1.5 Functional Description

2 Relay Logic to PLC Inputs/Outputs
2.1 Concept Of Relay Functioning
2.2 Relay Logic
2.3 Plc Inputs And Outputs
2.4 Plc Data Types
2.5 Memory Types
2.6 Address The Input And Output
2.7 Sinking And Sourcing

3 PLC Ladder Logic Programming
3.1 Introduction
3.2 Ladder Programming
3.3 Logic Functions
3.4 Multiple Outputs
3.5 Entering Programs
3.6 Function Block Diagram (Fbd)
3.7 Jump And Call
3.8 Jumps Within Jumps
3.9 Subroutines

4 Event Based Logic Programming
4.1 Introduction
4.2 Latching
4.3 Timer
4.4 Counter
4.5 Sequencer
4.6 Shift Registers
4.7 A Sequencing Application
4.8 Keeping Track Of Items

5 Data Handling and Advance Logic
5.1 Introduction
5.2 Data Handling
5.3 Logical Functions

6 Analog Programming
6.1 Introduction
6.2 Analog (A/D) Input
6.3 Analog (D/A) Output
6.4 Analog Data Handling
6.5 Analog I/O Potential Problems

7 Different PLC Programming Languages
7.1 Introduction
7.2 Instruction List Programming
7.3structured Text Programming
7.4 Ladder Diagram (Ld)
7.5 Function Block Programming
7.6 Sequential Function Charts


It gives a great pleasure to present this book on “Introduction to Practical PLC Programming”. This book has been written for the first course in “PLC Programming” especially for beginner learner of automation technology. This book covers introduction of programmable logic controllers with basic to advance ladder programming techniques. The main objective of this book is to bridge the gap between theory and practical implementation of PLC information and knowledge.

In this book, you will get an overview of how relay logic can be converted into PLC logic. There also lots of examples, tables, and ladder diagrams to help and explain the topics.

I would like to express my special thanks to my guide Dr. D P Vakharia to always motivate me for industrial problem solving exercise. Also, I would like to thanks my parents, wife for continue support me.



A Programmable Logic Controller (PLC) is a specialized industrial computer control system used to replace banks of electromagnetic relays in industrial process control via continuously monitoring the state of input devices and makes decisions based upon custom program to control the state of output devices. The PLC is also known as a programmable controller (PC). The tile "PC" for programmable controller could be confused in common usage with "PC" used to mean personal computer. To avoid this confusion, it is generally referred as programmable controller or programmable logic controller or PLC.

The programmable logic controller is like a heavy-duty computer system designed for machine control. Like a general-purpose computer, the PLC is based on digital logic and can be field-programmed. The programming language is a bit different because the purpose of the PLC is to control machines. The PLC is used to time and sequence functions that might be required in assembly lines, robots, and chemical processing. It is designed to deal with the harsh conditions of the industrial environment. Some of the physical environment problems could include vibration and shock, dirt and vapors, and temperature extremes. The PLC commonly has to interface with a wide variety of both input and output devices. Some input devices include limit and pressure switches, temperature and optical sensors, and analog- to digital converters (ADCs). Some output devices valves, motors and cylinders, and Digital-to Analog converts (DAC).

Before the advent of solid-state logic circuits, logical control systems were designed and built exclusively around electromechanical relays. Relays are far from obsolete in modern design, but have been replaced in many of their former roles as logic-level control devices, relegated most often to those applications demanding high current and/or high voltage switching. Systems and processes requiring "on/off" control abound in modern commerce and industry, but such control systems are rarely built from either electromechanical relays or discrete logic gates. Instead, digital computers fill the need, which may be programmed to do a variety of logical functions.

In the late 1960's an American company named Bedford Associates released a computing device they called the MODICON. As an acronym, it meant Modular Digital Controller, and later became the name of a company division devoted to the design, manufacture, and sale of these special-purpose control computers. Other engineering firms developed their own versions of this device, and it eventually came to be known in non-proprietary terms as a PLC, or Programmable Logic Controller.

The leading PLC Manufacturers are Siemens, Schneider, Allen Bradley, Mitsubishi, Omron, ABB, Panasonic, GE Fanuc, LG, Fatek, Delta etc.

The purpose of a PLC was to directly replace electromechanical relays as logic elements, substituting instead a solid-state digital computer with a stored program, able to emulate the interconnection of many relays to perform certain logical tasks.

A PLC has many "input" terminals, through which it interprets "high" and "low" logical states from sensors and switches. It also has many output terminals, through which it outputs "high" and "low" signals to power lights, solenoids, contactors, small motors, and other devices lending themselves to on/off control. In an effort to make PLC easy to program, their programming language was designed to resemble ladder logic diagrams. Thus, an industrial electrician or electrical engineer accustomed to reading ladder logic schematics would feel comfortable programming a PLC to perform the same control functions.

PLC are industrial computers, and as such their input and output signals are typically 230 volts AC, just like the electromechanical control relays they were designed to replace. Although some PLC has the ability to input and output low-level DC voltage signals of the magnitude used in logic gate circuits, this is the exception and not the rule.


A Programmable Logic Controller (PLC) is an industrial computer control system that continuously monitors the state of input devices and makes decisions based upon a custom program to control the state of output devices.

Almost any production line, machine function, or process can be greatly enhanced using this type of control system. However, the biggest benefit in using a PLC is the ability to change and replicate the operation or process while collecting and communicating vital information.

Another advantage of a PLC system is that it is modular. It can mix and match the different types of Input and Output devices to best suit other industrial applications.

illustration not visible in this excerpt

Figure 1.1: PLC systems with interconnections

According to NEMA (National Electrical Manufacturer Association) “PLC is a digitally operated electronic system, designed especially for the use in industrial environment, which use programmable memory for internal storage of user-oriented instructions for implementing specific function such as logic, sequencing, timing, counting & arithmetic to control, through digital & analog inputs & outputs for various types of machines & processes.”

Both the PLC & its associated peripherals are designed so that they can be easily integrated into an industrial control system & easily used in all intended functions.


1968 : Design of PLCs developed for General Motors Corporation to eliminate costly Scrapping or assembly line relays during model changeovers.

1969 : First PLCs manufactured for automotive industry as electronic equivalents of relays.

1971 : First application of PLCs outside the automotive industry.

1973 : Introduction of "smart" PLCs for arithmetic operations, printer control move, Matrix operations, CRT interface etc.

1974 : Introduction of analog PID (Proportional, integral, derivative) control, which Made possible the accessing of thermocouples, pressure sensors etc.

1975 : First use of PLCs in hierarchical configurations as part of an integrated Manufacturing system.

1977 : Introduction of very small PLCs based on microprocessor technology.

1978 : PLCs gain wide acceptance, sales approach $ 80 million.

1979 : Integration of plant operation through a PLC communication system.

1980 : Introduction of intelligent input and output modules to provide high speed, accurate control in positioning applications.

1981 : Data highways enable users to interconnect many PLCs up to 15000 feet from Each other. More 16-bit PLCs become available. Color graphic CRTs are available from several suppliers.

1982 : Larger PLCs with up to 8192 I/O become available.

1983 : "Third party" peripherals, including graphic CRTs, operator’s interfaces, I/O networks, panel displays, and documentation packages, become available from many sources.


Programmable logic controllers (PLCs) has several types. PLC divided into two types: Based on the size of the module and it can be classified according to its working,

1.4.1 Based on Size

I. Micro PLC or Small PLC: It is the simplest PLC with the Power Supply module, CPU, I / O modules and communication ports in a single chassis. This PLC types are usually limited to a few I / O discrete and can be expanded. There are various micro PLCs are in the market today. The vast majority offer analog I /O. with just about any micro PLC, or for that matter PLC in general, when the application requires the monitoring of various analog signals, a separate module is required for each signal (voltage, current, temperature). Examples of this type are CP1H Omron, Siemens S7-200, Fuji Electric SPB.

II. Medium PLC or Mini: It is PLC which has CPU module, I / O or communication port are separately. Each module is connected by connector or backplane. It has the capacity more than 2000 I / O. Examples of this type are Omron CS1, Siemens S7-300.

III. Large PLC or Rack: This kind of PLC is nearly equal to the medium one but it has large I/O capacity and more able to be connected with the higher control systems.

Examples of this type are CVM1 Omron, Siemens S7-400.

illustration not visible in this excerpt

Figure 1.2: Micro, Mini and Rack type PLC

1.4.2 Classified according to its Output working:

I . Relay based: This type of PLC are used for general purpose application.

II . Transistor based: This type of PLC are used for High speed application.

III . SCR based: This type of plc are used for heavy load switching.


A programmable controller manufactured by any company has several common functional parts. Figure illustrates a generic PLC architecture.

Programming device

Power supply Abbildung in dieser Leseprobe nicht enthalten CPU Abbildung in dieser Leseprobe nicht enthaltenAbbildung in dieser Leseprobe nicht enthalten Memory

illustration not visible in this excerpt

Figure 1.3: Generic PLC architecture

The diagram shows Power Supply, I/O, central processor, memory, and programming and peripheral device subsections. Each is discussed below.

1.5.1 Input System:

Inputs are defined as real-world signals giving the controller real-time status of process variables. These signals can be analog or digital, low or high frequency, maintained or momentary. Typically they are presented to the programmable controller as a varying voltage current or resistance value. Signals from thermocouples (TCs) and resistance temperature detectors (RTDs) are common examples of analog signals. Some flow meters and strain gauges provide variable frequency signals, while pushbuttons, limit switches, or even electromechanically relay contacts are familiar examples of digital, contact closure type signals. One additional type of input signal, the register input, reflects the computer nature of the programmable controller.

Inputs are devices that supply a signal/data to a PLC. Typical examples of inputs are push buttons, switches, and measurement devices. Basically, an input device tells the PLC, "Hey, something’s happening out here…you need to check this out to see how it affects the control program."

illustration not visible in this excerpt

Figure 1.4: common PLC Input devices

A discrete input, also referred to as a digital input, is an input that is either in an ON or OFF condition. Pushbuttons, toggle switches, limit switches, proximity switches, and contact closures are examples of discrete sensors which are connected to the PLC discrete or digital inputs. In the ON condition a discrete input may be referred to as logic 1 or logic high. In the OFF condition a discrete input may be referred to as logic 0 or a logic low.

illustration not visible in this excerpt

Figure 1.5: Discrete inputs

An analog input is a continuous, variable signal. Typical analog inputs may vary from 0 to 20 milliamps, 4 to 20 milliamps, or 0 to 10 volts. In the following example, a level transmitter monitors the level of liquid in a tank. Depending on the level transmitter, the signal to the PLC can either increase or decrease as the level increases or decreases.

Level Transmitter

illustration not visible in this excerpt

Figure 1.6: Analog inputs

1.5.2. Outputs:

There are three common categories of outputs: Discrete, Register, and Analog. Discrete outputs can be pilot lights, solenoid valves, or annunciator Windows (lamp box). Register output can drive panel meters or displays; analog outputs can drive signals to variable speed drives or to I/P (current to air) converters and thus to control valves.

Outputs are devices that await a signal/data from the PLC to perform their control functions. Lights, horns, motors, and valves are all good examples of output devices. These devices stay put, minding their own business, until the PLC says, "You need to turn on now" or "You’d better open up your valve a little more," etc.

illustration not visible in this excerpt

Figure 1.7: common PLC outputs devices

A discrete output is an output that is either in an ON or OFF condition.

Solenoids, contactor coils, and lamps are examples of actuator devices connected to discrete outputs. Discrete outputs may also be referred to as digital outputs. In the following example, a lamp can be turned on or off by the PLC output it is connected to.

illustration not visible in this excerpt

Figure 1.8: Discrete outputs

An analog output is a continuous, variable signal. The output may be as simple as a 0-10 VDC level that drives an analog meter. Examples of analog meter outputs are speed, weight, and temperature. The output signal may also be used on more complex applications such as a current-to-pneumatic transducer that controls an air-operated flow-control valve.

illustration not visible in this excerpt

Figure 1.9: Analog outputs

The PLC program is executed as part of a repetitive process referred to as a scan. A PLC scan starts with the CPU reading the status of inputs. The application program is executed using the status of the inputs. Once the program is completed, the CPU performs internal diagnostics and communication tasks. The scan cycle ends by updating the outputs, and then starts over. The cycle time depends on the size of the program, the number of I/Os, and the amount of communication required.

1.5.3. Control Processor Unit (Real Time):

The central processor unit (CPU), or central control unit (CCU), performs the tasks necessary to fulfill the PLC function. Among these tasks are scanning, I/O bus traffic control, program execution, peripheral and external device communications, special function or data handling execution (enhancements), and self-diagnostics.

One common way of rating how a PLC performs these tasks is its scan time. Scan time is roughly defined as the time it takes for the programmable controller to interrogate the input devices, execute the application program, and provide updated signals to the output devices. Scan times can vary from 0.1 milliseconds per 1K (1024) words of logic to more than 50 milliseconds per 1 K of logic. Therefore, when selecting a programmable controller other performance factors must be considered. The user should take into account the application as well as the speed of the controller.

1.5.4. Memory Unit:

The memory unit of the PLC serves several functions. It is the library where the application program is stored. It is also where the PLC's executive is stored. An executive program functions as the operating system of the PLC. It is the program that interprets, manages, and executes the user's application program. Finally, the memory unit is the part of the programmable controller where process data from the input modules and control data for the output modules are temporarily stored as data tables. Typically, an image of these data tables is used by the CPU and, when appropriate, sent to the output modules. Memory can be volatile or nonvolatile. Volatile memory is erased if power is removed. Obviously, this is undesirable, and most units with volatile memory provide battery back up to ensure that there will be no loss of program in the event of a power outage. Nonvolatile memory does not change state on loss of power and is used in cases in which extended power outages or long transportation time to job site (after program entry) are anticipated. The basic programmable controller memory element is the word. A word is a collection of 4, 8, 16, or 32 bits that is used to transfer data about the programmable controller. As word length increase more information can be stored in a memory location.

1.5.5. Programmer Units:

The programmer unit provides an interface between the PLC and the user During Program development, start-up, and troubleshooting. The instruction to be performed during each scan are coded and inserted into memory with the programmer.

Programmers vary from small hand-held units the size of a large calculator to desktop stand-alone intelligent CRT-based units. These units come complete with documentation, reproduction, I/O status, and on-line and off-line programming ability. Many PLC manufactures now offer controller models that can use a personal computer as the programming tool. Under these circumstances, the manufacture will sell a program for the personal computer that usually allows the computer that module installed in the programmable controller.

Programming units are the liaison between what the PLC understands (words) and what the engineer desires to occur during the control sequence. Some programmers have the ability to store programs on other media, including cassette tapes and floppy disks. Another desirable feature is automatic documentation of the existing program. This is accomplished by a printer attached to the programmer. With off-line programming, the user can write a control program on the programming unit, then take the unit to the PLC in the field and load the memory with the new program, all without removing the PLC.

Selection of these features depends on user requirements and budget. On-line programming allows cautions modification of the program while the PLC is controlling the process or the machine.


illustration not visible in this excerpt

Figure 1.11: Architecture of PLC

PLC inputs must convert a variety of logic levels to the 5Vdc logic levels used on the data bus. This can be done with circuits similar to those shown below. Basically, the circuits condition the input to drive an opto coupler. This electrically isolates the external electrical circuitry from the internal circuitry. Other circuit components are used to guard against excess or reversed voltage polarity.

PLC outputs must convert the 5Vdc logic levels on the PLC data bus to external voltage levels. This can be done with circuits similar to those shown below. Basically, the circuits use an Opto-coupler to switch external circuitry. This electrically isolates the external electrical circuitry from the internal circuitry. Other circuit components are used to guard against excess or reversed voltage polarity.



2.1.1 What is a relay?

The most of the high end industrial application devices have relays for their effective working. A relay is an electromagnetic switch operated by a relatively small electric current that can turn on or off a much larger electric current. Relays consist of an electromagnet and also a set of contacts. The heart of a relay is an electromagnet (a coil of wire that becomes a temporary magnet when electricity flows through it). Relay works as electric lever and switch it on with a tiny current and it switches on ("leverages") another appliance using a much bigger current. The switching mechanism is carried out with the help of the electromagnet. There are also other operating principles for its working. But they differ according to their applications.

illustration not visible in this excerpt

Figure 2.1 : Relay and its construction

2.1.2 Why is a relay used?

The main operation of a relay comes in places where only a low-power signal can be used to control a circuit. It is also used in places where only one signal can be used to control a lot of circuits. The application of relays started during the invention of telephones. They played an important role in switching calls in telephone exchanges.

They were also used in long distance telegraphy. They were used to switch the signal coming from one source to another destination. After the invention of computers, they were also used to perform Boolean and other logical operations. The high-end applications of relays require high power to be driven by electric motors and so on. Such relays are called contactors.

As the main purpose of the PLC is to reduce real world relays we convert its element in to 3 basic symbols for develop understanding over relays for CPU.

A relay is an electromagnetically actuated switch. When a voltage is applied to the solenoid coil, an electromagnetic field results. This causes the armature to be attracted to the coil core. The armature actuates the relay contacts, either closing or opening them, depending on a design. A return spring returns the armature to its initial position when current to the coil is interrupted.

illustration not visible in this excerpt

Figure 2.2 : Relay coil symbolic presentation


There are several kinds of logic that are made with the help of relay. This smaller logic is the base of all kind of functioning performed in industries. As we get command over these types of logics we can handle even complex functionality of plant or process. The panel made by the relay is known as relay logic panel.


2.3.1 Sensor (Connected to PLC Input)

A Sensor is a device that measures a physical quantity and converts it into a signal which can be read by an observer or by an instrument. For example, a mercury-in glass thermometer converts the measured temperature into expansion and contraction of a liquid which can be read on a calibrated glass tube. A thermocouple converts temperature to an output voltage which can be read by a voltmeter. For accuracy, most sensors are calibrated against known standards. Sensor are two types Digital Sensor: Digital Sensor have two unique voltage associated them to represent the two unique digital states of 0 to 1. These voltages are commonly OV to 24V but there are many also other. Ex. IR sensor, Proximity sensor, Hall sensor, PIR Sensor Analog Sensor: Analog sensor are sensor that vary with respect to time. Ex. Level sensor, Flow sensor, Temperature Sensor, Speed sensor.

Need for Sensors are omnipresent. They embedded in our bodies’ automobiles, airplane, cellular telephone, radio, chemical plant, industrial plant and countless other application.

2.3.2 Actuator (Connected to PLC Output)

An Actuator is a mechanical device for moving or controlling a mechanism or System. It is operated by a source of energy, usually in the form of an electric current, hydraulic fluid pressure or pneumatic pressure, and converts that energy into some kind of motion. Ex. Motor, Solenoid valve, seven segments Display, Contactor, Relay, and Buzzer.

2.3.3 Difference between Actuator and Sensor

A sensor controls the variable for example temperature and pressure and transfers a signal to indicator or transmitter. The actuator is a machine which knocks a valve or other machine in accordance with the control signal transferred to the transducer. The transducer generally transforms the control signal to a relative air signal which works the actuator with a great diaphragm opposite a spring.

The mainly common actuator is an actuator of electro-servo or an actuator of hydraulic. These are actuators of linear that transfer a piston rod to a place force and stroke. It is utilized to pull and push at a force and fixed length (stroke). The actuator can be utilized to transfer controls through variable geometry for example arcs used in conjunction with cranks and rods.

The Actuator of Hydraulic has an internal piston to the housing. The pressure of hydraulic is docked on one end and pushes the piston to stir to the opposite end, which forces the rod to enlarge it. Reversing the pressure of hydraulic will cause the rod to knock back to origin position. The force that is existing is similar to the pressure of hydraulic times the piston area.

A sensor or detectors is a tool that measures a physical quantity and transforms it into a signal which can be interpreted by a spectator or by an device. Sensors are utilized in everyday items for example touch-sensitive buttons of elevator and lamps which brighten or dim by contacting the base. There are also numerous applications for sensors of which mainly people are not aware. The appliances consist of machines, cars, aerospace, manufacturing, robotics and medicine.


There are 4 kinds of Data Types supported by most of the PLCs, which are as follows:

Bit (0,1)

Byte (combination of 8bits)

Word (combination of 16bits) = 2B

Double Word (combination of 32bits) = 2W

Table 2.1: Types of data supported by PLC

illustration not visible in this excerpt


There are different memory locations, which is represented by memory types abbreviations. The general the memory types are tabulated below.

Table 2.2: General memory locations in PLCs

illustration not visible in this excerpt


illustration not visible in this excerpt

Figure 2.3: Addressing of input and output memory


One of the most often misunderstood notions in control engineering is the concept of the Sinking and Sourcing relationship between I/O devices. This document is meant to give a solid understanding of these concepts, and clear up the definition issues of Sinking (NPN), and Sourcing (PNP), from both a technical and terminology perspective. “Sinking” and “Sourcing” terms are very important in connecting a PLC correctly with external environment. These terms are applied only for DC modules.

In general, sinking (NPN) and Sourcing (PNP) are terms that define the control of direct current flow in a load. They are only pertinent with DC components and should not be associated with AC control structures. Devices like relay outputs, reed switches, etc, are typically not affected since they are not current direction dependent (unless they have internal polarity sensitive devices like LEDs or unidirectional spike suppressors.

From an electro-pneumatic control perspective, it is important to understand this concept because it dictates which solenoid valve type (sinking or sourcing) is required for proper operation with a specific (sinking or sourcing) output module. The same issues also apply for inputs and sensor devices.

The following is a detailed explanation of these concepts that, in short, dictate:

“Sinking (NPN) provides a path to 0 VDC (-DC)”

“Sourcing (PNP) provides a path to +24 VDC (+DC)”

illustration not visible in this excerpt

Figure 2.4: circuit for sinking and sourcing


- Wire all I/O points with a shared common as either sinking or sourcing.
- Do not use an AC Power Supply on a DC sink/source I/O point.

illustration not visible in this excerpt

Figure 2.5 : NPN sinking and PNP sourcing circuit


Sinking (NPN) Output: Are outputs that “Sink” or “pull” current through the load.In this case the common connection to the load is the 24 VDC (+DC) line. Sinking output modules require the load to be energized by a current, which flows from +24 VDC (+DC), through the load, through the NPN Output Switch Device to the 0 VDC (-DC) line. Below is a representation of the circuit connection.

illustration not visible in this excerpt

Figure 2.6: NPN sinking current flow diagram


Excerpt out of 112 pages


Introduction Practical PLC (Programmable Logic Controller) Programming
Catalog Number
ISBN (eBook)
ISBN (Book)
File size
2634 KB
introduction, practical, programmable, logic, controller, programming
Quote paper
Dr. Dilip Patel (Author), 2017, Introduction Practical PLC (Programmable Logic Controller) Programming, Munich, GRIN Verlag,


  • No comments yet.
Look inside the ebook
Title: Introduction Practical PLC (Programmable Logic Controller) Programming

Upload papers

Your term paper / thesis:

- Publication as eBook and book
- High royalties for the sales
- Completely free - with ISBN
- It only takes five minutes
- Every paper finds readers

Publish now - it's free