IMDHMIControls LibraryShop main store

Explainer

Modicon M262 Modbus TCP addressing and the %MW relocation areas

Industrial networks Published 8 min read

Short answer

Read the M262 application data at %MW0 through %MW59999 over Modbus TCP: port 502, unit ID 255, zero-based register numbers, function codes 3, 6 and 16 only. Declare variables nowhere above %MW59999 — %MW60000 and %MW62000 are relocation-table windows, not memory — and split a large exchange into blocks of at most 125 registers per read and 123 per write.

On this page
  1. The integrated Modbus TCP server
  2. Why arrays at the relocation areas fail at download
  3. Zero-based registers and the 400001 notation
  4. Worked example: 1000 words each way between the M262 and the HMI
  5. When a relocation table is worth configuring
  6. Bits, wide values and word order
  7. Keeping command and status words apart
  8. Questions asked

A Modicon M262 already carries a Modbus TCP server, so a Visual Basic HMI exchanges data with it without any communication code in the controller project. Read and write the application data at %MW0 through %MW59999: the server answers at TCP port 502 and unit ID 255, accepts function codes 3, 6 and 16 on holding registers, and numbers registers zero-based, so %MW0 is wire register 0. The %MW60000 and %MW62000 areas are relocation-table windows, not allocatable memory — declare an array there and the download stops with an out-of-range allocation error. The sections below cover the connection settings, that download failure, the addressing arithmetic, a worked layout for a 1000-word exchange, and the cases where a relocation table earns its place.

The integrated Modbus TCP server #

Prerequisites are ordinary: the HMI PC and the controller on the same subnet, the application downloaded, the controller in RUN. The server is built into the controller — no communication function block and nothing to configure in the project. The client targets the controller IP address at TCP port 502.

Every request carries unit ID 255. That ID is fixed in the controller; you cannot configure another one, so set it explicitly in every client. A test tool left at a different ID fails every read and write even though the network path is perfect, because the server answers nothing else. A hand-rolled socket program that never checks the field may get away with it — set the ID all the same, so the frames you prove in the test tool run unchanged in the HMI.

On holding registers the server serves exactly three function codes:

  • 3 — read holding registers
  • 6 — write a single register
  • 16 — write a block of registers

Anything else the screen wants has to be built from those three; the last two sections show how.

Why arrays at the relocation areas fail at download #

Declare a contiguous array of WORDs at %MW60000 or %MW62000 and the project builds, then stops at download with an out-of-range allocation error. The array is not too big and the syntax is not wrong: those addresses are outside the range the application may allocate. They are the windows of the relocation tables, the mechanism the programming guide describes in its memory-mapping chapter, and the application cannot claim them as variable space.

Application data lives at %MW0 through %MW59999. Move the arrays into that range and the error disappears; nothing else in the project changes. The boundary is fixed, so no declaration trick makes a word above it allocatable.

Zero-based registers and the 400001 notation #

On the wire the register number is the plain %MW offset: request register 0 to read %MW0, register 1000 for %MW1000. Never put a 40000-series number in the request field. The extended display notation writes the same space as 400001 through 465536, where 400001 corresponds to %MW0 — that notation is for people and some tools, not for the request.

The server accepts the full offset range: a test client exercised holding registers across offsets 0 to 65535. Only %MW0 through %MW59999 of that range is application data; the positions above it are the relocation windows, not spare memory.

Some client libraries and test tools add 1 to what you type or display addresses 1-based. Verify instead of assuming:

  1. In the online watch window, force the word at %MW0 to a recognizable value, for example 4660.
  2. Read one register at wire offset 0 from the client.
  3. Write a second recognizable value to the wire offset that should map to %MW1000 and check it lands in %MW1000, not one word up or down.

If the read returns 4660 and the write lands on the right word, the offset is clean and you can scale up. A value one register off means the client applies a shift — correct it in the client before building the map, because every block in the plan shifts by the same word.

Worked example: 1000 words each way between the M262 and the HMI #

Inputs:

  • Exchange size: 1000 words the HMI reads, 1000 it writes — the requirement the HMI side set.
  • Data area: %MW0 through %MW59999, the application range of the controller memory map.
  • Per-request caps: 125 registers for a function 3 read and 123 for a function 16 write, the maxima the Modbus specification sets; the server cannot be coaxed past them.
  • Connection: the settings from the first section, already proven with single registers.

Rule in words: keep the words the HMI writes in a range the PLC program treats as its own input area, so a screen can never overwrite a controller output word; then split each direction into the largest requests its function code allows. Requests per direction = words to move ÷ registers per request, rounded up.

Arithmetic for the reads, function 3: place the 1000 words the HMI reads at %MW0 through %MW999, wire registers 0 to 999. 1000 ÷ 125 = 8 with no remainder, so eight requests of 125 registers each, at wire offsets 0, 125, 250, 375, 500, 625, 750 and 875; the last covers registers 875 to 999.

Arithmetic for the writes, function 16: place the words the HMI writes at %MW1000 through %MW1999, wire registers 1000 to 1999. 1000 ÷ 123 = 8 with a remainder: 8 × 123 = 984, and 1000 − 984 = 16. Nine requests, then: eight of 123 registers at wire offsets 1000, 1123, 1246, 1369, 1492, 1615, 1738 and 1861, then a closing request of 16 registers at offset 1984, which reaches 1999.

Direction Function code M262 addresses Wire registers Requests
HMI reads 3 %MW0–%MW999 0–999 8 of 125
HMI writes 16 %MW1000–%MW1999 1000–1999 8 of 123 and 1 of 16

Result: the whole exchange moves in 8 + 9 = 17 requests per refresh, every request inside the specification caps and every address inside the application area.

Decision: use this layout whenever you control the map — it needs no relocation configuration, and every tag resolves by a plain offset. Two checks make it trustworthy. First, the seams: force a value into the last word of the first read block (%MW124), read the block at offset 0, and confirm the value sits at position 124 of the response; the block at offset 125 must start clean. Second, the caps: a client that asks for more than the cap in one request earns an exception, not a longer reply, so an oversize request is a client bug, never a slow server.

The caps are hard, which makes concurrency the only lever when a screen needs fresher data than one sequential round trip of 17 requests delivers: running parallel clients beats a single sequential poller, as shown in why parallel Modbus TCP clients beat one sequential poller.

When a relocation table is worth configuring #

A relocation table maps individual words into consecutive windows in the %MW60000 area, so a client reads words that sit scattered through the program as if they were adjacent: %MW0 and %MW1374, for example, presented as two neighboring registers covered by one request. You build the mapping in the programming software; the client side changes nothing except the offsets it asks for.

The table allocates nothing and stores nothing — it presents words that already exist elsewhere. It buys requests, not memory.

Decision: if you control the layout, place the words contiguously and skip the table; for a block map like the worked one it saves nothing, because the words are already consecutive. Configure it when the words you must gather sit at addresses you cannot move — fixed interfaces, legacy code sections, a convention another program already depends on. That is the same gather-once, read-often problem solved for soft starters in scattered parameter reads over Ethernet/IP: collect the scattered items once into one readable place, then serve every reader from there.

Bits, wide values and word order #

On holding registers there is no bit access at all: Modbus defines no function that reads a single bit out of a 16-bit register, and this server offers only 3, 6 and 16. To read a bit, fetch the word with function 3 and test the bit in the client. To set one, let the PLC program do it, or fetch the word, change the bit and write the whole word back.

Values wider than one register — a DINT or a REAL — span two consecutive registers, and the client decides which word it treats as the high one. Prove the order with a recognizable pair of values before any screen is built on the type; the two-register test in the questions below takes two writes and one read.

Keeping command and status words apart #

Separate requests never form one snapshot: the scan can change words between two read blocks, and a write can land while the program is mid-change. Where a group of values must travel together — a recipe, a multi-word setpoint — add a handshake word the PLC sets last; the HMI accepts the group only after it sees that word move, and the group cannot tear.

Keep the two directions in separate ranges, and go further inside each word: the HMI writes command words, the PLC updates status words, and the program interprets a command — pulse it, acknowledge it — rather than the screen toggling bits inside a word the scan also touches. When both sides can change the same word anyway, arbitrate the writes with request logic instead of letting two writers race, the approach set out in PLC MOV priority with request logic. One safety rule anchors all of it: a word the screen writes is an operator command, so if a written bit can start motion, the guard conditions stay in the PLC program, never in the screen. The write-side checks that make such supervisory writes safe are worked through in safe Modbus writes to PLC output registers from SCADA.

Questions asked

How do I convert between %MW addresses and the 400001-style display notation?

Add the zero-based offset to 400001. Register %MW0 displays as 400001, %MW123 as 400124, %MW1000 as 401001. The six-digit number belongs in a tool display field; the request on the wire still carries the plain offset, so a tool that makes you type the 400001-style number converts it before sending. If a read comes back one register off, the tool applied the offset differently — correct it there, not in the map.

How can I check which register of a pair a client treats as the high word?

Write a different recognizable value to each register of the pair and read the two-register value back. For example write the pattern 16#1234 to the first register and 16#5678 to the second, then read the DINT or REAL: if it reads as 16#56781234, the first register is the low word; if it reads as 16#12345678, the first register is the high word. Fix the order in the client before building screens on that type.

Why does an ID sweep find nothing on the M262?

The integrated server answers only at unit ID 255, and discovery tools that sweep the low IDs never reach it, so they report no device even with the wiring and IP path perfect. Enter 255 directly in the client instead of scanning. The ID is fixed in the controller and no setting moves it, so any scan-based discovery keeps coming up empty.

Does the Visual Basic application need anything from the controller's programming software?

No. The exchange is plain Modbus TCP, so any client works: a socket program in Visual Basic or similar, a desktop test tool, or a commercial driver. Nothing from the programming environment runs on the HMI PC, and no runtime component is shared with the controller. The application needs the controller IP address, TCP port 502, unit ID 255 and a register map agreed with the PLC program.

Keep reading

  • How-to

    Connecting third-party Modbus TCP devices to a Modicon MC80

    Yes. A Modicon MC80 under Control Expert Classic exchanges data with any third-party Modbus TCP device through explicit READ_VAR and WRITE_VAR calls plus the device's register map — there is no ESD or EDS import, no IO Scanning and no DTM support. Run the MC80 as the TCP client, keep the exchange in the coil and holding-register tables, and latch each result in the reader so a 16 ms update survives a slower PLC poll.

    Industrial networks

  • Comparison

    Can a Modbus TCP server answer on multiple IP addresses

    No. A Modbus TCP server instance replies from the one IP assigned to the interface the client dialed, and a controller cannot put two interfaces in the same subnet. Serve both register ranges from one address with a flat register map, add server instances on separate TCP ports for extra simultaneous clients, or mount a second interface only in its own different subnet.

    Industrial networks

  • Selection guide

    Choosing a ControlLogix path to a Modbus TCP Schneider PLC

    ODVA Volume 7 defines how Modbus devices integrate into CIP; it is not a ControlLogix feature, so no stock 1756 Ethernet module speaks Modbus TCP natively. Choose from four paths: an in-rack or standalone gateway, Modbus TCP written over generic sockets on a 1756-EN2T at firmware 5 with RSLogix 5000 v20 (or a 1756-EWEB), an OPC bridge on a PC, or EtherNet/IP on the Schneider side where the CPU supports it.

    Industrial networks