You are on page 1of 46

Ladder Logic

Programming
THIS MODULE DISCUSSES HOW TO CREATE AND MANAGE A PROGRAM.
FOCUS IS ON LEARNING THE TOOLS WITHIN THE ME ENVIRONMENT THAT
ARE USED FOR PROGRAMMING.

UPON COMPLETION OF THIS MODULE, YOU SHOULD BE ABLE TO:


 Enter a simple program using the Relay Ladder
Logic (RLL) programming language;
 Assign addresses and variables to the program
elements;
 Document the program;
 Make offline and online changes to the program;
 Use the “Call” function to execute Ladder Diagram
(LD) Blocks (Subroutines);
 Configure the Ladder Diagram Editor options;
 Print out the ladder diagram.
Ladder Logic Programming

11 - 2
Ladder Logic Programming

Overview
Although today’s PLCs can be programmed with various languages,
Relay Ladder Logic (RLL) is still the most widely used programming
language. To understand why this is, one needs to look at the history of
PLC’s.

HISTORY OF PLCS
PLCs were first introduced in the late 1960’s. Originally, they were referred
to as Programmable Controllers, or PCs. When the personal computer was
introduced in the early 1980’s, people started referring to the personal
computer as a PC. By the late 1980’s, the term Programmable Logic
Controller, or PLC, became the widely accepted name for these devices in
order to differentiate them from personal computers. PLC’s were used to
replace relay systems. Schematic diagrams for systems wired with
electrical relays showed the logic of execution, or the “scheme” of things,
using a ladder type diagram such as the one depicted below.
In the following diagram, the lines labeled L1 and L2 are the ladder rails
where the power for the circuit comes from . This diagram shows one
ladder “rung” of logic. This is a standard stop/start circuit. The normally
closed Stop Push-Button passes power to the normally open Start
Push-Button . To start Motor 1, the Start Push-Button is pressed
and power passes to the M1 coil of the motor starter completing
the circuit and energizing it. When the contactor of the Motor 1 starter
closes as a result of the M1 coil being energized, the auxiliary normally
open contact, __||__ , also labeled M1, closes and seals the circuit so
that the M1 coil remains energized after the start button is released. To
stop Motor 1, the Stop Push-Button is pressed and interrupts the power
supply to the circuit causing the M1 coil to become de-energized. As a
result of its’ coil being de-energized, the contactor of the Motor 1 starter
opens and its’ auxiliary contact returns to its’ normally open condition
breaking the circuit seal. When the Stop Push-Button is released, power is
once again available for the circuit to be energized.

L1 L2

Stop PB Start PB

M1

M1

Figure 11-1. Sample Ladder Rung of Logic

11 - 3
Ladder Logic Programming

Electricians and engineers who worked with relay control systems


understood these types of schematics. In order to make the transition to
the new controllers as easy as possible, manufacturers chose to use a
programming language that had the same look and feel as relay ladder
schematics. They named this language Relay Ladder Logic (RLL). In
RLL, there are no pictorial representations of push-buttons or various
types of switches. The normally-open and normally-closed contacts are
used to depict all input type devices and the coil is used to depict all
output type devices. The same stop/start circuit that is shown above,
when programmed into a PLC, looks like the picture below. Contact
symbols are used to show the status of the input and output devices that
are wired to the PLC’s input and output modules. In the picture below,
contact A references the Stop Push-Button. Contact B references the Start
Push-Button. Contact C references the Auxiliary contact on the motor
starter. Output Coil Y references the output that controls the motor
starter.

A B Y

Figure 11-2. Sample Ladder Rung of Logic in RLL Language

PLC ADDRESSING
The symbols in a relay schematic reference an actual hardware device
such as a push-button or a motor starter coil. The contact and coil
symbols used in a PLC’s Relay Ladder Logic program reference locations
in the PLC’s memory. Each memory location has a unique “address”. An
address is simply a place marker or pointer that references a specific
memory location. For a given input, the state of the bit in the memory
location that references that particular input will follow the state of the
device wired to the input terminal of the input module. If the device is
passing power to the input module terminal, then its’ corresponding bit
in the PLC’s memory will have a value of 1. If the device is not passing
power to the input module terminal, then its’ corresponding bit in the
PLC’s memory will have a value of 0. Actual addressing formats and
naming conventions vary by manufacturer. For instance, inputs in GE
Fanuc PLC’s are referenced with an address that begins with %I such as
%I00001 or %I00002, etc. This doesn’t mean that another manufacturer’s
PLC products will reference input addresses the same way. They most
likely will not. The same holds true for output addressing. Output
addresses for GE Fanuc PLC’s start with %Q such as %Q00001 or
%Q00002, etc. The picture below shows the stop/start program
mentioned previously using GE Fanuc addressing.

11 - 4
Ladder Logic Programming

INPUT OUTPUT
CARD CARD

STOP %I1
%Q1 M
START
%I2

M-AUX
%I3

%I00001 %I00002 %Q00001

%I00003

91896

Figure 11-3. Sample Ladder Rung of Logic with GE Fanuc Addressing

VARIABLES
In addition to having unique addresses for inputs and outputs,
ME Logic Developer PLC software allows for the use of unique
variables for inputs and outputs. A variable is a name that is
used instead of an address to reference a specific input or output.
The picture below shows an actual screen shot from ME Logic
Developer PLC for the same stop/start program mentioned
above. The actual addresses are shown beneath the input and
output symbols; and the variable names assigned to the symbols
are shown above them. This picture shows default variable names
that have been assigned by the software.

Figure 11-4. Default Variable Names


In most cases, it makes more sense for the user to assign his/her own
variable names. The picture below shows the same program with user-
assigned variables. Variable names may contain both letters and numbers
but must start with a dollar sign $ or a letter. Spaces are not allowed, so
the underscore _ symbol must be used when a space is required. Only
numbers (0 through 9), letters (a through z), a dollar sign ($) or an
underscore (_) can be used within the variable name. Letters can be
uppercase or lowercase or any mixture of both.
11 - 5
Ladder Logic Programming

Figure 11-5. User Defined Variable Names


The software can display the variable and address simultaneously as in
the picture below.

Figure 11-6. Variable and Address Displayed Simultaneously

PROGRAM DOCUMENTATION
Documentation is one of the most important parts of any program. A
properly documented program will make it easier for someone to work
with the program in the future. Rung documentation can be provided
within the ladder diagram itself like in the picture below.

Figure 11-7. Rung Documentation Within Ladder Diagram


Additional documentation can be provided for individual variables. This
documentation is entered in the Description field within the Inspector
window. When an instruction is selected in the ladder diagram, the
properties associated with it can be viewed in the Inspector window as in
the picture below.

11 - 6
Ladder Logic Programming

Figure 11-8. Instruction Properties Displayed in Inspector Window

Import and Export Variables


To import variables from a file:
1. In the Variables tab of the Navigator, right-click anywhere in the
variable list (except on the variables or their elements) and choose
Import. The Import dialog box appears.

Figure 11-9. Right-Click and Choose Import


2. Browse to the file you want to import from and select it.

Note
Supported file formats are .csv, .snf, and .xml. When opening
.snf files saved in Microsoft Excel, it must have been
configured to use commas as delimiters between columns.
3. Click Open. The Import Variables wizard appears showing Step 1 -
Specify Options.

11 - 7
Ladder Logic Programming

Figure 11-10. Step 1 – Specify Options


4. Specify the following options:
Import into target - the name of the target in your project that will
receive the imported variables.
Device Driver - the default PLC access driver (automatically added to
your target) that imported variables will be associated with if an HMI
component is present on the target.
Identify variable options - the type of variable conflict the import
will detect.
If there is a conflict - the method of handling duplicate variable
names.
5. Click Next. The wizard shows Step 2 - Select Variables. The Filtered
Variables list initially shows all variables defined in the import file.

Figure 11-11. Step 2 – Select Variables


6. Click Next. A summary of your import setup is displayed.
7. Click Finish to complete the import.

To export variables to a file:


1. In the Variables tab of the Navigator, right-click anywhere in the
variable list (except on the variables or their elements) and choose
Export. The Export dialog box appears.
11 - 8
Ladder Logic Programming

Figure 11-12. Right-Click and Choose Export


2. Browse to the folder you want your file saved in and enter a file name
and type.
Supported file formats are Comma-separated Value (*.CSV), Standard
Name Form (*.SNF), and Proficy Machine Edition XML (*.XML).

Warnings:
SNF files are generally used with VersaPro and LM90. These
applications do not support two-dimensional arrays. When
these applications import the array, only one dimension will be
imported and its stored values may be corrupted.
When opening exported SNF files in Microsoft Excel (or similar
applications), make sure you configure the file to use a comma as a
delimiter between columns. Otherwise, your data will get corrupted
and any changes you make cannot be re-imported into a Machine
Edition project.
3. Click Save. The Export Variables dialog box appears.

Figure 11-13. Export Variable Dialog Box


4. Select the Target to export from. The default target is the currently
active target. Only variables from the specified target will be
exported.
5. Click OK. The variable definitions are saved in the selected file.

LADDER EDITOR OPTIONS


The following properties specify how ladder logic appears (online and
offline) and how editing operations are carried out.

To edit ladder logic options:

11 - 9
Ladder Logic Programming

1. In the Navigator, click the Options tab.


2. Click the Editors folder, then the Ladder folder.
3. Right-click an options page (for example Confirmations) then
choose Properties. The properties display in the Inspector window.
4. Modify the properties in the Inspector.

To restore any properties to their default values:


1. In the Navigator, click the Options tab.
2. Click the Ladder folder, then right-click one of the pages.
3. Choose Reset.

CONFIRMATIONS
These options specify which ladder editor operations require a
confirmation (that is, a message box appears each time the operation is
performed).

1. In the Navigator, click the Options tab.


2. Click the Editors folder, then the Ladder folder.
3. Right-click the Confirmations page, then choose Properties. The
Inspector appears.

In the Inspector, the following properties can be modified.

Note
To restore any Confirmations properties to their default values,
choose Reset from the right-click menu.
Changes: When True, a confirmation is required when you edit a
description and don't finish the operation by pressing ENTER or TAB
(that is, you click another item). When False (default), no confirmation
is required.
Deletions: When True, each deletion from a ladder program must be
confirmed by clicking OK on the Deletion dialog box. When False
(default), no confirmation is required.
New Variables: When True, each time a new variable is created in a
ladder program or the Control I/O tool (that is, when assigning
parameters to instructions or mapping to I/O terminals), it must be
confirmed by clicking OK on a confirmation dialog box. When False
(default), no confirmations are required.
Controller Actions: When True, each Controller access or command
must be confirmed by clicking OK on a confirmation dialog box.
When False (default), no confirmations are required.

11 - 10
Ladder Logic Programming

Undo Actions: When True, each ladder Editor Undo action must be
confirmed by clicking OK on a confirmation dialog box. When False
(default), no confirmations are required.

EDITING
These options specify the behavior of the ladder editor when inserting
rungs and instructions.

1. In the Navigator, click the Options tab.


2. Click the Editors folder, then the Ladder folder.

3. Right-click the Editing page, then choose Properties. The


Inspector appears.

In the Inspector, the following properties can be modified.


Auto-Edit New Instructions: (Logic Developer PC only) When True
(default), a smart List is opened upon insertion of an instruction,
ready to assign a parameter. When False, the instructions are simply
inserted; you are not prompted to assign parameters.
Append Rather Than Insert: When True (default), a new blank
column is inserted to the right of the selected column. When False, a
new blank column is inserted to the left of the selected column.

Note
A column is inserted as long as there is a blank one to the right
of the last instruction on the rung.
Auto-Replace: (Logic Developer - PC only) When True, typing will
automatically overwrite the currently selected item. For example, if a
parameter or description is selected and you begin to type, the
parameter or description will be replaced by what you type. If an
instruction is selected, the first parameter will be overwritten When
False (default), typing will have no effect on the currently selected
item, unless it is blank.
Undo Buffer Size: (Logic Developer - PLC only) Specifies the number
(default 10) of undo operations that can be performed. Valid range: 1-
100.

FONT AND COLORS


These options specify the type face and the size and color of various items
in a ladder program (online and offline).

1. In the Navigator, click the Options tab.


2. Click the Editors folder, then the Ladder folder.
3. Right-click the Font and Colors page, then choose Properties. The
Inspector appears.

11 - 11
Ladder Logic Programming

In the Inspector, the following properties can be modified.


Font: Specifies the font, font style, size and script displayed in a
ladder program.

In the Inspector, click +Font, and then click . The Font dialog
box appears where the following properties can be modified:
Font: Specifies the name of the font displayed in a ladder program
(default MS Serif).
Font style: Specifies the style of the font displayed in a ladder
program (default Regular).
Size: Specifies the size (pts) of the font displayed in a ladder program
(default 8 pts).
Script: Choose the appropriate script for the language being used on
your PC.
Background: Specifies the color (default white) of the background in a
ladder program.
Program Description: (Logic Developer - PC only) Specifies the color
(default green) of the program description text displayed in a ladder
program.
Rung Description: (Logic Developer - PC only) Specifies the color
(default purple) of the rung description text displayed in a ladder
program.
Parameter Description: Specifies the color (default black) of the
parameter (operand) descriptions displayed in the ladder program.
Linked Object Description: (Logic Developer - PC only) Specifies the
color (default blue) of the linked object descriptions displayed in a
ladder program.
Data Value: Specifies the color (default maroon) of the data value text
displayed in the ladder program.
Label: Specifies the color (default navy) of label and subroutine
names displayed in a ladder program.
Parameter: Specifies the color (default navy) of ladder instruction
parameters (operands) displayed in a ladder program.
I/O Address: Specifies the color (default gray) of I/O or reference
addresses displayed in a ladder program.
Forced States: Specifies the color (default red) of forced states
displayed in a ladder program.
Shunts and Borders: Specifies the color (default navy) of shunts and
borders displayed in a ladder program.

11 - 12
Ladder Logic Programming

Powered Rung: (Logic Developer - PC only) Specifies the color


(default green) of rungs receiving power, displayed in an online
ladder program.
Powered Rung Width: Specifies the width (default 3 pts) of rungs
receiving power, displayed in an online ladder program.
Modified Rung: Specifies the color (default fuchsia) of modified
rungs displayed in an online ladder program.
Modified Rung Width: (Logic Developer - PC only) Specifies the
width (default 3 pts) of modified rungs displayed in an online ladder
program.
Faulted Rung: (Logic Developer - PC only) Specifies the display color
(default red) of a rung on which a fault occurred in an online ladder
program.
Linked Object Background: Specifies the background color (default
light silver) of sections of logic that are linked to an fxClass.
Linked Object Foreground: Specifies the normal foreground color
(default navy) of sections of logic that are linked to an fxClass.
Instruction Background: (Logic Developer - PLC only) Specifies the
background color (default white) of ladder instructions.
Instruction Text: (Logic Developer - PLC only) Specifies the color
(default navy) of text on ladder instructions.
Comment Background: (Logic Developer - PLC only) Specifies the
background color (default white) of a comment bar in the LD editor.
Comment Text: (Logic Developer - PLC only) Specifies the color
(default green) of comment text in the LD editor.
Constant: Specifies the color (default blue) of constants in the LD
editor.
Control Background: (Logic Developer - PLC only) Specifies the
background color (default light yellow) of control elements such as
ENDMCR, LABEL in the LD editor.
Control Text: (Logic Developer - PLC only) Specifies the color
(default black) of text in control elements such as ENDMCR, LABEL
in the LD editor.
Rung Indicator: (Logic Developer - PLC only) Specifies the color
(default red) of the Rung Indicator line drawn around the 8th row and
10th column in the LD editor.

PSB Formal Reference. You can define up to seven input and up to


seven output formal parameters for a PSB. These parameters can be
used only in the LD logic inside the PSB for which they are defined.
For parameters to stand out in the LD logic, they can be assigned their

11 - 13
Ladder Logic Programming

own PSB formal reference color. Formal parameters are used just as
variable names are used in regular LD blocks.

VIEW
These options specify which items are displayed in a ladder program.

1. In the Navigator, click the Options tab.


2. Click the Editors folder, then the Ladder folder.

3. Right-click the View page, then choose Properties. The


Inspector appears.

In the Inspector, the following properties can be modified.


Program Description: (Logic Developer - PC only) When Tru e
(default), the program description is displayed at the beginning of a
ladder program. When False, the program description is hidden.
Rung Descriptions: (Logic Developer - PC only) When True (default),
rung descriptions are displayed above each rung in a ladder program.
When False, rung descriptions are hidden.
Variable Descriptions: When True (default), variable (or expression)
descriptions are displayed below ladder instructions that have a
parameter box at their top or on functions, below the operand. When
False, variable descriptions are hidden.
Linked Object Descriptions: (Logic Developer - PC only) When True
(default), linked object descriptions are displayed above linked logic
objects. When False, linked object descriptions are hidden.
Word-Wrap Descriptions: (Logic Developer - PC only) When True
(default), variable descriptions are formatted in a column (about the
width of an instruction) above the instructions the variables are
assigned to. When False, variable descriptions are displayed in a
single horizontal line.

11 - 14
Ladder Logic Programming

I/O Addresses:
Logic Developer – PC: When True (default), I/O addresses are
displayed in logic above variables and expressions that are mapped to
I/O terminals in the Control I/O window. When False, I/O addresses are
hidden.
Logic Developer – PLC: When True (default), reference addresses are
displayed in logic below operands that are mapped to them. When False,
addresses are hidden.
Forced States: (Logic Developer - PC only) When True (default), the state
of forced BOOL variables are displayed below variables and expressions
in logic. When False, forced states are hidden.
Parameters: When True (default), the parameters (operands) associated
with ladder instructions are displayed in logic. When False, the
parameters are hidden.
Data Values: When True (default), the values of instruction parameters
(operands) are displayed in logic. When False, values are hidden.
Power Flow: (Logic Developer - PC only) When True (default), the flow
of power displays in the logic for a ladder program online to a Controller.
When False, power flow does not display.
State Flow: When True, the state of BOOL instructions (coils, contacts)
are graphically indicated in the logic for a ladder program online to a
Controller. When False (default), state flow does not display.
Rung Indicator: (Logic Developer - PLC only) When True (default), the
8th row, 10th column rung indicator is displayed in the LD editor. When
False, the rung indicator is not visible.
Comment Mode: (Logic Developer - PLC only) When set to Full, entire
comment text is displayed. When set to Brief (default), abbreviated
comment text is displayed.
Description Mode: (Logic Developer - PLC only) When set to Full, four
lines are used for displaying a description. When set to Brief (default),
two lines of description text are displayed.
Operand Mode: (Logic Developer - PLC only) When set to Full, two lines
are used for operand name. When set to Brief (default), one line is used.
Coil Justification Column: (Logic Developer - PLC only) Specifies the
leftmost column in which coils can be placed. Default: 10. Valid range: 0 -
20. When you insert a coil to the left of the coil justification column, it is
moved over to the coil justification column and leading horizontal wires
link it to the cell you tried to insert it in. When you insert a coil to the
right of the coil justification column, it remains there and leading
horizontal wires link it to the left as required.

11 - 15
Ladder Logic Programming

Grid Cell Width: (Logic Developer - PLC only) Specifies the amount of
scaling (default 100%) applied to a cell's width. Increase this setting if
complete text does not fit within the cell it is in.

PRINTING
To print a ladder program:
1. Open a ladder program.
2. In the Navigator window, right click on the program file to be opened
and select Open.

Figure 11-14. Right-Click and Select Open

3. From the File menu, choose Print.

Figure 11-15. Choose File, Then Print

The Print dialog box appears.

11 - 16
Ladder Logic Programming

Figure 11-16. Print Dialog Box

4. Select which rungs to print.

Select All to print


all the rungs. Enter
the number of the
starting and ending
rungs in the from
and to boxes to
print a range of
rungs. If a rung was
selected in the
Ladder Editor
window, the option
to print only the
selected rung or
rungs is
highlighted. Figure 11-17. Print Selection Only is Highlighted

5. Click Options. The Logic Options dialog box opens.

Selecting Shrink to Fit will


force rungs to fit onto the size
paper that is being used as
opposed to wrapping around
to the next line on the page.

Selecting Show variable cross-


reference between rungs will
print the cross-reference
information in between each Figure 11-18. Logic Options Dialog Box
rung of logic that is printed.

6. Click the OK button on the Print dialog box to print the report.

11 - 17
Ladder Logic Programming

Lab Exercise – Using the Ladder Diagram


Editor and the Call Function
This exercise teaches how to use the Ladder Diagram editor to enter a
simple program using Relay Ladder Logic programming and how to use
the Call function to execute subroutines. It also shows how to enter
documentation text and how to modify the ladder logic offline and
online. The instructor will lead you through part of this exercise.

EDITING LADDER DIAGRAM LOGIC


1. In the Navigator window, right click on the + sign next to the LD
Blocks folder to expand it.

2. Right click on the _MAIN folder and select Open.

11 - 18
Ladder Logic Programming

The _MAIN Ladder Diagram (LD) is now open in the Editor window.

INSERTING LD INSTRUCTIONS INTO A RUNG


Basic Method
1. In the LD Editor, right-click the empty cell that will be the top-left cell
occupied by the new instruction and choose Place Instruction, or
click the empty cell that will be the top-left cell occupied by the new
instruction and then begin typing the instruction mnemonic.

In either case, a smart list appears prompting you to enter an


instruction mnemonic.

11 - 19
Ladder Logic Programming

2. Type or choose from the list the mnemonic NOCON for a normally
open contact.

Note
You do not need to type in the entire mnemonic. As soon as the
desired mnemonic is highlighted in the smart list, you can
press the TAB key or the Enter key to insert it.

3. Press the TAB key or the ENTER key.


The instruction appears in the LD logic.

11 - 20
Ladder Logic Programming

Toolbar Method of Inserting LD Instructions


1. Locate the Ladder Instructions toolbar.

If the Ladder
instructions toolbar isn’t
visible, click on the
Tools pull-down menu
and select Toolbars,
Logic Developer PLC.
The Ladder Instructions
Toolbar should now be visible.
2. Click the button on the Ladder Instructions toolbar to select a
normally open contact.
3. In the LD editor, click a cell that will be the top-left cell of the new
instruction.

The instruction corresponding to the selected toolbar button


appears in the LD logic.

4. Click the Pointer tool button or hit “Esc” to return to conventional


editing.

11 - 21
Ladder Logic Programming

Toolchest Method of Inserting LD Instructions


1. Open the Toolchest by clicking on the Toolchest icon on the overhead
toolbar.

The Toolchest window opens.

2. In the Toolchest, click on the arrow for the pull-down list and
select the PLC LD Instructions drawer from the list.
The drawer opens in the Toolchest window. Each folder in the
drawer contains several closely related instructions.

11 - 22
Ladder Logic Programming

3. Expand the folder named Contacts by clicking on the + sign next to it.

4. Select the NOCON instruction mnemonic hold down the left mouse
button and drag it to the the LD editor.

5. Drop the NOCON instruction on the cell that will be the top-left cell
for the new instruction by releasing the left mouse button.

11 - 23
Ladder Logic Programming

To duplicate an instruction:
1. In the LD editor, click the instruction you want to copy and then click
it again.
The instruction is highlighted in inverse video.

2. Click and, while holding down the


CTRL key, drag the instruction to its
new location.

3. When you release the left mouse button,the original instruction,


complete with operands, is duplicated in the new location,
overwriting anything that was present in the destination cells.

11 - 24
Ladder Logic Programming

To move an instruction:
5. In the LD editor, click the instruction you want to move and then click
it again.
The instruction will be highlighted in inverse video.

2. Drag the instruction to its new location.


When you release the left mouse button the original instruction,
complete with operands, appears in the new location, overwriting
anything that was present in the destination cells.

To replace an instruction:
1. Right click on the instruction to be replaced and choose Replace
Instruction.

A smart list appears prompting you to enter the mnemonic for the
replacement instruction.

11 - 25
Ladder Logic Programming

2. Type an instruction mnemonic or choose one from the list, and then
press ENTER or TAB.

The new instruction overwrites the original, retaining the original


operands if possible.

Notes
 You do not need to type in the complete name of the new
instruction. For example, if you type in AD, the smart list displays
ADD_DINT. If you then press ENTER, Logic Developer - PLC enters
ADD_DINT.
 When you replace an instruction with another of the same size and
with the same number of operands, the operands from the original
are automatically assigned to the replacement.
 When the original instruction has more operands than the
replacement, a disconnected operand is created for every unused
operand. Simply delete the disconnected operands.
 When the original instruction has fewer operands than the
replacement, the operands are assigned to the replacement starting

11 - 26
Ladder Logic Programming

with the first until all are used. The remaining operands on the
replacement are unassigned.
 You can type in the operands immediately after the instruction's
name (or the instruction's shorthand). Separate the instruction and
operands from each other with a space.

To Insert Horizontal and Vertical Wires:


Toolbar Method

On the Ladder Instruction toolbar, click the Horizontal/Vertical Wire


button.
In the LD editor, click a cell that you want a wire in. The orientation of
the wire placed depends on the orientation of the line in the mouse
pointer when you click.

Note
As you move the mouse pointer about the LD logic, the line in
the pointer changes between and to indicate the type of
wire that will be inserted.

Horizontal Line Vertical Line

Keyboard Method
1. In the LD editor, click a cell that you want to place a wire in.

2. Press CTRL + Arrow Key to place the wire. The wire is placed in the
direction of the arrow that was pressed. This method may take some
trial and error to become comfortable with it.

11 - 27
Ladder Logic Programming

Mouse Method
1. In the LD editor, right-click the end point of an existing wire or
operand terminal on a function (the starting point of your new wire).

2. Drag the mouse to the destination end point or operand terminal. A


temporary line appears indicating the connection.

3. Release the right mouse button. The two end points are now wired
together.

11 - 28
Ladder Logic Programming

To Insert and Edit a Comment:


1. In the LD editor, in a blank row, insert a COMMENT instruction by
clicking on the icon on the overhead toolbar.
A comment rung appears in the logic.

2. To edit an existing comment:


 Double-click the icon
 Right-click the icon and select Edit
 Click the icon and press ENTER.
The comment rung opens for editing.

Note
If you start typing, you will completely overwrite any existing
text in the comment.

3. In the box that appears, type the comment.

11 - 29
Ladder Logic Programming

4. To insert a line break in your comment text, press ENTER.

5. To edit an existing comment, place the cursor where you want to edit,
click and type.

6. To finish, click anywhere


outside the comment box.

To Insert a Blank Row:


1. In the LD editor, right-click a cell in the top row of a rung and choose
Insert Row.

A blank row is inserted above the cell you clicked.

11 - 30
Ladder Logic Programming

New Blank row

To insert a blank column within the rung that has the focus
cell in it:
1. Start with two contacts.
2. Click on the left most item.
3. In the LD editor, right-click any cell on a column and choose Insert
Column.

All existing cells in the current rung are shifted right or left by one
cell.

11 - 31
Ladder Logic Programming

Where the column is inserted (right or left of the selected cell) depends
upon the setting of the Append rather than insert property.
1. To set this property, select the Options tab in the Navigator window.

2. Expand the Editors folder by clicking on the + sign.

3. Expand the Ladder folder by clicking on the + sign and select Editing.

The editing properties are now visible in the Inspector window.

11 - 32
Ladder Logic Programming

4. Click in the field next to the Append rather than insert property to
view the pull-down list. This list allows you to select True or False.
If the Append rather than insert property is set to True, a new blank
column is inserted to the right of the cell you right-clicked on. If the
property is set to False, the blank column is inserted to the left of the
cell.
5. Select False.

6. Before proceeding, delete any rungs of logic that are in the _Main
ladder diagram. Select the rungs to be deleted by clicking the left
mouse button on the first rung and dragging down across all rungs to
be deleted. Then, right click on the selected rungs and select Delete
from the menu.

11 - 33
Ladder Logic Programming

OFFLINE PROGRAMMING
By now you should know how to determine if you are online or offline
and you should be able to enter a simple rung of logic.
1. After making sure that you are offline, enter the following rung of logic.
Ask the instructor if you need help.

2. Next, double click on the first normally open contact instruction to


open the variable editor window.

3. In the top window, type in the variable name Stop_PB1.

4. Press the Enter key. The variable Stop_PB1 has now been assigned to
the first normally open contact.

11 - 34
Ladder Logic Programming

5. Enter the rest of the variables for the rung so that they match the
picture below.

6. The next step is to assign a PLC reference address to each of the


variables used. Select the first instruction in the rung, labeled
Stop_PB1, by clicking on it.

7. The properties of this instruction can now be viewed in the Inspector


window. The reference address field appears in red with a line
through it. This is because no reference address has been assigned yet.
8. Click in the blank field next to Ref Address.

11 - 35
Ladder Logic Programming

9 There are two ways to assign a reference address to this instruction.


The first is to simply type the address into the blank field and press
the Enter key. Type in %I00001 as the address. This assigns the
address to the instruction.

The second way to assign a reference address is to click on the


button next to the blank field. This opens the Reference Address
Wizard.

10. Click on the arrow next to the field labeled Memory Area and select I-
Discrete Input.

11. In the field labeled Offset, the actual address number can be entered.
Enter 1 as the address and click the OK button. The result is the same
as with the first method (see #8 above).

11 - 36
Ladder Logic Programming

12. Next, enter addresses for the rest of the instructions in the rung to
match the picture below. Use either of the two methods shown
above.

13. Next, right click on the target, My PLC, and select Go Online.

14. Download the rung of logic to the PLC. Right click on the target, My
PLC, and select Download to PLC.

15. From the Options list, select Logic.

11 - 37
Ladder Logic Programming

16. Right click on the target, My PLC, and select Online Commands,
Start PLC.

17. Verify that the logic is operating by turning on the first two switches
on the simulator module in the Series 90-30 rack. This should cause
the first output on the discrete output module to turn on.
18. After verifying that the logic is working properly, turn off all switches
on the simulator module.

ONLINE PROGRAMMING
Caution
Programming changes can be made while online. However, the user
needs to exercise caution when making online programming changes.
Familiarity with the logic and the equipment that is being controlled is
very important to ensure that the changes do not cause damage to
equipment or injury to persons working with the equipment.
1. Change the first instruction in the rung, labeled Stop_PB1, from a
normally open contact to a normally closed contact. From the
overhead toolbar, select a normally closed contact.

11 - 38
Ladder Logic Programming

2. Click on the first instruction in the rung, labeled Stop_PB1, to replace it


with the newly selected instruction. The message below appears.
Selecting Yes will apply the change to the PLC immediately. Selecting
No will only apply the
change to the logic in the
editor and the change will
have to be applied to the
PLC later. Click on the Yes
button.
The logic now appears as
below.

SUBROUTINES AND THE CALL FUNCTION


Logic can be saved in LD blocks that are separate from the _Main LD
block. Any logic that is not contained in the _Main LD block is considered
to be a subroutine. There are several reasons for using subroutines, some
are listed below:
 Logic that is not required all the time can be placed in a subroutine
and “called” only when it is needed.
 Logic that needs to be repeated more than once during a program scan
can be placed in a subroutine and “called” as often as needed from the
_Main LD block.
 Logic can be placed in a subroutine and only “called” when certain
conditions exist.
 Some programmers prefer to organize all their logic in separate LD
blocks and then “call” these blocks from the _Main LD block. This
sometimes makes it easier to find specific portions of logic, especially
when troubleshooting.

11 - 39
Ladder Logic Programming

Whatever the reason for using subroutines, the Call function is the
instruction used to enable the logic contained in a subroutine. Before a
“call” to an LD block can be made, the block must exist.
1. First, right click on the Target and select Go Offline.
2. To create a new LD block, right click on the LD Blocks folder in the
Navigator and select New.

3. Type in Sub_1 as the name of the new LD block.

4. Double click on the Sub_1 LD block to open it in the Editor.

11 - 40
Ladder Logic Programming

5. Enter a rung of logic in the Sub_1 LD block like the picture below.

6. Next, in the Navigator window, select the Variables tab.

The Navigator window now shows the list of variables that have been
created so far.

7. Click on the variable labeled Stop_PB1 and, while holding down the
left mouse button, drag and drop it on the first instruction of the new
rung that was just created.

….to here.

Drag from here…

11 - 41
Ladder Logic Programming

8. The variable and the address are now assigned to the instruction.
Drag and drop variables for the other inputs like in the picture below.
Do not address the output yet.

9. Next, name the output instruction Motor_2 and address it as


%Q00002.

Now you have a rung of logic in the Sub_1 LD block. However, this
logic cannot execute unless the LD block is “called”. A rung using
the Call function needs to be programmed into the _Main LD block
to enable this.
10. Click on tab for the _Main LD block in the Editor.

The Call function can be programmed as an  unconditional rung or


logic that allows it to be enabled and disabled can precede it.

11 - 42
Ladder Logic Programming

Use a normally open contact ahead of the Call function so that it can be
enabled and disabled. Place a normally open contact in the next rung as
in the picture below.

11. Next, from the overhead toolbar, select the Call instruction.

12. Click in the space to the right of the normally open contact that was
just inserted to insert a Call instruction.

13. Press the Enter key then select the block to be called. Select the Sub_1
block and press the Enter key again.

11 - 43
Ladder Logic Programming

Sub_1 has been assigned as the LD block to be called whenever a


true logic condition exists for this rung.

14. Next, assign an internal discrete address to the normally open contact
ahead of the Call instruction. This will allow you to enable and
disable the rung by turning the contact on and off while online. Give
the instruction the variable name En_Sub_1 and address it as
%M00001 as in the picture below.

15. Next, go online, download the logic to the PLC. While online, turn on
the first two switches on
the input simulator
module. The logic in the
_Main LD block should
show that output
%Q00001 is now on and
the first output light on
the output simulator
module should be on.

The logic in the Sub_1 LD block should show the two inputs as being
on. However, output %Q00002 should be off as in the picture below.
This is because the logic on the rung containing the Call instruction in
the _Main LD block is false.

11 - 44
Ladder Logic Programming

16. Go to the _Main LD block and


right click on the normally open
contact labeled En_Sub_1 and
select Turn ON.

17. Next, go back to the Sub_1 LD block editor window. The output
labeled Motor_2 should now be on and the second light on the output
simulator module should also be on.

The logic in the subroutine will continue to be scanned and executed as


long as the rung containing the Call instruction remains true. If the logic
on the Call rung goes false, then the processor ignores the logic in the
subroutine.
When the CALL function receives power flow (a true condition), it causes
the scan to go immediately to the designated subroutine LD block and
execute it. After the subroutine block execution is complete, control
returns to the point in the logic immediately following the CALL
instruction.

11 - 45
Ladder Logic Programming

Review
In this module you have learned how to:
 Enter a simple program using the Relay Ladder Logic (RLL)
programming language;
 Assign addresses and variables to the program elements;
 Document the program;
 Make offline and online changes to the program;
 Use the “Call” function to execute Ladder Diagram (LD) Blocks
(Subroutines);
 Configure the Ladder Diagram Editor options;
 Print out the ladder diagram.

11 - 46

You might also like