Comparison
Choosing how a Siemens PLC talks to a Modicon M580
Short answer
An S7-1200 or S7-1500 and a Modicon M580 need no gateway: both speak Modbus TCP on their existing Ethernet ports, with the M580 as server and MB_CLIENT on the Siemens side or MB_SERVER polled by the M580's I/O scanner, and OPC UA is native to both. Add a PROFINET-to-Modbus TCP gateway only when a participant such as a PROFINET-only drive control unit cannot take a Modbus role, because the M580 has no PROFINET stack.
On this page
Skip the gateway box. An S7-1200 or S7-1500 and a Modicon M580 exchange data directly over Modbus TCP on the Ethernet ports both already have: the M580 serves its memory words while MB_CLIENT polls from the Siemens side, or MB_SERVER serves a data block that the M580's I/O scanner reads. OPC UA is the second native path, and it removes the register map entirely. A PROFINET-to-Modbus TCP gateway enters the panel only when a participant cannot take a Modbus TCP or OPC UA role at all — a PROFINET-only drive control unit, for example, because the M580 has no PROFINET stack. The table below puts the four routes side by side on hardware added, configuration and the faults each one produces, and the worked example pins down the register notation that breaks the direct path most often.
Use Modbus TCP before any gateway #
Nothing new to buy: MB_CLIENT and MB_SERVER come with TIA Portal for the S7-1200 and S7-1500, and the S7-1200 manual documents MB_CLIENT communicating through the PROFINET connector on the CPU with no additional communication hardware module required. The M580 serves its %MW memory words as Modbus TCP on TCP port 502, so the physical contract is one Ethernet cable and an agreed IP plan.
Pick the roles by who owns the data. When the M580's words are the source of truth, leave the M580 as server and poll it from the Siemens side. When the S7's data block is the source of truth, run MB_SERVER there and let the M580's I/O scanner read and write those registers on its own schedule. Either direction leaves the S7's PROFINET I/O running on the same port.
Agree the register notation once, in writing, because the two ecosystems write addresses differently: the 4-prefix reference style that puts MW10 down as 40010 is 1-based, while the request on the wire carries the same register numbered from zero. The guide to Modbus register numbering, 0-based versus 1-based references works through exactly which convention each side means. Run one MB_CLIENT instance per server as well: two instances pointed at one server stop the reads entirely, as why two MB_CLIENT instances stop Modbus TCP reads from one server documents.
How the four routes compare #
One question decides the row before anything else: can every participant take a Modbus TCP or OPC UA role? For an S7-1200 or S7-1500 against an M580 the answer is yes, so the first two routes cost configuration only; the gateway row exists for the day the answer turns to no.
| Route | Hardware you add | Who serves | Addressing you must agree on | First fault it produces |
|---|---|---|---|---|
| Modbus TCP, S7 as client | none | M580 serves %MW words on TCP port 502 | 4-prefix reference minus 40001, unit ID, word order | Request answered by diagnostics or ignored when the unit ID stays at the shipped value |
| Modbus TCP, S7 as server | none | MB_SERVER backs the registers with a data block; M580 I/O scanner polls | data-block word offset to register number, word order | Read of a register outside the mapped block |
| OPC UA, both native | none | whichever side owns the data serves nodes | none — typed values, no registers | Role or license missing on the exact CPU and firmware |
| PROFINET-to-Modbus TCP gateway | the gateway itself, mounted and powered | M580 still serves; gateway fronts the PROFINET side | the gateway's mapping table on top of both register maps | one mapping entry aimed at an unmapped register |
Where a read crosses registers nobody mapped, the server answers Modbus exception 02, illegal data address; how a read crossing a register map gap produces exception 02 is worth a read before you blame the cable.
When OPC UA beats registers #
OPC UA removes the register contract altogether: the client reads typed values by node, so there is no reference to convert, no word order to swap and no unit ID to set. An S7-1500 serves an embedded OPC UA server directly with no PC station in the path — when an S7-1500 needs no SIMATIC PC station for OPC UA sets out when exactly that holds. The price is engineering rather than hardware: confirm the server or client role you need exists on your exact CPU and firmware, and settle the Siemens-side licensing before the project commits to OPC UA.
Decision: OPC UA when many scattered typed values move between the programs or an OPC UA consumer already exists at line level; Modbus TCP for the handful of words you need moving this shift, with the register contract as the agreed price.
Set the unit ID on purpose #
MB_CLIENT ships with its unit ID at 255, so a fresh project sends 255 in every request until you change it. Schneider's FAQ on configuring the unit ID in a Modbus TCP request records that some Modbus TCP devices reserve unit IDs such as 100 and 255 for Ethernet diagnostic data, which means a request meant for the application can be answered by the diagnostic service instead. Set it deliberately in the instance data block, for example "MB_CLIENT_DB".MB_Unit_ID := 01;, and write the chosen value on the map sheet beside the partner IP address. The same discipline holds when the M580 I/O scanner is the client: the scanner polls the unit the server side expects, not whatever a default puts there.
Worked example: reading reference 40010 from an M580 into an S7-1500 #
Inputs, and where each comes from: the M580 runs as Modbus TCP server at 192.168.1.20 (an example address; substitute the CPU's real one), listening on TCP port 502; the test value is a REAL of 100.0 written on the M580 side into two consecutive %MW registers whose 4-prefix references are 40010 and 40011; the unit ID is set to 1 in the MB_CLIENT instance data block rather than left at the shipped value.
The rule in words: a 4-prefix holding-register reference is 1-based, the Modbus request carries a 0-based address, and the wire address equals the reference minus 40001.
The arithmetic: 40010 - 40001 = 9, so the read covers wire addresses 9 and 10 — references 40010 and 40011, two registers, 4 bytes, one 32-bit REAL. Call MB_CLIENT with the read mode for holding registers (function code 03), the start address 9, the length 2, the unit ID 1, and connection data pointing at 192.168.1.20, port 502.
The result: the read returns 16#42C8 (decimal 17096) followed by 16#0000. Assembled high word first, 16#42C80000 decodes as exactly 100.0. Assembled low word first, the same pair decodes as 16#000042C8, about 2.4×10^-41 — the tell-tale denormal of a swapped pair.
The decision: 100.0 back exactly proves the map, and you freeze reference, unit ID and word order on the map sheet. If you get 2.4×10^-41 or another value with no relation to the process, swap the two words, then if needed the bytes within each word, until the test value returns exactly — and encode that single conversion in the receiving routine instead of scattering swaps through the program. A read of references nobody mapped answers exception 02, so check the subtraction before the wiring. Prove all of this with the driven outputs in a safe state before the exchanged words take part in control.
When a PROFINET-to-Modbus TCP gateway is the only route #
The M580 has no PROFINET protocol stack: it cannot be the PROFINET IO controller for any device, and it cannot appear as a PROFINET IO device to an S7. That fact does not force PLC-to-PLC traffic through a gateway, though, because the S7 serves PROFINET I/O and runs its Modbus TCP instructions on the same port. A gateway enters the panel only when a participant cannot take a Modbus TCP or OPC UA role at all, and the case that reaches the field is a drive: a SINAMICS S120 with a CU320-2 PN control unit that the M580 must reach.
Three routes, in the order I would try them:
- A Siemens PLC owns the drive over PROFINET and passes the words the M580 needs across Modbus TCP or OPC UA. The drive stays on its native interface and the M580 sees only the registers the S7 maps for it.
- A gateway in the PROFINET IO controller role fronts the drive and speaks Modbus TCP to the M580. Verify the controller role in the gateway's datasheet before buying: a gateway offering only the IO device role cannot own a drive, as why a PROFINET IO-device gateway cannot be a controller explains.
- Order the drive control unit in its Profibus DP variant and keep the existing loop through the PMEPXM0100 Profibus master module. A Profibus master link does not carry over to a control unit whose fieldbus port is PROFINET — the fieldbus lives in the control unit ordering, not in an adapter cable.
When a gateway it is, its own configuration tool holds the whole mapping: ProSoft Configuration Builder, for one, takes the addresses of both sides, the Modbus slave ID of the M580 and the register mapping, and Anybus and HMS gateways fill the same role. Selecting a PROFINET controller gateway for a Modicon M580 walks through that choice.
Decision: direct Modbus TCP whenever both PLCs speak it — for an S7-1200 or S7-1500 against an M580, they always do; a gateway when a PROFINET-only endpoint such as the CU320-2 PN cannot be owned any other way; OPC UA when the data volume and the site architecture prefer typed values over a register map.
Questions asked
What does the M580's I/O scanner need from the S7 side?
An MB_SERVER instance whose holding-register area is a real data block, sized for the highest register the scanner addresses, plus the agreed mapping between register numbers and block offsets. The scanner addresses registers, not S7 byte addresses, so a table entry past the end of the block reads nothing useful. Give the scanner status a home in the S7 logic as well, so a stalled poll shows up on your side instead of failing silently.
What about an older S7-300 or S7-400?
The same two Modbus TCP roles exist there through the CP343 family of communication processors, which do client and server on the Ethernet side while the CPU keeps its own fieldbus traffic running. Configure it the same way: the server backs its registers with a data block, the client carries the partner IP, port 502 and the unit ID, and the notation and word-order traps of the worked example apply unchanged.
When are raw sockets with TCON, TSEND and TRCV worth it?
For a partner that is not a Modbus device. MB_CLIENT already frames the function code, the start address, the length and the unit ID, and returns status outputs you can alarm on; with TCON, TSEND and TRCV you assemble every Modbus byte yourself and debug it on a network capture. Between an S7 and an M580 the library block is the shorter and safer road.
Does the M580 have an OPC UA side of its own?
Yes, as a client: the M580 CPU provides embedded OPC UA client function blocks, and Schneider's documented procedure uses them to connect the M580 to an external OPC UA server. Confirm your CPU's firmware supports those blocks before you build the data path around them. That client role does not make the M580 a PROFINET partner — OPC UA is a separate Ethernet service on the CPU port.