松下plc连接电脑系统_松下plc连接线

若想让PLC与电脑连接,首先需要传输端口,当PLC 与电脑连接通讯线之后,右击“我的电脑”,选择“管理”。

在弹出的“计算机管理”窗口中,选择“设备管理器”。

查看通讯线所使用的com端口为多少,并记住这个端口,本实例为com10。

回到PLC编程软件,选择“在线”菜单栏,从下拉菜单中选择“传输设置”。

在“传输设置”对话框中,需要对“串行USB”接口进行设置,双击下图红色框所示按钮。

然后在弹出的端口设置界面将com端口设置为com10。

最后点击“通信设置”,如果显示与PLC连接成功了,即可点击确定,然后将程序写入PLC。

松下不是有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