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

5 Basics of PLC Programming (1)

This document provides an overview of PLC programming, focusing on processor memory organization, program files, data files, and the program scan cycle. It details the structure of program and data files in PLCs, the execution of programs through scanning, and the various PLC programming languages defined by the IEC 61131 standard. Additionally, it explains relay-type instructions used in ladder logic programming, including Examine If Closed, Examine If Open, and Output Energize instructions.

Uploaded by

Sha Cz
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)
40 views

5 Basics of PLC Programming (1)

This document provides an overview of PLC programming, focusing on processor memory organization, program files, data files, and the program scan cycle. It details the structure of program and data files in PLCs, the execution of programs through scanning, and the various PLC programming languages defined by the IEC 61131 standard. Additionally, it explains relay-type instructions used in ladder logic programming, including Examine If Closed, Examine If Open, and Output Energize instructions.

Uploaded by

Sha Cz
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/ 20

2/19/25

Basics of PLC
Programming
Lecture 5

Contents
Contents

• Processor Memory Organization


• Program Files
• Data Files
• Program Scan
• PLC Programming Languages
• Relay-type Instructions
• Basic Ladder Logics

1
2/19/25

Memory organization

Processor Memory Organization


• While the fundamental concepts of PLC programming are common to all manufacturers,
differences in memory organization, I/O addressing, and instruction set mean that PLC programs
are never perfectly interchangeable among different makers.
• Even within the same product line of a single manufacturer, different models may not be directly
compatible.
• The memory map or structure for a PLC processor consists of several areas, some of these
having specific roles.
• Allen-Bradley PLCs have two different memory structures identified by the terms rack-based
systems and tag-based systems.
• The memory organization for rack-based systems will be covered in this chapter.
• The memory space can be divided into two broad categories:
• program files and data files.
• Individual sections, their order, and the sections’ length will vary and may be fixed or variable,
depending on the manufacturer and model.

Memory Organization

Processor Memory Organization

• Program files are the part of the processor


memory that stores the user ladder logic program.
• The program accounts for most of the total
memory of a given PLC system.
• It contains the ladder logic that controls the
machine operation.
• This logic consists of instructions that are
programmed in a ladder logic format.
• Most instructions require one word of memory.

2
2/19/25

Memory Organization

Processor Memory Organization


• The data files store the information needed to carry
out the user program.
• This includes information such as the status of input
and output devices, timer and counter values, data
storage, and so on.
• Contents of the data table can be divided into two
categories: status data and numbers or codes.
• Status is ON/OFF type of information, represented
by 1’s and 0’s, stored in unique bit locations.
• Number or code information is represented by
groups of bits that are stored in unique byte or word
locations.
• The memory organizations of the rack-based Allen-
Bradley PLC-5 and SLC 500 controllers are very
similar.

Program files

Program files

• Program files are the areas of processor memory where


ladder logic programming is stored. They may include:
• System functions (file 0) —This file is always included
and contains various system-related information and
user-programmed information such as processor type,
I/O configuration, processor file name, and password.
• Reserved (file 1) —This file is reserved by the processor
and is not accessible to the user.
• Main ladder program (file 2) —This file is always
included and contains user-programmed instructions
that define how the controller is to operate.
• Subroutine ladder program (files 3–255) —These files
are user-created and are activated according to
subroutine instructions residing in the main ladder
program file.

3
2/19/25

Data files

Data files
• These files are organized by the type of data they
contain and may include:
• Output (file 0) —This file stores the state of the
output terminals for the controller.
• Input (file 1) —This file stores the status of the input
terminals for the controller.
• Status (file 2) —This file stores controller operation
information and is useful for troubleshooting
controller and program operation.
• Bit (file 3) —This file is used for internal relay logic
storage.
• Timer (file 4) —This file stores the timer
accumulated and preset values and status bits.

Data files

Data files

• Counter (file 5) —This file stores the counter


accumulated and preset values and status bits.
• Control (file 6) —This file stores the length, pointer
position, and status bit for specific instructions such as
shift registers and sequencers.
• Integer (file 7) —This file is used to store numerical
values or bit information.
• Reserved (file 8) —This file is not accessible to the user.
• Network communications (file 9) —This file is used for
network communications if installed or used like files
10–255.
• User-defined (files 10–255) —These files are user
defined as bit, timer, counter, control, and/or integer
data storage.

4
2/19/25

Data files

Data files

• Each data file is made up of numerous elements. Each


element may be one, two, or three words in length.
• Timer, counter, and control elements are three words in
length; floating-point elements are two words in length;
and all other elements are a single word in length.
• A word consists of 16 bits, or binary digits. The
processor operates on two different data types: integer
and floating point.
• All data types, except the floating-point files, are
treated as integers or whole numbers.
• All element and bit addresses in the output and input
data files are numbered octally.
• Element and bit addresses in all other data files are
numbered decimally.

Scanning

Program Scan

• When a PLC executes a program, it must know—in real time—when external devices
controlling a process are changing.
• During each operating cycle, the processor reads all the inputs, takes these values,
and energizes or de-energizes the outputs according to the user program.
• This process is known as a program scan cycle.
• Figure illustrates a single PLC operating cycle consisting of the input scan, program
scan, output scan, and housekeeping duties.
• Because the inputs can change at any time, it constantly repeats this cycle as long as
the PLC is in the RUN mode.

10

5
2/19/25

Scanning

Program Scan
• The time it takes to complete a scan cycle is called the scan cycle time and indicates how
fast the controller can react to changes in inputs.
• The time required to make a single scan can vary from about 1 millisecond to 20
milliseconds. If a controller has to react to an input signal that changes states twice during
the scan time, it is possible that the PLC will never be able to detect this change.
• For example, if it takes 8 ms for the CPU to scan a program, and an input contact is opening
and closing every 4 ms, the program may not respond to the contact changing state.
• The CPU will detect a change if it occurs during the update of the input image table file, but
the CPU will not respond to every change.
• The scan time is a function of the following:
• The speed of the processor module
• The length of the ladder program
• The type of instructions executed
• The actual ladder true/false conditions

11

Scanning

Program Scan

• The scan is normally a continuous and sequential process of reading the status of
inputs, evaluating the control logic, and updating the outputs.
• There are two basic scan patterns that different PLC manufacturers use to
accomplish the scan function.
• Allen-Bradley PLCs use the horizontal scan by rung method. In this system, the
processor examines input and output instructions from the first command, top left
in the program, horizontally, rung by rung.
• Modicon PLCs use the vertical scan by column method. In this system, the processor
examines input and output instructions from the top left command entered in the
ladder diagram, vertically, column by column and page by page.
• Pages are executed in sequence. Both methods are appropriate; however,
misunderstanding the way the PLC scans a program can cause programming bugs.

12

6
2/19/25

PLC Language

PLC Programming Languages


• The term PLC programming language refers to the method by which the user
communicates information to the PLC. The standard IEC 61131 was established to
standardize the multiple languages associated with PLC programming by defining
the following five standard languages:
• Ladder Diagram (LD) —a graphical depiction of a process with rungs of logic, similar
to the relay ladder logic schemes that were replaced by PLCs.
• Function Block Diagram (FBD) —a graphical depiction of process flow using simple
and complex interconnecting blocks.
• Sequential Function Chart (SFC) —a graphical depiction of interconnecting steps,
actions, and transitions.
• Instruction List (IL) —a low-level, text-based language that uses mnemonic
instructions.
• Structured Text (ST) —a high-level, text-based language such as BASIC, C, or PASCAL
specifically developed for industrial control applications.

13

PLC Language

PLC Programming Languages


• Ladder diagram language is the most commonly used PLC language and is designed to
mimic relay logic.
• The ladder diagram is popular for those who prefer to define control actions in terms of
relay contacts and coils, and other functions as block instructions.
• Figure shows a comparison of ladder diagram programming and instruction list
programming.
• Functional block diagram programming uses instructions that are programmed as
blocks wired together on screen to accomplish certain functions.
• Typical types of function blocks include logic, timers, and counters.
• Functional block diagrams are similar in layout to electrical/electronic block diagrams
used to simplify complex systems by showing blocks of functionality.
• The primary concept behind a functional block diagram is data flow.
• Function blocks are linked together to complete a circuit that satisfies a control
requirement.

14

7
2/19/25

PLC Language

PLC Programming Languages

• Sequential function chart (SFC)


programming language is similar to a
flowchart of your process.
• SFC programming is designed to
accommodate the programming of
more advanced processes.
• This type of program can be split into
steps with multiple operations
happening in parallel branches. The
basic elements of a sequential
function chart program are shown in
Figure.

15

PLC Language

PLC Programming Languages


• Structured text is a high level text language
primarily used to implement complex procedures
that cannot be easily expressed with graphical
languages.
• Structured text uses statements to define what to
execute. Figure illustrates how structured text and
ladder diagram programming could be used to
produce the same logical output.
• For this application, the objective is to energize SOL
1 whenever either one of the two following circuit
conditions exists:
• Sensor 1 and Sensor 2 switches are both closed.
• Sensor 3 and Sensor 4 switches are both closed and
Sensor 5 switch is open.

16

8
2/19/25

Relay Instructions

Relay-Type Instructions
• Representations of contacts and coils are the basic symbols of the logic ladder diagram instruction set.
• The three fundamental symbols that are used to translate relay control logic to contact symbolic logic
are Examine If Closed (XIC), Examine If Open (XIO), and Output Energize (OTE).
• Each of these instructions relates to a single bit of PLC memory that is specified by the instruction’s
address.
• The symbol for the Examine If Closed (XIC) instruction is shown in Figure. The XIC instruction, which is
also called the Examine-on instruction, looks and operates like a normally open relay contact.
• Associated with each XIC instruction is a memory bit linked to the status of an input device or an
internal logical condition in a rung. This instruction asks the PLC’s processor to examine if the contact
is closed.

17

Relay Instructions

Relay-Type Instructions
• It does this by examining the bit at the memory location
specified by the address in the following manner:
i. The memory bit is set to 1 or 0 depending on the status
of the input (physical) device or internal ( logical) relay
address associated with that bit.
ii. A 1 corresponds to a true status or on condition.
iii. A 0 corresponds to a false status or off condition.
iv. When the Examine-on instruction is associated with a
physical input, the instruction will be set to 1 when a
physical input is present (voltage is applied to the input
terminal), and 0 when there is no physical input present
(no voltage applied to the input terminal).

18

9
2/19/25

Relay Instructions

Relay-Type Instructions
v. When the Examine-on instruction is associated by
address with an internal relay, then the status of the
bit is dependent on the logical status of the internal
bit with the same address as the instruction.
vi. If the instruction memory bit is a 1 (true) this
instruction will allow rung continuity through itself,
like a closed relay contact.
vii. If the instruction memory bit is a 0 (false) this
instruction will not allow rung continuity through
itself and will assume a normally open state just like
an open relay contact.

19

Relay Instructions

Relay-Type Instructions
• The symbol for the Examine If Open (XIO) instruction is shown in Figure.

• The XIO instruction, which is also called the Examine-off instruction,


looks and operates like a normally closed relay contact.
• Associated with each XIO instruction is a memory bit linked to the status
of an input device or an internal logical condition in a rung.
• This instruction asks the PLC’s processor to examine if the contact is
open. It does this by examining the bit at the memory location specified
by the address in the following manner:
i. As with any other input the memory bit is set to 1 or 0 depending on
the status of the input (physical) device or internal (logical) relay
address associated with that bit.
ii. A 1 corresponds to a true status or on condition.
iii. A 0 corresponds to a false status or off condition.

20

10
2/19/25

Relay Instructions

Relay-Type Instructions
• When the Examine-off instruction is used to examine a physical input, then
the instruction will be interpreted as false when there is a physical input
(voltage) present (the bit is 1) and will be interpreted as true when there is
no physical input present (the bit is 0).
• If the Examine-off instruction were associated by address with an internal
relay, then the status of the bit would be dependent on the logical status of
the internal bit with the same address as the instruction.
• Like the Examine-on instruction, the status of the instruction (true or false)
determines if the instruction will allow rung continuity through itself, like a
closed relay contact.
• The memory bit always follows the status (true = 1 or false = 0) of the input
address or internal address assigned to it. The interpretation of that bit,
however, is determined by which instruction is used to examine it.
• Examine-on instructions always interpret a 1 status as true and a 0 status as
false, while Examine-off instructions interpret a 1 status as false and a 0
status as true.

21

Relay Instructions

Relay-Type Instructions
• The symbol for the Output Energize (OTE) instruction is shown in Figure.

• The OTE instruction looks and operates like a relay coil and is associated with a
memory bit.
• This instruction signals the PLC to energize (switch on) or de-energize (switch off )
the output.
• The processor makes this instruction true (analogous to energizing a coil) when
there is a logical path of true XIC and XIO instructions in the rung.
• The operation of the Output Energize instruction can be summarized as follows:

22

11
2/19/25

Relay Instructions

Relay-Type Instructions
• The status bit of the addressed Output
Energize instruction is set to 1 to energize the
output and to 0 to de-energize the output.
• If a true logic path is established with the input
instructions in the rung, the OTE instruction is
energized and the output device wired to its
terminal is energized.
• If a true logic path cannot be established or
rung conditions go false, the OTE instruction is
de-energized and the output device wired to it
is switched off.

23

Relay Instructions

Relay-Type Instructions
• The main function of the ladder logic diagram program is to
control outputs based on input conditions, as illustrated in
Figure.
• This control is accomplished through the use of what is referred
to as a ladder rung.
• In general, a rung consists of a set of input conditions,
represented by contact instructions, and an output instruction at
the end of the rung, represented by the coil symbol.
• Each contact or coil symbol is referenced with an address that
identifies what is being evaluated and what is being controlled.
• The same contact instruction can be used throughout the
program whenever that condition needs to be evaluated.
• The number of ladder logic relays and input and output
instructions is limited only by memory size.
• Most PLCs allow more than one output per rung.

24

12
2/19/25

Relay Instructions

Relay-Type Instructions
• For an output to be activated or energized, at least
one left-to-right true logical path must exist, as
illustrated in Figure.
• A complete closed path is referred to as having
logical continuity. When logical continuity exists in
at least one path, the rung condition and Output
Energize instruction are said to be true.
• The rung condition and OTE instruction are false if
no logical continuity path has been established.
• During controller operation, the processor
evaluates the rung logic and changes the state of
the outputs according to the logical continuity of
rungs.

25

Basic Ladder Logics

1. Seal-in Circuit
• A Seal-in circuit is a method of maintaining current flow
after a momentary switch has been pressed and
released.
• Consider a Relay is used to control the power supply to a
motor. Here we are calling this relay as “Motor Starter
Coil”. This Relay another NO contact is used to seal-in or
latch the start signal.
• As start push button is a push & release type i.e., signal
will be available for some time say momentarily and
then signal will be lost.
• So, we have to latch this circuit in order to make motor
run continuously even after release of start push button.
• For this purpose, we are using Relay (M) NO contact
across Start push button such that it will take care of
start signal after start button is released.

26

13
2/19/25

Basic Ladder Logics

1. Seal-in Circuit
• The seal-in auxiliary contact (NO Contact) of the
starter (M) is connected in parallel with the start
button to keep the starter coil (M) energized when
the start button released.
• After Start Push button pressed : The Motor starter
coil energized, and its NO contact becomes NC as
shown in below figure.
• During Starting, Start push button will give the
signal to energize the coil (M), after that coil NO
contact which is connected across.
• Start Push button will be used to latch the start
signal as start push button will be released after
pressing ( start button are momentary type ).

27

Basic Ladder Logics

2. State/fault coil
• The State Coil (sometimes called a Memory Coil) is an
extension to the Sealed in Coil pattern.
• The pattern consists of a trigger condition, a coil, with a
contact from the coil branching around the trigger
condition to “seal itself in”, and then some other
condition to “break the seal”.
• Like the Sealed in Coil, the State Coil will always revert
to a de-energized state if the PLC loses power or the
program is reset.
• However, unlike the Sealed in Coil, the State Coil turns
on and off during normal operation of the program.
• The purpose of this pattern is to remember a single
true/false condition representing internal state of the
machine.

28

14
2/19/25

Basic Ladder Logics

2. State/fault coil
• You will commonly see the State Coil pattern to represent a
“Fault” condition. Let’s say you have a “fault” with the
machine (i.e. something that must cause the machine to
stop, and the condition must be reported to the operator,
and they must acknowledge it).
• In this example, the “fault condition” is the “Trigger”
contact in the logic above.
• For example, it might be an over-temperature sensor on a
motor.
• When the over-temperature sensor indicates a fault, it
energizes the Fault (State Coil), and the Fault stays
energized.
• A contact from this Fault coil is typically used to stop the
machine (or at least the motor) to prevent damage to the
machine.

29

Basic Ladder Logics

2. State/fault coil
• Another contact from this coil might be used to drive
an alarm light, or a message on a screen to notify the
operator of the problem.
• Finally, a “fault reset button” would act as the Break
Condition to break the seal and reset the fault.
• Notice that if the fault condition is still “active” (i.e.
the over-temperature switch is still indicating an
over-temperature condition) then the Fault will stay
sealed in.
• This is what someone means when they say that “a
fault must be cleared before it can be reset.”

30

15
2/19/25

Basic Ladder Logics

3. Start/Stop Circuit
• This pattern is an extension to the Sealed in Coil pattern
and is similar to the State Coil.
• However, where the State Coil is “trigger dominant” (i.e.
the Trigger condition takes priority over the Break
Condition), the Start/Stop Circuit is “stop dominant”.
• Like the Sealed in Coil, the Run coil will always revert to a
de-energized (off) state if the PLC is turned off, or if the
ladder logic program is reset.
• That’s a useful property because when starting up the
machine we likely want motors, etc., to be in the off
state until the logic decides to start them.
• If the operator pushes the Start button, then the Run coil
will turn on, and it seals itself in until the operator
pushes the Stop button.

31

Basic Ladder Logics

3. Start/Stop Circuit
• The reason that this pattern is “stop dominant” is that we
want the Stop condition to take priority over the Start
condition in the case where both signals are active.
• Imagine a case where the Start condition was stuck on for
some reason.
• At least the operator could stop the motor, etc., by holding
the Stop button on until they can turn the machine off with
the main switch.
• The reason the buttons are wired this way is so that if the
wire to the Stop button becomes disconnected or power to
the Stop button is lost, then the machine will act as if the
Stop button has been pressed, and the motor, etc., will
stop.
• This is presumably a safer condition than allowing the
motor to continue running without the ability to stop it.

32

16
2/19/25

Basic Ladder Logics

4. Set/Reset Circuit
• The Set/Reset pattern, also known as the Latch/Unlatch
pattern or simply “Latch Bit” is for remembering some
on/off state of the machine that has to survive a power
outage.
• Note that in an Allen-Bradley PLC, you will see the terms
Latch (L) and Unlatch (U) used instead of Set and Reset.
• In the logic shown above, this is a “reset dominant”
Set/Reset.
• That’s because if both the Set and Reset conditions are
active at the same time, the memory will be reset.
• Of course, you can make this “set dominant” by simply
reversing the logic.

33

Basic Ladder Logics

4. Set/Reset Circuit
• The Set/Reset pattern is often used for part tracking in a machine.
• Imagine you have a machine where a robot places a part into a fixture, and
then some manufacturing operation is performed to that part (like a
grinding or milling operation), and then another robot removes the part
from the fixture, moving it to the next station.
• Ideally there will be a sensor in the fixture to indicate if a part is present.
• You will need some way to “remember” the status of the manufacturing
operation performed on that part.

34

17
2/19/25

Basic Ladder Logics

4. Set/Reset Circuit
• First, you will need a Set/Reset to remember that the manufacturing
operation has been started, and secondly you will need another Set/Reset
to remember that the manufacturing operation has been completed.
• In the event of a power outage, the machine can then recover: if neither
memory is on, then you still need to perform the manufacturing operation
on the part, and if both are on then you just need to remove the part from
the fixture.
• If the Started memory is on but the Finished memory is off, then you may
need to scrap the part, or you may be able to continue the operation.

35

Basic Ladder Logics

5. Step Circuit
• The logic for each Step is simple:
• You can combine any number of steps to form a
Sequence.
• The steps will execute sequentially. When the Step
In Progress, coil turns on, this should be the signal
to actuate a mechanism somewhere else in the
program.
• For instance, if the Step is “Extend Cylinder” then
a contact from the Step In Progress coil could be
used to turn on the pneumatic valve to extend the
cylinder.
• The Step stays active (i.e. the Step In Progress coil
stays on) until the Step Done condition is true.
• In the example of extending the cylinder, the Step
Done condition could be the Cylinder Extended
input.
36

18
2/19/25

Basic Ladder Logics

5. Step Circuit
• Here is an example of a two step sequence. Step 1 is
“Extend Cylinder” and Step 2 is “Retract Cylinder”:
• The Sequence Start condition is what initiates the
sequence.
• This should be something like “the machine is in Auto
Mode, an Auto Cycle is running, a part is present, and the
part hasn’t been processed yet”.
• When the sequence is complete, then the Sequence
Complete coil turns on.
• This can be used in combination with the Set/Reset pattern
to latch a memory bit to indicate that the part has been
processed.
• Presumably this causes another sequence to begin, such as
an Unload Part sequence.
• Alternatively we might just wait for the operator to remove
the part.

37

Basic Ladder Logics

6. Mission Circuit
• The Mission Ladder Logic Programming Pattern is
used for higher level decision making in a
machine.
• While many machines are so simple that they only
have one sequence of steps for their Automatic
Mode, some are more complex.
• A good example of such a complex machine is
an Automated Storage and Retrieval System or
AS/RS.
• This type of machine can perform several tasks,
such as storing incoming bins of material in the
storage racks, or picking up bins from storage and
bringing them to an outgoing station.
• It’s typical to break these kinds of problems into
smaller tasks, such as:

38

19
2/19/25

Basic Ladder Logics

6. Mission Circuit
• Pick up bin from incoming station
• Place bin in storage location X
• Retrieve bin from storage location X
• Place bin in outgoing station
• In the Mission pattern, each of these higher level
tasks is called a “Mission”.
• The logic is responsible for choosing the
appropriate mission to perform next, and monitor
for the completion of that mission, or abort the
mission if appropriate.

39

Basic Ladder Logics

7. Mode Circuit
• Most machines have a mode selection mechanism,
and the most common modes are Auto(matic) and
Manual:
• The Auto/Manual Mode pattern above has two useful
properties:
• At program start, since the Auto Mode coil will default
to Off, Manual Mode will be on
• The system can never be in both Auto Mode and
Manual Mode at the same time
• The first property is important because we never want
a system to start up in Automatic Mode. It’s always
safer to start in Manual Mode and have the operator
request Auto Mode.
• The second property is one we want for all Mode
systems: only one mode can be active at a time

40

20

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy