0% found this document useful (0 votes)
19 views24 pages

PLC Programming with Sequential Function Charts

This document serves as a comprehensive guide to PLC programming, focusing on Sequential Function Charts (SFC) and ladder logic. It covers the basics of PLCs, including their architecture, input/output functions, and programming techniques, while also providing practical examples and exercises. The book emphasizes a generic programming style to facilitate learning across different PLC models and includes the use of TriLogi software for hands-on practice.

Uploaded by

Yaser Hoseny
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views24 pages

PLC Programming with Sequential Function Charts

This document serves as a comprehensive guide to PLC programming, focusing on Sequential Function Charts (SFC) and ladder logic. It covers the basics of PLCs, including their architecture, input/output functions, and programming techniques, while also providing practical examples and exercises. The book emphasizes a generic programming style to facilitate learning across different PLC models and includes the use of TriLogi software for hands-on practice.

Uploaded by

Yaser Hoseny
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

3.3 Evolution of the Sequential Function Chart....................

32

3.4 Programming using the Sequential Function Chart.......33

3.5 Entering the SFC program into the PLC.........................35

3.6 Modifying an SFC Program...............................................43

3.7 Use of Timers and Counters in SFC Programming.........44

Questions and Exercises......................................................51

4. Selective Branching..........................................................................60

4.1 Introduction..........................................................................60

Questions and Exercises.......................................................79

5. Parallel Branching.............................................................................89

5.1 Introduction............................................................................89

5.2 Parallel Branching and the SF chart....................................89

Appendix A: Using the TriLogi software........................................A1


Introduction
I have been teaching PLC programming for fifteen years and the question that
I hear most often from students is “Can you recommend a book on this?” In response
I have trotted out the titles of various standard text books but I have never come
across a book that really develops the skill of PLC programming instead of telling the
reader what PLCs are all about. I have finally decided to fill this gap in the market
myself.

“What sort of PLCs do you use?” is another popular question. It implies that
familiarity with one make and model of PLC will leave the programmer struggling
when asked to use a different type. I deliberately teach a generic style of
programming that allows the learner to switch between types of PLC as easily as
between different makes of electronic calculator. Every skill needs practice however
and my thanks are due to TriLogi for permission to use their excellent PLC simulator
software throughout this book. The students can load the software onto a computer
and practice the examples and exercises provided.

The third problem that authors have failed to address is the variety of
programming languages available. Ladder logic is by far the most popular
programming language in use because of its resemblance to hard-wire control
diagrams. On its own, however it is unsuitable for complex programs. As the
automation task grows so the ladder program expands organically, until only the
original programmer can find his way through the tangle of inputs and outputs, relays
and function blocks.

This problem has been solved by the use of Sequential Function Chart
(GRAFCET) methods but the obvious popularity of ladder logic persists. The solution
is to plan the program using a sequential function chart and then to enter it into the
PLC using ladder logic. In this way program is highly structured, standardised and
easy to debug and modify, while the familiarity of ladder logic is preserved.

The first two chapters of the book are used for programming basics. The
remainder concentrates on the control of automation sequences commonly found in
industry.

The examples used in the book have all been thoroughly tested and their
suitability for use in the classroom and in industry established.

1
Chapter 1
PLC Basics

1.1 Function of a PLC

A PLC is a microprocessor-based controller with multiple inputs and outputs.


It uses a programmable memory to store instructions and carry out functions to
control machines and processes.

The PLC performs the logic functions of relays, timers, counters and
sequencers. It has the following advantages:

Low cost
Reliability
Reprogramability

Program

Inputs Outputs

PLC

Fig 1.1 A programmable logic controller

1.2 Inputs and Outputs

The PLC inputs give it information about the machine or process that it is
controlling. These are typically switches and sensors. The switches are connected to
an input module that provides the interface between the switches or sensors and the
PLC.

Input module circuits have opto-isolators to protect the internal PLC


circuitry from damage.

LED Photo
transistor

Fig 1.2 An Opto-Isolator


2
The PLC outputs are connected directly or indirectly (e.g. through a relay) to
actuator controls. Examples include solenoids on directional control valves, motors,
motor contactors, alarms and warning lights.

There are three main types of output module:

Relay (volt-free): The signal from the PLC operates a relay within the output
module connecting the control voltage to the output port and hence to the actuator.

Internal
relay contact

Common Output
port Port

Control
Voltage (+) Solenoid

Fig 1.3 PLC Relay Output

Transistor: A transistor is used to switch on the output. This is faster than a


relay output but is only suitable for low power direct current applications.

Triac: This solid state device is used for switching alternating current
devices. It requires some form of over current protection.

3
1.3 PLC Architecture and Wiring Diagrams

Fig 1.4 PLC Connections

S1 S2 S3

X1 X2 X3 X4

Y1 Y2 Y3

Fig 1.5 PLC wiring diagram

Fig 1.4 shows a pictorial view of the PLC with its connections. In practice we work
with a simplified diagram as shown in Fig 1.5.

4
1.4 Network Protocols

The wiring diagram in Fig 1.5 shows the inputs and outputs connected directly
(hard wired) to the PLC. The devices shown are on/off or digital in nature but the
signal to the PLC is analog. Many commonly used devices conform to a 4-20 mA
standard whereby 4mA and 20mA form respectively the minimum and maximum
values of an analog signal.

With analog devices, a separate cable needs to be run between the end device
and the control system because only a single analog signal can be represented on the
circuit. The 4-20 mA standard is slowly being replaced by network or fieldbus
communications. Fieldbus is a multi-drop digital two-way communication link
between intelligent devices. Fieldbus allows the connection of a number of sensors all
located in the same area to the same cable. Fieldbus comes in many varieties
depending on the manufacturer and application. Examples include ASibus, Profibus,
Devicenet and Modbus.

A more recent trend is the development of Industrial Ethernet which has the
capacity to transport large quantities of data not only for process control but also to
integrate the process with management information systems.

This book concentrates on PLC programming and while the sample wiring
diagrams are of the type shown in Fig 1.5 the programs are designed to receive data
from inputs and to send data to outputs regardless of the network system being used.

Questions
1.
Switches, proximity devices and sensors are generally used in what way in a plc
application?

Answer: a. Relays
b. Software elements
c. Inputs
d. Outputs

5
2.

Fig 1.6

In the diagram Fig 1.6 of a plc.


Why would it be necessary to connect a PC?

Answer: a. To read the inputs and set the outputs.


b. To store the output values
c. To edit the plc program.
d. To store the input values.

3.
Which option below best describes the action of an opto-coupler?

Answer: a. It breaks the contact when there is excess current.


b. It breaks the contact when there is excess voltage.
c. It transmits the input signal using fibre optics.
d. It isolates the plc from the input voltage

6
4.

Fig 1.7

Study the diagram Fig 1.7 and pick the correct statement about it.

Answer: a. When the power is switched on to the plc all the n/o relay contacts
shown close.
b. The 24 V supply shown is used to power the plc itself.
c. The plc energises an output by closing the relevant relay contact.
d. When the plc outputs are energised they are all latched on by the relay
contacts shown

5.
"This type of plc output is solid-state and is used for switching alternating current."

The description above best describes what type of switch?

Answer: a. triac
b. push button
c. transistor
d. relay

7
Chapter 2
Ladder Programming

2.1 Conditional Logic

The PLC scans its inputs and, depending on the program, switches on or off
various combinations of outputs. The logic state of the output depends on the input
conditions and so the term conditional logic is used.

A simple example of conditional logic could be stated as follows:

“A machine switches on if either of two start switches are closed and all of
three stop switches are closed.”

The conditions could be realised by a hard wire solution as shown in Fig 2.1.
+V

. Start 1 Start 2

Stop 1

Stop 2

Stop 3

0V
Machine
relay

Fig 2.1 Hard-Wire Conditional Logic Example

The two start switches are connected in parallel. Current will flow if one or
the other or both are closed. The start switches are normally open. This means that the
contacts are apart and no current flows when the switches are in their normal (or
unoperated or rest) state.

The three stop switches are connected in series. Current can only flow if the
first and the second and the third are closed. The stop switches are normally closed.
This means that the contacts are connected and current can flow when the switches
are in their normal state.

8
The relay is a switch with multiple contacts that is operated when its coil is
energised. The contacts are usually capable of carrying a larger current than push-
button or limit switches. Large relays for motor starting are called contactors. The
schematic diagram for a typical relay is shown in Fig 2.2.

contacts

coil

n/o n/c
Fig 2.2 Relay
2.2 Ladder Diagrams

To realise the conditional logic statement from section 2.1 using ladder logic we
connect the switches to a PLC as shown in Fig 2.3.

Start 1 Start 2 Stop 1 Stop 2 Stop 3

X1 X2 X3 X4 X5

Y1

Machine Relay

Fig 2.3 PLC Wiring Diagram

9
To avoid later confusion regarding the concept of normally open (n/o) and
normally closed (n/c) it is worth looking again at Fig 2.3 and remembering that the plc
scans each input and asks “Is it on or is it off?” The five switches shown are external
devices and the PLC knows nothing about them. As far as the PLC is concerned, at
the moment, inputs X1 and X2 are off and X3, X4 and X5 are on.

I have written the ladder logic using the TriLogi software. (For details of
entering program elements see the Appendix)

Fig 2.4 PLC Ladder Diagram

It can be seen from the Fig 2.3 and Fig 2.4 that the output machine will not be
energised until one of the inputs Start 1 or Start 2 is switched [Link] any of the
three Stop switches will turn off the input and so de-energise the output. It is normal
practice to use normally closed push-button switches for stop buttons so that a failure
of control voltage supply has the same effect as the pressing of the stop button.

2.3 Normally closed contacts

Fig 2.5 Normally closed contact.

The contact Start 1 in Fig 2.5 will be closed when the input is switched off and
so the output Machine will be switched on. Switching on the input opens the contact
and switches the output off. Remember that the nature (n/o or n/c) of the external
switch that turns the input on, has no effect on the ladder logic.

10
2.4 Outputs and latches
Output states (on or off) can be used in programs as conditions for other actions.
Fig 2.6 is the wiring diagram for the program shown in Fig 2.7.

S1 S2

X1 X2

Y1 Y2 Y3

DCV Green Red light


light

Fig 2.6

Fig 2.7

Switching on the input S1 switches on the output DCV which in turn switches on the
red light. When the output DCV is off the green light is on.

11
Example 2.1

Write a PLC program to implement the conditional logic statements (a), (b)
and (c) below.

(a) A PLC output is to switch on if any of three inputs is switched on.


(b) A PLC output is to switch on if any one of three inputs is switched on but
not two or more.
(c) A PLC output is to switch on if any two outputs are switched on, but not the
third.
Solution
(a)

Fig 2.8
(b)

Fig 2.9
This program can be read:
“The output switches on if Input 1 is on AND the other two are off, OR input 2 is on
AND the other two are off, OR input three is on AND the other two are off.”

( c)

Fig 2.10
This program is similar to (b) above.

12
The push button and limit switches most commonly used in industrial
automation are the momentary contact type. A spring action reverts the switch to the
normal state as soon as the button or roller is released. These are obviously not the
same as the self- latching switches used, for example, in domestic circuits.

The fact that the majority of control switches are not self-latching is not as
inconvenient as it sounds. We can easily program in a latch in the ladder diagram.

Start Stop

X1 X2

Y1

Fig 2.11

When the start push button switch in Fig 2.11 is pressed, the output Y1 is to switch
on and stay on until the stop button is pressed.

Fig 2.12

When the output Y1 is energised we use a normally open contact of it in parallel with
the start button to hold (or latch) it on. The output can only be de-energised by the
pressing of the stop button. Note that we have used a normally closed switch as a stop
button as explained in section 2.2.

13
Start 1 Start 2 Stop 1 Stop 2 Stop 3

X1 X2 X3 X4 X5

Y1

Machine Relay
Fig 2.13
The latch concept can be extended to any number of start and stop switches. The
output Y1 in Fig 2.13 is to be switched on by X1 or X2 and is to stay on until any of
the inputs X3, X4 or X5 is switched off. The required ladder diagram is shown in Fig
2.14 below.

Fig 2.14

14
2.5 Internal relays

These have the same properties as outputs but they only exist in software. They have
many uses. Fig 2.15 shows an internal relay being used to implement the logic
function NAND. This is the inverse of the result of X1 AND X2. We will be making
extensive use if internal relays later in the book.

Fig 2.15 Use of internal relay

Note: Most PLCs include a function called a Set and Reset or a flip-flop which
latches and delatches an output or an internal relay. Throughout this book I use the
latch as described in section 2.4, because of the visual resemblance of the ladder rung
to the equivalent hard-wire circuit, in which a relay coil is latched on by a normally-
open contact connected in parallel with the start button.

2.6 Timers

The delay-on timer introduces a delay between the start of one event and the
start of another.

For example, when a start push button is pressed, the pneumatic cylinder shown
in Fig 2.16 extends, remains extended for 5 seconds and then returns. Draw the PLC
wiring diagram and the appropriate ladder logic.
a+

Y1

Fig 2.16

15
Start a+

X1 X2

Y1

Fig 2.17

The start button and the end-of-stroke limit switch a+ are the PLC inputs and the
solenoid Y1 is the output. Any other components needed for the program can be
created in software.

Fig 2.18

Pressing the start button latches on an internal relay called start_latch. The
start_latch relay switches on the output Y1 which energises the solenoid, and the
cylinder extends. The cylinder rod closes the limit switch a+ which starts the timer in
software. When the timer set value time has elapsed the normally-closed contact
Timer_1 in the first line of the program de-energises the Start_latch relay and the
cylinder returns.

16
The timer set value in the TRiLOGI software is in units of 0.1 s. For a 5 s delay a
value of 50 is entered in the drop-down menu. (More details are given in the
appendix)

Fig 2.19 Setting Timer preset Value

We can do another example using the same hardware with the addition of an alarm as
a second output:

Start a+

X1 X2

Y1 Y2

Fig 2.20

17
When the start push button is pressed and released there is a 5 s delay before the
cylinder extends and returns. An alarm sounds during the 5 s delay.

Fig 2.21
When the start button is pressed the start_latch relay is energised. The
Start_latch relay switches on the timer input and the alarm. When the timer set value
has elapsed the alarm switches off and the solenoid Y1 is energised. When the
cylinder is fully extended the limit switch a+ de-energises the start_latch relay which
de-energises the solenoid and resets the timer.

The input to the delay-on timer must remain on for the duration of the timer set
value otherwise the timer will not operate. If the signal to start the timer is only
momentary then a latch is used to sustain it. When the input to the timer switches off,
the timer contacts revert immediately to their normal states.

In some PLC models a timer function block can be is located in the centre of a
rung as shown in Fig 2.22. When the timer set value has elapsed the timer output
switches on allowing a software signal to energise an internal relay coil or an output.
In this book all timer function blocks are located at the right hand side of the ladder
diagram and their contacts, normally-open or normally closed, have the same label as
the timer.

Timer 1
5 sec
in out

Fig 2.22

The delay-off timer causes a delay between its input switching off and its contacts
reverting to their normal states. The delay-on timer is used throughout this book.

18
2.7 The Pulse Generator

Two counters can be combined to make a pulse generator. This is best


illustrated by an example.

Y1

Fig 2.23

Start Stop

X1 X2

Y1

Fig 2.24
When the Start button in Fig 2.24 is pressed the cylinder in Fig 2.23 oscillates,
extending for 2 s and returning for 1 s until the Stop button is pressed.

19
Fig 2.25 Pulse Generator

It can take a while to figure out how the pulse generator works but it is time very
well spent. The flow chart in Fig 2.26 should help.

Fig 2.26 Pulse Generator Flowchart

20
2.7 Counters
A counter allows a number of occurrences of input signals to be counted. The
counter is set to a preset number value and when this value of input pulses has been
received, it will operate its contacts. A second input or software coil is provided to
reset the current value of the counter to zero.

Consider the cam shaft in Fig 2.27.

Fig 2.27

When a start button has been pressed the shaft is to make 10 revolutions and then
stop. Pressing the start button also resets the counter. The PLC wiring diagram is
shown in Fig 2.28.

Start d

X1 X2

Y1

Motor
contactor

Fig 2.28

21
Fig 2.29

The pulse generator and counter can be combined as shown in this final
example.

When a start push button is pressed and held down, an alarm sounds six times
before a conveyor starts. Pressing the conveyor stop button also resets the counter.
Fig 2.30 and Fig 2.31 show a solution to the problem.

Start Stop

X1 X2

Y1

Conveyor

Fig 2.30

22

You might also like