IF IN(inspect_i)=ON THEN
VR(i_pointer)=1 'load 1 for rejected product ELSE
VR(i_pointer)=0 'load 0 for good product ENDIF
'--Check FIFO output pointer to fire product reject output. IF VR(o_pointer)=1 THEN OP(reject_o,ON) WA(dwell) OP(reject_o,OFF)
GOSUB display_fifo WA(dwell) WEND
display_fifo:
pa=(i_pointer+4) MOD(5) pb=(i_pointer+3) MOD(5) pc=(i_pointer+2) MOD(5) pd=(i_pointer+1) MOD(5)
PRINT #5,VR(i_pointer)[0];VR(pa)[0];VR(pb)[0];VR(pc)[0];VR(pd)[0] RETURN
'==============================================================================
这是我在手册上看到的一个先入先出的例子,在这个例子中用来检测产品的好坏,不合格的产品被推出传送带,在这个程序中的while 1=1的成是怎样得来的?
i_pointer = (i_pointer+1) MOD(5) 'increment FIFO input pointer
o_pointer = (o_pointer+1) MOD(5) 'increment FIFO output pointer 这两句的做用是什么呢? pa=(i_pointer+4) MOD(5) pb=(i_pointer+3) MOD(5) pc=(i_pointer+2) MOD(5)
pd=(i_pointer+1) MOD(5) 这四句的做用又是什么呢?
答:在这里的WHILE 1=1 .......WEND和REPEAT.......UNTIL FALSE的作用相同, i_pointer = (i_pointer+1) MOD(5) o_pointer = (o_pointer+1) MOD(5)
这两句的作用是把VR区限定在VR(0)到VR(5),在程序值行时有这两句存在可以对VR(0)-VR(5)进行周期性的循环扫描,