Vous êtes sur la page 1sur 54

Join Us In Industrial Automation Group For Training & Consulting

https://www.facebook.com/groups/722593891132335/
ENG.ABDELKAWY MOUBARAK | 01014871075 2
E N G . A B D E L K A W Y M O U B A R A K | 0 1 0 1 4 8 71 07 5 2
‫‪ ‬تحتوي علي ‪Instructions & Data‬‬ ‫‪ ‬تحتوي فقط علي ‪ Data‬خاصة بالبرنامج‬
 SIMATIC Manager  Blocks  Right Click  Insert New Object 

 Organization Block

 Function

 Function Block

 Data Block

 Data Type

 Variable Table
‫‪ ‬هي ‪ Blocks‬يقوم الـ ‪ PLC‬بعمل ‪ Call‬لها دون تدخل من المبرمج‬

‫‪ ‬لن يتم تنفيذ اي امر لم يتم كتابته او ‪ Function‬لم يتم استدعائها من داخل ‪ OB‬بشكل‬
‫مبارشر او غير مباشر‬
‫‪ ‬بشكل مباشر‪ :‬يتم كتابته داخل الـ ‪ OB‬مباشرة‬
‫‪ ‬بشكل غير مباشر ‪ :‬يتم كتابته داخل ‪ Function‬يتم استدعائها من داخل ‪OB‬‬
 Where The program that is to be continuously
executed is stored

 After the user program has been completely


executed in OB 1, a new cycle begins with the
updating of the process images and the processing
of the first statement in OB 1.\

 The scan cycle time and the response time of the


system is a result of these operations.

ENG.ABDELKAWY MOUBARAK | 01014871075 7


 Is a Subroutine Which called to Execute a Specific Function

‫ مختلفين دون برمجتها اكثر من مرة‬I/Ps & O/Ps ‫ الواحدة لعدد من الـ‬Function ‫ تكرار الـ‬

OB1 ‫ في البرامج الكبيرة يفضل عدم البرمجة في الـ‬


Functions ‫ لكن يتم تقسيم البرنامج لـ مجموعة من الـ‬
OB1 ‫ و باالخص‬OBs ‫ يتم استدعائها من داخل الـ‬

 SIMATIC Manager > Blocks > Right Click > Insert New Object > Function

ENG.ABDELKAWY MOUBARAK | 01014871075


 SIMATIC Manager > Blocks > Right Click > Insert New Object > Function

Function Name OR Function Address

Symbolic Name of Function

Comment on Function Program

Function Programming Language

To Create the Function


Function Address

Function Program
I/Ps Which Executed when O/Ps
Data To the the Function Called Data From the
Function Function

You Must Define Data of Function ( I/Ps , O/Ps , Local Data )


&
Write Function Program
- Start / Stop for 2 Motors Using The Same Function
ENG.ABDELKAWY MOUBARAK | 01014871075 17
E N G . A B D E L K A W Y M O U B A R A K | 0 1 0 1 4 8 71 07 5 17
 Data types determine the properties of data
 how the contents of one or more associated addresses are to be
represented
 what the permissible range of values is.

 The data type also determines which operations can be used.

ENG.ABDELKAWY MOUBARAK | 01014871075 18


E N G . A B D E L K A W Y M O U B A R A K | 0 1 0 1 4 8 71 07 5 18
E N G . A B D E L K A W Y M O U B A R A K | 0 1 0 1 4 8 71 07 5 19
 Never more than 32 bits long.
 can be loaded into the accumulators of the S7
Elementary
processor in full and processed with elementary
Data Types STEP 7 instructions.

 Complex data types can only be used in conjunction


Complex with variables declared in global data blocks.
 Complex data types cannot be completely loaded into
Data Types the accumulators with load instructions.

User-Defined  A user-defined data type can be used for data blocks


or as a data type in a variable declaration table.
Data Types  You use the Data Block Editor to create UDTs.

E N G . A B D E L K A W Y M O U B A R A K | 0 1 0 1 4 8 71 07 5 20
Bit data types  This Classification is depends on the Area of Storage
Memory

Mathematical  This Classification is depends on the Mathematical


data types Properties .

 This Classification is depends on the Time Data


Time types
Types

ENG.ABDELKAWY MOUBARAK | 01014871075 21


E N G . A B D E L K A W Y M O U B A R A K | 0 1 0 1 4 8 71 07 5 21
 This Classification is depends on the Area of Storage Memory

 Special forms of these data types are the BCD numbers


 The CHAR data type represents a character in ASCII code.

E N G . A B D E L K A W Y M O U B A R A K | 0 1 0 1 4 8 71 07 5 22
Bit

Byte = 8 Bit

Word = 2 Byte = 16 Bit

E N G . A B D E L K A W Y M O U B A R A K | 0 1 0 1 4 8 71 07 5 23
 What is the first bit in this byte ?
 What is it Called ?

7 6 5 4 3 2 1 0

Byte
Bit 7 Bit 0
MSB LSB

E N G . A B D E L K A W Y M O U B A R A K | 0 1 0 1 4 8 71 07 5 24
7 6 5 4 3 2 1 0
Byte 0
W0
Byte 1
Byte 2
W2
Byte 3
Byte 4
W4
Byte 5
Byte 6
W6
Byte 7
Byte 8

E N G . A B D E L K A W Y M O U B A R A K | 0 1 0 1 4 8 71 07 5 25
W0
215 214 213 212 211 210 29 28 27 26 25 24 23 22 21 20

Byte 0 Byte 1
Bit 7 Bit 0
MSB W54 LSB

215 214 213 212 211 210 29 28 27 26 25 24 23 22 21 20

Byte 54 Byte 55
Bit 7 Bit 0
MSB LSB

E N G . A B D E L K A W Y M O U B A R A K | 0 1 0 1 4 8 71 07 5 26
D0

Byte 0 Byte 1 Byte 2 Byte 3


Bit 31 Bit 0
MSB LSB

E N G . A B D E L K A W Y M O U B A R A K | 0 1 0 1 4 8 71 07 5 27
 This Classification is depends on the Mathematical Properties .

 Variables of these data types represent numbers that can be used in mathematical
operations.

E N G . A B D E L K A W Y M O U B A R A K | 0 1 0 1 4 8 71 07 5 28
‫ عدد صحيح موجب او سالب‬
 Storage Area of integer : 16 Bit

Positive Integer

E N G . A B D E L K A W Y M O U B A R A K | 0 1 0 1 4 8 71 07 5 29
Negative Integer:

Value Range: -32768 to +32767


(without sign: 0 to 65535)

Arithmetic Operations:
such as + I, * I, <I, ==I

E N G . A B DEENLG K
. AAB W
D EYL KM
AWOYU M
B OAURBAA K | |0 011001144 88771
RAK 1 007
75 5 30
30
‫ عدد صحيح موجب او سالب‬
 Storage Area of Double integer : 32 Bit
Positive Double Integer

E N G . A B D E L K A W Y M O U B A R A K | 0 1 0 1 4 8 71 07 5 31
Negative Double Integer

Value Range: L# -2147483648 to L#+2147483647


(without sign: 0 to 4294967295)

Arithmetic Operations: such as + D, * D, <D, ==D

E N G . A B D E L K A W Y M O U B A R A K | 0 1 0 1 4 8 71 07 5 32
Floating Point Number ,32 Bit

E N G . A B D E L K A W Y M O U B A R A K | 0 1 0 1 4 8 71 07 5 33
ENG.ABDELKAWY MOUBARAK | 01014871075 34
E N G . A B D E L K A W Y M O U B A R A K | 0 1 0 1 4 8 71 07 5 34
Decimal Binary Hexadecimal

0 0 0
1 1 1
2 1 0 2
3 1 1 3
4 1 0 0 4
5 1 0 1 5
6 1 1 0 6
7 1 1 1 7
8 1 0 0 0 8
9 1 0 0 1 9
1 0 1 0 1 0 A
1 1 1 0 1 1 B
1 2 1 1 0 E N G0. A B D E L K A W Y M O U B A R A K | 0 1 0 1 4C8 7 1 0 7 5 35
E N G . A B D E L K A W Y M O U B A R A K | 0 1 0 1 4 8 71 07 5 35
27 26 25 24 23 22 21 20
Binary Number:
1 0 1 0 0 1 1 1

Decimal Number: 1x20 +1x21 +1x22 +0x23 +0x24


+1x25 +0x26 +1x27

= 1+2+4+0+0+32+128 = 167

E N G . A B D E L K A W Y M O U B A R A K | 0 1 0 1 4 8 71 07 5 36
Decimal Number: 167
Remainder
167 2 1
83 2 1
41 2 1
20 2 0
10 2 0
5 2 1
2 2 0
1 2 1
0
27 26 25 24 23 22 21 20
Binary Number: 1 0 1 0 0 1 1 1
E N G . A B D E L K A W Y M O U B A R A K | 0 1 0 1 4 8 71 07 5 37
Decimal Number: 167

27 26 25 24 23 22 21 20
Binary Number: 1 0 1 0 0 1 1 1
Decimal To BCD:
1 6 7

0 0 0 1 0 1 1 0 0 1 1 1

BCD Number : 0001 0110 0111

E N G . A B D E L K A W Y M O U B A R A K | 0 1 0 1 4 8 71 07 5 38
•Counter UP
CU

•Counter Down
CD

•Counter UP/Down
CUD

E N G . A B D E L K A W Y M O U B A R A K | 0 1 0 1 4 8 71 07 5 39
S7-300 Instruction

E N G . A B D E L K A W Y M O U B A R A K | 0 1 0 1 4 8 71 07 5 40
Counting Diagram

E N G . A B D E L K A W Y M O U B A R A K | 0 1 0 1 4 8 71 07 5 41
S7-300 Instruction

E N G . A B D E L K A W Y M O U B A R A K | 0 1 0 1 4 8 71 07 5 42
Counting Diagram

ENG.ABDELKAWY MOUBARAK | 01014871075 43


E N G . A B D E L K A W Y M O U B A R A K | 0 1 0 1 4 8 71 07 5 43
S7-300 Instruction

ENG.ABDELKAWY MOUBARAK | 01014871075 44


E N G . A B D E L K A W Y M O U B A R A K | 0 1 0 1 4 8 71 07 5 44
Counting Diagram

E N G . A B D E L K A W Y M O U B A R A K | 0 1 0 1 4 8 71 07 5 45
Full
SR

E N G . A B DEENLG K
. AAB W
D EYL KM
AWOYU M
B OAURBAA K
RAK
| |0 011001144 88771
1 007
75 5 46
46
 You can use comparison
instructions to compare the
following pairs of numerical values:

I  Compare integers (on the basis of 16 bit fixed-point number)


 D Compare integers (on the basis of 32 bit fixed-point number)
R Compare floating-point numbers (on 32 bit real number basis

If the result of comparison is “ True “ then the RLO of the


Operation Is “1” , otherwise it is “0” .
ENG.ABDELKAWY MOUBARAK | 01014871075 47
E N G . A B D E L K A W Y M O U B A R A K | 0 1 0 1 4 8 71 07 5 47
==
•IN1 is equal to IN2

<>
•IN1 is not equal to IN2

>
•IN1 is greater than IN2

•IN1 is less than IN2


<

•IN1 is greater than or equal to IN2


>=

•IN1 is less than or equal to IN2.


<=
ENG.ABDELKAWY MOUBARAK | 01014871075 48
E N G . A B D E L K A W Y M O U B A R A K | 0 1 0 1 4 8 71 07 5 48
Full
SR

E N G . A B DEENLG K
. AAB W
D EYL KM
AWOYU M
B OAURBAA K
RAK
| |0 011001144 88771
1 007
75 5 49
49
S1 S2 Right
Lamp

Start Reset
30
Stop

Alarm

E N G . A B DEENLG K
. AAB W
D EYL KM
AWOYU M
B OAURBAA K
RAK
| |0 011001144 88771
1 007
75 5 50
50
ADD_I : ADD  Type of math Operation
I  For Integer Numbers

EN Enable Inputs


ENO  Enable Outputs

IN1  the 1st I/P form math operation


IN2  the 2nd I/P form math operation

OUT  The result of the mathematical


operation is stored at the
address at output OUT.
 You can use Math instructions with the following pairs of numerical values:

•ADD_I - SUB_I
Integers (I)
•MUL_I - DIV_I

•ADD_DI - SUB_DI
Double •MUL_DI - DIV_DI
integers (DI)

•ADD_R - SUB_R
Real (R)
•MUL_R - DIV_R
S1 S2 Right
Lamp

Start Reset
30
Stop

Alarm

E N G . A B DEENLG K
. AAB W
D EYL KM
AWOYU M
B OAURBAA K
RAK
| |0 011001144 88771
1 007
75 5 53
53
𝐴2 : 4𝐴 : 5
𝑋=
5𝐵:2

ENG.ABDELKAWY MOUBARAK | 01014871075 54


E N G . A B D E L K A W Y M O U B A R A K | 0 1 0 1 4 8 71 07 5 54

Vous aimerez peut-être aussi