登录
首页 PLC论坛 欧姆龙OMRON
回帖 发帖
正文

主题:请问是否有VB编写上位机与OMRON PLC通讯的程序

点击:13435 回复:18

请老狮子与陈先生帮忙,提供一些这样的样本,复杂一点最好,这样比较贴近工控的实际情况
最后修改:2003-12-13 15:30:53
03-12-12 21:55
好,給準備!
03-12-13 15:52
我也想要!!liuyz@public.yc.hb.cn
03-12-13 21:51
豹子头,不要光吆喝,亮出禁军总教头的风采。呵呵~~~~~~
03-12-14 19:30
我也想要呀.    ha56789@163.net
03-12-14 20:27
热烈欢迎!狂顶!!!!!!!!!
03-12-15 10:38
热烈欢迎!
03-12-15 11:34
測試用,其他流程自行修改
Private Sub Command1_Click()
Timer1.Enabled = True
Timer2.Enabled = False
End Sub
Private Sub Command2_Click()
MSComm1.PortOpen = False
Timer1.Enabled = False
Timer2.Enabled = False
End
End Sub
Private Sub Command3_Click()
Timer1.Enabled = False
Timer2.Enabled = True
End Sub
Private Sub Form_Load()
MSComm1.PortOpen = True
Timer1.Enabled = False
Timer2.Enabled = False
End Sub
Private Sub Timer1_Timer()
cmm$ = "@00RD00000001" 'READ DM 0000
GoSub FCS
cmm1$ = cmm$ + R$ + "*"
Label1.Caption = cmm1$
MSComm1.Output = Trim(cmm1$ + Chr(13))
' Ū¨ú©Ò¦³¥i¥Î¸ê®Æ.
MSComm1.InputLen = 0
' Àˬd¸ê®Æ.
If MSComm1.InBufferCount Then
  ' Read data.
  INSTRING1 = MSComm1.Input
End If
Label2.Caption = INSTRING1
Label3.Caption = Str(Val(Mid(INSTRING1, 8, 4)))
Label4.Caption = Str(Val(Mid(INSTRING1, 12, 2)))
Exit Sub
FCS:
   Q = 0
   L = Len(cmm$)
   For I = 1 To L
   Q = Asc(Mid(cmm$, I, 1)) Xor Q
   Next I
   R$ = Hex$(Q)
   If Len(R$) = 1 Then
       R$ = "0" + R$
       End If
Return
End Sub
Private Sub Timer2_Timer()
Wmm$ = "@00WD0000" + Text1 'WRITE DM0000
GoSub FCS
Wmm1$ = Wmm$ + R$ + "*"
Label1.Caption = Wmm1$
MSComm1.Output = Trim(Wmm1$ + Chr(13))
MSComm1.InputLen = 0
If MSComm1.InBufferCount Then
  ' Read data.
  INSTRING2 = MSComm1.Input
End If
Label2.Caption = INSTRING2
Label3.Caption = ""
Label4.Caption = ""
Exit Sub
FCS:
   Q = 0
   L = Len(Wmm$)
   For I = 1 To L
   Q = Asc(Mid(Wmm$, I, 1)) Xor Q
   Next I
   R$ = Hex$(Q)
   If Len(R$) = 1 Then
       R$ = "0" + R$
       End If
Return
End Sub
03-12-15 17:25
谢谢你能指教,我也想学习一下。
sulianbo@163.com
04-06-16 16:03
我都正在做
04-07-08 11:56

上一页下一页

工控新闻

更多新闻资讯