How to Communicate with Mitsubishi PLCs Using the MC Protocol
What Is the MC Protocol?
The MC protocol is a communication protocol for accessing devices on Mitsubishi Electric MELSEC series PLCs over Ethernet.
It can read and write D devices, M devices, X and Y devices and more.
Overview
Reads and writes memory using the MELSEC communication protocol (MC protocol) on the Ethernet port of a MITSUBISHI PLC
This library uses the following frame and code
| Frame | 3E frame |
| Code | Binary code |
The MITSUBISHI PLC is the server, and no ladder is needed on the MITSUBISHI side
Features of McLink
- Supports MC protocol 3E frames
- Supports binary code
- Supports TCP communication
- Supports UDP communication
- Supports D device reading
- Supports M device reading
- Supports random reading
- Supports the NX/NJ series
List of FBs for the MC protocol
Namespace: McLink
| McpRead | Batch read |
| McpReadBit | Batch read in bit units |
| McpRandomRead | Random reading |
| McpWrite | Batch write |
| McpWriteBit | Batch write in bit units |
| McpUDP | Send MC protocol command UDP |
| McpTCP | Send MC protocol command TCP |
McpRead (batch read)

- IpAddress
- STRING[200]
- Destination IP address
- Port
- UINT
- Port number
- Device
- McLink\DeviceCode
- Device code
- Address
- UDINT
- First device
- ReadSize
- UINT
- Number of device points
- ReciveData
- ARRAY[*] OF WORD
- Received data
McpReadBit (batch read in bit units)

- IpAddress
- STRING[200]
- Destination IP address
- Port
- UINT
- Port number
- Device
- McLink\DeviceCode
- Device code
- Address
- UDINT
- First device
- ReadSize
- UINT
- Number of device points
- ReciveData
- ARRAY[*] OF WORD
- Received data
McpRamdomRead (random read)

- IpAddress
- STRING[200]
- Destination IP address
- Port
- UINT
- Port number
- WordDevice
- STRING[255]
- Word device names (comma-separated)
- DWordDevice
- STRING[255]
- Double word device names (comma-separated)
- ReadDataW
- ARRAY[0..9] OF WORD
- Word device received data
- ReadDataDW
- ARRAY[0..9] OF DWORD
- Double word device received data
McpWrite (batch write)

- IpAddress
- STRING[200]
- Destination IP address
- Port
- UINT
- Port number
- Device
- McLink\DeviceCode
- Device code
- Address
- UDINT
- First device
- WriteSize
- UINT
- Number of device points
- WriteData
- ARRAY[*] OF WORD
- Write data
McpWriteBit (batch write in bit units)

- IpAddress
- STRING[200]
- Destination IP address
- Port
- UINT
- Port number
- Device
- McLink\DeviceCode
- Device code
- Address
- UDINT
- First device
- WriteSize
- UINT
- Number of device points
- WriteData
- ARRAY[*] OF WORD
- Write data
McpUDP (send MC protocol command UDP)

- IpAddress
- STRING[200]
- Destination IP address
- Port
- UINT
- Port number
- CmdSize
- MUINT
- Number of bytes to send
- ReciveSize
- UINT
- Number of bytes received
- Cmd
- ARRAY[*] OF BYTE
- Send command
- ReciveData
- ARRAY[*] OF BYTE
- Received data
McpTCP (send MC protocol command TCP)

- IpAddress
- STRING[200]
- Destination IP address
- Port
- UINT
- Port number
- CmdSize
- MUINT
- Number of bytes to send
- ReciveSize
- UINT
- Number of bytes received
- Cmd
- ARRAY[*] OF BYTE
- Send command
- ReciveData
- ARRAY[*] OF BYTE
- Received data
Program example
McpRead (batch read)
| FB input variables | ||||
| Device | \\McLink\DeviceCode#D | |||
| Address | 0 | |||
| ReadSize | 5 | |||
| FB input/output variables | ||||
| ReadData | [0001,0002,0003,0004,0005] | |||
McpReadBit (batch read in bit units)
| FB input variables | ||||
| Device | \\McLink\DeviceCode#M | |||
| Address | 0 | |||
| ReadSize | 10 | |||
| FB input/output variables | ||||
| ReadBitData | [TRUE,TRUE,TRUE,TRUE,TRUE,FALSE,FALSE,FALSE,FALSE] | |||
McpRamdomRead (random read)
| FB input variables | |||
| WordDevice | 'D0,D10,X10' | ||
| DWordDevice | 'D100,M0,Y20' | ||
| FB input/output variables | |||
| ReadDataW | [0001,000A,000F] | ||
| ReadDataDW | [00660065,04030201,12345678] | ||
McpWrite (batch write)
| FB input variables | ||||
| Device | \\McLink\DeviceCode#D | |||
| Address | 0 | |||
| WriteSize | 2 | |||
| FB input/output variables | ||||
| WriteData | [000A,000B] | |||
McpWriteBit (batch write in bit units)
| FB input variables | ||||
| Device | \\McLink\DeviceCode#M | |||
| Address | 0 | |||
| WriteSize | 6 | |||
| FB input/output variables | ||||
| WriteData | [TRUE,TRUE,,TRUE,TRUE,TRUE,TRUE] | |||
McpUDP (send MC protocol command UDP)
| FB input variables | |||
| CmdSize | 10 | ||
| FB output variables | |||
| ReciveSize | 4 | ||
| FB output variables | |||
| Cmd | [01,04,00,00,00,00,00,A8,02,00] | ||
| ReciveData | [01,00,02,00] | ||
McpTCP (send MC protocol command TCP)
| FB input variables | |||
| CmdSize | 10 | ||
| FB output variables | |||
| ReciveSize | 4 | ||
| FB output variables | |||
| Cmd | [01,04,00,00,00,00,00,A8,02,00] | ||
| ReciveData | [01,00,02,00] | ||
Related pages
The Free edition is free. One Pro license unlocks all five tools
TCP and UDP communication test tool

ComCom
An application that sends messages you create using Ethernet socket communication
Python MC protocol communication

MITSUBISHI MC Protocol Communication
MC protocol communication with MITSUBISHI PLCs
MITSUBISHI

MC Protocol Error Codes
Meanings and fixes for MC protocol (SLMP) end codes such as C059, C056 and C051
McLink library
By downloading, you are deemed to have agreed to the Terms of Use
Files included with the library
- McLink.slr (library file)
- McLink.csm2 (library source file)
- McLinkSample.csm2 (sample using the library)
- McLink.md (library description)
