<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 基于VB實(shí)現(xiàn)PC機(jī)與單片機(jī)的串行通訊

          基于VB實(shí)現(xiàn)PC機(jī)與單片機(jī)的串行通訊

          作者: 時(shí)間:2012-03-22 來源:網(wǎng)絡(luò) 收藏


          Private sub form_l oad()
          Comm1.portopen=true
          Timer.interval=1000 '定時(shí)器時(shí)間間隔為1000s
          Timer.enabled=true
          Mscomm1.compore=1 '選擇口1
          Mscomm1.settings=“110,n,8,1” '波特率110,無奇偶校驗(yàn),8個(gè)數(shù)據(jù)位,一個(gè)停止位
          Mscomm1. inputmode=1 '通過input屬性以二進(jìn)制形式取回?cái)?shù)據(jù)
          Mscomm1.inputlen=0 '讀取接收緩沖區(qū)全部?jī)?nèi)容
          Mscomm1.rthreshold=1 '每收到一個(gè)字符位引發(fā)oncomm事件
          Graph1.scale(0,10)-(20,0) '定制坐標(biāo)
          Grahp1.forecoclr=rgb(0,0,255)
          End sub
          Private Sub Command1_Click()
          Dim a!(30), b!(30)
          num = MSComm1.InBufferCount '取輸入緩沖區(qū)字節(jié)個(gè)數(shù)
          instring = MSComm1.Input '把輸入緩沖區(qū)數(shù)據(jù)送給數(shù)組
          For i = 0 To num - 1
          a(i) = i
          b(i) = instring(i)
          GRAPH1.Cls
          If i = 1 Then
          GRAPH1.PSet (a(i), b(i))
          Else
          GRAPH1.Line -(a(i), b(i)) '將數(shù)組數(shù)據(jù)給繪圖函數(shù)
          End If
          Next i
          End Sub

          20.gif

          3、結(jié)束語

          利用6.0的事件驅(qū)動(dòng)方式可以很方便地開發(fā)數(shù)據(jù)采集與監(jiān)控系統(tǒng),用單臺(tái)機(jī)可以測(cè)量和監(jiān)控多路控制信號(hào),整控制系統(tǒng)設(shè)計(jì)方便,對(duì)小型測(cè)控系統(tǒng)的設(shè)計(jì)具有很大的實(shí)用性。

          參考文獻(xiàn):
          1、 何立民,應(yīng)用系統(tǒng)設(shè)計(jì).北京:航空航天大學(xué)出版社,1992
          2、 美Jan Axelson 著,端口大全,精英科技譯,2001.5


          上一頁 1 2 3 下一頁

          評(píng)論


          相關(guān)推薦

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

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();