0% found this document useful (0 votes)
228 views

PRO2 01e

The document describes status bits and their use in logic programming for SIMATIC S7 PLCs. It contains: - An overview of the register and memory areas of an S7 CPU, including accumulators, address registers, and the status word. - A description of the meaning and use of status bits like RLO, OV, and condition codes in instructions, blocks, and jump functions. - Examples of instructions like SET, CLR, and NOT that manipulate status bits and their use in checking conditions. - Information on programming techniques using status bits, like jump distributors, loop instructions, and block end instructions. - Practice exercises on using status-dependent jump instructions in

Uploaded by

ghita_gabriel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
228 views

PRO2 01e

The document describes status bits and their use in logic programming for SIMATIC S7 PLCs. It contains: - An overview of the register and memory areas of an S7 CPU, including accumulators, address registers, and the status word. - A description of the meaning and use of status bits like RLO, OV, and condition codes in instructions, blocks, and jump functions. - Examples of instructions like SET, CLR, and NOT that manipulate status bits and their use in checking conditions. - Information on programming techniques using status bits, like jump distributors, loop instructions, and block end instructions. - Practice exercises on using status-dependent jump instructions in

Uploaded by

ghita_gabriel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 14

Status Bit-Dependent Instructions

SIMATIC S7
Siemens AG 2001. All rights reserved.

Date:
File:

09.01.2015
PRO2_01E.1

SITRAIN Training for


Automation and Drives

Register and Memory Areas of an S7-CPU


Accumulators
ACCU4
only
S7-400

32 Bit

Load Memory
ACCU3

32 Bit

ACCU2

32 Bit

ACCU1

32 Bit

Work Memory
L, A, O,...

Address Register
AR1

32 Bit

AR2

32 Bit

T, S, =,...

open DB

DB Length

open DI

DI Length
16 Bit

Status Word
Status Bits

16 Bit

Siemens AG 2001. All rights reserved.

Logic Blocks
Data Blocks

I/O Area

Process-image input table


Process-image output table
Bit memories
Timers
Counters

Local Data Stack


Interrupt Stack
Block Stack

S7-CPU Memory Areas

S7-CPU Register
SIMATIC S7

System Memory

Data Block Register

16 Bit

Logic Blocks
Data Blocks

Date:
File:

09.01.2015
PRO2_01E.2

SITRAIN Training for


Automation and Drives

Status Word Structure


Meaning of the bits in the status word
Bit

Assignment

Value

Meaning

/FC

20

First check bit

RLO

21

Result of logic operation

STA

22

Status

OR

23

Or

OS

24

Stored overflow

OV

25

Overflow

CC 0

26

Condition code

CC 1

27

Condition code

BR

28

Binary result

9...15

Unassigned

29 ..210

SIMATIC S7
Siemens AG 2001. All rights reserved.

Date:
File:

09.01.2015
PRO2_01E.3

SITRAIN Training for


Automation and Drives

Checking the Status Bits


Checking in STL

A OV

Scan overflow display

A OS

Scan stored overflow

A BR

Scan BR flag

Checking the Condition Code (CC0, CC1)

A == 0 Result equal to 0

A > 0 Result greater than 0

A <> 0 Result not equal to 0

A =< 0 Result less than or equal to 0


etc.

A UO

Instruction is unordered

Checking in LAD and in FBD


OV

SIMATIC S7
Siemens AG 2001. All rights reserved.

M 4.0
S

>0

Date:
File:

09.01.2015
PRO2_01E.4

M 4.0
S

SITRAIN Training for


Automation and Drives

Instructions with Status Bits


Instruction

Meaning

Example

SET

Set RLO to "1"

SET
= M 0.1

//RLO-1

CLR

Set RLO to "0"

CLR

//RLO-0

NOT

Invert RLO

O Manual mode;
O Automatic mode;
NOT;
= Operating modes
= M0.0

SAVE

Save RLO in binary


result

A BR

Check binary result

SIMATIC S7
Siemens AG 2001. All rights reserved.

Date:
File:

09.01.2015
PRO2_01E.5

I 1.0

I 1.1

I 1.2

||

||

||

BR

Q 4.2

||

||

(SAVE)
Q 5.0

()

SITRAIN Training for


Automation and Drives

BR Bit and ENO in a Block Call or Complex Functions


LAD

STL

Network 1: Cyclic Program


FC23

I0.0

MW10

M100.0
ENO

EN

Network 1: Cyclic Program


A
I
0.0
JNB
_001
CALL FC 23
Step_bit_memory
Step_display :=QW12
_001: A
BR
=
M
100.0

Step_bit Step_dis
_memory play

( )
QW12

Network 2: ???
MUL_I

I0.1

M100.1

EN

ENO

( )

345

IN1

OUT

MW10

987

IN2

SIMATIC S7
Siemens AG 2001. All rights reserved.

Network 2: ???
A
I
0.1
JNB
_002
L
345
L
987
*I
T
MW 10
AN
OV
SAVE
CLR
_002: A
BR
=
M
100.1

Date:
File:

09.01.2015
PRO2_01E.6

SITRAIN Training for


Automation and Drives

:=M

Jump Functions Dependent on Status Bits

JU Label1)

Jump unconditional

JC Label1)

Jump if "RLO" bit =1

JCN Label1)

Jump if "RLO" bit = 0

JCB Label1)

Jump if "RLO" bit = 1 and save RLO

JNB Label1)

Jump if "RLO" bit = 0 and save RLO

JBI Label1)

Jump if "BR" bit = 1

JNBI Label1)

Jump if "BR" bit = 0

JO Label1)

Jump if "OV" bit in status word =1

JOS Label1)

Jump if "OS" bit in status word =1


1) Label

SIMATIC S7
Siemens AG 2001. All rights reserved.

Date:
File:

09.01.2015
PRO2_01E.7

can consist of 4 alpha-numeric characters

SITRAIN Training for


Automation and Drives

Jump Functions Dependent on Condition Codes

JZ Label1)

Jump if in the status word bit "CC 1"=0 and "CC 0"=0
(Result = 0)

JN Label1)

Jump if in the status word bit "CC 1" is not equal to "CC 0"
(Result <> 0)

JP Label1)

Jump if in the status word bit "CC 1"=1 and "CC 0"=0
(Result > 0)

JM Label1)

Jump if in the status word bit "CC 1"=0 and "CC 0"=1
(REsult < 0)

JPZ Label1)

Combines the jumps JZ and JP


(Result >= 0)

JMZ Label1)

Combines the jumps JM and JZ


(Result <= 0)

JUO Label1)

Jump if: invalid Real number or division by zero


1) Label

can consist of 4 alpha-numeric

characters

SIMATIC S7
Siemens AG 2001. All rights reserved.

Date:
File:

09.01.2015
PRO2_01E.8

SITRAIN Training for


Automation and Drives

Programming Jump Distributors


Mode of Operation

OVER:
M_0:

Example: Jump distributor with 3 entries

Load jump
number

L Recipe no

// Load recipe no.

JL OVER

JL OVER

// Jump distributor with 3 entries

JU M_0

JU Rec0

// Jump to recipe no. 0 (ACCU1 = 0)

..
.

JU Rec1

// Jump to recipe no. 1 (ACCU1 = 1)

JU M_n

JU Rec2

// Jump to recipe no. 2 (ACCU1 = 2)

Instructions if
ACCU1 > n

OVER: JU ERROR

Instructions if
ACCU1 = 0

Rec0: L DBW4

// Jump if ACCU1 > 2

...
...

..
.

Rec1: L DBW6
...

M_n:

Instructions if
ACCU1 = n

Rec2: L DBW8
...
ERROR:

CLR

...

SIMATIC S7
Siemens AG 2001. All rights reserved.

Date:
File:

09.01.2015
PRO2_01E.9

SITRAIN Training for


Automation and Drives

Programming Loop Instructions


Mode of Operation

Example: Loop instruction


with 4 scans

Initialize
loop counter
Transfer
to loop counter

NEXT:

L +4
NEXT: T MW10

// Load loop counter


// Beginning of the loop

Code section to be
executed several
times

// Code

// Code

Load loop counter


in ACCU1.

// Code

L MW10

// Load loop counter again

LOOP NEXT

// Loop counter -1 and


// jump to jump label
// NEXT if Accu 1> 0

Yes

LOOP NEXT
decrement ACCU1,
ACCU1 <> 0 ?

No
Continue

SIMATIC S7
Siemens AG 2001. All rights reserved.

Date:
File:

09.01.2015
PRO2_01E.10

SITRAIN Training for


Automation and Drives

Instructions for Block End

BE

Block End

BEU

Block End Unconditional (within a block)

BEC

Block End Conditional (dependent on the RLO)

SIMATIC S7
Siemens AG 2001. All rights reserved.

(RET)

in the LAD programming language

RET

in the FBD programming language

Date:
File:

09.01.2015
PRO2_01E.11

SITRAIN Training for


Automation and Drives

Exercise 1.1: Jump After a Subtraction


Toggle switch on the Simulator

Pushwheel button
1

0 0 0 0 0 0 0 0 1 0 0 1 0 0 1 0
215

convert to BTD
DINT

27

BTD

20

convert to
DINT

-D
Pos. result (>=0)
Neg. result
[JM Label]
Write the value of IW 0
in the display

Delete display

Decade switch:
Toggle switch:

SIMATIC S7
Siemens AG 2001. All rights reserved.

S7-300: IW4 (IW2, 32-Bit Mod.)


S7-400: IW 30
S7-300: IW0 (IW0)
S7-400: IW28

Date:
File:

Display:

09.01.2015
PRO2_01E.12

S
S

SITRAIN Training for


Automation and Drives

Exercise 1.2: Jump After a Multiplication


Toggle switch on the Simulator

Pushwheel button
1

0 0 0 0 0 0 0 0 1 0 0 1 0 0 1 0
215

convert to BTD
DINT

BTD

27

20

DTB

Convert result
to BCD

convert to
DINT

*I
No overflow
Overflow
[JO Label]

Output result
to the display

Delete display

Decade switch:
Toggle switch:

SIMATIC S7
Siemens AG 2001. All rights reserved.

S7-300: IW4 (IW2, 32-Bit Mod.)


S7-400: IW30
S7-300: IW0 (IW0)
S7-400: IW28

Date:
File:

Display:

09.01.2015
PRO2_01E.13

S
S

SITRAIN Training for


Automation and Drives

Exercise 1.3: Programming a Jump Distributor


Function:
Pushwheel button

[ JL Label]
1
2
3
4
5

Motor_let run to the right


Motor_let run to the left
Motor off
Horn on
Horn off

Label: Jump using Jump to List

Addresses:
Motor_right:
Motor_left:
Horn:

SIMATIC S7
Siemens AG 2001. All rights reserved.

S7-300 (16-Bit)
Q20.5
Q20.6
Q20.7

S7-300 (32-Bit)
Q8.5
Q8.6
Q8.7
Date:
File:

09.01.2015
PRO2_01E.14

S7-400
Q40.5
Q40.6
Q40.7
SITRAIN Training for
Automation and Drives

You might also like