Date,2009-7-30
File,SSP2_01C.1
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
结构化编程操作系统
OB1 FC
FB FC
FB
SFC
SFB
其它
OBs
Date,2009-7-30
File,SSP2_01C.2
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
IEC 1131 标准
第一部分,主要信息定义 PLC 的术语
PLC 的主要功能特点
第二部分,设备要求电气,机械和功能上的要求制造商需提供的信息符合标准的规则 (一致性 )
第三部分,编程语言梯形图,功能方框图,语句表,顺序功能图和结构化文本
第四部分,用户指南系统分析和描述
PLC的选择和应用安全和保护,安装和维护
第五部分,通讯模式,通讯块,与 ISO协议的对应关系
Modul,IEC_T1D.
Date,2009-7-30
File,SSP2_01C.3
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
IEC1131 内容 - 第三部分
编译为标准代码的规则
软件模型,通讯模型,编程模型
可编程逻辑控制语言中的通用元件数据类型和变量功能和功能块程序和任务
指令表 (IL) (= 语句表 (STL))
结构化文本 (ST) (= 结构化控制语言 (SCL))
梯形图 (LD) (= LAD)
功能方框图 (FBD)
顺序功能图 (SFC) (= S7-GRAPH)
附加的语法规则和编程示例
Modul,IEC_T1D.
Date,2009-7-30
File,SSP2_01C.4
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
SIMATIC 管理器下的项目结构项目
S7/M7 程序 (未分配给硬件的 )
用 S7 块组成的用户程序,
OBs,FBs,FCs,DBs,等
STL 用户程序源文件
S7-300 可编程的 CPU
S7/M7 程序 (分配给硬件的 )
用户程序硬件站
STL 源文件
Date,2009-7-30
File,SSP2_01C.5
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
STEP7的块
Date,2009-7-30
File,SSP2_01C.6
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
块的组成部分变量声明表代码部分
Date,2009-7-30
File,SSP2_01C.7
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
块的首部
(36字节 )
块体变量声明部分和程序部分或数据压缩的接口描述块的结构
Date,2009-7-30
File,SSP2_01C.8
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
结构化编程
OB 1
电机 1
FC 1
电机 2
FC 1
电机 3
FC 1
Date,2009-7-30
File,SSP2_01C.9
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
利用局部数据进行控制
FC1 (数学功能 )
OB1
FC1
Input1
Input2
Input3
Output_A
FC1
Input1
Input2
Input3
Output_A
MW5
3369
MW10
QW12
QW20MW2
6869
MW16
I0.5
I0.5
SUB_I
IN1
IN2
( )
M5.1
O
ADD_I
IN1
IN2
M5.0
O #TEMP1
#INPUT1
#INPUT2
#TEMP1
#INPUT3
#Output_A
0.0
2.0
4.0
6.0
8.0
Input1
Input2
Input3
Output_A
TEMP1
in
in
in
out
temp
int
int
int
int
int
sample measure 1
constant
offset
result
intermediate
Date,2009-7-30
File,SSP2_01C.10
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
局部变量临时变量
当相关块执行完毕后被清除
临时存储在 L stack中
可在下列块中使用
OBs / FCs / FBs
静态变量
当相关块执行完毕后仍然保留
永久存储在 DBs中
只能在 FBs中使用局部变量 / 数据
(只在一个块中有效 )
全局变量 /数据
(在全部程序中有效 )
PII / PIQ
I/ O
M / T / C
DB areas
符号地址绝对地址访问方式
Date,2009-7-30
File,SSP2_01C.11
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
临时变量
Date,2009-7-30
File,SSP2_01C.12
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
执行的程序局部数据堆栈的大小对于 S7-300:
局部堆栈大小优先级
256 bytes1
27
总容量,
1.5 Kbyte
(CPU 313..316)
启动程序 (只执行一次 )
循环扫描程序
256 bytes
256 bytes
256 bytes12
3
2
时间中断日时钟中断延时处理中断循环处理中断循环扫描中的错误处理中断
256 bytes16
28
26
256 bytes
事件驱动中断硬件中断启动过程中的错误处理中断
Date,2009-7-30
File,SSP2_01C.13
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
块所需要的局部数据区的长度
rechts
Date,2009-7-30
File,SSP2_01C.14
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
256
By
tes
事件所占用的
L stack
1
OB1
OB 1
1
操作系统程序所占用的局部数据区的总长度
FC 2
有临时变量
OB1
FC2
FC1
3
3
OB1
FC1
4
4
OB1
FC1
6
6
FC 3
有临时变量
OB1
FC3
FC1
5
5
FC 1
有临时变量
2
OB1
FC1
2
7
OB1
7
Date,2009-7-30
File,SSP2_01C.15
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
练习 1.1,使用临时变量替换为临时变量
QW6
Date,2009-7-30
File,SSP2_01C.16
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
示例:故障信息指示
Disturbance
LED
Acknowledge
Report Memory
Edge Mem,Bit
Disturb,Input
Acknowl.
Flash Freq.
Disturb,Input
Display
RS
&
=
>=1&QS
R
P
Report Memory
Report Memory
解决方案要求
Date,2009-7-30
File,SSP2_01C.17
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
Disturb_
input
Report_
memory
Acknowledge
Edge_
mem_bit
Display
Flash_freq
FC 20
调用可以分配参数的块
A i 1.2
R m 40.0
A i 1.3
Fp m 40.1
S m 40.0
A m 40.0
A m 10.3
O
Anm 40.0
A i 1.3
= Q 4.3
不可以分配参数的块形式参数
M 40.0
M 40.1
I 1.3
I 1.2
Q 4.3
M 10.3
实际参数
A #Acknowledge
R #Report memory
A #Disturb_input
FP #Edge_mem_bit
S #Report_memory
A #Report_memory
A #Flash_freq
O
AN #Report_memory
A #Disturb_input
= #Display
可以分配参数的块程序
Date,2009-7-30
File,SSP2_01C.18
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
定义形式参数使用方法 图形显示只能读 在块的左侧只能写 在块的右侧参数类型输入参数输出参数输入 /输出 参数定义
in
out
In_out 可读 /可写 在块的左侧形式参数
FC 20 的变量声明表
Date,2009-7-30
File,SSP2_01C.19
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
编辑一个可分配参数的块对于无参数分配的块,此处可能是,
绝对地址,I1.3
符号地址,,End_left”
Date,2009-7-30
File,SSP2_01C.20
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
Disturb_input
Acknowledge
Flash_freq
Edge_mem_bit
Display
ENO
EN FC20
调用一个分配了参数的块
Network 3,First Call
Network 4,Second Call
M40.1
,Position
error”
,End left”
....
,Acknow.button”
M10.3
M40.0
,End right”
Q4.1
,Acknow.button”
M10.3
M40.2
符号的绝对的寻址方式符号 局部符号 -->形式参数符号表全局符号
Disturb_input
Acknowledge
Flash_freq
Report_memory
Edge_mem_bit
Display
ENO
EN FC20
M40.3
Q5.4
Report_memory
Date,2009-7-30
File,SSP2_01C.21
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
LAD/FBD STL
在块调用时使用 EN/ENO参数
CALL FC 1
NOP 0
例子
,?
FC 1
EN ENO
FC 2
EN ENO
FC 3
EN ENO =
FC 1
EN ENO,?无条件调用
A I 0.1
JNB _001
CALL FC 1
_001,A BR
= Q 5.0
FC 1
EN ENOI 0.1 =
Q 5.0
条件调用
Date,2009-7-30
File,SSP2_01C.22
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
FC 20 的变量声明表练习 1.2,生成一个分配了参数的 FC块无参数的块 分配了参数的块
FC 20
A I 1.2
R M 40.0
A I 1.3
FP M 40.1
S M 40.0
A M 40.0
A M 10.3
O
AN M 40.0
A I 1.3
= Q 5.3
A #Acknowledge
R #Report_memory
A #Disturb...
:
:
:
:
:
:
:
:
2.
1.
Date,2009-7-30
File,SSP2_01C.23
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
练习 1.3,调用一个分配了参数的 FC块
Disturb_input
Report_memory
Acknowledge
Edge_mem_bit
Display
Flash_freq
第一次调用 FC20时的参数分配
M 40.0
M 40.1
I 1.3
I 1.2 Q 5.3
M 10.3
FC 20
Disturb_input
Report_memory
Acknowledge
Edge_mem_bit
Display
Flash_freq
M 40.2
M 40.3
I 1.4
I 1.2 Q 5.4
M 10.3
FC 20
第二次调用 FC20时的参数分配
Date,2009-7-30
File,SSP2_01C.24
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
FB块
FB 2
EN
Disturb,input
Acknowledge Display
Flash freq,ENO
DB 2
OB 1
FB块的变量声明表
Date,2009-7-30
File,SSP2_01C.25
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
用 FB实现的故障信息显示
FB的声明表背景数据块
Date,2009-7-30
File,SSP2_01C.26
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
生成背景数据块
1,在 FB调用时生成背景数据块 2,创建一个新的背景数据块
Date,2009-7-30
File,SSP2_01C.27
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
多重背景模型
DB10
普通背景模型
FB20
OB 1
Call FB20,DB10
Disturb._Input:=
Acknowledge:=
Flash_Freq:=
Display:=
DB11
FB20
Call FB20,DB11
Disturb._Input:=
Acknowledge:=
Flash_Freq:=
Display:=
DB12
FB20
Call FB20,DB12
Disturb._Input:=
Acknowledge:=
Flash_Freq:=
Display:=
多重背景模型
FB 100
DB100
Call FB100,DB100
OB 1
stat Dist_1 FB20
stat Dist_2 FB20
Parameters and
static variables
of the 2nd,call
of FB20
Call Dist_2
Disturb._Input:=
Acknowledge:=
Flash_Freq:=
Display:=
Parameters and
static variables
of the 1st,call
of FB20
Call Dist_1
Disturb._Input:=
Acknowledge:=
Flash_Freq:=
Display:=
Date,2009-7-30
File,SSP2_01C.28
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
练习 1.4,编写一个 FB块
FB 20 的变量声明表1.
FB 20 中的部分程序 A #AcknowledgeR #Report memory
A #Disturb.,..
:
:
2.
Date,2009-7-30
File,SSP2_01C.29
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
练习 1.5,调用 FB并调试
Date,2009-7-30
File,SSP2_01C.30
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
插入 /删除块的参数可能遇到的问题
Date,2009-7-30
File,SSP2_01C.31
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
调用被修改过的块时应做的更正当调用块被打开时,
单击鼠标右键
Date,2009-7-30
File,SSP2_01C.32
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
练习 1.6,多台设备的风扇监控功能
A
B
C
=1 S_ODT
TIME
ACKN
SIG
&
A
B
C
R
S Q >=1
FLT
FC101
REPORT
A
B
C
ACKN
TIME
TV
FLT
SIG
功能 符号
Date,2009-7-30
File,SSP2_01C.33
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
练习 1.7,风扇监控功能的扩展
A
B
C
=1 S_
ODT
TIME
ACKN
SIG
&
A
B
C
R
S Q >=1
FLT
FC101
REPORT
A
B
C
ACKN
TIME
TV
FLT
SIG
功能 符号
ENAB
&ENAB
ENAB
Date,2009-7-30
File,SSP2_01C.34
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
练习 1.8,识别变量的类型
Absolute Symbolic Temporary Static Parameter
L #Number_1
T #Max_value
T MW 40
Statement
L #Number_2
L #Intermediate_result
L,Number_1”
T #Number_2
Global Local
Date,2009-7-30
File,SSP2_01C.35
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
总结,块的调用
CALL FC1
UC FC1
CC FC1
STL
LAD
FBD FC1EN
ENO
FC1
EN ENO
FC1
( CALL )
FB
无参数,无背景数据块
UC FB1
CC FB1
CALL
有参数
CALL FC2
Par1,...
Par2,...
Par3,...
FC2
EN ENO
Par3
Par1
Par2
FC2
EN
ENO
Par1
Par2
Par3
有参数,有背景数据块
CALL FB2,DB3
Par1,...
Par2,...
Par3,...
FB2
EN ENO
Par3
Par1
Par2
DB3
FB2
EN
ENO
Par3
Par1
Par2
DB3
无参数语言
FC
FC1
File,SSP2_01C.1
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
结构化编程操作系统
OB1 FC
FB FC
FB
SFC
SFB
其它
OBs
Date,2009-7-30
File,SSP2_01C.2
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
IEC 1131 标准
第一部分,主要信息定义 PLC 的术语
PLC 的主要功能特点
第二部分,设备要求电气,机械和功能上的要求制造商需提供的信息符合标准的规则 (一致性 )
第三部分,编程语言梯形图,功能方框图,语句表,顺序功能图和结构化文本
第四部分,用户指南系统分析和描述
PLC的选择和应用安全和保护,安装和维护
第五部分,通讯模式,通讯块,与 ISO协议的对应关系
Modul,IEC_T1D.
Date,2009-7-30
File,SSP2_01C.3
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
IEC1131 内容 - 第三部分
编译为标准代码的规则
软件模型,通讯模型,编程模型
可编程逻辑控制语言中的通用元件数据类型和变量功能和功能块程序和任务
指令表 (IL) (= 语句表 (STL))
结构化文本 (ST) (= 结构化控制语言 (SCL))
梯形图 (LD) (= LAD)
功能方框图 (FBD)
顺序功能图 (SFC) (= S7-GRAPH)
附加的语法规则和编程示例
Modul,IEC_T1D.
Date,2009-7-30
File,SSP2_01C.4
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
SIMATIC 管理器下的项目结构项目
S7/M7 程序 (未分配给硬件的 )
用 S7 块组成的用户程序,
OBs,FBs,FCs,DBs,等
STL 用户程序源文件
S7-300 可编程的 CPU
S7/M7 程序 (分配给硬件的 )
用户程序硬件站
STL 源文件
Date,2009-7-30
File,SSP2_01C.5
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
STEP7的块
Date,2009-7-30
File,SSP2_01C.6
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
块的组成部分变量声明表代码部分
Date,2009-7-30
File,SSP2_01C.7
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
块的首部
(36字节 )
块体变量声明部分和程序部分或数据压缩的接口描述块的结构
Date,2009-7-30
File,SSP2_01C.8
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
结构化编程
OB 1
电机 1
FC 1
电机 2
FC 1
电机 3
FC 1
Date,2009-7-30
File,SSP2_01C.9
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
利用局部数据进行控制
FC1 (数学功能 )
OB1
FC1
Input1
Input2
Input3
Output_A
FC1
Input1
Input2
Input3
Output_A
MW5
3369
MW10
QW12
QW20MW2
6869
MW16
I0.5
I0.5
SUB_I
IN1
IN2
( )
M5.1
O
ADD_I
IN1
IN2
M5.0
O #TEMP1
#INPUT1
#INPUT2
#TEMP1
#INPUT3
#Output_A
0.0
2.0
4.0
6.0
8.0
Input1
Input2
Input3
Output_A
TEMP1
in
in
in
out
temp
int
int
int
int
int
sample measure 1
constant
offset
result
intermediate
Date,2009-7-30
File,SSP2_01C.10
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
局部变量临时变量
当相关块执行完毕后被清除
临时存储在 L stack中
可在下列块中使用
OBs / FCs / FBs
静态变量
当相关块执行完毕后仍然保留
永久存储在 DBs中
只能在 FBs中使用局部变量 / 数据
(只在一个块中有效 )
全局变量 /数据
(在全部程序中有效 )
PII / PIQ
I/ O
M / T / C
DB areas
符号地址绝对地址访问方式
Date,2009-7-30
File,SSP2_01C.11
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
临时变量
Date,2009-7-30
File,SSP2_01C.12
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
执行的程序局部数据堆栈的大小对于 S7-300:
局部堆栈大小优先级
256 bytes1
27
总容量,
1.5 Kbyte
(CPU 313..316)
启动程序 (只执行一次 )
循环扫描程序
256 bytes
256 bytes
256 bytes12
3
2
时间中断日时钟中断延时处理中断循环处理中断循环扫描中的错误处理中断
256 bytes16
28
26
256 bytes
事件驱动中断硬件中断启动过程中的错误处理中断
Date,2009-7-30
File,SSP2_01C.13
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
块所需要的局部数据区的长度
rechts
Date,2009-7-30
File,SSP2_01C.14
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
256
By
tes
事件所占用的
L stack
1
OB1
OB 1
1
操作系统程序所占用的局部数据区的总长度
FC 2
有临时变量
OB1
FC2
FC1
3
3
OB1
FC1
4
4
OB1
FC1
6
6
FC 3
有临时变量
OB1
FC3
FC1
5
5
FC 1
有临时变量
2
OB1
FC1
2
7
OB1
7
Date,2009-7-30
File,SSP2_01C.15
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
练习 1.1,使用临时变量替换为临时变量
QW6
Date,2009-7-30
File,SSP2_01C.16
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
示例:故障信息指示
Disturbance
LED
Acknowledge
Report Memory
Edge Mem,Bit
Disturb,Input
Acknowl.
Flash Freq.
Disturb,Input
Display
RS
&
=
>=1&QS
R
P
Report Memory
Report Memory
解决方案要求
Date,2009-7-30
File,SSP2_01C.17
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
Disturb_
input
Report_
memory
Acknowledge
Edge_
mem_bit
Display
Flash_freq
FC 20
调用可以分配参数的块
A i 1.2
R m 40.0
A i 1.3
Fp m 40.1
S m 40.0
A m 40.0
A m 10.3
O
Anm 40.0
A i 1.3
= Q 4.3
不可以分配参数的块形式参数
M 40.0
M 40.1
I 1.3
I 1.2
Q 4.3
M 10.3
实际参数
A #Acknowledge
R #Report memory
A #Disturb_input
FP #Edge_mem_bit
S #Report_memory
A #Report_memory
A #Flash_freq
O
AN #Report_memory
A #Disturb_input
= #Display
可以分配参数的块程序
Date,2009-7-30
File,SSP2_01C.18
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
定义形式参数使用方法 图形显示只能读 在块的左侧只能写 在块的右侧参数类型输入参数输出参数输入 /输出 参数定义
in
out
In_out 可读 /可写 在块的左侧形式参数
FC 20 的变量声明表
Date,2009-7-30
File,SSP2_01C.19
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
编辑一个可分配参数的块对于无参数分配的块,此处可能是,
绝对地址,I1.3
符号地址,,End_left”
Date,2009-7-30
File,SSP2_01C.20
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
Disturb_input
Acknowledge
Flash_freq
Edge_mem_bit
Display
ENO
EN FC20
调用一个分配了参数的块
Network 3,First Call
Network 4,Second Call
M40.1
,Position
error”
,End left”
....
,Acknow.button”
M10.3
M40.0
,End right”
Q4.1
,Acknow.button”
M10.3
M40.2
符号的绝对的寻址方式符号 局部符号 -->形式参数符号表全局符号
Disturb_input
Acknowledge
Flash_freq
Report_memory
Edge_mem_bit
Display
ENO
EN FC20
M40.3
Q5.4
Report_memory
Date,2009-7-30
File,SSP2_01C.21
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
LAD/FBD STL
在块调用时使用 EN/ENO参数
CALL FC 1
NOP 0
例子
,?
FC 1
EN ENO
FC 2
EN ENO
FC 3
EN ENO =
FC 1
EN ENO,?无条件调用
A I 0.1
JNB _001
CALL FC 1
_001,A BR
= Q 5.0
FC 1
EN ENOI 0.1 =
Q 5.0
条件调用
Date,2009-7-30
File,SSP2_01C.22
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
FC 20 的变量声明表练习 1.2,生成一个分配了参数的 FC块无参数的块 分配了参数的块
FC 20
A I 1.2
R M 40.0
A I 1.3
FP M 40.1
S M 40.0
A M 40.0
A M 10.3
O
AN M 40.0
A I 1.3
= Q 5.3
A #Acknowledge
R #Report_memory
A #Disturb...
:
:
:
:
:
:
:
:
2.
1.
Date,2009-7-30
File,SSP2_01C.23
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
练习 1.3,调用一个分配了参数的 FC块
Disturb_input
Report_memory
Acknowledge
Edge_mem_bit
Display
Flash_freq
第一次调用 FC20时的参数分配
M 40.0
M 40.1
I 1.3
I 1.2 Q 5.3
M 10.3
FC 20
Disturb_input
Report_memory
Acknowledge
Edge_mem_bit
Display
Flash_freq
M 40.2
M 40.3
I 1.4
I 1.2 Q 5.4
M 10.3
FC 20
第二次调用 FC20时的参数分配
Date,2009-7-30
File,SSP2_01C.24
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
FB块
FB 2
EN
Disturb,input
Acknowledge Display
Flash freq,ENO
DB 2
OB 1
FB块的变量声明表
Date,2009-7-30
File,SSP2_01C.25
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
用 FB实现的故障信息显示
FB的声明表背景数据块
Date,2009-7-30
File,SSP2_01C.26
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
生成背景数据块
1,在 FB调用时生成背景数据块 2,创建一个新的背景数据块
Date,2009-7-30
File,SSP2_01C.27
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
多重背景模型
DB10
普通背景模型
FB20
OB 1
Call FB20,DB10
Disturb._Input:=
Acknowledge:=
Flash_Freq:=
Display:=
DB11
FB20
Call FB20,DB11
Disturb._Input:=
Acknowledge:=
Flash_Freq:=
Display:=
DB12
FB20
Call FB20,DB12
Disturb._Input:=
Acknowledge:=
Flash_Freq:=
Display:=
多重背景模型
FB 100
DB100
Call FB100,DB100
OB 1
stat Dist_1 FB20
stat Dist_2 FB20
Parameters and
static variables
of the 2nd,call
of FB20
Call Dist_2
Disturb._Input:=
Acknowledge:=
Flash_Freq:=
Display:=
Parameters and
static variables
of the 1st,call
of FB20
Call Dist_1
Disturb._Input:=
Acknowledge:=
Flash_Freq:=
Display:=
Date,2009-7-30
File,SSP2_01C.28
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
练习 1.4,编写一个 FB块
FB 20 的变量声明表1.
FB 20 中的部分程序 A #AcknowledgeR #Report memory
A #Disturb.,..
:
:
2.
Date,2009-7-30
File,SSP2_01C.29
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
练习 1.5,调用 FB并调试
Date,2009-7-30
File,SSP2_01C.30
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
插入 /删除块的参数可能遇到的问题
Date,2009-7-30
File,SSP2_01C.31
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
调用被修改过的块时应做的更正当调用块被打开时,
单击鼠标右键
Date,2009-7-30
File,SSP2_01C.32
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
练习 1.6,多台设备的风扇监控功能
A
B
C
=1 S_ODT
TIME
ACKN
SIG
&
A
B
C
R
S Q >=1
FLT
FC101
REPORT
A
B
C
ACKN
TIME
TV
FLT
SIG
功能 符号
Date,2009-7-30
File,SSP2_01C.33
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
练习 1.7,风扇监控功能的扩展
A
B
C
=1 S_
ODT
TIME
ACKN
SIG
&
A
B
C
R
S Q >=1
FLT
FC101
REPORT
A
B
C
ACKN
TIME
TV
FLT
SIG
功能 符号
ENAB
&ENAB
ENAB
Date,2009-7-30
File,SSP2_01C.34
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
练习 1.8,识别变量的类型
Absolute Symbolic Temporary Static Parameter
L #Number_1
T #Max_value
T MW 40
Statement
L #Number_2
L #Intermediate_result
L,Number_1”
T #Number_2
Global Local
Date,2009-7-30
File,SSP2_01C.35
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
总结,块的调用
CALL FC1
UC FC1
CC FC1
STL
LAD
FBD FC1EN
ENO
FC1
EN ENO
FC1
( CALL )
FB
无参数,无背景数据块
UC FB1
CC FB1
CALL
有参数
CALL FC2
Par1,...
Par2,...
Par3,...
FC2
EN ENO
Par3
Par1
Par2
FC2
EN
ENO
Par1
Par2
Par3
有参数,有背景数据块
CALL FB2,DB3
Par1,...
Par2,...
Par3,...
FB2
EN ENO
Par3
Par1
Par2
DB3
FB2
EN
ENO
Par3
Par1
Par2
DB3
无参数语言
FC
FC1