兔小喵一只
級(jí)別: 探索解密
精華主題: 0
發(fā)帖數(shù)量: 4 個(gè)
工控威望: 114 點(diǎn)
下載積分: 831 分
在線(xiàn)時(shí)間: 3(小時(shí))
注冊(cè)時(shí)間: 2012-09-20
最后登錄: 2013-04-17
查看兔小喵一只的 主題 / 回貼
樓主  發(fā)表于: 2012-11-14 16:45
用西門(mén)子SCL語(yǔ)言編程,一些計(jì)算過(guò)程需要自己編寫(xiě)函數(shù)實(shí)現(xiàn)。遇到的問(wèn)題是:一個(gè)函數(shù)的輸入值是另一個(gè)函數(shù)的輸出值,所以我想到用FC調(diào)用FC。

目前有三個(gè)函數(shù),是FC48,FC4,F(xiàn)C49。在FB40里調(diào)用三個(gè)函數(shù)。

//下面是程序**********************************************紅色的變量是輸入輸出值

FUNCTION_BLOCK FB40 //谷電期蓄能總控制
VAR_OUTPUT
RESULT_Q:INT; //輸出Q量
RESULT_W:INT;
RESULT_Wt:INT;
END_VAR

BEGIN //調(diào)用FC48計(jì)算Q
RESULT_Q:=FC48(Ai := "A" // IN: INT
,Hdesign_total := "Hdt" // IN: INT
,Wpower_real :="W0" // IN: INT
,Qdesign_total :="Q0" // OUT: INT
); // INT

//調(diào)用FC4計(jì)算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

//調(diào)用FC49計(jì)算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


編譯后的錯(cuò)誤時(shí)invalid assignment。在調(diào)用FC48和FC4處有問(wèn)題.

三個(gè)FC函數(shù)分別編譯都沒(méi)有問(wèn)題。下面是三個(gè)函數(shù):

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;//第二天預(yù)計(jì)供熱負(fù)荷
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