EasyManua.ls Logo

YASKAWA MP3000 Series - Page 349

YASKAWA MP3000 Series
435 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
2.12 Communications with a Windows PC (Visual Basic Application)
Using Automatic Reception with the MP3000 as a Slave
2-331
Ethernet Communications
'---- Get the MP3000’s IP address. ----
DstPort = Val(TextBox10.Text)
'---- Get the connection type ----
TransPort = ComboBox1. SelectedIndex ' 0:TCP 1:UDP
'---- Open a TCP/UDP port ----
rc = MemobusMasterMain(TransPort, MyIP, MyPort, DstIP, DstPort)
If rc = 0 Then
MsgBox (“Socket created”)
Else
MsgBox (“Socket creation failed”)
End If
End Sub
Private Sub Command2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Han-
dles Command2.Click
’Timer processing --- Start
Timer1.Interval = 100 '100ms
Timer1.Enabled = True
End Sub
Private Sub Command3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Han-
dles
Command3.Click
’Timer processing --- Stop
Timer1.Enabled = False
End Sub
’The following process starts the Timer and executes every 100 ms
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Timer1.Tick
Dim rc As Short
SFC = &H9 ’Read contents of hold registers (extended)
CPUNum = 1 ’Set the remote device as CPU1
Adr = 0 ’Set the first address to MW00000
DataNum = 10 ’Read 10 words from the first address
'---- Create Extended MEMOBUS send data ----
MkCmdData(SFC, CPUNum, Adr, DataNum, Ssbuf)
'---- Send Extended MEMOBUS command and receive response ----
rc = MemobusMsg(TransPort, Ssbuf, Srbuf)
If rc <> 0 Then
Timer1.Enabled = False ’Timer processing --- Stop
closesocket(0) ’Close the socket
WSACleanup() ’Release the Winsock.DLL
End If
'---- Reflect values in the register monitor ----
’Add code to display the read register values
End Sub
End Class

Table of Contents

Other manuals for YASKAWA MP3000 Series

Related product manuals