新聞中心

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

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

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


評論


技術專區(qū)

關閉