You are on page 1of 140

PLC Basics

CONTENTS
1. What is PLC?
2. Principle of PLC operation and their
functions
3. PLC hardware components
4. PLC hardware and software training of
SIMATIC S7 300
5. Practical installation and programming
exercises and tests
1. What is PLC
Programmable Logic Controller
Hardware and software components
Hardware is selected and installed
Hardware configured
Program designed and prepared as per
installation
Downloaded
Edited
Set to a preferred mode
2. Principle of PLC Operation
Hardware is selected and installed
User program programmed using PC and interfacing
cables and downloaded to PLC CPU
Cyclically execute user program
Reads inputs at input address called PII (process input
images)
Evaluates the logic program using the input values
Writes result of logic operation (RLO) to the output
addresses called process output images(PIQ).
External circuit and signal modules copy these PII and
wait for CPU to read in to its internal memory
External circuit and signal modules copy PIQ and
transfer to activate an external actuator
3. PLC hardware components

Can have:
Power supply module (PS)
CPU: ALU, Control unit, memory, I/O and
control bus
Signal Modules(SM): Digital and Analog.
Rack
Interfacing Modules(IM)
Communication processor(CP)
4. PLC hardware and software
training of SIMATIC S7 300
SIMATIC S7 PLC is the most advanced
and widely used PLC by SIEMENS
SIMATIC S5 Family
SIMATIC S7 Family
S7 PLC RANGE

S7-200
S7-400
S7-400
S7-200

S7-300
S7-300
S7-200

EM 221

SIEMENS SF I0.0 I1.0 Q0.0 Q1.0 CPU 214 DI 8 x DC24V


RUN I0.1 I1.1 Q0.1 Q1.1 I.0
STOP I0.2 I1.2 Q0.2 I.1
I0.3 I1.3 Q0.3 I.2
I0.4 I1.4 Q0.4 I.3
I0.5 I1.5 Q0.5 I.4
I0.6 Q0.6 I.5
I0.7 Q0.7
I.6
SIMATIC
I.7
S7-200
S7-300
S7-300: Modules

PS CPU IM SM: SM: SM: SM: FM: CP:


DI DO AI AO - Counting - Point-to-Point
- Positioning
- PROFIBUS (L2)
- Closed-loop
- Industrial Ethernet
control
S7-300: CPU Design
SIEMENS CPU314 SIEMENS CPU315-2 DP

SF SF SF DP
BATF BATF BUSF
DC5V DC5V
FRCE FRCE
RUN RUN
STOP STOP
RUN-P RUN-P
RUN RUN
STOP STOP
M RES M RES

SIMATIC SIMATIC
S7-300 S7-300
Battery MPI Battery MPI DP
S7-400
S7-400: Modules

PS CPU SM: SM: SM: SM: CP FM SM IM


DI DO AI AO
S7- 400: CPU Design (Part 1)

Mode Selector Switch

Example CPU414-1 Example CPU414-2DP


S7-400: CPU Design (Part 2)

Fault LEDs

Slot for Memory


Card

MPI Interface

DP Interface

External Battery
Supply
Memory Concept of the S7-
300 Load
Blocks:
memory:
Logic
blocks
Symb
(OB,FC,FB)
ols
Comme Work Data
nts OB,FC,FB
blocks
memory:
Blocks:
Logic (DB) DB
n. reten.
blocks Additional
reten.

with info.
System
(OB,FB,FC) Power PII, PIQ
memory:
Data ON M, T,
n. reten.
blocks without C reten. When
Blocks: battery Power
(DB)
Logic backup Retentive OFF
blocks Flash EPROM Retentive
memory: without
Memory Card M, T, C battery
(OB,FB,FC) in PG Retent. data backup
Data (once blocks
blocks programmed
Memory Concept of the S7-
400 Load
Blocks:
memory:
Logic
blocks
Comme (OB,FC,FB)
nts
Symbols Work Data

blocks
memory:
Blocks:
OB,FC,FB
(DB)
Logic
blocks Additional
DB Backu
info
System p
(OB,FC,FB) PII,
memory: via
Data PIQ batter
blocks M, T, y
Blocks: C
(DB)
Logic
blocks Flash EPROM
Memory Card
(OB,FC,FB) in PG
Data (subsequentl
blocks y inserted in
Loading Blocks into /out of Flash EPROM Memory Card

"Load from hard disk to FEPROM"


Load memory
Flash EPROM

After inserting
Download Load " Load memory the memory
internal RAM card:
Do a memory
"Load program back to PG" reset after
Sections
relevant
which the
for system copies
execution
the info into
the Work
Work memory
memory.
RAM
The Simatic Manager

Simatic

Manager
STEP 7 Project Structure
Starting the SIMATIC
Manager

or
SIMATIC Manager Menus and
Toolbars
Titlebar

Menubar

Toolbar

Statusbar

Taskbar
Creating an S7 Project

Enter project
name here
and confirm
with "OK"
Inserting an S7 Program
Offline / Online View in the SIMATIC
Manager
Standard Libraries
Hardware Configuration

Hardware

Configuration
Insert a Hardware Station
Starting The HW
Configuration
Generating a Hardware Setpoint
Configuration
Module Address Overview

Address Overview
Variable Slot Addressing

2x
HW Config: Edit Symbols,
Monitor/Modify Variables

1x right
CPU Properties: Cycle / Clock
Memory

Clock Memory Bit 7 6 5 4 3 2 1 0

Frequency (Hz) 0.5 0.62 1 1.25 2 2.5 5 10

Period (s) 2 1.6 1 0.8 0.5 0.4 0.2 0.1


Load and Transfer
MEMORY AREAS
MEMORY AREAS

Load Transfer
ACCUMULATOR 1
PII
PIQ
Peripheral Inputs PIQ
Memory Bit Area Peripheral Outputs
Timer Memory bit area
Counter ACCUMULATOR 2 Data Blocks, etc.
Data Blocks,etc.
Load Operation
Program
Accumulator 1 Accumulator 2
A B B A C D D C F F F F F F F F

L W#16#A1C2 0 0 0 0 A
0 0
1 C
0 0
2 A B B A C D D C

L W#16#14CF 0 0 0 0 0
1 0
4 C
0 0
F 0 0 0 0 A 1 C 2
Loading and Transferring
Data
Program
31 23
Contents of ACCU1

15 7 0

L MB 60 000000000000000000000000 MB60

31 23 15 7 0

Load L MW 60 0000000000000000 MB60 MB61

31 23 15 7 0

L MD 60 MB60 MB61 MB62 MB63

T QD 4
QD 4

Transfer T QW 4
QW 4

T QB 4
QB 4
S7 Blocks Types

OBs DBs

Organization Data
Blocks Blocks
FBs

Function
Blocks

FCs

Functions
Types of Blocks

Operatin OB
FC FB FC
g
System Organization
Blocks

FB FC SFC

DB DB
Inserting an S7 Block
The STEP7 Programming
Formats FBD
Function Block Diagram

I 3.0 &
Q7.5
LAD I 3.1 =
Ladder Diagram

I 3.0 I 3.1 Q7.5

STL
Statement List
A I 3.0
A I 3.1
= Q7.5
Starting the LAD/STL/FBD
Editor
2x
Selecting the Programming
Formats
Programming in LAD/FBD
Saving a Block
Downloading Blocks into the
PLC

Select the required blocks and click


on the download icon
Calling a Block in OB1
Digital Operations
CCoo
mmpp
aarra
attoo
rrss
Time
rs rs
u n t e
Co
S5 Counters in STEP 7
FBD LAD STL

C35 C35 A I1.4


S_CUD S_CUD CU C35
I 1.4 Q 9.6
I 1.4 CU CU Q
Q A I1.5
CD C35
I 1.5
I 1.5 CD CD A I1.3
I 1.3 L C#90
I 1.3 S CV MW 8 S S C35
A I1.7
C#90 PV CV_BC QW 10 C#90 PV CV MW 8
D Q 9.6 R C35
I 1.7
I 1.7 R QQ = R CV_B QW 10 L C35
CD T MW8
LC C35
T QW10
A C35
= Q9.6
Counters: Bit Instructions
LAD FBD STL

Network 1 Network 1 C5 Network 1

I 0.0 C5 I 0.0 SC
A I 0.0
S L C#20
C# CV S C5
C
C# 20
Network 2 20 Network 2 Network 2

I 0.1 C5 C5
I 0.1 C A I 0.1
C CU C5
U U
Network 3 Network 3 Network 3

I 0.2 C5 C5 A I 0.2
C I 0.2 C CD C5
D D
Network 4 Networ Network 4
k4
C5 Q 4.0 Q 4.0 A C5
C5 = = Q
4.0
Timers: Pulse (SP)
FBD LAD STL

T14 T4 A I 3.7
S_PULSE I 3.7 S_PULSE Q10.5 L S5T#45s
I 3.7 S BI MW32 S Q
SP T14
S5T#45sTV BCD QW12 S5T#45s TV BI MW32
MW0
Q10.5 A I 3.5
I 3.5
I 3.5 R Q = R BCD QW12 R T14
L T14
T MW32
RLO at LC T14
S input T QW12
RLO at
R input A T14
Timer = Q10.5
Timing out operati
on
Q of
timer
Minimum time=S5T#10ms
Data type S5TIME Maximum time=S5T#2h46m30s
Timers: Extended Pulse (SE)
FB LAD STL
D
T14 T14
A I 3.7
S_PEXT I 3.7 S_PEXT Q10.5 L
S Q S5T#45s
I 3.7 S BI MW32 SE T14
S5T#45sTV BCD QW12 S5T#45s TV BI MW32
A10.5 I 3.5 A I 3.5
I 3.5 R Q = R BCD QW12 R T14
L T14
T MW32
RLO at
LC T14
S input
RLO at T QW12
R A T14
Timing out Timer
input = Q10.5
Operat
ion
Q of
Timer
Timers: ON Delay (SD)
T14 T14
S_ODT I 3.7 S_ODT AI 3.7
Q10.5 LS5T#45s
I 3.7 S BI MW32 S Q
S5T#45sTV BCD QW12 S5T#45s TV BI MW32 SD T14
Q10.5 I 3.5 AI 3.5
I 3.5 R Q = R BCD QW12 R T14
L T14
T MW32
RLO at LC T14
I(S)
RLO at T QW12
A T14
(R)
Timer = Q10.5

operati
on
Q of
Timer
Timers: Lathching ON Delay (SS)
FBD LAD STL

T14 T14 A I 3.7


S_ODTS I 3.7 S_ODTS Q10.5 L S5T#45s
I 3.7 S BI MW32 S Q
SS T14
S5T#45sTV BCD QW12 S5T#45s TV BI MW32
Q10.5 A I 3.5
I 3.5
I 3.5 R Q = R BCD QW12 R T14
L T14
T MW32
RLO at LC T14
S input T QW12
RLO at
R input A T14
Timer = Q10.5
Timing out
operati
on
Q of
Timer
Timers: OFF Delay (SF)
FBD LAD STL
T14 T14 A I 3.7
S_OFFDT I 3.7 S_OFFDT Q10.5 L
I 3.7 S BI MW32 S Q
S5T#45s
S5T#45sTV BCD QW12 S5T#45s TV BI MW32
Q10.5 SF T14
I 3.5
I 3.5 R Q = R BCD QW12 A I 3.5
R T14
L T14
RLO at T
S MW32
RLO at
input LC T14
R input
Timer T
Timing out operati QW12
on A T14
Q of =
timer Q10.5
Timers: Bit Instructions
FBD LAD STL

Network 1: Network 1: Network 1:


T14
I 3.0 & SP I 3.0 T14 A I 3.0
S L S5T#45s
S5T# TV P SP T14
45s S5T#
Network 2: Network 2:
45s Network 2:

Q 8.7 T14 Q 8.7 A T14


T14 & = = Q 8.7

Network 3: Network 3: Network 3:


T14 I 3.1 T14 A I 3.1
I 3.1 & R R R T14
Comparison Operations
LAD FBD STL

M0.0 CMP ==D Q 9.7 CMP ==D A M0.0


A(
L I D0
I D0 IN1
L I D2
I D0 IN1
==D
I D2 IN2 I D2 IN2 )
Q9.7
& = Q9.7
=
M0.0
Up Down Counter
PULSE
& CU
O
GEN. CV
& CD
1 Hz FREQ.
CV_BCD MW
Comp==I
OR Q IN
1 S
IB IN2
Q
OR
Program Control Instructions

CC
CALL

UC
BEC BEU
Calling a Block
Calling a Block
Unconditionally
Calling a Block Conditionally
Block End Unconditional
Block End Conditional
STEP7 Faultfinding and
Error Recovery(1)
ERROR
Error
PLC STOP PLC RUN

Faultfinding Tools: Faultfinding Tools:

Diagnostic Buffer Debug Monitor


Diagnostic Buffer
Interrupt Stack Monitor Variables
Interrupt Stack
Block Stack Modify Variables
Block Stack
Reference Data
STEP7 Faultfinding and
Error Recovery(2)
ERROR
Error
PLC STOP PLC RUN

Faultfinding Tools: Faultfinding Tools:

Diagnostic Buffer Debug Monitor


Diagnostic Buffer
Interrupt Stack Monitor Variables
Interrupt Stack
Block Stack Modify Variables
Block Stack
Reference Data
Debugging Tools and Error
Types
Error

Error detected by the System: Functional fault:


CPU in STOP CPU in RUN
(e.g. accessing a non-existent DB) (process fault) or
(programming error)

Debugging Tools: Debugging Tools:


Module Information Enable Peripheral Outputs
- Diagnostic buffer (modify outputs)
- I STACK Monitor / Modify Variable
- B STACK Monitor Blocks (Debug Monito
- L STACK Reference Data
Hardware Diagnostics
Testing Blocks: Debug
Monitor"
Information Displayed with
"Block Debug
LAD/STL/FBD Editor -> Options
->Customize
> Monitor"
... or
in running status:
right mouse click
on
Displaying CPU Messages
The "Module Information"
Tool
SIMATIC Manager LAD/STL/FBD
Editor

Module Information
Module Information :
"Diagnostic Buffer"
Analysing Error Messages in
the Diagnostic Buffer
Opening an Error Block
Diagnostics with I Stack, B
Stack, L Stack
Program structure Block containing error

Interruption point

The B stack shows a list of the


blocks that were executed in sequence
Point of interruption
Up to the point of interruption.

The contents of the


accumulators,
registers, status word
etc. at the time of
interruption are in the
B Stack Screen
I Stack Screen
L Stack Screen
Display the Hardware Diagnostics of a Module

twice
The "Monitor/Modify
Variables" Tool
Trigger Point Options
PII

Trigger point
Start of Scan
Cycle" Monitor / Modify
Update Status / Modify
Set
according to Values (once only
Trigger
trigger setting monitor / modify)
Cyclic
program
execution Trigger point
"Transition to
STOP"

Trigger point
"End of Scan
Cycle"
PIQ
Setting Up Connections to
the CPU
Modifying Outputs in the
Stop State
Overwriting Variables using
"Force"
Reference Data
Reference: Program
Structure
Displaying Cross References
Filtering the Cross
References List
Block Correction from the
Cross References screen

twice
Go To Location

1x right
Reference Data: "Find"
Assignment of I, Q, M, T, C
Unused Symbols /
Addresses without Symbols
Rewire
Front connector the User Program
FC 20
signal module
A I 8.4
. "old" program
.
.
Faulty Input .
I 8.4 AN I 8.4

Rewire
Spare Input FC 20
I 9.0
A I 9.0
. "new" program
.
.
.
AN I 9.0
Rewiring with the SIMATIC
Manager
Comparing Blocks (1)

SEE SCREEN
ON THE NEXT PAGE
Comparing Blocks (2)
System Information
SC
CY AN
O RY C
MEM TIM LE
E

CPU
MODULE
INFORMATION

PE
RF DAT
SY IME
EM

OR A
ST

MA
T

NC
E
System Information -
Overview
Module Information:
Memory " Tab
Module Information: "Scan
Cycle Time" Tab
Module Information: "Time
System" Tab
Setting the Real Time Clock
Select from the SIMATIC
Set DateManager the
and Time
menu options PLC
Module Information:
"Performance Data" Tab
Performance Data: Blocks
"Block Folder Properties:
OFFLINE

Click right
mouse
Symbols
Absolute Addressing
A I 5.0

Symbolic Addressing
Start
Absolute and Symbolic
A I 10.0
Addressing
A START 1"
= Q18.0 = MOTOR 1
RUN"
A I 10.4
A START 2"
= Q28.5
= "MOTOR 2
Call FC54
RUN"
Call MOTOR CTL"
Symbol Address Data Comment
MOTOR 1 Q18.0 Type
BOOL Motor 1 belt
RUN forward
FC18 FC18
MOTOR CTL Motor control block
I 10.0 BOOL
START 1 Switch to start
Q28.5 BOOL
MOTOR 2 motor forward
I 10.4 BOOL
RUN
(max. 24 Motor 2 80
(max. belt
characters) reverse
characters)
START 2
Switch to start
Opening the Symbol Table
Edit: Find and Replace
View: Filter
View: Sort
Symbol Table: Export
Where do you want to
store the table?

Select the format in


which you want to store
the table?
Symbol Table: Import

Select directory
path here

Select file Enter file


format name
Editing Symbols (in the
LAD/STL/FBD Editor)
Symbol Information (in the
LAD/STL/FBD Editor)
Documenting, Saving,
Archiving
Documentation Facilities

Network title
Network comment
Statement comment
Program overview
Cross references
Assignment of I/Q/M/T/C
Checklists
Symbol table
Configuration
Network configuration
Page Setup
Print Setup
Block Documentation
Saving User Data
Uploading the program 1. Create a new S7 program in the
SIMATIC Manager
from the CPU to the PG 2. Switch to the online view
(PLC copy) 3. Open the new S7 program and select the
Upload
blocks Station in the PG SIMATIC Manager ->PLC ->
Upload Station
Load program from4. PGSIMATIC
1. Open two windows in the SIMATIC
Manager -> PLC -> Upload
Manager:
to Memory Card... "Blocks folder of the S7 program" and "S7
Memory Card"
... inserted in PG / PC 2a. Copy blocks into "S7 Memory Card"
using program
Copy drag & drop
from CPU or to
... inserted
Memory Card
in CPU 2b.SIMATIC
SIMATIC
Manager
Manager ->->
PLCPLC
->->Copy RAM to
ROM... Download user program to memory card
Project archiving 1. Select the CPU on whose Memory Card
(only S7-300)
the project data are to
on Memory Card be saved
Project archiving 1.
(nur S7-400) 2. SIMATIC
SIMATIC Manager
Manager ->-> File
PLC ->
-> Archive
Save Project
on
on diskette
Memory Card 2. Select project to be archived
3. Specify name and storage path of the
archive file and start function
4. In the Windows Explorer, copy the archive
Copying a Program onto a Memory Card
Archiving on Diskette
DATA BLOCKS

DATA

KS
O C
BL
Storage Areas for Data
Data
Bit blocks
memo D
PIQ
ries L Data Stack
DBB4
PII
DB23
I/O area DB1
Data Blocks (DBs)
OB 1 Function Instance data
block block DB 16
FB 12

Function
FC 25
Global data
block
DB 20
Function
FC 26
Data Types in STEP 7
Elementary data types Bit data types (BOOL, BYTE, WORD, DWOR
(32 bits or less) Mathematical data types (INT, DINT, REAL)
Time types (S5TIME, TIME, TIME_OF_DAY)

Complex data types(more Time (DATE_AND_TIME)


than 32 bits) Array (ARRAY)
Structure (STRUCT)
Character chain (STRING)

User-defined data Data type UDT (User Defined Data


types(longer than 32 bits) Type)
Elementary Data Types
Data Type Length (num- Example of this data type
ber of bits)
BOOL 1 1 or 0
BYTE 8 B#16#B9
WORD 16 W#16#F98C
DWORD 32 DW#16#FAF13CD4

INT 16 5369
DINT 32 68799
REAL 32 125.98

S5TIME 16 S5T#2h_20m35s
TIME 32 T#5D_4H_12M_48S_10MS
DATE 16 D#2001-05-19
TIME_OF_DAY 32 TOD#10:39:16.48

CHAR 8 'H'
Creating a New Data Block
How to Enter, Save,
Download and Monitor a
Data Block
Addressing Data Elements

8
7 Bits 0
Data Byte 0 1 DBB 0
Data Byte 1 Byt DBW 0
e
Data Byte 2
DBD 0
Data Byte 3
DBX 4.1

DBD 8188

DBW 8190
Data Byte 8191 DBB 8191
Accessing
DB 19 Info"
Data Elements Addressing Types
Addr Name Type absolute symbolic
0.0 Trigger BOOL OPN Info"
A DB19.DBX0.0 A Info".Trigger
A DBX 0.0
1.0 Rec_no BYTE
2.0 Number INT
OPN DB 19
L DB19.DBB1 L Info".Rec_no
L DBB 1
4.0 Temp[1] REAL
OPN Info"
L DB19.DBW2 L Info".Number
T DBW 2

OPN DB 19
8.0 Temp[2] REAL L DBD 8
L DB19.DBD8 L Info".Temp[2]
Validity of an Open DB
OB 1
FC 20
OPN DB 7
FC 21
L DBW8 DB 7 T DBW DB
6 7
T DBW DB
6 8
CALL FC 20 OPN DB 8
L DBB3DB 8 OPN DB 16
CALL FC 21 DB 16
L DBB6
DB 7 L DBW DB
0 8 T DB6.DBBDB0 6
T DBW 12
L DBW DB
4 6
FB 1
CALL FB1, DB1

L DBW 10
Complex Data Types
Data Type Length (in bits) Example

DATE_AND_TIME 64 DT#01-05-22-20:15:55.0

STRING 8 * (number of String of characters


(character string with characters +2)
MOTOR 1 RUN
max. 254 characters)

ARRAY Determined by
Application Measured values:
ARRAY[1..100]
(Group of elements INT
of the same data type)

STRUCT Determined by Motor10: STRUCT


(Group of elements Application Speed : REAL
of different data
Torque: REAL
Setpoint
Example of an Array
1. Setpoint, data type Real
2. Setpoint, data type Real
Array with the name Setpoint"
3. Setpoint, data type Real
(several elements

of the same data type)

10. Setpoint, data type Real

Display in the Program Editor (Data block DB 2):


Example
Motor_data of a Structure
RPM, data type Integer
Rated Current, data type RealStructure with the name "Motor_data"
Startup Current, data type Real(several elements
with different data types)
Direction rotation, data type Bool

Display in the Program Editor (Data block DB 1):


Star/Delta

K1 = Main Contactor
K2 = Star Contactor
K3 = Delta Contactor
FC 30
Call Exercise
RLO from I 0.0
FC 31

= Q 4.0

A I 0.0
CALL FC 31 RLO from
A I 0.1
= Q 4.2 I 0.1 = Q 4.1

FC 32

= Q 4.4
A I CC
0.2if RLO = 1
BEC if RLO = 1 A I 0.3
CC FC 32
BEC
= Q 4.3
= Q 4.5
RLO from
I 0.4

A I 0.4
= Q 4.6
Binary Scaler
ON OFF ON OFF
RLO RES STA RLO RES STA RLO RES STA RLO RES STA
A I 0.0

AN M 20.0

S Q 4.0

A I 0.0

A M 20.0

R Q 4.0

AN I 0.0

A Q 4.0

S M 20.0

AN I 0.0

AN Q 4.0

R M 20.0
The Conveyor Model
The Conveyor Model
sw 1 to sw 3 LB1
(Proximity switches
Light
NO)barrier (NC)

M 1 L 1, L 2, L 3, L4 S 1, S 2, S 3, S 4
(Motor
(Station indicatorsLEDs)
(Pushbutton switches NO)
Fwd and Rev)

You might also like