亚洲国产精品一区二区久久hs,国产精品久久久久久久久久直播,亚洲人成色7777在线观看不卡,国产亚洲精品久久19p,免费无码又爽又刺激高潮视频

tangfeng
學(xué)海無涯
級別: 探索解密
精華主題: 0
發(fā)帖數(shù)量: 44 個(gè)
工控威望: 143 點(diǎn)
下載積分: 922 分
在線時(shí)間: 96(小時(shí))
注冊時(shí)間: 2010-01-24
最后登錄: 2025-03-25
查看tangfeng的 主題 / 回貼
樓主  發(fā)表于: 2017-09-02 16:50
'在窗體的Load事件中加入下列代碼對串口進(jìn)行初始化:
Private Sub Form_Load()
  MSComm1.CommPort = 1                  ' 設(shè)置通信端口號為COM1
  MSComm1.InputMode = 1                 ' 接收二進(jìn)制型數(shù)據(jù)
  MSComm1.RThreshold = 1                ' 設(shè)置并返回要接收的字符數(shù)
  MSComm1.SThreshold = 1                ' 設(shè)置并返回發(fā)送緩沖區(qū)中允許的最小字符數(shù)
  MSComm1.Settings = "9600,E,7,1"       ' 設(shè)置串口1通信參數(shù)
  MSComm1.PortOpen = True               ' 打開通信端口1
  Timer1.Enabled = False
End Sub
'向PLC發(fā)送指令:02 30 31 30 30 30 32 30 03 35 36,功能是從D0開始讀取32個(gè)字節(jié)數(shù)據(jù)
Private Sub Cmdsend_Click()
  MSComm1.Output = Chr(&H2) & Chr(&H30) & Chr(&H31) & Chr(&H30) & Chr(&H30) & Chr(&H30) & Chr(&H32) & Chr(&H30) & Chr(&H3) & Chr(&H35) & Chr(&H38)
  Timer1.Enabled = True
End Sub
'獲得各輸入端口狀態(tài)
Private Sub Timer1_Timer()
  Dim Inbyte() As Byte
  Dim buffer As String
  ReDim Inbyte(100)
  Inbyte = MSComm1.Input                         '返回的數(shù)據(jù)串
  For i = LBound(Inbyte) To UBound(Inbyte)
     buffer = buffer + Hex(Inbyte(i)) + Chr(32)
  Next i
  'Text1.Text = buffer                            '顯示返回的數(shù)據(jù)串,需自己添加TextBox
  If Hex(Inbyte(2)) = "31" Then                  '31表示觸點(diǎn)閉合
    Shape1(0).FillColor = QBColor(12)
  Else                                           '30表示觸點(diǎn)斷開
    Shape1(0).FillColor = QBColor(10)
  End If
  If Hex(Inbyte(6)) = "31" Then
    Shape1(1).FillColor = QBColor(12)
  Else
    Shape1(1).FillColor = QBColor(10)
  End If
  If Hex(Inbyte(10)) = "31" Then
    Shape1(2).FillColor = QBColor(12)
  Else
    Shape1(2).FillColor = QBColor(10)
  End If
  If Hex(Inbyte(14)) = "31" Then
    Shape1(3).FillColor = QBColor(12)
  Else
    Shape1(3).FillColor = QBColor(10)
  End If
  If Hex(Inbyte(18)) = "31" Then
    Shape1(4).FillColor = QBColor(12)
  Else
    Shape1(4).FillColor = QBColor(10)
  End If
  If Hex(Inbyte(22)) = "31" Then
    Shape1(5).FillColor = QBColor(12)
  Else
    Shape1(5).FillColor = QBColor(10)
  End If
  If Hex(Inbyte(26)) = "31" Then
    Shape1(6).FillColor = QBColor(12)
  Else
    Shape1(6).FillColor = QBColor(10)
  End If
  If Hex(Inbyte(30)) = "31" Then
    Shape1(7).FillColor = QBColor(12)
  Else
    Shape1(7).FillColor = QBColor(10)
  End If
  If Hex(Inbyte(34)) = "31" Then
    Shape1(8).FillColor = QBColor(12)
  Else
    Shape1(8).FillColor = QBColor(10)
  End If
  If Hex(Inbyte(38)) = "31" Then
    Shape1(9).FillColor = QBColor(12)
  Else
    Shape1(9).FillColor = QBColor(10)
  End If
  If Hex(Inbyte(42)) = "31" Then
    Shape1(10).FillColor = QBColor(12)
  Else
    Shape1(10).FillColor = QBColor(10)
  End If
  If Hex(Inbyte(46)) = "31" Then
    Shape1(11).FillColor = QBColor(12)
  Else
    Shape1(11).FillColor = QBColor(10)
  End If
  If Hex(Inbyte(50)) = "31" Then
    Shape1(12).FillColor = QBColor(12)
  Else
    Shape1(12).FillColor = QBColor(10)
  End If
  If Hex(Inbyte(54)) = "31" Then
    Shape1(13).FillColor = QBColor(12)
  Else
    Shape1(13).FillColor = QBColor(10)
  End If
  If Hex(Inbyte(58)) = "31" Then
    Shape1(14).FillColor = QBColor(12)
  Else
    Shape1(14).FillColor = QBColor(10)
  End If
  If Hex(Inbyte(62)) = "31" Then
    Shape1(15).FillColor = QBColor(12)
  Else
    Shape1(15).FillColor = QBColor(10)
  End If
  Timer1.Enabled = False
End Sub
'當(dāng)退出程序時(shí),關(guān)閉串行口
Private Sub Cmdquit_Click()
  MSComm1.PortOpen = False           '關(guān)閉串口
  Unload Me
End Sub
// 讀不到PLC 輸入點(diǎn),下標(biāo)越界,望高手指點(diǎn)修改
roger614
級別: 略有小成
精華主題: 0
發(fā)帖數(shù)量: 78 個(gè)
工控威望: 235 點(diǎn)
下載積分: 472 分
在線時(shí)間: 154(小時(shí))
注冊時(shí)間: 2007-10-28
最后登錄: 2018-09-26
查看roger614的 主題 / 回貼
1樓  發(fā)表于: 2018-03-10 14:15
用4樓方法編寫簡單

主站蜘蛛池模板: 俄罗斯老妇性xxxxx| 亚洲精品无码不卡av| 人妻洗澡被强公日日澡| 欧美日产国产精品| 亚洲av永久无无码精品一区二区三区| 国产成人无码精品久久久小说| www国产精品人妻一二三区| 久久精品国产亚洲av天海翼| 中文精品一卡2卡3卡4卡| 大地资源在线播放观看mv| 在线播放免费人成毛片乱码| 人妻少妇乱子伦精品| 99久久精品国产一区二区蜜芽 | 少妇愉情理伦片bd| 久久精品国产亚洲av蜜臀| 正在播放国产剧情亂倫| 久久久国产一区二区三区| 熟女少妇内射日韩亚洲| 中文字幕人妻色偷偷久久| 国产内射性高湖| 国产国产国产国产系列| 国产精华最好的产品入口| 无码国产福利av私拍| 台湾佬中文网站| 中文无码热在线视频| 51久久夜色精品国产水果派解说| 米奇7777狠狠狠狠视频影院| 长腿校花无力呻吟娇喘| 肉大捧一进一出免费视频| 国产精品∧v在线观看| 麻豆亚洲av成人无码久久精品 | 亚洲av成人中文无码专区| 三个老头同嫖一个老妇| 少妇与子乱在线观看| 四虎影视永久无码精品| 四十如虎的丰满熟妇啪啪| 丰满少妇人妻无码| 国产激情久久久久影院老熟女免费 | 丁香美女社区| 国产精品视频一区二区三区四| 日本国产一区二区三区在线观看|