Mitsubishi Electric MELSEC-L SERIES Basic User Manual page 370

Melsec-l ethernet interface module
Hide thumbs Also See for MELSEC-L SERIES:
Table of Contents

Advertisement

Private Sub Command1_Click(ByVal eventSender As System.Object, ByVal eventArgs
As System.EventArgs) Handles Command1.Click
'Connect to the Ethernet interface module.
Dim sock As New Sockets.Socket(Sockets.AddressFamily.InterNetwork, _
Sockets.SocketType.Stream, Sockets.ProtocolType.Tcp)
Ajsock = sock
Dim ip As IPAddress = Dns.Resolve("192.0.1.253").AddressList(0)
Dim ipend As IPEndPoint = New IPEndPoint(ip, "8192")
Me.Ajsock.Connect(ipend)
MsgBox("Connection Completed")
State = Me.Ajsock.Connected()
End Sub
Private Sub Command2_Click(ByVal eventSender As System.Object, ByVal eventArgs
As System.EventArgs) Handles Command2.Click
Dim SData As Byte()
Dim RData(256) As Byte
'Rend D0 to D4 (5 points) with the A-compatible 1E frame command.
SData = Encoding.ASCII.GetBytes("01FF000A4420000000000500")
'Read D0 to D4 (5 points) with the QnA-compatible 3E frame command.
'SData = Encoding.ASCII.GetBytes("500000FF03FF000018000A04010000D
'Send the data.
Me.Ajsock.Send(SData)
MsgBox("Send completion", MsgBoxStyle.Information)
'Read the response from the PLC CPU.
Me.Ajsock.Receive(RData)
MsgBox(Encoding.ASCII.GetString(RData), MsgBoxStyle.Information)
End Sub
Private Sub Command3_Click(ByVal eventSender As System.Object, ByVal eventArgs
As System.EventArgs) Handles Command3.Click
'Close the TCP (UDP) connection socket (disconnect the line).
Me.Ajsock.Shutdown(Net.Sockets.SocketShutdown.Both)
Me.Ajsock.Close()
MsgBox("The disconnection was successful", MsgBoxStyle.Information)
State = Me.Ajsock.Connected()
End Sub
368
*0000000005")

Advertisement

Table of Contents
loading

Table of Contents