0% found this document useful (0 votes)
788 views

2.1 Conditional Logic: Ladder Programming

This document discusses ladder logic programming for PLCs. It provides examples of using ladder logic to implement conditional logic statements based on input conditions. Specifically, it shows how to use normally open and normally closed contacts, timers, and internal relays to control outputs based on multiple input conditions over time. Diagrams of example circuits and their corresponding ladder logic programs are presented to illustrate these concepts.

Uploaded by

Luka Nikitovic
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)
788 views

2.1 Conditional Logic: Ladder Programming

This document discusses ladder logic programming for PLCs. It provides examples of using ladder logic to implement conditional logic statements based on input conditions. Specifically, it shows how to use normally open and normally closed contacts, timers, and internal relays to control outputs based on multiple input conditions over time. Diagrams of example circuits and their corresponding ladder logic programs are presented to illustrate these concepts.

Uploaded by

Luka Nikitovic
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
You are on page 1/ 10

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.
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


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 on.Pushing 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.
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.
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.
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.
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
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
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.
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

You might also like