PLC編程中有大量的定時器和計數(shù)器可用,做工業(yè)自動化控制的朋友在LABVIEW編程時經(jīng)常因?yàn)檎也坏筋愃剖煜さ墓δ芏鵁?其實(shí)LABVIEW本身提供的邏輯功能非常強(qiáng)大,遠(yuǎn)遠(yuǎn)超過PLC.看看加計數(shù)器的說明:它有兩個控制端initialize--是計數(shù)器復(fù)位端,相當(dāng)于PLC計數(shù)器的resetactivate----計數(shù)控制端,當(dāng)ACTIVATE=TRUE時,每調(diào)用一次,計數(shù)器內(nèi)部計數(shù)加1.兩個輸出端:Counter---輸出計數(shù)器當(dāng)前計數(shù),U32數(shù)據(jù)類型,最大計數(shù)范圍0XFFFFFFFFOverflow---溢出,當(dāng)超過計數(shù)器最大計數(shù),為真,計數(shù)器自動復(fù)位,重新從1開始計數(shù).應(yīng)用舉例:記錄SUBVI被調(diào)用的次數(shù)加計數(shù)器的程序框圖減計數(shù)器基本類似,更為常用,比如計數(shù)器10次觸發(fā)一次事件,就減計數(shù)器就非常合適,就不詳細(xì)介紹了Data Queue是一個非常重要的VI,仔細(xì)分析它的程序結(jié)構(gòu),他實(shí)際上是一個先進(jìn)先出的緩沖區(qū)(FIFO BUFFER)它默認(rèn)的是一個DOUBLE類型的輸入,改動一下,就可以適應(yīng)各種數(shù)據(jù)類型(重用LABVIEW的VI是一個重要的編程方法)程序框圖
initialize, when TRUE, initializes the internal state of the VI.input data point is an input data point.sample length is the length of each set of incoming data. The VI processes each set of data. The default is 100. sample length must be greater than zero.eliminated element is the first point eliminated from the queue.Current Queue is the new array created by eliminating the first point and appending the new point.Previous Queue is the set of data before any operation in this call.error returns any error or warning from the VI. You can wire error to the Error Cluster From Error Code VI to convert the error code or warning into an error cluster.current length is the size of the current queue應(yīng)用舉例:XY GRAPH如果顯示一個不斷變化的曲線那,改造這個VI,DOUBLE輸入改造成簇,包括X,Y,代表一個點(diǎn),在程序循環(huán)中不斷加入新點(diǎn),這樣一個XY GRAPH就變成了類似CHART的圖表了.