新聞中心

EEPW首頁 > 測試測量 > 設(shè)計(jì)應(yīng)用 > labview的軟件計(jì)數(shù)器和FIFO BUFFER

labview的軟件計(jì)數(shù)器和FIFO BUFFER

作者: 時(shí)間:2017-01-09 來源:網(wǎng)絡(luò) 收藏
PLC編程中有大量的定時(shí)器和計(jì)數(shù)器可用,做工業(yè)自動(dòng)化控制的朋友在LABVIEW編程時(shí)經(jīng)常因?yàn)檎也坏筋愃剖煜さ墓δ芏鵁?其實(shí)LABVIEW本身提供的邏輯功能非常強(qiáng)大,遠(yuǎn)遠(yuǎn)超過PLC.
看看加計(jì)數(shù)器的說明:
它有兩個(gè)控制端
initialize--是計(jì)數(shù)器復(fù)位端,相當(dāng)于PLC計(jì)數(shù)器的reset
activate----計(jì)數(shù)控制端,當(dāng)ACTIVATE=TRUE時(shí),每調(diào)用一次,計(jì)數(shù)器內(nèi)部計(jì)數(shù)加1.
兩個(gè)輸出端:
Counter---輸出計(jì)數(shù)器當(dāng)前計(jì)數(shù),U32數(shù)據(jù)類型,最大計(jì)數(shù)范圍0XFFFFFFFF
Overflow---溢出,當(dāng)超過計(jì)數(shù)器最大計(jì)數(shù),為真,計(jì)數(shù)器自動(dòng)復(fù)位,重新從1開始計(jì)數(shù).
應(yīng)用舉例:
記錄SUBVI被調(diào)用的次數(shù)
加計(jì)數(shù)器的程序框圖
減計(jì)數(shù)器基本類似,更為常用,比如計(jì)數(shù)器10次觸發(fā)一次事件,就減計(jì)數(shù)器就非常合適,就不詳細(xì)介紹了
Data Queue是一個(gè)非常重要的VI,仔細(xì)分析它的程序結(jié)構(gòu),他實(shí)際上是一個(gè)先進(jìn)先出的緩沖區(qū)(FIFO BUFFER)
它默認(rèn)的是一個(gè)DOUBLE類型的輸入,改動(dòng)一下,就可以適應(yīng)各種數(shù)據(jù)類型(重用LABVIEW的VI是一個(gè)重要的編程方法)
程序框圖
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如果顯示一個(gè)不斷變化的曲線那,改造這個(gè)VI,DOUBLE輸入改造成簇,包括X,Y,代表一個(gè)點(diǎn),
在程序循環(huán)中不斷加入新點(diǎn),這樣一個(gè)XY GRAPH就變成了類似CHART的圖表了.


評論


技術(shù)專區(qū)

關(guān)閉