兔小喵一只
级别: 探索解密
精华主题: 0
发帖数量: 4 个
工控威望: 114 点
下载积分: 831 分
在线时间: 3(小时)
注册时间: 2012-09-20
最后登录: 2013-04-17
查看兔小喵一只的 主题 / 回贴
楼主  发表于: 2012-11-14 16:45
用西门子SCL语言编程,一些计算过程需要自己编写函数实现。遇到的问题是:一个函数的输入值是另一个函数的输出值,所以我想到用FC调用FC。

目前有三个函数,是FC48,FC4,FC49。在FB40里调用三个函数。

//下面是程序**********************************************红色的变量是输入输出值

FUNCTION_BLOCK FB40 //谷电期蓄能总控制
VAR_OUTPUT
RESULT_Q:INT; //输出Q量
RESULT_W:INT;
RESULT_Wt:INT;
END_VAR

BEGIN //调用FC48计算Q
RESULT_Q:=FC48(Ai := "A" // IN: INT
,Hdesign_total := "Hdt" // IN: INT
,Wpower_real :="W0" // IN: INT
,Qdesign_total :="Q0" // OUT: INT
); // INT

//调用FC4计算Wpower_real******************************************
RESULT_W:=FC4(Wpower_real_today :="W1" // IN: INT
,Toutdr_offpk_sta_tody :="T01" // IN: INT
,Toutdr_offpk_sta_yesdy := "T02" // IN: INT
,Wpower_real :="W0" // OUT: INT
); // INT

//调用FC49计算Wpower_real_today************************************
RESULT_Wt:=FC49 (Theating_unit_11 := "Q2" // IN: REAL
,Theating_unit_12 := "Q3" // IN: REAL
,Theating_unit_21 := "Q4" // IN: REAL
,Theating_unit_22 := "Q5" // IN: REAL
,Theating_unit_31 := "Q6" // IN: REAL
,Theating_unit_32 := "Q7" // IN: REAL
,Qadd := "Qa" // IN: REAL
,A := "A" // IN: REAL
,Huser :="Hu" // IN: REAL
,Ttime_offpkend_11 := "Q11" // IN: REAL
,Ttime_offpkend_12 := "Q12" // IN: REAL
,Ttime_offpkend_21 := "Q21" // IN: REAL
,Ttime_offpkend_22 := "Q22" // IN: REAL
,Ttime_offpkend_31 := "Q31" // IN: REAL
,Ttime_offpkend_32 := "Q32" // IN: REAL
,Wpower_real_today := "W1" // OUT: REAL
); // REAL
END_FUNCTION_BLOCK


编译后的错误时invalid assignment。在调用FC48和FC4处有问题.

三个FC函数分别编译都没有问题。下面是三个函数:

FUNCTION FC48 : INT

VAR_INPUT
Ai:INT;
Hdesign_total:INT;
Wpower_real:INT;
END_VAR

VAR_OUTPUT
Qdesign_total:INT;

END_VAR

BEGIN

FC48:=(Ai*Hdesign_total)*Wpower_real;
Qdesign_total:=FC48;
// Statement Section


END_FUNCTION

//****************************************************

FUNCTION FC4 : INT

VAR_INPUT
Wpower_real_today:INT;
Toutdr_offpk_sta_tody:INT;
Toutdr_offpk_sta_yesdy:INT;

END_VAR
VAR_OUTPUT
Wpower_real:INT;
END_VAR

BEGIN

//*******************************************

FUNCTION FC49 : INT



VAR_INPUT
Theating_unit_11:INT;
Theating_unit_12:INT;
Theating_unit_21:INT;
Theating_unit_22:INT;
Theating_unit_31:INT;
Theating_unit_32:INT;
Qadd:INT;
A:INT;//房间面积
Huser:INT;
Ttime_offpkend_11:INT;
Ttime_offpkend_12:INT;
Ttime_offpkend_21:INT;
Ttime_offpkend_22:INT;
Ttime_offpkend_31:INT;
Ttime_offpkend_32:INT;
END_VAR

VAR_OUTPUT
Wpower_real_today:INT;//第二天预计供热负荷
END_VAR

BEGIN
FC49:=(a*(Theating_unit_11+Theating_unit_12+Theating_unit_21+Theating_unit_22+Theating_unit_31+Theating_unit_32-Ttime_offpkend_11-Ttime_offpkend_12-Ttime_offpkend_21-Ttime_offpkend_22-Ttime_offpkend_31-Ttime_offpkend_32)+Qadd)/(A* Huser);
Wpower_real_today:=FC49;

END_FUNCTION