查表指令应用示例

一位高人发了个邮件没收到,请高手再发个S7-200查表指令应用实例.我的邮箱;wzw1965222@yahoo.com.cn

最佳答案

STL
 NETWORK 1 // Create table with 20 entries starting with memory location VW4
 LD SM0.1 // On the first scan,
 MOVW +20 VW0 // define maximum length of table 

 NETWORK 2 // Reset table with input I0.0
 LD I0.0 // On the rising edge of I0.0,
 EU
 FILL +0 VW2 21 // fill memory locations from VW2 with "+0" 

 NETWORK 3 // Write value to table with input I0.1
 LD I0.1 // On the rising edge of I0.1,

 EU
 ATT VW100 VW0 // copy value of memory location VW100 to table 

 NETWORK 4 // Read first table value with input I0.2
 // Moves the last table value to location VW102. This reduces the number of entries. 
 LD I0.2 // On the rising edge of I0.2,
 EU

 LIFO VW0 VW102 // Move last table value to memory location VW102 

 NETWORK 5 // Read last table value with input I0.3
 // Moves the first table value to location VW102. This reduces the number of entries. 
 LD I0.3 // On the rising edge of I0.0,
 EU
 FIFO VW0 VW104 // Move first table value to memory location VW104

 NETWORK 6 // Search table for first location that has a value of "10"

 // In order to search the entire table, the index (VW106) must set to 0 before doing the find.

 // If a match is found then the index will have the table entry number, but if
 // no match is found then the index will match the current entry count for the 
 // table (VW2).
 LD I0.4 // On the rising edge of I0.4,
 EU
 MOVW +0 VW106 // reset index pointer

 FND= VW2 +10 VW106 // find a table entry that equals 10

提问者对于答案的评价:
ok

原创文章,作者:ximenziask,如若转载,请注明出处:https://www.zhaoplc.com/plc359071.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2021年7月5日
下一篇 2021年7月5日

相关推荐

发表回复

登录后才能评论