Professional Documents
Culture Documents
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.
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
11 - 3
Ladder Logic Programming
A B Y
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
%I00003
91896
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.
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.
11 - 6
Ladder Logic Programming
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
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.
11 - 9
Ladder Logic Programming
CONFIRMATIONS
These options specify which ladder editor operations require a
confirmation (that is, a message box appears each time the operation is
performed).
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.
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.
11 - 11
Ladder Logic Programming
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
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.
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.
11 - 16
Ladder Logic Programming
6. Click the OK button on the Print dialog box to print the report.
11 - 17
Ladder Logic Programming
11 - 18
Ladder Logic Programming
The _MAIN Ladder Diagram (LD) is now open in the Editor window.
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.
11 - 20
Ladder Logic Programming
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.
11 - 21
Ladder Logic Programming
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.
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.
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.
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.
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.
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).
3. Release the right mouse button. The two end points are now wired
together.
11 - 28
Ladder Logic Programming
Note
If you start typing, you will completely overwrite any existing
text in the comment.
11 - 29
Ladder Logic Programming
5. To edit an existing comment, place the cursor where you want to edit,
click and type.
11 - 30
Ladder Logic Programming
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.
3. Expand the Ladder folder by clicking on the + sign and select Editing.
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.
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.
11 - 35
Ladder Logic Programming
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.
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
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.
11 - 40
Ladder Logic Programming
5. Enter a rung of logic in the Sub_1 LD block like the picture below.
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.
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.
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.
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
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
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.
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