重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
PLC的协议厂家一般都不会公开,不过厂家都有提供高级语言开发的解决方案,百度一下能找到相关资料,三菱的ENTFXPLC,ENTQSPLC,西门子的WINTCPS7,欧姆龙的FINSTCP都有VB.NET和C#的范例的;
创新互联公司服务项目包括阜南网站建设、阜南网站制作、阜南网页制作以及阜南网络营销策划等。多年来,我们专注于互联网行业,利用自身积累的技术优势、行业经验、深度合作伙伴关系等,向广大中小型企业、政府机构等提供互联网行业的解决方案,阜南网站推广取得了明显的社会效益与经济效益。目前,我们服务的客户以成都为中心已经辐射到阜南省份的部分城市,未来相信会继续扩大服务区域并继续获得客户的支持与信任!
PLC厂家一般都会提供高级语言的控制接口的:
三菱:ComFxPlc / EntQsPlc
欧姆龙: FinsTCP / FinsCom / HostLink
西门子:WinTcpS7 / WinS7_PPI
施耐德: ModbusTCP / ModbusRTU
可以百度一下 ......
西门子:WinTcpS7,三菱:EntQsPlc,欧姆龙:FinsTCP,百度都能搜到资源的;
提供一个VB.NET与OMRON以太网通讯的代码,是我项目里面复制出来的:
Dim Handle1 As Int32 'PLC的连接句柄
Dim EntLink As Boolean '连接标志
Dim PLC As New FinsTcp.PlcClient '引用OMRON的通讯组件
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)
txtReLink.Text = re.ToString
If re = 0 Then
EntLink = True
MsgBox("PLC联接成功! ")
Else
EntLink = 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
EntLink = False
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 EntLink Then
MsgBox("还未与PLC建立联接!")
Exit Sub
End If
Dim mry As FinsTcp.PlcClient.PlcMemory = cmbReadMry.SelectedIndex + 1
Dim typ As FinsTcp.PlcClient.DataType = cmbReadType.SelectedIndex + 1
re = PLC.CmdRead(Handle1, mry, typ, CUShort(Val(txtReadAdd.Text)), CUShort(Val(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 re 0 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 EntLink 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 i UBound(temp) Then
WD(i) = 0
Else
WD(i) = Trim(temp(i))
End If
Next i
Dim mry As FinsTcp.PlcClient.PlcMemory = cmbWriteMry.SelectedIndex + 1
Dim typ As FinsTcp.PlcClient.DataType = cmbWriteType.SelectedIndex + 1
re = PLC.CmdWrite(Handle1, mry, typ, CUShort(Val(txtWriteAdd.Text)), CUShort(Val(txtWriteCnt.Text)), WD)
txtReWrite.Text = re.ToString
If re 0 Then
Timer1.Enabled = False
butScan.Text = "Cycle R/W"
End If
End Sub