Troubleshooting
Why an S7-200 Modbus slave compile shows dozens of V-memory errors
Short answer
Dozens of compile errors naming V addresses almost always come from one or two allocation faults: the library memory block was never assigned, or the holding-register range set by HoldStart and MaxHold overlaps program V memory or runs past the CPU's V-memory limit. Assign the block in the Library Memory dialog, place the range clear of it, and expect 0 errors on recompile.

On this page
Dozens of compile errors that all name V addresses, appearing the moment the Modbus slave library joins an S7-200 project, almost always come from one or two allocation faults, not from your logic. The library keeps its working data in a reserved block of V memory, and the holding registers the master reads map onto a second V range set by HoldStart and MaxHold on MBUS_INIT. Leave the block unassigned, let the two ranges collide, or run the holding range past the CPU's V memory, and every library reference fails to resolve, each one printing its own error line. Assign the block in the Library Memory dialog, place the holding range clear of it, and the same compile that returned 58 errors returns 0.
Read the error list as one fault #
The Modbus RTU slave for the S7-200 is an instruction library installed into STEP 7-Micro/WIN, not a built-in instruction; once installed, its calls appear in the Libraries branch of the operations tree. The library stores its working data in a private V-memory block, and Micro/WIN resolves every internal reference in that code against the block assigned in the Library Memory dialog. When the block is missing or overlaps V addresses your program already uses, every reference fails and each failure prints its own message, so the count follows the number of library references in your project, not the number of mistakes. One valid block assignment usually clears the whole list, which is why a compile with 58 messages and one with 6 deserve the same first move.
| What the list shows | Likely cause | Where to check |
|---|---|---|
| Many errors naming V addresses at the library calls | Library memory never assigned | The Library Memory dialog shows no block |
| Errors naming addresses your own code also uses | Block overlaps program V memory | Cross-reference for that V range |
| A single error on the holding range | HoldStart plus MaxHold times two lands past the CPU's V memory | V-memory size for the exact CPU, in its datasheet |
| Errors naming unknown instructions | Library missing for this Micro/WIN release | The Libraries branch of the operations tree |
The two V ranges the compile checks #
Library memory is one contiguous byte block reserved for the library's internal data. The Library Memory dialog reports the size the installed library release needs; read it there, because the size follows the release rather than being a fixed figure.
Holding registers are the V range the master reads and writes: HoldStart sets its first V word, MaxHold sets how many 16-bit registers the master may address, so the range occupies MaxHold × 2 bytes. Both ranges must also sit inside the CPU's own V memory and clear of every symbol, data block and network in the project.
A collision that slips past the compile can corrupt process data on a running machine, because the master writes straight into your V memory, so verify both ranges before the download.
Checking a 781-byte library block against a 100-register holding range #
Inputs, and where each comes from:
- Library block size: 781 bytes, documented for the Modbus slave instruction library in the S7-200 SMART Modbus RTU communication manual; the classic S7-200 library reports its own figure in the dialog, and this example works with the documented 781.
- Block start proposed by the dialog: VB3000, an example value for this case.
- Holding range set on MBUS_INIT: HoldStart at VB200 with MaxHold at 100 registers, example settings for the case.
The rule in words: the holding range spans MaxHold × 2 bytes beginning at HoldStart, and it must end below the block's first byte, with both ranges inside the CPU's V memory.
The arithmetic:
- Holding range: 100 × 2 = 200 bytes, so the range covers VB200 through VB399, because 200 + 200 − 1 = 399.
- Library block: 3000 + 781 − 1 = 3780, so the block covers VB3000 through VB3780.
- Overlap test: VB399 lies under VB3000, so the two ranges are clear of each other.
Result: with these addresses the allocation is valid and the compile should return 0 errors. The end address VB399 is also what must sit inside the CPU's V-memory limit for the CPU fitted; a CPU whose V memory ends below VB399 rejects the range at compile.
Decision: for these settings the threshold is VB400. A block that begins at VB400 or higher is clear; any block below VB400 collides. Had the dialog proposed VB350, the block would span VB350 through VB4130, because 350 + 781 − 1 = 4130, and it would swallow VB350 through VB399 of the holding range — so take the next proposed address from VB400 up, or move HoldStart and MaxHold down, then recompile.
Assign the block and rebuild #
- Open the project in STEP 7-Micro/WIN. Do not retype it into TIA Portal to escape the errors: TIA Portal targets S7-1200 and later CPUs, and an ET 200 CPU picked there is a different product line, so this project neither opens nor compiles there.
- Confirm the Modbus RTU slave instructions appear under the Libraries branch of the operations tree. If they do not, install the library release that matches your Micro/WIN version and restart the software.
- Open the Library Memory dialog — its entry sits with the program block or under the Project menu, depending on the Micro/WIN release — and run the action that suggests an address. Note the start address and the size it proposes.
- Open the cross-reference and the data block view, and confirm no symbol, data block or network touches the proposed range.
- On MBUS_INIT, set HoldStart and MaxHold so the range — MaxHold × 2 bytes beginning at HoldStart — ends below the block and inside the CPU's V memory.
- Give MBUS_INIT its own network driven by SM0.1, the first-scan bit, so it runs once, and set Mode, Addr, Baud, Parity, Delay, MaxIQ, MaxAI, MaxHold and HoldStart to what the master expects.
- Place MBUS_SLAVE in the main program in a network driven by SM0.0 so it executes every scan; in a subroutine that is called conditionally it misses requests and stalls the master. Wire its Done and Error outputs to spare V or M bits so runtime codes stay visible.
- Compile. Expected result: 0 errors. Anything left is now one genuine fault with one address.
When errors survive the assignment #
- Messages naming instructions the compiler does not know: the library is not installed for this Micro/WIN release, so return to step 2.
- Messages naming V addresses your own code also uses: the block and your data share a range, so repeat the cross-reference check with the new block address.
- One message on the holding range: HoldStart plus MaxHold × 2 runs past the CPU's V memory, so shrink MaxHold or move HoldStart down and recompile.
- A clean compile but error 10 on the slave at runtime: the wrong holding range has surfaced after the download, and the fix pattern is the one described in Why S7-200 MODBUS_SLAVE reports error 10 on HoldStart overlap.
- The programming cable: once the slave claims Port 0, PPI programming no longer shares that port with a PC, as explained in Why an S7-200 cannot share one RS-485 port with a PC and Modbus, so download and go online before enabling Modbus. For the RS-485 pins and termination on that port, follow S7-200 Port 0 Modbus RTU wiring: pins 3, 8, termination.
Habits that bring the list back #
- Moving the project to another PC or upgrading Micro/WIN or the library without revisiting the Library Memory dialog: an upgrade can change the required size, and the block must be proposed again before the next compile.
- Reusing part of the holding range for ordinary program variables: the master then overwrites process data with what you store there.
- Driving MBUS_INIT every scan instead of once on SM0.1: each call re-initializes the port and drops communication.
- Mixing register numbering between tools: a master that shows the first register as 40001 and a tool that shows offset 0 describe the same word at HoldStart, so a mismatch reads the neighbouring word. Verify by writing a known value from the master and watching the word at HoldStart in a status chart.
Questions asked
Why does my Library Memory dialog show a different size than 781 bytes?
The 781 bytes is the figure the S7-200 SMART Modbus RTU communication manual documents for its own slave library release, and the requirement follows the library release, not a fixed rule. Your dialog is the authority for the release installed on your PC, so accept the size it reports and let it propose the block; do not copy a figure between releases.
Can a holding range that overlaps the library block still compile clean?
Sometimes yes. The compile rejects a holding range that leaves the CPU's V memory, but a collision with the reserved block can pass unnoticed, because the compile checks addresses, not ownership. Such a range corrupts data once a master writes into it, so treat the cross-reference check of both ranges as part of the fix, before the download goes to the CPU.
What does error code 10 from the slave mean once it runs?
The Error output of the slave reports runtime codes, and code 10 points at the holding-register setup on MBUS_INIT: the HoldStart and MaxHold pair describes a range the library cannot serve, most often because it collides with other V memory. Correct the two parameters and restart the slave; the wiring and the master settings are not the cause.
Does one library provide both Modbus master and slave instructions?
The S7-200 Modbus RTU library family carries both sides: MBUS_INIT with MBUS_MSG for a master, and MBUS_INIT with MBUS_SLAVE for a slave, each with its own memory requirement in the Library Memory dialog. A project that acts as both master and slave needs both instruction sets allocated, and each side reserves its own block of V memory.

