Introduction
A PLC programming device can be:
Programming PLCs A hand-held device
(Introduction) A desktop console
A computer
Hand-held device: contains enough memory to allow the unit to
retain programs while being carried from one place to another
1/22/2021 PLC Programming 2
Introduction… Introduction…
Desktop Consoles: have a visual display unit with a keyboard
1/22/2021 PLC Programming 3 1/22/2021 PLC Programming 4
1
Introduction… Introduction…
Personal Computers:
PCs should have appropriate software
need for special communications cards to interface with the
PLC
PCs provide a much bigger memory
1/22/2021 PLC Programming 5 1/22/2021 PLC Programming 6
PLC Brands PLC Brands…
PLC Manufacturers have programming software for their PLCs: Provides offline simulation for all PLC types
Mitsubishi have MELSOFT GX Developer: MELSOFT supports programming methods such as:
Their GX developer supports all MELSEC controllers from the Instruction List (IL)
compact PLCs of the MELSEC FX series to modular PLCs Ladder Diagram (LAD/LD)
including MELSEC system Q and uses a Windows based Sequential Function Chart (SFC)
environment
The package consists of powerful editors and diagnostics
functions for configuring MELSEC networks and hardware
Consists of extensive monitoring and testing functions
1/22/2021 PLC Programming 7 1/22/2021 PLC Programming 8
2
PLC Brands… PLC Brands…
Siemens have SIMATIC STEP 7 that provides: SIMATIC STEP 7 supports different programming methods:
System diagnostic capabilities Ladder Diagram (LAD)
Process diagnostic tools Function Block Diagram (FBD)
Remote maintenance Instruction List (IL)
Plant documentation Structured Text (ST)
Sequential Function Chart (SFC)
1/22/2021 PLC Programming 9 1/22/2021 PLC Programming 10
PLC Brands… Ladder Programming
Other manufacturers include: Programs for microprocessor-based systems have to be loaded in
Rockell Automation have RSLogix machine code
Allen Bradley
GE Fanuc When assembly language is used, an assembler is used to translate
Horner Electric mnemonics into machine code
Telemechanique
High level languages may be used as well – a compiler is necessary
1/22/2021 PLC Programming 11 1/22/2021 PLC Programming 12
3
Ladder Programming… Ladder Diagrams
Ladder programming provides a means of writing programs which Consider a simple circuit for switching on or off an electronic
can then be converted into machine code by some software for use motor
by the PLC microprocessor
International Electro-technical Commission (IEC 1131-3) specifies
the following programming languages:
Ladder Diagrams (LAD)
Instruction List (IL)
Sequential Function Block (SFC)
Structured Text (ST)
1/22/2021 PLC Programming 13 1/22/2021 PLC Programming 14
Function Block Diagrams
Ladder Diagrams… Ladder Diagrams…
The ladder diagram of the above circuit is as shown below: The two vertical lines represent the input power rails
The power rails are like the vertical sides of a ladder with the
horizontal circuit lines like the rungs of the ladder
The emphasis is on clearly showing how the control is exercised
1/22/2021 PLC Programming 15 1/22/2021 PLC Programming 16
4
Ladder Diagrams… Ladder Diagrams…
The figure below shows a ladder diagram for a circuit that is used In the normal state:
to start and stop a motor using push buttons Push button 1 is open
Push button 2 is closed
When button 1 is pressed the motor circuit is completed and the
motor starts Also, the holding contacts wired in parallel with the
motor close and remain closed as long as the motor is running
When push button 1 is released the holding contacts maintain the
circuit and hence the power to the motor
1/22/2021 PLC Programming 17 1/22/2021 PLC Programming 18
Ladder Diagrams… Conventions for Drawing Ladder Diagrams
To stop the motor, button 2 is released hence disconnecting power vertical lines of the diagram represent the power rails between
to the motor and the holding contacts open which circuits are connected. The power flow is taken to be from
the left-hand vertical across a rung
The motor is therefore started by pressing button 1 and stopped by each rung on the ladder defines one operation in the control
pressing button 2 process
a ladder diagram is read from left to right and from top to bottom
When the PLC is in its run mode, it goes through the entire ladder
program to the end, the end rung of the program being clearly
denoted, and then promptly resumes at the start
1/22/2021 PLC Programming 19 1/22/2021 PLC Programming 20
5
Conventions for Drawing Ladder Diagrams… Conventions for Drawing Ladder Diagrams…
This procedure of going through all the rungs of the program is
termed a cycle
The end rung might be indicated by a block with the word END or
RET, for return, since the program promptly returns to its
beginning
The scan time depends on the number of rungs in the program,
taking about 1ms per 1000 bytes of program and so typically
ranging from about 10ms up to 50ms
1/22/2021 PLC Programming 21 1/22/2021 PLC Programming 22
Conventions for Drawing Ladder Diagrams… Conventions for Drawing Ladder Diagrams…
each rung must start with an input or inputs and must end with at a particular device can appear in more than one rung of a ladder.
least one output: For example, we might have a relay that switches on one or more
Input: is used for a control action, such as closing the contacts devices. The same letters and/or numbers are used to label the
of a switch device in each situation
Output: is used for a device connected to the output of a PLC,
such as a motor the inputs and outputs are all identified by their addresses; the
electrical devices are shown in their normal condition. Thus a notation used depends on the PLC manufacturer. This is the
switch that is normally open until some object closes it is shown as address of the input or output in the memory of the PLC
open on the ladder diagram. A switch that is normally closed is
1/22/2021 PLC Programming 23 1/22/2021 PLC Programming 24
shown closed.
6
PLC Scan Cycle PLC Scan Cycle…
1/22/2021 PLC Programming 25 1/22/2021 PLC Programming 26
PLC Scan Cycle… PLC Scan Cycle…
A PLC works by continuously scanning a program
The scan cycle consists of three major steps:
Check input status
Execute program
Update output status
1/22/2021 PLC Programming 27 1/22/2021 PLC Programming 28
7
PLC Scan Cycle… PLC Scan Cycle…
1/22/2021 PLC Programming 29 1/22/2021 PLC Programming 30
PLC Scan Cycle… PLC Scan Cycle…
Because the inputs can change at anytime, it constantly repeats this House Keeping: perform internal checks on memory, speed and
cycle as long as the PLC is in the RUN mode operation. Service any communications requests.
The PLC also carries out some housekeeping duties The time it takes to complete a scan cycle is called the scan cycle
Input Scan: the status of external inputs is written to the input time and indicates how fast the controller can react to changes in
image table inputs
Program Scan: each ladder rung is scanned and solved. The The time required to make a single scan can vary from about 1ms
resulting logic is written to the output image table to 20ms
Output Scan: the output image data is transferred to the external
output circuits, turning the output device ON/OFF
1/22/2021 PLC Programming 31 1/22/2021 PLC Programming 32
8
PLC Scan Cycle… PLC Scan Cycle…
If the controller has to react to an input signal that changes states For each rung executed, the PLC processor will:
twice during the scan time, it is possible that the PLC will never be Examine the status of the input image table bits
able to detect this change. Solve the ladder logic in order to determine logical continuity
The scan time is a function of the following: Update the appropriate output image table bits, if necessary
Speed of the processor module Copy the output image table status to all the output terminals.
The length of the ladder program Power is applied to the output device if the output image table
The type of instruction executed bit has been previously set to a 1
The actual ladder true/false condition Copy the status of all the input terminals to the input image
table. If an input is active, the corresponding bit in the input
1/22/2021 PLC Programming 33 1/22/2021 PLC Programming 34
image table will be set to a 1
PLC Scan Cycle… PLC Scan Cycle…
1/22/2021 PLC Programming 35 1/22/2021 PLC Programming 36
9
PLC Scan Cycle… PLC Scan Cycle…
1/22/2021 PLC Programming 37 1/22/2021 PLC Programming 38
PLC Scan Cycle… Standard IEC 1131-3 Symbols
Below are the standard IEC 1131-3 symbols that are used for input
and output devices
1/22/2021 PLC Programming 39 1/22/2021 PLC Programming 40
10
Standard IEC 1131-3 Symbols… Example 1
Some slight variations occur between the symbols when used in Consider a situation where the energizing of an output device
semigraphic form and when in full graphic, the semigraphic form depends on a normally open start switch being activated by being
being the one created by simply typing using the normal keyboard, closed
whereas the graphic form is the result of using drawing tools
1/22/2021 PLC Programming 41 1/22/2021 PLC Programming 42
Example 1… Example 1…
In drawing ladder diagrams the names of associated variable or The more descriptive the name, the better, such as pump motor
addresses of each element are appended to its symbol control switch rather than just input, and pump motor rather than
just output.
1/22/2021 PLC Programming 43 1/22/2021 PLC Programming 44
11
Example 2 Example 3
If there had been a normally closed switch with the output there Suppose we have a hydraulic unit and we wish to give a “Healthy
would have been an output until that switch was opened. Only Lamp” indication when:
while there was no input to the contacts would there have been an The pump is running: sensed by an auxiliary contact on the
output pump starter
There is oil in the tank – sensed by a level switch which
closes when the switch is covered
There is oil pressure – sensed by a pressure switch which
makes for adequate pressure
1/22/2021 PLC Programming 45 1/22/2021 PLC Programming 46
Example 3…
END
1/22/2021 PLC Programming 47 1/22/2021 PLC Programming 48
12