三菱ST編程02
https://mp.weixin.qq.com/s/aSPsQGHgqlZapJV6IBpwpw3.FOR......Do語句
4.While......Do語句
別人用PLC寫的貪吃蛇部分程序(有很多值得借鑒與學(xué)習(xí))
(四)使用ST語句注意事項(xiàng)
(五)功能塊的創(chuàng)建與使用
(六)ST調(diào)用 功能塊 FB
注:對于進(jìn)行了ST程序轉(zhuǎn)換時的運(yùn)算結(jié)果,由于不對處理值是單字型還
是雙字型進(jìn)行判斷,是進(jìn)行無符號運(yùn)算,而在可編程控制器CPU中是
進(jìn)行帶符號運(yùn)算。
<使用示例>
Data1 = -32768;
Data2 = 16#8000;
·ST Result := Data1 / Data2; → -32768÷32768 = -1
·CPU Result := Data1 / Data2; → -32768÷-32768 = 1
數(shù)組標(biāo)簽全局變量
只要指定起始軟元件就行。如下圖所示:
(七)ST常用運(yùn)算符與函數(shù)
實(shí)例:
3天產(chǎn)能統(tǒng)計(jì)實(shí)例:
程序樣例:
(*單控氣缸動作*)
OUT((M_action AND A_stop AND NOT A_action) OR (A_action AND NOT A_stop), O_cylinder);
(*單控氣缸報(bào)警*)
IF SM412=FALSE THEN
MIddle10:=1;
END_IF ;
IF SM412=TRUE THEN
MIddle10:=0;
END_IF ;
IF SM412=FALSE THEN
MIddle11:=1;
END_IF ;
IF SM412=TRUE THEN
MIddle11:=0;
END_IF ;
IF (O_cylinder AND NOT LimitNeg) THEN
INCP(NOT MIddle11, time11);
IF time11=AlarmDelay THEN
Tim11:=1;
time11:=0;
END_IF;
END_IF;
IF (NOT O_cylinder AND LimitNeg) AND AlarmReset THEN
Tim11:=0;
END_IF;
IF (NOT O_cylinder AND NOT LimitPos) THEN
INCP(NOT MIddle10, time10);
IF time10=AlarmDelay THEN
Tim10:=1;
time10:=0;
END_IF;
END_IF;
IF (NOT O_cylinder AND LimitPos) AND AlarmReset THEN
Tim10:=0;
END_IF;
(*單控氣缸報(bào)警*)
(*OUT_T((O_cylinder AND NOT LimitNeg), time11,AlarmDelay);
OUT_T((NOT O_cylinder AND NOT LimitPos) ,time10, AlarmDelay);*)
OUT((Tim11 OR (outAlamNeg AND NOT AlarmReset)) , outAlamNeg);
OUT((Tim10 OR (outAlamPos AND NOT AlarmReset )) ,outAlamPOs);
閱讀 16贊