UP/MAKRO程序調(diào)用
該指令可用于調(diào)用子程序并將子程序調(diào)用鏈接到條件(布爾操作數(shù))。如果需要,可以鏈接多個(gè)操作數(shù)(最多11個(gè))。
子程序的調(diào)用次數(shù)沒(méi)有限制。
UP101 = F78 + F79 激活條件UP101
;%{SE}%MKUKATPVW %CVW_SPS %VUP %P 2:UP101 = F78 + F79,3:UP
;ENDFOLDSEL_RES=SELECT(#UP,101,$FLAG[78] OR $FLAG[79])
REPEAT UP101 N= 999 STOP= !F298 條件滿(mǎn)足停止循環(huán)調(diào)用UP101
SEL_RES=SELECT (#CYC_UP,101,TRUE,#NUM,999,#NOT_F,298,FALSE)
;ENDFOLD
;ENDFOLD
DEFFCT INT SELECT
(SUB :IN,NO :IN,CALL_CND :IN,ARI_OP :IN,ARI_NUM :IN,BOOL_OP :IN,BOOL_NUM :IN,MAKRO_ADV :IN)
SUB : 選擇調(diào)用的類(lèi)型UP/makro
NO : 程序號(hào)
CALL_CND : 激活條件
ADV_RESULT = 0
IF NOT CALL_CND THEN ---如果不激活就跳步到最后
GOTO PEXIT -----跳步到退出
ENDIF
SWITCH SUB
CASE #UP 使用調(diào)用UP
CALLBYSELECT=TRUE
SWITCH NO ;調(diào)用UP程序號(hào)
CASE 101 ---程序號(hào)
UP101( ) 調(diào)用UP程序號(hào)
CASE 102
UP102( )
CASE 103
UP103( )
CASE 112
UP112( )
CASE 201
UP201( )
CASE 206
UP206( )
DEFAULT
$LOOP_MSG[]=" "
OFFSET = 0
---程序號(hào)不能被調(diào)用---
SWRITE($LOOP_MSG[],STATE,OFFSET,"UP%D ist nicht vorhanden",NO)
HALT ---程序號(hào)不能被調(diào)用---使得程序停止
$LOOP_MSG[]=" "
ENDSWITCH
CALLBYSELECT=FALSE
CASE #MAKRO
SWITCH NO ;開(kāi)始調(diào)用MAKRO程序號(hào) --
CASE 0 要激活的程序號(hào)
ADV_RESULT= MAKRO0 (MAKRO_ADV) 激活MAKRO0程序
CASE 1
ADV_RESULT= MAKRO1 (MAKRO_ADV) 激活MAKRO1程序
CASE 2
ADV_RESULT= MAKRO2 (MAKRO_ADV)
CASE 3
ADV_RESULT= MAKRO3 (MAKRO_ADV)
CASE 4
ADV_RESULT= MAKRO4 (MAKRO_ADV)
CASE 5
ADV_RESULT= MAKRO5 (MAKRO_ADV)
CASE 6
ADV_RESULT= MAKRO6 (MAKRO_ADV)
CASE 7
ADV_RESULT= MAKRO7 (MAKRO_ADV)
CASE 8
ADV_RESULT= MAKRO8 (MAKRO_ADV)
CASE 9
ADV_RESULT= MAKRO9 (MAKRO_ADV)
CASE 10
ADV_RESULT= MAKRO10 (MAKRO_ADV)
CASE 11
ADV_RESULT= MAKRO11 (MAKRO_ADV)
CASE 12
ADV_RESULT= MAKRO12 (MAKRO_ADV)
CASE 13
ADV_RESULT= MAKRO13 (MAKRO_ADV)
CASE 14
ADV_RESULT= MAKRO14 (MAKRO_ADV)
CASE 15
ADV_RESULT= MAKRO15 (MAKRO_ADV)
CASE 20
ADV_RESULT= MAKRO20 (MAKRO_ADV)
CASE 50
ADV_RESULT= MAKRO50 (MAKRO_ADV)
CASE 57
ADV_RESULT= MAKRO57 (MAKRO_ADV)
CASE 80
ADV_RESULT= MAKRO80 (MAKRO_ADV)
CASE 81
ADV_RESULT= MAKRO81 (MAKRO_ADV)
CASE 82
ADV_RESULT= MAKRO82 (MAKRO_ADV)
CASE 83
ADV_RESULT= MAKRO83 (MAKRO_ADV)
CASE 89
ADV_RESULT= MAKRO89 (MAKRO_ADV)
DEFAULT
$LOOP_MSG[]=" "
-------沒(méi)有建立的Makro號(hào)被調(diào)用
OFFSET = 0
SWRITE($LOOP_MSG[],STATE,OFFSET,"Makro%D ist nicht vorhanden",NO)
用來(lái)模擬顯示: 沒(méi)有建立的Makro號(hào)被調(diào)用
HALT -----如果沒(méi)有號(hào)需要停止
$LOOP_MSG[]=" "
ENDSWITCH 結(jié)束了MAKRO選擇
CASE #CYC_UP -----循環(huán)執(zhí)行UP程序
NR=0
WHILE NOT (CHECK_BOOL(BOOL_OP,BOOL_NUM) OR CHECK_ARI(NR,ARI_OP,ARI_NUM)) CHECK_BOOL/ CHECK_ARI啟動(dòng)功能條件開(kāi)啟
NR=NR+1 從0開(kāi)始計(jì)數(shù)大于給定值將不執(zhí)行循環(huán)程序
CALLBYSELECT=TRUE
SWITCH NO ; UP程序號(hào)調(diào)用
CASE 101
UP101( )
CASE 102
UP102( )
CASE 103
UP103( )
CASE 112
UP112( )
CASE 201
UP201( )
CASE 206
UP206( )
DEFAULT
$LOOP_MSG[]=" "
UP程序號(hào)沒(méi)有被激活的程序號(hào)
OFFSET = 0
SWRITE($LOOP_MSG[],STATE,OFFSET,"UP%D ist nicht vorhanden",NO)
HALT 程序號(hào)沒(méi)有使用程序停止
$LOOP_MSG[]=" "
ENDSWITCH
CALLBYSELECT=FALSE
ENDWHILE
CASE #CYC_MAKRO -----循環(huán)執(zhí)行MAKRO程序
NR=0
WHILE NOT (CHECK_BOOL(BOOL_OP,BOOL_NUM) OR CHECK_ARI(NR,ARI_OP,ARI_NUM)) 大于給定值將不執(zhí)行循環(huán)程序
NR=NR+1 從0開(kāi)始計(jì)數(shù)大于給定值將不執(zhí)行循環(huán)程序
SWITCH NO -----調(diào)用的程序號(hào)
CASE 0
ADV_RESULT= MAKRO0 (MAKRO_ADV) 調(diào)用執(zhí)行MAKRO程序
CASE 1
ADV_RESULT= MAKRO1 (MAKRO_ADV)
CASE 2
ADV_RESULT= MAKRO2 (MAKRO_ADV)
CASE 3
ADV_RESULT= MAKRO3 (MAKRO_ADV)
CASE 4
ADV_RESULT= MAKRO4 (MAKRO_ADV)
CASE 5
ADV_RESULT= MAKRO5 (MAKRO_ADV)
CASE 6
ADV_RESULT= MAKRO6 (MAKRO_ADV)
CASE 7
ADV_RESULT= MAKRO7 (MAKRO_ADV)
CASE 8
ADV_RESULT= MAKRO8 (MAKRO_ADV)
CASE 9
ADV_RESULT= MAKRO9 (MAKRO_ADV)
CASE 10
ADV_RESULT= MAKRO10 (MAKRO_ADV)
CASE 11
ADV_RESULT= MAKRO11 (MAKRO_ADV)
CASE 12
ADV_RESULT= MAKRO12 (MAKRO_ADV)
CASE 13
ADV_RESULT= MAKRO13 (MAKRO_ADV)
CASE 14
ADV_RESULT= MAKRO14 (MAKRO_ADV)
CASE 15
ADV_RESULT= MAKRO15 (MAKRO_ADV)
CASE 20
ADV_RESULT= MAKRO20 (MAKRO_ADV)
CASE 50
ADV_RESULT= MAKRO50 (MAKRO_ADV)
CASE 57
ADV_RESULT= MAKRO57 (MAKRO_ADV)
CASE 80
ADV_RESULT= MAKRO80 (MAKRO_ADV)
CASE 81
ADV_RESULT= MAKRO81 (MAKRO_ADV)
CASE 82
ADV_RESULT= MAKRO82 (MAKRO_ADV)
CASE 83
ADV_RESULT= MAKRO83 (MAKRO_ADV)
CASE 89
ADV_RESULT= MAKRO89 (MAKRO_ADV)
DEFAULT
$LOOP_MSG[]=" "
Makro程序號(hào)沒(méi)有被激活的程序號(hào)
OFFSET = 0
SWRITE($LOOP_MSG[],STATE,OFFSET,"Makro%D ist nicht vorhanden",NO)
HALT -----程序號(hào)沒(méi)有使用程序停止
$LOOP_MSG[]=" "
ENDSWITCH ---結(jié)束選擇程序
ENDWHILE ---結(jié)束條件
DEFAULT --- 沒(méi)有UP,MAKRO,CYC_MAKRO,CYC_UP
ENDSWITCH ---結(jié)束選擇程序
PEXIT: -------跳步退出
RETURN ADV_RESULT
ENDFCT
---檢查位用于循環(huán)調(diào)用---
DEFFCT BOOL CHECK_BOOL(BOOLOP :IN,BOOLOP_NUM :IN)
INT BOOLOP_NUM 位號(hào),數(shù)字
DECL BOOL_TYP BOOLOP 各種類(lèi)型
BOOL STOP_BOOL
SWITCH BOOLOP
CASE #EIN
STOP_BOOL=TRUE ---激活
CASE #AUS
STOP_BOOL=FALSE ---關(guān)閉
CASE #E
STOP_BOOL=$IN[BOOLOP_NUM] ---用輸入激活
CASE #NOT_E
STOP_BOOL= NOT $IN[BOOLOP_NUM] ---輸入取反激活
CASE #A
STOP_BOOL=$OUT[BOOLOP_NUM] ---用輸出激活
CASE #NOT_A
STOP_BOOL= NOT $OUT[BOOLOP_NUM] ---用輸出的非激活
CASE #M
STOP_BOOL=$CYCFLAG[BOOLOP_NUM] ---用M量激活
CASE #NOT_M
STOP_BOOL= NOT $CYCFLAG[BOOLOP_NUM] ---用M量的非激活
CASE #F
STOP_BOOL=$FLAG[BOOLOP_NUM] 用F量激活
CASE #NOT_F
STOP_BOOL= NOT $FLAG[BOOLOP_NUM] 用F量的非激活
CASE #T
STOP_BOOL=$TIMER_FLAG[BOOLOP_NUM] 用時(shí)間量激活
CASE #NOT_T
STOP_BOOL= NOT $TIMER_FLAG[BOOLOP_NUM] 用時(shí)間量的非激活
CASE #S
STOP_BOOL=S[BOOLOP_NUM] S量一般不用
CASE #NOT_S
STOP_BOOL= NOT S[BOOLOP_NUM]
ENDSWITCH
RETURN (STOP_BOOL) 條件滿(mǎn)足反饋
ENDFCT
-----用于輸入數(shù)---
DEFFCT BOOL CHECK_ARI(ACT_NR :IN, ARIOP :IN ,ARIOP_NUM :IN)
INT ACT_NR, ARIOP_NUM, MAX_NR
DECL ARI_TYP ARIOP
SWITCH ARIOP
CASE #NUM 直接給入數(shù)
MAX_NR=ARIOP_NUM
CASE #COUNT 計(jì)數(shù)器
MAX_NR=$COUNT_I[ARIOP_NUM]
CASE #BIN 二進(jìn)制
MAX_NR=$B_OUT[ARIOP_NUM]
CASE #BININ 二進(jìn)制輸入
MAX_NR=ARIOP_NUM
CASE #ANA 模擬量輸出
MAX_NR=$ANOUT[ARIOP_NUM]*1000
CASE #ANAIN 模擬量輸入
MAX_NR=$ANIN[ARIOP_NUM]*1000
CASE #TIMER 時(shí)間控制
MAX_NR=$TIMER[ARIOP_NUM]*0.01
CASE #PROCPAR P值控制
MAX_NR=PROCPAR[ARIOP_NUM]
ENDSWITCH
RETURN (ACT_NR>=MAX_NR) 計(jì)數(shù)大于給定值.
ENDFCT
;ENDFOLD
;ENDFOLD
編輯:jq
-
plc
+關(guān)注
關(guān)注
5010文章
13271瀏覽量
463055 -
KUKA
+關(guān)注
關(guān)注
3文章
217瀏覽量
16516
原文標(biāo)題:KUKA的程序調(diào)用--VSS版本解析
文章出處:【微信號(hào):gh_a8b121171b08,微信公眾號(hào):機(jī)器人及PLC自動(dòng)化應(yīng)用】歡迎添加關(guān)注!文章轉(zhuǎn)載請(qǐng)注明出處。
發(fā)布評(píng)論請(qǐng)先 登錄
相關(guān)推薦
評(píng)論