能给我发个VB与三菱PLC通讯的源代码实例吗 , 非常感谢啊得说明是什么型号的PLC啊,串口还是网口,VB6还是VB.NET?
算了 , 写段代码,VB.NET与Q系列以太网通讯的:
Imports System.Net
Imports System.Runtime.InteropServices
Public Class Form1
Dim Handle1 As Int32
Dim EntLink1 As Boolean
Dim ScanCount1 As Long
Dim PLC As New EntQsPlc_Asc.PlcClient'EntQsPlc_ASC.DLL是Q系列以太网通讯组件
Public Declare Function timeGetTime Lib "winmm.dll" () As UInt32
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.CenterToScreen()
cmbReadMry.Items.Clear()
cmbReadMry.Items.Add("X")
cmbReadMry.Items.Add("Y")
cmbReadMry.Items.Add("M")
cmbReadMry.Items.Add("D")
cmbReadMry.Items.Add("R")
cmbReadMry.Items.Add("Z")
'
cmbWriteMry.Items.Clear()
cmbWriteMry.Items.Add("X")
cmbWriteMry.Items.Add("Y")
cmbWriteMry.Items.Add("M")
cmbWriteMry.Items.Add("D")
cmbWriteMry.Items.Add("R")
cmbWriteMry.Items.Add("Z")
'
cmbBitMry.Items.Clear()
cmbBitMry.Items.Add("X")
cmbBitMry.Items.Add("Y")
cmbBitMry.Items.Add("M")
'
cmbReadType.Items.Clear()
cmbReadType.Items.Add("INT16")
cmbReadType.Items.Add("UINT16")
cmbReadType.Items.Add("DINT32")
cmbReadType.Items.Add("HEX32")
cmbReadType.Items.Add("REAL32")
cmbReadType.Items.Add("BIN16")
'
cmbWriteType.Items.Clear()
cmbWriteType.Items.Add("INT16")
cmbWriteType.Items.Add("UINT16")
cmbWriteType.Items.Add("DINT32")
cmbWriteType.Items.Add("HEX32")
cmbWriteType.Items.Add("REAL32")
cmbWriteType.Items.Add("BIN16")
cmbReadMry.SelectedIndex = 3
cmbWriteMry.SelectedIndex = 3
cmbBitMry.SelectedIndex = 2
cmbReadType.SelectedIndex = 0
cmbWriteType.SelectedIndex = 0
lstRead.Items.Clear()
txtWrite.Text = ""
'
cmbCmdType.SelectedIndex = 0
End Sub
Private Sub butLink_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butLink.Click
Dim re As Short
Dim restr As String = ""
re = PLC.EntLink(Trim(txtLocalIP.Text), Val(txtLocalPort.Text), Trim(txtRemoteIP.Text), Val(txtRemotePort.Text), "DEMO", Handle1, 1000, CBool(cmbCmdType.SelectedIndex))
txtReLink.Text = re.ToString
If re = 0 Then
EntLink1 = True
MsgBox("PLC联接成功! ")
Else
EntLink1 = False
MsgBox("PLC联接失败: "restr)
End If
End Sub
Private Sub butClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butClose.Click
Dim re As Short
If Not EntLink1 Then
MsgBox("还未与PLC建立联接!")
Exit Sub
End If
re = PLC.DeLink(Handle1)
txtReClose.Text = re.ToString
End Sub
Private Sub butRead_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butRead.Click
Dim re As Short
Dim i As Short
Dim RD() As Object
ReDim RD(Val(txtReadCnt.Text - 1))
If Not EntLink1 Then
MsgBox("还未与PLC建立联接!")
' Exit Sub
End If
Dim mry As EntQsPlc_Asc.PlcClient.PlcMemory = cmbReadMry.SelectedIndex1
Dim typ As EntQsPlc_Asc.PlcClient.DataType = cmbReadType.SelectedIndex1
re = PLC.CmdRead(Handle1, mry, typ, CInt(txtReadAdd.Text), CUShort(txtReadCnt.Text), RD)
txtReRead.Text = re.ToString
lstRead.Items.Clear()
For i = 0 To UBound(RD) Step 1
If Not IsNothing(RD(i)) Then lstRead.Items.Add(RD(i))
Next i
If re0 Then
Timer1.Enabled = False
butScan.Text = "Cycle R/W"
End If
End Sub
Private Sub butWrite_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butWrite.Click
Dim re As Short
Dim i As Short
Dim temp() As String
Dim WD() As Object
If Not EntLink1 Then
MsgBox("还未与PLC建立联接!")
Exit Sub
End If
ReDim WD(Val(txtWriteCnt.Text) - 1)
temp = Split(txtWrite.Text, vbCrLf)
For i = 0 To UBound(WD) Step 1
If iUBound(temp) Then
WD(i) = 0
Else
WD(i) = Trim(temp(i))
End If
Next i
Dim mry As EntQsPlc_Asc.PlcClient.PlcMemory = cmbWriteMry.SelectedIndex1
Dim typ As EntQsPlc_Asc.PlcClient.DataType = cmbWriteType.SelectedIndex1
re = PLC.CmdWrite(Handle1, mry, typ, CInt(txtWriteAdd.Text), CUShort(txtWriteCnt.Text), WD)
txtReWrite.Text = re.ToString
If re0 Then
Timer1.Enabled = False
butScan.Text = "Cycle R/W"
End If
End Sub
Private Sub butScan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butScan.Click
If Not EntLink1 Then
MsgBox("还未与PLC建立联接!")
Exit Sub
End If
Timer1.Enabled = Not Timer1.Enabled
If Timer1.Enabled Then
ScanCount1 = 0
butScan.Text = "Stop R/W"
Else
butScan.Text = "Cycle R/W"
End If
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Timer1.Enabled = False
Dim tim As Integer = timeGetTime
If Not EntLink1 Then
MsgBox("还未与PLC建立联接!")
Exit Sub
End If
'
Call butRead_Click(Nothing, Nothing)
Call butWrite_Click(Nothing, Nothing)
'
If (Val(txtReRead.Text)0) Or (Val(txtReWrite.Text)0) Then
butScan.Text = "Cycle R/W"
Exit Sub
Else
ScanCount1= 1
txtScanCnt.Text = ScanCount1
txtScanPrd.Text = (timeGetTime - tim)"ms"
End If
Timer1.Enabled = True
End Sub
Private Sub butBitTest_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butBitTest.Click
If Not EntLink1 Then
MsgBox("还未与PLC建立联接!")
Exit Sub
End If
Dim rd As Boolean
Dim re As Short
Dim mry As EntQsPlc_Asc.PlcClient.PlcMemory = cmbBitMry.SelectedIndex1
re = PLC.Bit_Test(Handle1, mry, CUShort(txtBitAdd.Text), rd)
txtBitTest.Text = rd
txtReBit.Text = re
End Sub
Private Sub butBitSet_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butBitSet.Click
If Not EntLink1 Then
MsgBox("还未与PLC建立联接!")
Exit Sub
End If
Dim re As Short
re = PLC.Bit_Set(Handle1, cmbBitMry.SelectedIndex1, Val(txtBitAdd.Text))
txtReBit.Text = re
End Sub
Private Sub butBitRst_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butBitRst.Click
If Not EntLink1 Then
MsgBox("还未与PLC建立联接!")
Exit Sub
End If
Dim re As Short
re = PLC.Bit_Reset(Handle1, cmbBitMry.SelectedIndex1, Val(txtBitAdd.Text))
txtReBit.Text = re
End Sub
End Class
vb.net 2010与三菱PLC通讯为何不使用三菱的MX Component部件呢?在三菱官网可以下载4.08版本,支持VS2010,你可以在MX软件的手册上找到例程 。
VB.net2010 通过三菱MX Componet软件与FX 3u PLC通讯,造成界面卡顿,如何解决?那个控件好像是阻塞的,可以放在线程里面,或者自己去了解协议,自己写驱动
vb.net与三菱PLC通讯线通讯代码,急用,能读写IO及数据寄存器即可PLCvb.net与三菱plc的协议厂家一般都不会公开 , 不过厂家都有提供高级语言开发的解决方案,百度一下能找到相关资料,三菱的ENTFXPLC,ENTQSPLC,西门子的WINTCPS7 , 欧姆龙的FINSTCP都有VB.NET和C#的范例的vb.net与三菱plc;
大神,你好 。我最近在学VB.net,我需要与omron或者三菱PLC进行通讯 , 有案例嘛?西门子vb.net与三菱plc:WinTcpS7,三菱vb.net与三菱plc:EntQsPlc,欧姆龙:FinsTCPvb.net与三菱plc,百度都能搜到资源vb.net与三菱plc的vb.net与三菱plc;
VB和三菱Q系列PLC通信1.0 通讯组件概述
通讯组件用于PC与可编程控制器(PLC)、智能仪表等进行数据通讯,适用于基于PC高级语言的工业自动化控制系统 。组件采用动态链接库文件(*.DLL)的形式,在PC系统的项目工程里引用该组件 , 调用相应的属性与方法函数,即可快速实现PC与PLC的高效数据交换 。
DLL通讯组件无须安装 , 直接复制到工程文件目录,方便打包安装部署;无须任何配置,直接调用函数,与应用开发无缝衔接;多年工程经验的软件团队开发测试,经过本公司及客户的海量实际工程应用检验 , 稳定可靠;采用稳定高效的内部协议,无须编写PLC内部程序配合,直接访问PLC的内存,通讯响应快速;内建动态管理的多独立线程连接 , 同时支持外部应用的多线程结构调用;兼容WINDOWS系统下的所有开发环境,包括各种版本的VB.NET、C#、VC,以及DEIPHI 、VB、LabView等;支持几乎所有PLC的CPU自带通讯口、通讯扩展模块 。
你可以在技成看视频教程,这个案例比较经典,看视频更容易理解 。
【vb.net与三菱plc 三菱plc和labview通讯】vb.net与三菱plc的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于三菱plc和labview通讯、vb.net与三菱plc的信息别忘了在本站进行查找喔 。
推荐阅读
- 关于asp.net后台怎么写的信息
- 小米怎么保存路由器的视频,小米路由器怎么保存设置
- 读书直播的工具,读书直播哪个平台更好?
- php查询数据 PHP查询数据库记录时间
- 笔记本机械硬盘怎么拔,笔记本机械硬盘怎么拔出来视频
- 头条关注公众号在哪里看,头条关注公众号在哪里看到
- 路由器怎么连接到电脑网线,路由器怎么接入电脑
- php判断是否多为数据 php怎么判断数据库是否有某个数据
- 海南可以拍摄什么,海南适合拍照的地方