You are on page 1of 53

The SIMATIC S7 System Family

SIMATIC
PCS 7

SIMATIC
SIMATIC NET
Software

SIMATIC
HMI
SIMATIC SIMATIC
PC
SIMATIC
WinCC

SIMATIC
DP
SIMATIC
Controller
Positioning of the Modular S7 Controllers
Advanced SIMATIC
S7-400

SIMATIC S7-400
SIMATIC SIMATIC
S7-1500 S7-1500
Basic

SIMATIC S7-300 SIMATIC


S7-300
Micro

SIMATIC
SIMATIC S7-200 S7-1200
SIMATIC S7-1200

TIA Portal
S7-300: Modules

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


(optional) (optional) DI DO AI AO - Counting - Point-to Point
- Positioning - PROFIBUS
- Closed-loop - Industrial Ethernet
control
The SIMATIC Manager
Creating an S7 Project
Setting the PG/PC Interface
Access Point
STEP 7 of the Application:
S7ONLINE

Interface Parameter
CP5611 Assignment Used:
CP5611 (MPI)

CPU
"Accessible Nodes": ONLINE View (project-
independent)
Erasing a Memory Card (Memory or MMC
Card)Memory card is inserted in the CPU:

right
Memory card is inserted in the PG: mouse button
Exercise 1: Setting the PG Interface to MPI
SIMATIC Manager
Options
Exercise 2: Performing a CPU Memory Reset
and a Warm Restart
Until Oct. 2002 After Oct. 2002
RUN-P
RUN
RUN 1. Set the mode selector switch to STOP
STOP
MRES
STOP

MRES
RUN-P
2. Hold (Press) the mode selector switch in the MRES
RUN
RUN position until the STOP LED has flashed twice slowly.
STOP
Release the mode selector switch so that it returns to
MRES
STOP the STOP position.
MRES
within 1 sec
RUN-P
3. Turn (press) the mode selector switch to the MRES posi-
RUN RUN
-tion once more until the STOP LED begins to flash quickly. STOP
Release the mode selector switch so that it returns to MRES
STOP
the STOP position.
MRES
RUN-P

RUN RUN
4. Set the mode selector switch to the RUN-P (RUN)
STOP
position. (A warm restart is carried out in the transition
STOP MRES
from STOP to RUN/RUN-P)
MRES
Inserting a Station
Starting the Hardware Configuration Editor
Generating a Hardware Setpoint
Configuration
DI/DA Addressing in Multi-Tier
Configurations
PS IM 96.0 100.0 104.0 108.0 112.0 116.0 120.0 124.0
Rack (Receive)
3 to to to to to to to to
99.7 103.7 107.7 111.7 115.7 119.7 123.7 127.7

PS IM 64.0 68.0 72.0 76.0 80.0 84.0 88.0 92.0


Rack (Receive)
to to to to to to to to
2
67.7 70.7 75.7 79.7 83.7 87.7 91.7 95.7

PS IM 32.0 36.0 40.0 44.0 48.0 52.0 56.0 60.0


Rack (Receive) to to to to to to to to
1
35.7 39.7 43.7 47.7 51.7 55.7 59.7 63.7

PS CPU IM 0.0 4.0 8.0 12.0 16.0 20.0 24.0 28.0


Rack (Send)
to to to to to to to to
0
3.7 7.7 11.7 15.7 19.7 23.7 27.7 31.7
Slot 1 2 3 4 5 6 7 8 9 10 11
Variable Addressing

2x
Saving the Setpoint Configuration and
Downloading it in Modules

Download
(only when CPU is
in STOP mode)
Absolute and Symbolic Addressing
Absolute Representation Symbolic Representation

A I0.0 A "SYSTEM_ON"
= Q8.0 = "LED_ON"
A I0.4 A "M_FORW"
= Q20.5 = "MOTOR_FOR"
Call FC18 Call "COUNT"

Symbol Address Data Type Comment


MOTOR_FOR Q20.5 BOOL Motor moves forward
COUNT FC18 FC18 Count bottles
SYSTEM_ON I0.0 BOOL Switch system on
SYSTEM_ON Q8.0 BOOL Indicator: System is “On”
M_FORW I0.4 BOOL Pushbutton: Motor forward

(max. 24 characters) (max. 80 characters)


The Symbol Table
Types of Program Blocks
Operating System
DB DB

Cycle

Time OB
FC FB SFC
Organization
Process Blocks

Error FB FC SFB

Legend: Maximum nesting depth:


OB = Organization Block S7-300: 8
FB = Function Block
FC = Function S7-400: 24
SFB = System Function Block FB
SFC = System Function FB with (for each priority class,
DB = Data Block Instance DB 2 to 4 additional levels for Error OBs)
Program Structuring Possibilities
Linear Program Program Partitioned into Areas Structured Program

Recipe A
Pump
OB 1 OB 1 Recipe B OB 1

Mixer
Outlet

Outlet

All instructions are The instructions for the individual Reusable functions are loaded into
found in one block (usually functions are found in individual individual blocks. OB 1 (or other
in Organization Block OB blocks. OB 1 calls the individual blocks blocks) call these blocks and pass on
1) one after the other. the pertinent data.
Process Images
S1 K1

I 2.0 Q 4.3

PII PIQ
User
Byte 0 Byte 0
Program
Byte 1 1 Byte 1
Byte 2 1 Byte 2
: : :
: : : 1
: A I 2.0 :
1 = Q 4.3
:
:
2 A I 6.4
= Q 4.3
CPU Memory Area : CPU Memory Area
Cyclic Program Execution
• Startup program: Call and execution of OB 100
(once, after Power ON, for example)
• Transfer PIQ to the digital output modules

Start of the cycle monitoring time digital


input
module

Reading the input states from the digital input modules


and saving the states in the process image (PII)

Call and execution of OB1


CPU Cycle

(possible interruption by call of other OBs


for events such as time-of-day interrupt,
hardware interrupts etc. ) digital
output
module
Writing the process-image output table
(PIQ) in the digital output modules
Exercise 3: Jogging the Conveyor Motor (FC
16)
Exercise 4: Calling FC 16 in OB 1
Binary Logic Operations: AND, OR
LAD FBD STL

I 0.0 I 0.1 Q 8.0 I 0.0 & Q 8.0


A I 0.0
=
I 0.1 A I 0.1
Q 8.1 = Q 8.0
Q 8.1 = Q 8.1
=

I 0.2 Q 8.2
I 0.2 >=1 Q 8.2 O I 0.2
= O I 0.3
I 0.3
I 0.3 = Q 8.2
Binary Logic Operations: Exclusive OR (XOR)
LAD FBD STL

I 0.4 & A I 0.4


I 0.4 I 0.5 Q 8.0 Q 8.0 AN I 0.5
I 0.5 >=1 O
=
AN I 0.4
I 0.4 & A I 0.5
I 0.4 I 0.5 I 0.5 = Q8.0

Q 8.0 X I 0.4
I 0.4 XOR
= X I 0.5
I 0.5 = Q8.0
Problem 1: Sensors and Symbols
Task: In all three examples, the light should be on when S1 is activated and S2 is not activated!

Hardware

S1 S2 S1 S2 S1 S2

E 1.0
I1.0 EI1.1
1.1 EI1.0
1.0 E 1.1
I1.1 EI1.0
1.0 E I1.1
1.1
Programmable controller Programmable controller Programmable controller
Q 4.0 Q 4.0 Q 4.0

Light Light Light

Software
I 1.0 I 1.1 Q 4.0 I 1.0 I 1.1 Q 4.0 I 1.0 I 1.1 Q 4.0
LAD

I 1.0 & I 1.0 & I 1.0 &

FBD
I 1.1 Q 4.0 I 1.1 Q 4.0 I 1.1 Q 4.0

....... I 1.0 ....... I 1.0 ....... I 1.0


STL ....... I 1.1 ....... I 1.1 ....... I 1.1
....... Q 4.0 ....... Q 4.0 ....... Q 4.0
Assignment, Setting, Resetting
LAD FBD STL

I 1.0 I 1.1 Q 8.0 A I 1.0


I 1.0
( ) & Q 8.0 A I 1.1
Assignment
I 1.1 = = Q 8.0

I 1.2 I 1.3
Q 8.1 I 1.2 A I 1.2
& Q 8.1
Set (S ) A I 1.3
I 1.3 S S Q 8.1

I 1.4 Q 8.1
(R ) I 1.4 O I 1.4
>=1 Q 8.1 O I 1.5
Reset I 1.5 R
I 1.5 R Q 8.1
Setting and Resetting a Flip Flop
LAD FBD STL

M 5.7 M 5.7
I1.2 Q 9.3 A I 1.2
SR
Dominant S Q I1.2 S SR S M 5.7
A I 1.3
Reset Q9.3
I1.3 R M 5.7
I1.3 R Q = A M 5.7
R
= Q 9.3

M 5.7 M 5.7
I1.3 Q 9.3 A I 1.3
RS
Dominant R Q I1.3 R RS R M 5.7
Set Q9.3 A I 1.2
I1.2 S M 5.7
I1.2 Q = A M 5.7
S S
= Q 9.3
Exercise 5: Programming the Operating
Mode Section (FC 15)
DI DO
I 0.0 T_System_ON
I 0.1 T_System_OFF L_SYSTEM Q 4.1
I 0.2 T_Jog_RIGHT L_MAN Q 4.2
I 0.3 T_Jog_LEFT L_AUTO Q 4.3 V

I 0.4 S_M/A_ModeSelect
I 0.5 T_M/A_Accept
-15V...+15V AI2 AO1
-15V...+15V
AI1 AO2

AI1 AI2
V

0 8 1 5 AI1 AI2 AO1 AO2


Exercise 6: "FC_Mode" (FC 15), Solution Hints
Network 1: Indicator Light System ON
Q 4.1
SR
ON-Condition S

OFF-Condition R Q

Network 2: Indicator Light MAN Mode


Q 4.2
SR
ON-Conditions S

OFF-Conditions R Q

Network 3: Indicator Light AUTO Mode


Q 4.3
SR
ON-Conditions S

OFF-Conditions R Q
Exercise 7: Conveyor in AUTO Mode
(Expanding FC 16)
Conv. Start Transport Phase Conv. Stop

Prox.Sens.Bay 1
I 8.5

Mom.Cont.Bay 1
I 8.1

Prox.Sens.Bay 2
I 8.6

Mom.Cont.Bay 2
I 8.2

Light Barrier
I 8.0

Run Conveyor
RIGHT
Q8.5
Exercise 8: "FC_ConvMotor" (FC 16), Solution
Hints
Network x Jog RIGHT in MANUAL mode

Conditions for JOGGING


RIGHT M 16.2 Memory bit for
Jog RIGHT
in MANUAL mode = In MANUAL mode

Network y Run Conveyor RIGHT in AUTO mode

M 16.4
Conditions for
Memory bit for
Run Conveyor RIGHT S
Run Conveyor RIGHT
in AUTO mode R in AUTO mode

Network z Control Run Conveyor RIGHT

M 16.2 >=1
Run Conveyor RIGHT
Q 8.5

M 16.4 =
Signal – Edge Detection
LAD FBD STL

I 1.0 A I 1.0
I 1.0 I 1.1 &
M8.0 I 1.1 A (
POS
Q POS M8.0 A I 1.1
M1.0 M_BIT = FP
M1.0 M_BIT
M1.0
)
I 1.0 I 1.1 I 1.0 =
M8.1 I 1.1 &
M8.0
NEG
Q NEG M8.1 A I 1.0
M1.1 M_BIT M1.1 M_BIT = A (
A I 1.1
FN
M1.1
I 1.0 )
=
I 1.1 M8.1

M8.0
OB1 Cycle

M8.1
OB1 Cycle
Exercise 9: Integrating the Edge Detection in
FC 16

Conv. Start Transport Phase Conv. Stop

Part at
Light barrier
Start condition
in AUTO mode

Light Barrier
(I 8.0)

Run Conveyor
RIGHT
(Q8.5)
Exercise 10: Controlling Indicator Lights +
Horn (FC 14) in MANUAL mode:
2Hz pulsed honking
while conveyor jogging
"BAY1" "BAY2"
(I 8.5) (I 8.6)
"Horn"
(Q 8.7)

"L_Bay1" "L_Bay2"
(Q 8.1) (Q 8.2)
in AUTO mode:
- Constant light at both bays when a new part can be placed (both bays empty)
- 1Hz flashing light at the bay where the part is placed and the conveyor has not yet been started
- 2Hz flashing light at both bays during conveyor movement
Digital Operations

F1
Acquiring, Processing and Outputting Data
Operating 0248
Thumbwheel
+ monitoring V buttons,
processes Potentiometer,
0 8 1 5 7-segment
display
Operator Panel

Control such as MPI


Processing
unit the values

DI/ AI/
DO AO

such as PROFIBUS

Process Field devices


controller
Integer (INT, 16-Bit Integer) Data Type
Value range -32768 to +32767 Arithmetic
(without sign: 0 to 65535) operations: such as + I, * I, <I, ==I

Display Formats:
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

DEC: + 662 BIN.: 2# 0 0 0 0 0 0 1 0 1 0 0 1 0 1 1 0 HEX: W#16#0 2 9 6


9
without
+2 7 sign
Sign +2 0
4 6 x 16 = 6
positive +2 2 1
numbers +2 1 9 x 16 = 144
+2 2 x 16
2
= 512
+ 662 662

15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

DEC: - 662 BIN.: 2# 1 1 1 1 1 1 0 1 0 1 1 0 1 0 1 0 HEX: W#16#F D 6 A


15 without
-2
+2 13
14 sign
Sign
negative +2 12 0
+2 11 10 x 16 =10
1
numbers +2 10 6 x 16 = 96
2
8 6
+2 +2 +2 5 13 x 16 = 3328
3 1 3
Representation as +2 +2 +2 15 x 16 = 61440
Twos complement - 662 64874
Double Integer (DINT, 32-Bit Integer) Data
Type
Value range L# -2147483648 to L#+2147483647 Operations: such as + D, * D, <D, ==D
(without sign: 0 to 4294967295)

Display Formats:
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

DEC: L# +540809 BIN.: 2# 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 1 0 0 1

Sign
positive
numbers

HEX: DW#16# 0 0 0 8 4 0 8 9
(without sign)

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

DEC: L# -540809 BIN.: 2# 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 0 1 1 1 1 1 1 0 1 1 1 0 1 1 1

Sign
negative
numbers
Representation as HEX: DW#16# F F F 7 B F 7 7
Twos complement
(without sign)
REAL (Floating-point Number, 32 Bit) Data
Type
Value range -3.402823•10+38 to -1.175495•10-38 , 0.0, +1.175495•10-38 to +3.402823•10+38

Operations: such as + R, * R, <R, ==R


sin, acos, ln, exp, SQR

General format of a Real number = (Sign) • (1.f) • (2e-127)

Example: 0.75

Sign of
Real no. e = Exponent (8 Bit) f = Mantissa (23 Bit)

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

0 0 1 1 1 1 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27 26 25 24 23 22 21 20 2-1 2-2 2-3 2-4 ..... 2-23

Real no. = +1.5 * 2 126-127 = 0.75


The BCD Code for Inputting and Outputting
Integers
Value range 16 Bit: - 999 to + 999 Conversion
32 Bit: -9999999 to + 9999999 operations: BTI, BTD, ITB, DTB
(no arithmetic!)

0 2 9 6

16 Bit: BIN.: 2# 0 0 0 0 0 0 1 0 1 0 0 1 0 1 1 0

Sign (+) 2 9 6
HEX: W#16# 0 2 9 6 DEC: + 662

Sign (+) 0 0 0 0 2 9 6

32 Bit: BIN.: 2# 0 x x x 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 1 0 1 1 0

HEX: DW#16# 0 0 0 0 2 9 6 DEC: + 662


Loading and Transferring Data

(ACCU 1)
12345678 A1B2C3D4
S5 Counter Functions
LAD FBD STL

A I 0.4
C5 C5
CU C5
I 0.4
S_CUD Q 8.3
S_CUD A I 0.5
CU Q
Q I 0.4 CU CD C5
I 0.5 A I 0.3
CD CV MW 4 I 0.5 CD L C#5
S C5
I 0.3
S CV_BCD QW 12 I 0.3 S CV MW 4 A I 0.7
R C5
C#5 PV C#5 PV CV_BCD QW 12 L C5
Q 8.3 T MW4
I 0.7
LC C5
R I 0.7 R Q
Q =
T QW12
A C5
= Q8.3
Counters: Function Diagram
CU

CD

5
4
3
Count
2
1
0

Q
Exercise 11: Counting the Transported
Parts (FC 18, C 18)
DI DO
I 0.0 T_System_ON Act Quantity
I 0.1 T_System_OFF L_SYSTEM Q 4.1
I 0.2 T_Jog_RIGHT L_MAN Q 4.2
I 0.3 T_Jog_LEFT L_AUTO Q 4.3 V

I 0.4 S_M/A_ModeSelect
I 0.5 T_M/A_Accept "QW_DigDisp" (QW 6)
-15V...+15V AI2 AO1
-15V...+15V
AI1 AO2

AI1 AI2
V

AI1 AI2 AO1 AO2


0 8 1 5
S5 Timer Functions
Pulse Timer (SP) Extended Pulse (SE)

T44 T44
S_PULSE S_PEXT
MW0 MW0
I 0.7 S B I 0.7 S B
S5T#35s QW12 S5T#35s QW12
TV I
BCD M8.5 TV I
BCD M8.5
I 0.5 R Q = I 0.5 R Q =
ON Delay (SD)

T44
S_ODT
MW0
I 0.7 S B
S5T#35s QW12
TV I
BCD M8.5
I 0.5 R Q =
Stored ON Delay (SS) OFF Delay (SF)

T44 T44
S_ODTS S_OFFDT
MW0 MW0
I 0.7 S BI I 0.7 S B
S5T#35s QW12 S5T#35s QW12
TV BCD M8.5 TV I
BCD M8.5
I 0.5 R Q = I 0.5 R Q =
Timers: ON Delay (SD)
LAD FBD STL

T4 T4
I 0.7 S_ODT S_EVERZ A I 0.7
Q8.5
S Q S B MW0 L S5T#35s
I 0.7
S5T#35s B SD T4
TV MW0 S5T#35s TV I
BCD QW12
I 0.5 Q8.5 A I 0.5
I
R BCD QW12 I 0.5 R Q = R T4
L T4
T MW0
RLO at S LC T4
RLO at R T QW12
A T4
Time = Q8.5
operation
Example

Data type 0.01s <-- 0 0


0.1s <-- 0 1
“S5TIME” 1s <-- 1 0 Units of time: 0 to 999 (BCD-coded)
10s <-- 1 1
Exercise 12: Monitoring the Transport
Functions (FC 17)
DI DO

I 0.0 T_System_ON
I 0.1 T_System_OFF L_SYSTEM Q 4.1
I 0.2 T_Jog_RIGHT L_MAN Q 4.2
I 0.3 T_Jog_LEFT L_AUTO Q 4.3
I 0.4 S_M/A_ModeSelect
I 0.5 T_M/A_Accept

T_Ackn L_Conv
I 1.0 Q 5.0
_Fault _Fault
Comparison Operations
LAD FBD STL

M 3.4 CMP >=I Q 9.7 CMP >=I A M 3.4


A(
IN1 L IW 0
IW0
IN1 L IW 2
IW 0 M 3.4 & Q9.7 >=I
IW 2 IN2 IW2 IN2 = )
= Q 9.7
Basic Mathematical Functions
LAD FBD STL

ADD_I ADD_I L MW4


Addition EN ENO EN OUT MW6 L MW10
MW4 IN1 MW4 IN1 +I
MW10 IN2 OUT MW6 MW10 IN2 ENO T MW6

SUB_I SUB_I L MW8


Subtrac- MW6
tion EN ENO EN OUT L MW12
MW8 IN1 MW8 IN1 -I
MW12 IN2 OUT MW6 MW12 IN2 ENO T MW6

MUL_DI MUL_DI L MD6


Multipli- MD66
EN ENO EN OUT L MD12
cation
MD6 IN1 MD6 IN1 *D
MD12 IN2 MD66 ENO
T MD66
MD12 IN2

DIV_R DIV_R L MD40


EN OUT MD32
Division EN ENO L MD4
MD40 IN1 MD40 IN1 /R
MD4 IN2 OUT MD32 MD4 IN2 ENO T MD32
Exercise 13: Counting the Transported
Parts (FC 19)
DI DO SETPOINT Quantity ACTUAL Quantity
I 0.0 T_System_ON
I 0.1 T_System_OFF L_SYSTEM Q 4.1
0 8 1 5
I 0.2 T_Jog_RIGHT L_MAN Q 4.2
I 0.3 T_Jog_LEFT L_AUTO Q 4.3
I 0.4 S_M/A_ModeSelect "IW_Thumbw" (IW 2) "QW_DigDisp" (QW 6)
I 0.5 T_M/A_Accept

I 1.0 T_Ackn_Fault L_Conv_Fault Q 5.0

ACT=SET Acknowledgement
"L_Bay-LB" (Q 8.4) "T_Bay-LB" (I 8.4)
Exercise: Counting the Transported Parts (FC
19), Solution Hints
NW 1: Set "Counter" to 0

MOVE
Condition
for resetting EN OUT MW 20
0 IN ENO

NW 2: Counting via memory word, ACT quantity

ADD_I
Rising edge of
counting event EN

MW 20 IN1 OUT MW 20
1 IN2 ENO

NW 3: Display ACT quantity on the BCD digital display

Convert ACT quantity (MW 20) from Integer to BCD -> Result on BCD digital display (QW 6)

NW 4: Read in SETP quantity and convert from BCD to Integer

Convert value from thumbwheel button (IW 2) from BCD to Integer -> Store SETP quantity (Integer) in MW 22

NW 5: ACT-SETP comparison, Conveyor indicator light Q 8.4

Compare ACT (MW 20) to SETP (MW 22) -> Place comparison result on indicator light

You might also like