26

Introduction to PLC Ladder

Embed Size (px)

DESCRIPTION

Introduction to PLC Ladder

Citation preview

Page 1: Introduction to PLC Ladder
Page 2: Introduction to PLC Ladder

Learn Ladder Logic

P a g e | 1 www.LADDER-LOGIC.com

Table of Contents Legal Notice ........................................................................................................................... 2

Preface ...................................................................................................................................... 3 Chapter 1 Establish a Base ........................................................................................................ 5

Rails & Rungs ......................................................................................................................... 6 Understanding the logical flow of rungs .................................................................................. 8 A bit about instructions ..........................................................................................................12 Tags, an address to memory .................................................................................................15

Creating Tag Names ..........................................................................................................15 Tag Data Types .................................................................................................................16

Project Structure ....................................................................................................................18 Project Tasks .....................................................................................................................18 Programs ...........................................................................................................................19 Program Routines ..............................................................................................................19

End of Chapter Review ..........................................................................................................20 Putting it all together ..............................................................................................................20 End of chapter review Questions. ..........................................................................................21 Test Answers .........................................................................................................................25

Page 3: Introduction to PLC Ladder

Learn Ladder Logic

P a g e | 2 www.LADDER-LOGIC.com

Legal Notice

All rights reserved. No part of the contents of the book may be reproduced or

transmitted in any form or by any means without the written permission of the publisher..

This book expresses the author’s views and opinions. The infomration contained in this book is provided without any express, statutory, or implied warranties. Neither the author, nor its resellers or distributors will be held

liable for any damages caused or alleged to be caused either directly or indirectly by this book.

Page 4: Introduction to PLC Ladder

Learn Ladder Logic

P a g e | 3 www.LADDER-LOGIC.com

Preface

his eBook is for anyone who wants to learn ladder logic. Whether your

goal is to trouble-shoot logic, write programs, or simply learn how to

make changes to a process, you’re on the right track. The best way to

accomplish these goals, you the future programmer/technician, must

understand the intent and architecture of ladder logic. Identifying the various

parts and pieces of a ladder logic project, and how these pieces relate to one

another is the forefront to learning the language. It’s all but impossible to

troubleshoot and write code without first being able to identify the various

components and understand the logical flow of the language.

Ladder logic is a language, and learning a language can be difficult, learning a

language lacking the proper tools is plain torture. This eBook teaches the

language, the fundamentals. Material is presented in such a way that the

reader is not inundated with technical data, which would be a recipe for

disaster.

The material in this book is not an attempt to regurgitate datasheets which are

readily available. It’s a roadmap for successfully mastering ladder logic. It’s

written by a programmer working in the field, not a technical-writer in a

cubicle collecting a paycheck. Publications churned out by corporations have a

place, and that is to provide specific information when and where it’s needed

for both technical and legal reasons. If you have unsuccessfully tried to decode

ladder logic from material like this, as I have, don’t fret it’s not your fault; the

material is dry and not intended to teach the language. Rockwell Software has

extensive libraries covering technical material. Datasheets, help files, and

programming publications are freely available. Don’t misunderstand; technical

information is necessary, but necessary when you need it. It’s not a good read

and probably doesn’t belong in a book, certainly not this one.

This book is about fundamentals. If you want to learn the structure of a

project, learn how to read and write ladder logic, learn how to navigate code,

and avoid common pitfalls then this book is for you. If you are looking for

specific details pertaining to software or hardware use the supplied help files

and check out the knowledge base at www.rockwellsoftware.com . You can also

check out www.ladder-logic.com for more specifics.

Finally, if you’re looking for a quick fifteen minute solution to trouble-shooting

and programming ladder logic expect some disappointment in your life. Put

simply; that book, online course, or free tutorial doesn’t exist. Learning Ladder

T

Page 5: Introduction to PLC Ladder

Learn Ladder Logic

P a g e | 4 www.LADDER-LOGIC.com

logic takes time, dedication, effort, and practice. This eBook is an excellent

start, so free yourself from distractions and dig in.

Page 6: Introduction to PLC Ladder

Learn Ladder Logic

P a g e | 5 www.LADDER-LOGIC.com

Chapter 1 Establish a Base

his book is about learning ladder logic. If you’re reading this book then

it’s assumed that you at least have a basic understanding of

Programmable Logic Controllers. If not you should.

A PLC is a computer, or more precisely an industrial computer. PLC’s are

designed to withstand harsh environments; assembly lines, mines, food

processing plants, automotive plants and more. Most PLC’s are modular; they

can be scaled up or down as needed. Inputs cards, output cards,

communication cards, motion control cards all can be added or removed to

satisfy most engineering needs. They are designed for a very specific purpose,

machine control. The PLC is the brain of any intelligent control system.

Just as the integrated circuit chip replaced multiple transistor circuits in

electronics, the PLC replaced multiple electromechanical relays in industrial

circuits. Automated equipment from the not so distant past was controlled by

electromechanical relays, and lots of them. Complex machines contained

thousands of relays. Today a single PLC can replace all the logical relays,

timers, and other peripheral devices common in the machines of the past. The

modern PLC can control machines, collect data, crunch numbers and so much

more. All they need is an architect, someone to tell them what to do.

Enter you the programmer/technician, master of virtual circuits, more

specifically the master of ladder logic, the language of virtual relay circuits. As

the story has been told, ladder logic was developed for engineers who were

skilled at designing and working with ladder diagrams. Ladder logic was

developed as a programming language to mimic ladder diagrams, it emulates

industrial electrical circuits. These virtual circuits made up of rails, rungs, and

instructions are packaged into routines, programs and tasks. The aim of this

eBook is to place each component of the language under the virtual microscope

to acquire a better understanding of roles and how the various components

relate to one another.

T

Page 7: Introduction to PLC Ladder

Learn Ladder Logic

P a g e | 6 www.LADDER-LOGIC.com

Rails & Rungs

Ladder logic is similar to a ladder; you know the kind you climb. I’m not

kidding stick with me here. There are two major components two a ladder, rails

and rungs, Ladder logic is structured similarly. A ladder diagram has rails and

rungs. The rails represent the opposing polarities of an electrical circuit and

the rungs represent wires connected between the two.

Let’s back up just a little. It’s important to point out that most programming

languages are textual. That is the code is written out. Compare the following

code written in a textual based programming language with the equivalent code

created with ladder logic.

If Button_Pressed Then

Light := 1;

Else

Light := 0;

End_IF;

The above example is a textual language called Structured Text. Note that the

code is written in a structured format. Below is the equivalent statement

written using ladder logic.

Ladder logic is a graphical language as opposed to a textual based language.

Rather than writing code in a text editor, rungs are placed between rails, and

instructions are placed on the rungs. The rung along with the instructions

make the code.

Using the same rung example let’s explore how the graphical based ladder logic

programming software emulates industrial electrical circuits made up of

Contact

Rails

Coil

Rung

Structured Text is a

textual PLC programming

language.

Page 8: Introduction to PLC Ladder

Learn Ladder Logic

P a g e | 7 www.LADDER-LOGIC.com

electromechanical components. Ladder logic is intended to be written, read and

executed using principles defined by electrical circuits. This can be confusing

for people who are used to writing and reading textual based programming

languages. Ladder logic was developed for electrical engineers and technicians

as a way to write software that emulates electrical circuits.

Below is an example of an electrical circuit. The circuit consists of a battery

connected to a switch in series with a load. When the switch is closed an

electrical path is created allowing current to flow through the circuit. As the

current flows, the light is energized, or turned on. When the switch is opened

the electrical path is removed and the light turns off.

Below is an example of how the circuit could be created with ladder logic

software. The left and right rails represent the opposing polarities of the power

source. Think of the left and right rails as the positive and negative terminals of

the battery as shown above. The rung represents the wires that connect the

components together. This rung behaves just like the electrical circuit

described above.

Note the green highlighting of the rails; this indicates that the PLC is in active

scan mode. In the first rung, only the rails are highlighted. The Switch contact

is not highlighted indicating that the Switch contact is open. The path from one

rail to the other is open resulting in the Load coil being off. In the second rung

Page 9: Introduction to PLC Ladder

Learn Ladder Logic

P a g e | 8 www.LADDER-LOGIC.com

the Switch contact is highlighted in green indicating the Switch is closed. A

path to the load coil is created; notice the Load coil is highlighted indicating it

is on.

Green Highlighting is used to indicate the state of contacts, coils, and rails.

Green highlighting on a contact indicates the contact is closed; a path to the

right of the contact is present. The absence of highlighting indicates the

contact is open; no path to the right of the contact exists.

In the case of the coil green highlighting indicates the coil is on while the

absence of highlighting indicates the coil is off.

Rather than thinking in terms of If Then Else statements ladder logic can be

thought of in terms of contacts, coils and wires. Consider a contact as an input

and a coil as an output. If the contact is closed an electrical path is created via

the rung which energizes the coil. If the contact is open the electrical path is

removed and the coil is de-energized. Contacts, or rung inputs, create a logical

path that energizes coils, or rung outputs.

Key concepts - This is a basic fundamental concept of ladder logic, read it

again. If you don’t understand this material there’s not much point in moving

forward. Put simply, the input rung logic creates a

path to an output. The output is the action; it can be

anything, turning on a light, indexing a counter,

initiating a database lookup. Inputs always reside left

in respect to an associated output. It makes sense

when you think about program flow, which is always

from left to right.

Understanding the logical flow of rungs

Similar to climbing-ladders programs consist of more than one rung. Each

rung can be thought of as a single logical circuit. Rungs can be related to other

rungs or completely independent of one another. Take the following rung

examples. Using the logical flow analysis described above, determine the value

of the output coils. What conditions must be satisfied in order to turn on the

output coils of the following rungs?

Ladder logic is scanned like

a book is read; from top to

bottom, left to right.

Page 10: Introduction to PLC Ladder

Learn Ladder Logic

P a g e | 9 www.LADDER-LOGIC.com

The above rung has an unconditional output.

There are no inputs to evaluate in order to

turn the output coil on hence the

unconditional part of the rung. As a side

note rungs reside in routines which are

blocks of code. Routines may or may not be

called or executed. Rails are highlighted in

green even if the rung logic is not executed.

The highlighting of the rails indicates the processor is in active scan mode.

These two rungs demonstrate that a contact can be addressed to an output

coil. The second rung is dependent upon the output coil of the first rung. If the

first rung is evaluated as false the output of the second rung will also be false.

If the output of the first rung is true then the output of the second will also be

true.

Rungs reside in routines. Routines can be

scanned or not, it’s configurable. Just

because rails are highlighted doesn’t

mean the rung logic is being executed.

Page 11: Introduction to PLC Ladder

Learn Ladder Logic

P a g e | 10 www.LADDER-LOGIC.com

The above example is a conditional rung with

two input contacts. Both contacts have to be

closed in order to create a logical path to the

output coil. This type of circuit is known as and

logic because contact 1 and contact 2 must be

closed to turn the output coil on. Looking at the

states of the input coils what is the condition of

the output coil on or off? Input_1 is on while

Input_2 is off resulting in an open circuit leaving the coil Ouput_1 off.

The example above is another conditional rung with two contacts. In this

scenario only one contact needs to be closed in order to create a logical path to

the output coil. This type of circuit is known as or logic. Either contac1 or

contact 2 is required to be closed to turn on the output coil. Notice that this

circuit has the same number of inputs and outputs as the previous circuit. The

only difference between the rungs is where the inputs have been placed. The

placement of contacts and coils determines the logic of the rung. The virtual

wire that connects Input_2 to the rung is known as a branch. The inputs of this

circuit are in parallel while the inputs of the previous and logic circuit are in

series.

Trouble-shooting tip: Look at the

state of the output coil first. Look for

the green highlighting of the coil. If

the coil is off trace the logic backward

from there.

Page 12: Introduction to PLC Ladder

Learn Ladder Logic

P a g e | 11 www.LADDER-LOGIC.com

The above rung is a conditional rung with two contacts and two coils. Notice

the contacts reside on the right side of the rung, but still left of their respective

output coils. If contact 1 is closed, Output_1 coil is on. If contact 2 is closed

Output_2 coil is on. This rung has two circuits in parallel. The circuits are

independent of one another; therefore the rung has two possible outputs.

Recall that the previous rung contained a branch that was described as or

logic. Would this rung be described similarly? Not necessarily, because the

output coils are not part of or logic in respect to the input contacts. Observe

the Output_2 coil; it turns on only when Input_2 is closed, not Input_1 or

Input_2. Output_1 behaves similarly with respect to the Input_1 contact.

Once again, determining the logic of the rung is all about where contacts and

coils are placed. When determining the rung output remember the logical flow

is always from left to right or input to output. Incidentally the flow is always

from top to bottom as well. That means that Input_1 and Ouput_1 are solved

before Input_2 and Output_2.

The above rung looks similar to the previous rung with the exception of the

first conditional contact. Adding this contact creates two and logic circuits.

The two circuits still act independently in respect to one another.

Circuit 1 – Input_1 and Input_2 must be closed to turn on Output_1 coil.

Circuit 2 – Input_1 and Input_3 must be closed in order to turn on Output_2 coil.

Page 13: Introduction to PLC Ladder

Learn Ladder Logic

P a g e | 12 www.LADDER-LOGIC.com

The above rung may be confusing and seem to break the left to right rule at

first however it can also be broken down into two logical circuits.

Circuit 1 – Input_1 must be closed in order to turn on Output_1.

Circuit 2 – Input_1 and Input_2 must be closed in order to turn on Output_2.

Output_1 has no bearing on the output of circuit 2.

Again the input is always on the left in respect to the output of the circuit.

Complex rungs like the one above can be broken down into individual circuits

to decipher the appropriate logical flow to the outputs. As a side note rungs

written like this are completely legitimate and completely confusing. There are

several ways to write this circuit that would cause less confusion. Can you

think of any?

A bit about instructions

Thinking about ladder logic in terms of contacts and coils is an essential part

of understanding the language. Contacts and coils are symbols that can be

placed on rungs to create logical circuits. These symbols have a name they are

called instructions.

RSLogix 5000 has numerous symbolic instructions from very simple to very

complex. You can even create your own custom instructions called Add On

Instructions. Instructions define logical statements. Let’s take a look at a basic

instruction called the Examine If Closed or XIC instruction. Think of an XIC

instruction is a contact; it’s either open or closed. When the contact is closed a

path is created and “current” is allowed to flow from left to right through the

contact. When the contact is open the path is removed removing “current” flow

through the contact. Take a look at the rung below.

XIC – Examine If Closed

Page 14: Introduction to PLC Ladder

Learn Ladder Logic

P a g e | 13 www.LADDER-LOGIC.com

When the input contact (XIC instruction) is closed a path is created allowing

“current” to flow to the output coil. In a real electrical circuit the contact might

be a mechanical switch/button which is closed with a hand. The action of

closing the switch would allow electrons to flow through the circuit resulting in

the output, maybe a light, turning on.

In an electrical circuit the contact and coil are real devices, something which

can be mechanically triggered. In the ladder rung circuit the

contact and coil are symbols. So, how does one press a symbol,

or turn a virtual coil on?

Instructions have arguments called operands. When the above

rung is scanned the contact closes to create a path and opens

to remove a path. The XIC instruction accomplishes this by

checking the value of the argument associated with the instruction. The XIC

instruction, similar to the electromechanical contact has two possible states,

open or closed. The argument associated with the instruction has two possible

states one and zero.

The XIC instruction checks the Operand for its value. If the value is one the

XIC is “closed” and a path is created allowing “current” to flow to the output

coil. If the value is zero the XIC is “open” removing the path of “current” to the

output coil.

The coil symbol is called an Output Energize or OTE instruction.

The OTE instruction also requires an Operand similar to the XIC

instruction. Rather than checking the value of the argument the

OTE sets the value of the argument to either a one or zero. If the XIC

instruction is one a path is created and the OTE sets the associated argument

to one.

Page 15: Introduction to PLC Ladder

Learn Ladder Logic

P a g e | 14 www.LADDER-LOGIC.com

The table below shows the XIC and OTE instructions displaying both possible

states. The XIC instruction has an operand named XIC_Argument and the OTE

instruction has an operand named OTE_Argument.

Operand Name

Instruction

Graphics Value Alternate Name

XIC_Argument 1 On True Set

0 Off False Clear

Operand Name

Instruction

Graphics Value Alternate Name

OTE_Argument 1 On True Set

0 Off False Clear

Input instructions check values of associated operands, while output

instruction set values of associated operands. Operands can also be called

arguments. The most commonly used instructions are bit instructions. Bit

instructions have two possible states which can be referred to as one and zero,

on and off, set and clear, and true and false.

In order to fully understand the language it must be broken down into logical

components. An instruction is a graphical symbol that instructs the PLC to do

a specific task. In the case of the XIC instruction that task is to check the value

of the associated argument. In the case of the OTE instruction that task is to

set the value of the associated argument.

Page 16: Introduction to PLC Ladder

Learn Ladder Logic

P a g e | 15 www.LADDER-LOGIC.com

Tags, an address to memory

All programming languages make use of what are known as variables. A

variable is simply a memory location, an address. In ladder logic these

variables are called Tags. Tags are basically made up of two parts, the tag

name and the tag type.

RSLogix 5000 software requires users to define tags. Tags are addresses to

memory locations. Picture this, somewhere in the deep dark depths of the PLC

exists a vast array of empty warehouses. These warehouses are memory banks,

one after another, as far as the eye can see. Their sole purpose is to store data.

Accessing these memory locations is simple. All you need to do is create a tag.

To create a tag you simply give it a name and define the amount of memory the

tag will access. The software automatically associates your new tag name to a

spot in the warehouse of memory. To access this memory simply use the tags

name. Easy.

Creating Tag Names

Tags are named by you the programmer. Simple enough right? There are a few

governing rules that must be followed when naming tags which is covered later.

As a general rule tag names should be descriptive. The tag name should have

something to do with what tag was created for.

For instance, suppose you were writing a program that required a door to be

closed in order for a process to start. Your job is to give descriptive names to

tags. What would you call them? You could name it after your nephew,

girlfriend, boyfriend, or dog. What if you could give it a descriptive name that

makes your code more readable? Look at the following examples, which one is

more readable rung -1 or rung-2?

Obviously rung-2 makes much more sense, it’s more readable. If the door is

closed then go ahead and start the machine. Rung-1 is the exact same logic as

Rung-2 however what is the objective of the rung? Why did the programmer

write the rung? The logic does the same thing as Rung-2 but because the tag

Page 17: Introduction to PLC Ladder

Learn Ladder Logic

P a g e | 16 www.LADDER-LOGIC.com

names are irrelevant to the logic who knows what the rung is supposed to

accomplish.

Believe it or not programmers do this all the time. Take this scenario for

example. Alexander works the night shift at the bubble gum plant. The bubble

gum expander machine locks up and won’t run. Alexander, being the savvy

programming type, opens up the program and adds an XIC instruction. All

good, but rather than creating a tag that makes sense he uses his name.

To him this made sense, think about it, if anyone needed to see what he had

done they could simply search for his name and they would surely be

impressed by his witty contribution to the bubble gum expander. In reality

Alexander just made the code hard to read. Don’t be an Alexander, make your

code readable.

Tag Data Types

A tag is a memory location addressable by a name. In order to create an

addressable memory location one has to define the amount of memory that will

be used. When a tag is created you the programmer/technician selects how

much memory the tag will use. To select how much memory a tag will address

simply choose an existing data type. The data type defines the amount of

memory the tag will address. The software has several data types which are

nothing more than predefined memory sizes.

In all the previous rung examples the XIC and OTE instructions used are

binary. They have two states, on and off. Another way of saying binary is

Boolean. According to Google the definition of Boolean is: a binary variable,

having two possible values called “true” and “false”. Incidentally a binary

instruction will only accept binary arguments (tags).

Page 18: Introduction to PLC Ladder

Learn Ladder Logic

P a g e | 17 www.LADDER-LOGIC.com

RSlogix 5000 has several native data types which are referred to as Atomic

Data Types. The software has numerous instructions that require operands of

one or more of the following data types.

Atomic Data Type Description Minimum Maximum Bits

BOOL Binary Data Type 0 1 1 bit

SINT Short Signed Integer -128 +127 8 bit

INT Signed Integer -32,768 +32,767 16 bit

DINT Double Signed Integer -2,147,483,648 +2,147,483,647 32 bit

REAL Real Number +/-1.1754944E-38 +/-3.402823E38 32 bit

As an example the MOV (Move) instruction

requires two operands, a source operand and

a destination operand. The required data type

can be SINT, INT, DINT, or REAL. Unlike the

XIC or OTE instructions the MOV instruction

can accept multiple data types. In the picture

to the right both the Source and Destination

arguments are of type DINT. When the instruction is executed the data in the

memory location addressed by the tag Source_Argument is copied into the

memory location addressed by the tag Destination_Argument. Because the

tags were defined as DINT data types 32 bits of data is copied from the source

to the destination.

Once a tag is created it can be associated with an instruction. Once associated

with an instruction the tag then becomes the argument for the instruction. The

instruction then has the ability to examine or change the addressed data. No

numbered addresses or cryptic codes to remember. Give a tag a unique name

and define the amount of memory it will access.

Page 19: Introduction to PLC Ladder

Learn Ladder Logic

P a g e | 18 www.LADDER-LOGIC.com

Project Structure

Now that you have a better understanding of how the code components of the

language works let’s take a look at an overall project. Specifically where does

the code reside and why? What initiates code execution?

Code and tags make up programs. A program is nothing more than a set of

instructions that execute step by step. RSLogix 5000 has a hierarchy type of

organizational method.

Code, rungs instructions and such, reside in routines. Routines reside in

programs. Programs reside in tasks. Why make it so complicated? To answer

that question let’s ask more questions. Suppose you write a program. What will

initiate your code? What starts the process? Think about it, should it be

started in response from a trigger or event? Should it run continuously over

and over again as soon as it’s placed in the PLC? Maybe it would be better to

run it periodically, say every second until the end of time.

Project Tasks

Programs are assigned to tasks. A task is nothing more than a way to schedule

programs. Every program needs a mechanism to initiate the execution of logic

contained in the program. There are three types of tasks available, the

Continuous Task, the Periodic Task and the Event task.

Continuous Task

The continuous task is initiated when the processor is placed in run mode.

Programs assigned to the continuous task will execute from start to finish.

Once a program in the task completes it immediately starts again.

Periodic Task

A periodic task is triggered at a user selectable time. Programs in this task are

triggered first when the processor is placed in run mode, then at the selected

interval. If the interval is set to 100 milliseconds and the program assigned to

the task takes 10 milliseconds to execute the program will not run again until

the 100 millisecond time interval has expired.

Event Task

An event task is triggered from an event. The event is selectable; it can be

triggered by an instruction, from an input, consumed tag, or motion

operations. In other words there are plenty of selectable triggers to start a

Page 20: Introduction to PLC Ladder

Learn Ladder Logic

P a g e | 19 www.LADDER-LOGIC.com

program. Once a program has completed its execution it waits for another

trigger to start again.

Programs

Programs are nothing more than a logical group of components. These

components are code, variables, and routines. Refereeing to a program is

referring to a group of components with the same schedule (task). A single PLC

can have multiple programs. Each program can operate independently or in

conjunction with one other.

Programs are an excellent way to organize projects. Several programmers can

work on a project at once. If a project contains multiple programs multiple

programmers can work on individual programs without stepping on the toes of

others.

If a program already exists that controls a process why create a new one?

Simply import an existing program into a new project. Placing code in

programs makes the code portable. It can be transferred from one process to

another with little or no modifications if it was written and grouped correctly.

Program Routines

Routines serve several purposes they can up a program, make it more

readable. They can give sections of code that ability to be conditional. They can

be used to pass parameters allowing code to be called again and again

crunching different data. This can make code smaller and is covered in later

material.

It’s possible to write an entire program in one routine although not advised.

Every program has at least one routine, the main routine. It is executed

unconditionally, meaning it is called when the program is triggered. All code in

the main routine is scanned when the program is triggered.

Any subsequent routines in a program must be called

with a Jump To Subroutine (JSR) instruction. Routines

can be called conditionally by placing conditions on a

JSR instruction. JSR instructions can also pass and receive parameters from

routines. Routines are inherent to programs. They are logical elements of a

program.

Page 21: Introduction to PLC Ladder

Learn Ladder Logic

P a g e | 20 www.LADDER-LOGIC.com

End of Chapter Review

Ladder logic is a graphical programming language used to create virtual

circuits. Ladder logic is the most commonly used programming language for

PLC programming. The code part of ladder logic is comprised of rungs,

instructions and tags. There are two types of instructions input instructions

and output instructions. Input instructions examine data while output

instructions change data. Variables or tags are addresses to memory locations.

Instructions examine/change data addressed by tags. Tags are nothing more

than addresses to a defined block of memory.

When a rung is scanned it is done so from top to bottom, left to right never in

reverse. A single rung can have multiple circuits or outputs. The output of a

rung is dependent on the placement of instructions and branches.

PLC projects are made up of at least one program scheduled in one task. The

code is made up of various components dispersed in logical routines.

Putting it all together

This chapter serves as a base for learning the language. After completing this

chapter, you the reader, should be able to clearly identify basic rung logic. You

should also be able to identify the various components that make up code.

Code is made of rungs, branches, instructions and tags. The code resides in

routines, routines reside in programs, and programs reside in tasks which are

all covered in the book.

These basic components serve as the base of ladder logic. As you will soon

discover there are more complex instructions and tags. Some instructions are

dedicated to managing program flow rather than manipulating data. Tags can

get more complex with aliasing, arrays, and visibility. The important thing to

remember is that regardless of the complexity of the components they all follow

the same basic rules.

Page 22: Introduction to PLC Ladder

Learn Ladder Logic

P a g e | 21 www.LADDER-LOGIC.com

End of chapter review Questions.

Each chapter is followed up with a brief set of supplemental questions. The

questions are designed to instill key concepts.

1. A modern PLC is capable of running multiple programs. True or

False.

2. Highlighting an instruction and pressing the ___ key will bring up a

context sensitive help file.

a) H

b) F1

c) F

d) CTL + H

3. Ladder Logic programming, similar to other languages is a textual based

language. True or False.

4. Which of the following statements best describes an unconditional rung :

a) A rung which has a parallel branch.

b) A rung with at least one input instruction.

c) A rung that is dependent upon another rung.

d) A rung with an output instruction only.

5. The scan flow of a rung always follows what path?

a) Left to Right

b) Input to Output

c) Is dependent upon the placement of the instructions

d) Is selectable when the rung is created

6. Output instructions are always ______ of their respective input

instructions.

a) Complimentary

b) Right

c) Inherited as well as complimentary

d) The inverse

7. Which statement best describes the OTE instruction.

a) An OTE instruction is an output instruction that sets or clears

data addressed by an associated tag.

Page 23: Introduction to PLC Ladder

Learn Ladder Logic

P a g e | 22 www.LADDER-LOGIC.com

b) The OTE instruction is an output instruction that sets the data

addressed by an associated tag. An OTI instruction is used to clear

the data.

c) The OTE instruction can be used as either an input or output

instruction. It inherits its properties from an associated input

instruction.

d) An OTE instruction is an output instruction that sets or clears

data addressed by an associated tag. Only one OTE instruction is

allowed per rung.

8. The XIC instruction is an input instruction that examines the data

addressed by an associated tag. True or False

9. Using the following input tag values, find the values of the tags

referenced to the OTE instructions.

Switch_1 = 1, Switch_2 = 1, Switch_3 = 0

Ouput_1 ___ Output_2___ Output_3___ Ouput_4___ Output_5____

10. Bit Instructions require arguments. Arguments are placeholders

for _____ .

a) Tags

b) Rungs

c) Routines

d) Programs

Page 24: Introduction to PLC Ladder

Learn Ladder Logic

P a g e | 23 www.LADDER-LOGIC.com

11. A tags name is essentially a(n) ______ to a memory location.

a) cypher

b) address

c) communication asset

d) peer connection

12. There are ____ different types of tasks available for scheduling

programs.

13. Each program in the PLC must be scheduled in a different task.

True or False.

14. Every program has a default main routine which is triggered when

the program is run. How are subsequent routines called?

a) From the task scheduler

b) With a JSR instruction

c) Automatically after the main routine is called

d) Alphabetical order

Page 25: Introduction to PLC Ladder

Learn Ladder Logic

P a g e | 24 www.LADDER-LOGIC.com

Page 26: Introduction to PLC Ladder

Learn Ladder Logic

P a g e | 25 www.LADDER-LOGIC.com

Test Answers

1. True, PLC’s can run multiple programs scheduled in a continuous,

periodic or event task.

2. b) F1 key. Highlighting an instruction and pressing the F1 key will bring

up a context sensitive help file. Use it.

3. False, Ladder Logic is a graphical based programming language, unlike

popular PC based programming languages such as Java and C++.

4. d) A rung with an output instruction only. Note the question asked which

selection best describes an unconditional rung. An unconditional rung

could have several outputs.

5. a) Left to Right.

6. b) Right. Outputs will always be right of their respective inputs.

7. a) An OTE instruction is an output instruction that sets or clears data

addressed by an associated tag.

8. True, an XIC or Examine If Closed instruction examines the data of the

operand or tag.

9. Output_1 = 1, Output_2 = 1, Output_3 = 1, Output_4 = 1, Output_5 = 0

10. a) Tags

11. b) Address

12. Three available tasks. Continuous, Periodic, and Event.

13. False, multiple programs can be scheduled in each task.

14. b) With a JSR or Jump To Subroutine instruction.