EasyManua.ls Logo

YASKAWA MP3000 Series - Page 353

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-335
Ethernet Communications
'---- Receive response data ----
Srbuf = Space(4096)
from_len = Len(PC_addr)
rlen = recvfrom(sock, Srbuf, 4096, 0, PC_addr, from_len)
If (rlen <= 0) Then
MsgBox("receive error " & WSAGetLastError())
closesocket(0)
WSACleanup() ’Release the Winsock.DLL
Return -1
End If
'---- Check response data ----
rc = ChkRspData(rlen, Srbuf)
If (rc <> 0) Then
MsgBox("receive data format error")
closesocket(0)
WSACleanup() ’Release the Winsock.DLL
Return -1
End If
Return rc
End Function
'------------------------------------------------------------------------------
’Create Extended MEMOBUS protocol command
'------------------------------------------------------------------------------
Function MkCmdData(ByVal SFC As Byte, ByVal CPUNum As Byte, _
ByVal Adr As Short, ByVal DataNum As Short, _
ByRef Ssbuf As String) As Object
Dim i As Integer
Dim Swork As String
'---- Calculate number of data items ----
'---- MEMOBUS data length from MFC to end of data ----
Select Case SFC
Case &H9
MDATAi = 8
Case Else
MsgBox (“Function code error”)
Return -1
End Select
'---- Calculate total number of data items ----
DATAi = MDATAi + 14 ’218 header (12 bytes) + Length part (2 bytes) + MEMOBUS data length
(variable)
If DATAi > 4096 Then
MsgBox (“Register size error”)
Return -1
End If

Table of Contents

Other manuals for YASKAWA MP3000 Series

Related product manuals