在线看毛片网站电影-亚洲国产欧美日韩精品一区二区三区,国产欧美乱夫不卡无乱码,国产精品欧美久久久天天影视,精品一区二区三区视频在线观看,亚洲国产精品人成乱码天天看,日韩久久久一区,91精品国产91免费

<abbr id="27omo"></abbr>

<menu id="27omo"><dl id="27omo"></dl></menu>
    • <label id="27omo"><tt id="27omo"></tt></label>

      關(guān) 閉

      新聞中心

      EEPW首頁 > 工控自動化 > 設(shè)計(jì)應(yīng)用 > 基于VB6.0的工控機(jī)與智能流量積算儀的串口通信

      基于VB6.0的工控機(jī)與智能流量積算儀的串口通信

      作者:牛輝,孟華,侯建明 時間:2008-06-13 來源:中國工控網(wǎng) 收藏

        3.2 通信功能的編程實(shí)現(xiàn)

      本文引用地址:http://www.biyoush.com/article/84182.htm

        程序框圖如下:

      圖2 程序框圖

      串口初始化:1.CommPort = 1
      1.SThreshold = 1
      1.Settings = 9600,N,8,1
      MSComm1.InBufferSize = 1024
      MSComm1.OutBufferSize = 1024
      MSComm1.InputMode = comInputModeBinary
      打開串口并定時發(fā)送數(shù)據(jù)命令:Private Sub Timer1_Timer()
      Dim bytearray(0 To 7) As Byte
      bytearray(0) = &H1
      bytearray(1) = &H3
      bytearray(2) = &H0
      bytearray(3) = &H2
      bytearray(4) = &H0
      bytearray(5) = &H8
      bytearray(6) = &HE5
      bytearray(7) = &HCC
      MSComm1.InputLen = 21
      MSComm1.InBufferCount = 0
      MSComm1.OutBufferCount = 0
      MSComm1.RThreshold = 1
      MSComm1.PortOpen = True
      If MSComm1.PortOpen = True Then
      MSComm1.Output = bytearray
      End If
      End Sub
      接受數(shù)據(jù):Private Sub MSComm1_OnComm()
      Do
      DoEvents
      Loop Until MSComm1.InBufferCount = 21
      Dim dataread() As Byte
      Dim tempdata As Variant
      Dim str As String
      If MSComm1.CommEvent = comEvReceive Then
      tempdata = MSComm1.Input
      ReDim dataread(UBound(tempdata)) As Byte
      For i = 0 To UBound(tempdata)
      dataread(i) = tempdata(i)
      End Sub
      同理利用以上程序框圖和通信協(xié)議可以完成下圖的所有功能:

      圖3 基于的D08-8CZM型流量積算儀

      4、結(jié)束語

        利用6.0的MSComm 控件和協(xié)議,實(shí)現(xiàn)了與帶RS-232輸出的智能數(shù)字流量積算儀之間的功能,使其能夠?qū)崟r的采集瞬時流量,并成功的應(yīng)用于底吹氬流量閉環(huán)控制系統(tǒng)。這種通信方式靈活方便,結(jié)構(gòu)簡單,可靠性高,完全達(dá)到了預(yù)期的要求,具有較好的實(shí)際價值和使用性。


      上一頁 1 2 下一頁

      評論


      相關(guān)推薦

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

      關(guān)閉