新聞中心

EEPW首頁(yè) > 測(cè)試測(cè)量 > 設(shè)計(jì)應(yīng)用 > 基于組態(tài)王和VB的智能儀表實(shí)時(shí)監(jiān)控系統(tǒng)

基于組態(tài)王和VB的智能儀表實(shí)時(shí)監(jiān)控系統(tǒng)

作者: 時(shí)間:2012-12-01 來(lái)源:網(wǎng)絡(luò) 收藏

該模塊中的OnComm 函數(shù)響應(yīng)程序如下:

Private Sub Timer1 Timer

Timer1. Enabled = False

Text_SEND. Text = "" ∥清空發(fā)送文本框

MSComm. OutBufferCount = 0 ∥清除發(fā)送緩沖區(qū)數(shù)據(jù)

Dim OutByte (1 To 3) AsByte

IfNotMSComm. PortOpen Then ∥保證串口打開(kāi)

MSComm. PortOpen = True

End If

'24臺(tái)積算儀循環(huán)數(shù)據(jù)采集

If k = 1 Then

OutByte (1) = HCA

OutByte (2) = 0

OutByte (3) = 1

End If

If k = 2 Then

OutByte (1) = HCA

OutByte (2) = 0

OutByte (3) = 2

End If

k = k + 1

If k > 24 Then

k = 1

End If

MSComm. InBufferCount = 0 ∥清除接收緩沖區(qū)數(shù)據(jù)

MSComm. OutBufferCount = 0 ∥清除發(fā)送緩沖區(qū)數(shù)據(jù)

MSComm. Output = OutByte

For j = 1 To 3

OutByte again ( j) = OutByte ( j)

Next

For i = 1 To 50000000

'延時(shí)Next

End Sub

Private Sub Timer1 Timer

Timer1. Enabled = False

Text_SEND. Text = "" ∥清空發(fā)送文本框

MSComm. OutBufferCount = 0 ∥清除發(fā)送緩沖區(qū)數(shù)據(jù)

Dim OutByte (1 To 3) AsByte

IfNotMSComm. PortOpen Then ∥保證串口打開(kāi)

MSComm. PortOpen = True

End If

'24臺(tái)積算儀循環(huán)數(shù)據(jù)采集

If k = 1 Then

OutByte (1) = HCA

OutByte (2) = 0

OutByte (3) = 1

End If

If k = 2 Then

OutByte (1) = HCA

OutByte (2) = 0

OutByte (3) = 2

End If

??

k = k + 1

If k > 24 Then

k = 1

End If

MSComm. InBufferCount = 0 ∥清除接收緩沖區(qū)數(shù)據(jù)

MSComm. OutBufferCount = 0 ∥清除發(fā)送緩沖區(qū)數(shù)據(jù)

MSComm. Output = OutByte

For j = 1 To 3

OutByte again ( j) = OutByte ( j)

Next

For i = 1 To 50000000

'延時(shí)Next

End Sub

④ 容錯(cuò)模塊。通過(guò)增加數(shù)據(jù)采集容錯(cuò)模塊,保證數(shù)據(jù)采集的實(shí)時(shí)性、準(zhǔn)確性,提高系統(tǒng)工作可靠性。

⑤ 數(shù)據(jù)庫(kù)模塊。主要利用Access數(shù)據(jù)庫(kù),實(shí)現(xiàn)對(duì)計(jì)算機(jī)采集數(shù)據(jù)存儲(chǔ)、管理、分析及歷史數(shù)據(jù)的查詢等。

⑥ 其他程序模塊。主要完成發(fā)送、接收文本框的清空工作等。

通過(guò)上述幾個(gè)模塊的協(xié)調(diào)工作,就可以較好地實(shí)現(xiàn)間的串行通信、數(shù)據(jù)分析及歷史數(shù)據(jù)查詢等。

3 結(jié)束語(yǔ)

通過(guò)間的串行通信及組態(tài)王與間的通信,并利用組態(tài)王豐富的圖形和組態(tài)工藝,較好地完成了數(shù)據(jù)的實(shí)時(shí)刷新、各種曲線、報(bào)警的顯示。運(yùn)行結(jié)果表明,該系統(tǒng)具有友好的人機(jī)界面,良好的穩(wěn)定性、可靠性,較好地解決了組態(tài)王與一般間的實(shí)時(shí)通信問(wèn)題,實(shí)現(xiàn)了組態(tài)王對(duì)智能化儀表的實(shí)時(shí)監(jiān)控。


上一頁(yè) 1 2 下一頁(yè)

關(guān)鍵詞: VB 智能儀表 DDE

評(píng)論


相關(guān)推薦

技術(shù)專(zhuān)區(qū)

關(guān)閉