How-to
Configuring an R16CPU as a Modbus TCP master in GX Works3
Short answer
An R16CPU has no dedicated Modbus TCP master page: you reach Modbus TCP master duty over its built-in Ethernet port through GX Works3's Predefined Protocol Support Tool and the SP.ECPRTCL instruction, with an Active open to the robot's port 502 and FC03, FC06 or FC16 transactions.

On this page
- Why don't the FX5U Modbus TCP tutorials match the R16CPU?
- Do you need an extension module for Modbus TCP master on an R16CPU?
- How does a Modbus TCP master work on the iQ-R built-in Ethernet port?
- How do you configure the connection to the robot in GX Works3?
- How do you build the FC03, FC06 and FC16 protocols in the Predefined Protocol Support Tool?
- How does the ladder trigger each transaction with SP.ECPRTCL?
- How do you prove the R16CPU and the robot are exchanging frames?
- Questions asked
An R16CPU runs Modbus TCP master duty over its built-in Ethernet port through GX Works3's Predefined Protocol Support Tool and the SP.ECPRTCL instruction. The FX5U-style Modbus TCP parameter pages do not exist on an iQ-R CPU, which is why the FX5U walkthroughs lead nowhere: you build FC03, FC06 and FC16 transactions in the support tool, register them in the built-in port's module parameters, write them to the CPU, and trigger each transaction from ladder with an Active open against the robot's port 502. Everything below assumes the base CPU alone and a collaborative robot acting as a Modbus TCP server.
Why don't the FX5U Modbus TCP tutorials match the R16CPU? #
Because the FX5U's built-in Ethernet port carries a dedicated Modbus TCP device function in its parameters, while the iQ-R R16CPU reaches the same master role through the predefined protocol support function, driven from your program by SP.ECPRTCL instead of an automatic refresh table.
Robot integration manuals use the FX5U for their examples, and every setting those examples touch belongs to a parameter screen an iQ-R CPU does not have, so the tutorial clicks land on menus that are not there. The frames on the wire stay identical — same 7-byte MBAP header, same function codes — because both families implement the same protocol; what moves is where the setup lives and what fires each transaction. The FX5U side of that split, a dedicated Modbus TCP setup with automatic refresh, is what Making an FX5U a Modbus TCP server for a KTP700 panel shows from the server end. For the iQ-R, the MELSEC iQ-R MODBUS and MODBUS/TCP Reference Manual gives the frame specifications of the built-in port, and the MELSEC iQ-R Programming Manual (CPU Module Instructions) defines the predefined protocol support function, which builds protocol definitions per external device and stores the protocol setting data your program then executes.
Do you need an extension module for Modbus TCP master on an R16CPU? #
No — the R16CPU's built-in Ethernet port handles the whole Modbus TCP master task, so the base CPU alone is enough, and an intelligent-function Ethernet module only adds a second interface you do not need for one robot.
The port parameters, the connection table and the protocol store all sit on the CPU itself. An intelligent-function Ethernet module earns its slot when you need a separate physical network or serial protocols beside the robot link; taking that route moves the parameter set and the instruction operands to the module's own start I/O number, a different layout to learn for no gain here. Sharing the built-in port with GX Works3 monitoring is normal practice, but expect online monitoring traffic to add short bursts of latency to the polling cycle while an engineer stays connected.
How does a Modbus TCP master work on the iQ-R built-in Ethernet port? #
The CPU's built-in Ethernet port opens a TCP connection to the robot's port 502 with an Active open, then sends each registered transaction over that socket when SP.ECPRTCL executes — the master requests, the robot's server answers.
In Modbus the master requests function execution and the slaves carry it out; over TCP each frame rides the MBAP header and the server listens on its registered port. Because the robot is the server, the CPU dials first: the Active open goes in the connection settings, and the robot's side stays passive. The predefined protocol support function stores the protocol definitions for each external device in the module parameters, and the program executes them; the slave role toward a panel or SCADA client is configured separately from this master work. The short list of PLC-side items — own node address, subnet mask, who opens — is the same in principle for any such link, as What you must configure on the PLC side for Modbus TCP lays out.
How do you configure the connection to the robot in GX Works3? #
You set the CPU's own IP address in the built-in Ethernet port's module parameters, then register a connection with an Active open to the robot's IP address and port 502, with the predefined protocol function marked in use for that connection.
- In GX Works3, open the module parameters and select the CPU's built-in Ethernet port; its settings page holds both the addressing and the protocol store.
- Enter the CPU's IP address and subnet mask on the robot's network — for example 192.168.3.10 with 255.255.255.0 against a robot at 192.168.3.50 — and leave the default gateway at 0.0.0.0 while the peer sits in the same subnet.
- Add a connection for the robot: TCP as the protocol, Active as the open method, the robot's IP address as the destination, 502 as the destination port, and an unused local port on the CPU's side.
- Mark the predefined protocol function in use for that connection, so the transactions you build next run across it.
- If the CPU has sat powered down for a while, confirm its firmware before the write; the iQ-R firmware verification and update guide for GX Works3 walks that check inside GX Works3.
Writing the module parameters to the CPU then loads the addressing, the connection and the registered protocols in one pass, so one write brings the whole link up.
How do you build the FC03, FC06 and FC16 protocols in the Predefined Protocol Support Tool? #
Launch the Predefined Protocol Support Tool from GX Works3's tool menu, create one protocol per transaction — an FC03 read holding registers, an FC06 write single register and an FC16 write multiple registers — and give each protocol's variable fields to devices you control from the ladder.
- Create a new protocol, pick Modbus TCP as the external device type, and choose FC03, read holding registers, for the first one.
- Keep the MBAP header at its 7 bytes: a transaction identifier that changes per transaction, a protocol identifier of 0x0000, and a length field that counts the unit ID and everything after it.
- Set the unit ID to the slave address the robot's documentation names; many TCP servers ignore it, but the ones that check it reject every frame when it is wrong.
- Make the starting address and the register quantity variable fields, each bound to a device, so one FC03 protocol reads any block the ladder points it at.
- Save it, repeat for FC06 and FC16, register the set to the port's parameters, and write the parameters to the CPU.
Worked example — reading a cobot status block. Suppose the robot's register map lists 16 holding registers from register 0: eight REAL joint values, two registers each. The request is 7 header bytes + 1 unit ID + 1 function code + 2 address bytes + 2 quantity bytes = 12 bytes on the wire, with the MBAP length field at 1+1+2+2 = 6, so 0x0006. The answer is 7 + 1 + 1 + 1 + 32 = 42 bytes, and the data checks out: 16 registers × 16 bits = 256 bits = 32 bytes. An FC16 write of those eight REAL values carries a byte count of 2 × 8 = 16, shown 0x10, and a length field of 1+1+2+2+1+16 = 23, so 0x0017 in a 30-byte frame.
How does the ladder trigger each transaction with SP.ECPRTCL? #
Each transaction is one SP.ECPRTCL call in your program: the instruction runs the registered protocol over the connection you opened, and its completion and error outputs tell the ladder whether the robot answered — nothing moves on the wire until that call executes.
Before the call, drop the variable fields you bound in the tool — the starting address and the register quantity — into their devices. The MELSEC iQ-R Programming Manual (CPU Module Instructions) fixes the instruction's operand layout and the completion and error devices for the protocol channels; the pattern around the call is the same for every protocol:
// Illustrative devices - assign your own in the project
// M100 = request pulse, M101 = busy, M102 = completion, M103 = error
IF M100 AND NOT M101 THEN
D200 := 0; // example map: the status block begins at register 0
D201 := 16; // 16 registers carry the eight REAL joint values
// SP.ECPRTCL for the opened connection runs the registered FC03 protocol
END_IF;
IF M102 THEN // completion: hand the 16 reply words (D202..D217) to scaling
M101 := FALSE;
M100 := FALSE;
END_IF;
IF M103 THEN // error: keep the code, drop busy, let the sequence retry
M101 := FALSE;
END_IF;
Writes follow the same shape: fill the FC16 data devices from the sequence logic, pulse the request, hold busy until the completion device turns on, and re-arm only when the error device is clear. Gate each new request on the previous transaction's completion — one transaction per call, never two in flight on the same socket.
One guard belongs here: the MELSEC iQ-R Ethernet User's Manual (Application) requires an interlock in the PLC program whenever an external connection can modify the data of a running controller, so put every write command behind the robot's own enabling logic — the PLC link alone must never be able to start motion.
How do you prove the R16CPU and the robot are exchanging frames? #
Open the built-in Ethernet port diagnostics in GX Works3 to confirm the connection is established, then read one register whose value the robot also shows on its own display — a match on that register proves parameters, protocol and ladder in one shot.
The link LED on the CPU should sit steady while polling runs. At frame level, mirror the switch port the CPU uses and capture with a filter of tcp.port == 502: the capture should show the 12-byte request from the worked example and a 42-byte answer whose byte count reads 32. If the frames look right but a joint position reads as garbage, the two-register REAL is word-swapped — the robot's documentation names big-endian or word-swapped order, and you fix it once in your scaling logic, never inside the protocol definition. Close the loop with a harmless write to a register the robot only logs, then read it back and watch the value return unchanged.
Questions asked
Does one project run unchanged on both an FX5U and an R16CPU?
No. The FX5U configures its Modbus TCP role in its own parameter layout and refreshes devices on its own, while the iQ-R CPU needs predefined protocol definitions plus SP.ECPRTCL calls in the program. The frames on the wire are identical, but the parameters, protocol data and program must be rebuilt for the iQ-R before it talks to the robot.
What does a Modbus exception answer from the robot tell you?
A failed transaction returns the function code with 128 added, so an FC03 read that fails answers with function code 131, shown as 0x83, followed by one exception byte. Code 01 marks an illegal function, 02 an address outside the server's map, 03 a bad quantity, and 04 a server-side failure. Read that byte before you change any ladder.
Can the R16CPU serve Modbus TCP to a panel while it polls the robot?
Yes. The iQ-R MODBUS and MODBUS/TCP reference manual documents the built-in port's Modbus/TCP slave function alongside the predefined-protocol work, so a supervisor can read CPU registers while the program drives the robot link. Configure the two roles separately and keep the register areas distinct so the two write paths cannot collide.
Do the protocol definitions survive a power cycle or a CPU replacement?
Yes. The protocols live in the project's module parameters for the built-in Ethernet port, and writing the parameters stores them in the CPU across power cycles and replacements. After a CPU swap or a firmware update, write the parameters again and confirm the link with one read of a register whose value you already know.


