成人电影在线播放,色婷婷亚洲精品天天综合影院,狠狠躁夜夜躁人人爽野战天天,精品一线二线三线精华液

tangfeng
學(xué)海無涯
級(jí)別: 探索解密
精華主題: 0
發(fā)帖數(shù)量: 44 個(gè)
工控威望: 143 點(diǎn)
下載積分: 922 分
在線時(shí)間: 95(小時(shí))
注冊(cè)時(shí)間: 2010-01-24
最后登錄: 2025-03-05
查看tangfeng的 主題 / 回貼
樓主  發(fā)表于: 2017-09-02 16:50
'在窗體的Load事件中加入下列代碼對(duì)串口進(jìn)行初始化:
Private Sub Form_Load()
  MSComm1.CommPort = 1                  ' 設(shè)置通信端口號(hào)為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
級(jí)別: 略有小成
精華主題: 0
發(fā)帖數(shù)量: 78 個(gè)
工控威望: 235 點(diǎn)
下載積分: 472 分
在線時(shí)間: 154(小時(shí))
注冊(cè)時(shí)間: 2007-10-28
最后登錄: 2018-09-26
查看roger614的 主題 / 回貼
1樓  發(fā)表于: 2018-03-10 14:15
用4樓方法編寫簡(jiǎn)單

国产a级毛片| 亚洲av无码国产综合专区| 男男开荤粗肉NP尿在里面| 亚洲精品乱码久久久久久| 富豪们的玩物np全肉小说| 中文字幕乱码中文字乱码| 性xxxfreexxxx国产| 性饥渴艳妇K8经典A片| 又硬又粗进去好爽a片潘金莲 | 中文字幕AV久久一区二区| 変态奴隷人形ひとみ调教| 邻居少妇张开腿让我爽了在线观看| 校草学长h肉高辣1v1| 欧美成人精品a片免费一区99 | 极品白嫩的小少妇| 日韩在线视频| 在熟睡夫面前侵犯我在线播放 | 亚洲国产精品自在自线观看| 亚洲av天堂一区二区香蕉 | 黑人一个接一个上来糟蹋| 亚洲 欧洲 日产国码| 少妇大乳妓女毛片A片| 97久久精品人人澡人人爽 | 久久久久99精品成人片| 欧美另类丰满熟妇乱xxxxx| 和寡妇房东在做爰HD| 英语老师解开裙子坐我腿中间| 久久变态刺激另类sm按摩| 唐三偷喝宁荣荣乳液污黄文| 第一次破学生处视频免费观看| 亚洲av无码一区二区三区人| 老公的朋友跟我做完就不理我了| 欧美zc0o人与善交另类a片| 天干夜天干天天天爽视频| 一女三男做2爱a片免| 久久日产一线二线三线| 真人试看体验区120秒| 国产大学生粉嫩无套流白浆| 再用点力今晚随你弄| 大肉大捧一进一出| 免费人成在线观看网站体验站|