S7-300 STL 簡單程序編寫和仿真
程序概覽

地址分配
?數(shù)據(jù)塊 motor 地址分配
Static
i0.0 Bool 0.0 false True True False PEB1 光電傳感器
i0.1 Bool 0.1 false True True False PEB2 光電傳感器
q4.0 Bool 0.2 false True True False 向右運動顯示? right
q4.1 Bool 0.3 false True True False 向左動動顯示 left
m0.0 Bool 0.4 false True True False PMB1 脈沖存儲存位
m0.1 Bool 0.5 false True True False PMB2 脈沖存儲存位
BTN0 Bool 0.6 false True True False
BTN1 Bool 0.7 false True True False
Flage0 Bool 1.0 false True True False
Flage1 Bool 1.1 false True True False
motor0_FB? 程序
程序段1
水平方向安裝兩只光電,當傳送帶的包裹檢從左測經(jīng)過光電時左測選檢測到包裹此時右測光電無信號
當傳送帶的包裹檢從右側經(jīng)過光電時左側光電選檢測到包裹此時右測光電無信號
? ? ? A? ? ?"motor"."i0.1"
? ? ? FP? ? "motor"."m0.0"
? ? ? AN? ? "motor"."i0.0"
? ? ? S? ? ?"motor"."q4.1"
? ? ? A? ? ?"motor"."i0.0"
? ? ? FP? ? "motor"."m0.1"
? ? ? AN? ? "motor"."i0.1"
? ? ? S? ? ?"motor"."q4.0"
? ? ? AN? ? "motor"."i0.0"
? ? ? AN? ? "motor"."i0.1"
? ? ? R? ? ?"motor"."q4.0"
? ? ? R? ? ?"motor"."q4.1"
程序段2???Simple AND and AND NOT Operation
? ? ? A? ? ?"motor".BTN0
? ? ? AN? ? "motor".BTN1
? ? ? =? ? ?"motor".Flage0
// "motor".Flage0 := "motor".BTN0 AND? NOT "motor".BTN1
程序段3 Simple OR and OR? NOT Operation
? ? ? O? ? ?"motor".BTN0
? ? ? ON? ? "motor".BTN1
? ? ? =? ? ?"motor".Flage1
? ? ? =? ? ?"Tag_9"
// "motor".Flage1 := "motor".BTN0 OR? NOT "motor".BTN1

仿真時,在仿真字窗口插入 通用變量就可以修改 DB塊中變量的值了。

在模擬器中對DB塊進行監(jiān)視
