vb.net松下plc VBNET松下plc与电脑232通讯
大佬,求助松下fp7plc与电脑PC端通信
松下不是有PC通讯解决方案吗?
成都创新互联公司是一家集网站建设,西畴企业网站建设,西畴品牌网站建设,网站定制,西畴网站建设报价,网络营销,网络优化,西畴网站推广为一体的创新建站企业,帮助传统企业提升企业形象加强企业竞争力。可充分满足这一群体相比中小企业更为丰富、高端、多元的互联网需求。同时我们时刻保持专业、时尚、前沿,时刻以成就客户成长自我,坚持不断学习、思考、沉淀、净化自己,让我们为更多的企业打造出实用型网站。
我之前用的VB.NET的代码:
Imports System.Net
Imports System.Runtime.InteropServices
Public Class Form1
Dim Handle1 As Int32
Dim EntLink As Boolean
Dim ScanCount As Long
Dim PLC As New NaisTcpFp.PlcClient 'TCP:NaisTcpFp.DLL/COM:NaisComFP.DLL
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
Dim i As Short
Me.CenterToScreen()
cmbReadMry.Items.Clear()
cmbReadMry.Items.Add("WX")
cmbReadMry.Items.Add("WY")
cmbReadMry.Items.Add("WR")
cmbReadMry.Items.Add("DT")
'
cmbWriteMry.Items.Clear()
cmbWriteMry.Items.Add("WX")
cmbWriteMry.Items.Add("WY")
cmbWriteMry.Items.Add("WR")
cmbWriteMry.Items.Add("DT")
'
cmbBitMry.Items.Clear()
cmbBitMry.Items.Add("X")
cmbBitMry.Items.Add("Y")
cmbBitMry.Items.Add("R")
cmbBitMry.Items.Add("D")
'
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")
For i = 0 To 15 Step 1
cmbBit.Items.Add("Bit" i)
Next i
cmbReadMry.SelectedIndex = 3
cmbWriteMry.SelectedIndex = 3
cmbBitMry.SelectedIndex = 1
cmbBit.SelectedIndex = 0
cmbReadType.SelectedIndex = 0
cmbWriteType.SelectedIndex = 0
lstRead.Items.Clear()
txtWrite.Text = ""
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)
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
If Not EntLink 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 EntLink Then
MsgBox("还未与PLC建立联接!")
Exit Sub
End If
re = PLC.CmdRead(Handle1, 1, cmbReadMry.SelectedIndex + 1, cmbReadType.SelectedIndex + 1, Val(txtReadAdd.Text), 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
re = PLC.CmdWrite(Handle1, 1, cmbWriteMry.SelectedIndex + 1, cmbWriteType.SelectedIndex + 1, Val(txtWriteAdd.Text), Val(txtWriteCnt.Text), WD)
txtReWrite.Text = re.ToString
If re 0 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 EntLink Then
MsgBox("还未与PLC建立联接!")
Exit Sub
End If
Timer1.Enabled = Not Timer1.Enabled
If Timer1.Enabled Then
ScanCount = 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 EntLink 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
ScanCount += 1
txtScanCnt.Text = ScanCount
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 EntLink Then
MsgBox("还未与PLC建立联接!")
Exit Sub
End If
Dim rd As Boolean
Dim re As Short
re = PLC.Bit_Test(Handle1, 1, cmbBitMry.SelectedIndex + 1, Val(txtBitAdd.Text), cmbBit.SelectedIndex, 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 EntLink Then
MsgBox("还未与PLC建立联接!")
Exit Sub
End If
Dim re As Short
re = PLC.Bit_Set(Handle1, 1, cmbBitMry.SelectedIndex + 1, Val(txtBitAdd.Text), cmbBit.SelectedIndex)
txtReBit.Text = re
End Sub
Private Sub butBitRst_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butBitRst.Click
If Not EntLink Then
MsgBox("还未与PLC建立联接!")
Exit Sub
End If
Dim re As Short
re = PLC.Bit_Reset(Handle1, 1, cmbBitMry.SelectedIndex + 1, Val(txtBitAdd.Text), cmbBit.SelectedIndex)
txtReBit.Text = re
End Sub
End Class
松下plc报警后无法和电脑通信
1、没有选择正确的通讯口,或着所选的通讯口被其他程序占用。
2、通讯线有问题,三菱plc所用的通讯口是422的方式,所以对于电脑的232来说要用专用的通讯电缆,这里可能是电路板坏了或者连接线断开。也可能是电脑的通讯口接触不良或者坏掉,建议换个通讯口试试或者换台电脑试一下。
3、可能是PLC的编程口(准确是所用的通讯口)没有插好或者说坏掉。PLC进行在线监控。如果是在电脑上运行了其他,比如:触摸屏在线模拟、用vb或者delphi/c/c++等自己开发的软件等与PLC通讯的,还要看程序里面所选择的PLC的型号是否正确。
VB.NET和PLC通讯 ,小白有问。
这个圈里的是通讯过程中传送的Asc码,包含了PLc的站号地址、指令、起始符等内容,具体要看你的PLc通讯协议。通讯与开关量是两回事,你得补习下与通讯相关的内容。
如何将松下PLC如FP2SH,和个人电脑连起来,我的意思是想在个人电脑上用VB写一个操作界面,用电脑来当触摸屏
自然是选个PLC以太网模块,用网线和个人电脑的网卡链接(有的型号需要专用网卡)。1、需要熟悉你所用的PLC程序、功能、控制工艺。2、需要知道VB转换成以太网通讯的编程关系。3、不是触摸屏是 鼠标点击屏。4、有点难度和门槛。祝成功!!!
文章题目:vb.net松下plc VBNET松下plc与电脑232通讯
文章路径:http://cdiso.cn/article/hepdcg.html