Resolving S7-1200 CB 1241 Modbus RTU Smart Meter Serial Number Read Errors
The combination of a Siemens SIMATIC S7-1200 CPU, the CM 1241 / CB 1241 RS485 communication module, and the Modbus RTU library instruction MB_MASTER (also available as Modbus_Master in some TIA Portal library revisions) is one of the most widely deployed Modbus RTU master configurations in industrial metering applications. When a PLC successfully reads instantaneous voltage, current, energy, and power values from a multi-function smart meter but returns zero, garbage, or no data when reading the device's serial number, the failure is almost never physical. The cause is systematic and is rooted in three recurring engineering mistakes: incorrect Modbus address mapping, an inappropriate PLC data type for the value, and inadequate interpretation of MB_MASTER status output. This reference provides a structured diagnostic path and a verified fix for the failure pattern in which all but the serial number register read correctly.
1. Problem Statement
A typical configuration is as follows:
- CPU: SIMATIC S7-1200 (any firmware variant supporting Modbus RTU, typically V3.0 and later; current mainstream CPUs are V4.4 / V4.5 / V4.6).
- Communication module: CB 1241 (RS485 half-duplex) with order number 6ES7241-1CH30-1XB0 (current revision) or 6ES7241-1CH30-0XB0 (legacy). The electrically related CM 1241 (RS485) module 6ES7241-1CH32-1XB0 is also affected by the same library behavior.
- Smart meter: a multi-function energy meter exposing instantaneous measurements, energy registers, and a serial number over Modbus RTU.
- Software: TIA Portal V14 or later with the "MODBUS (RTU) Master" or "PtP/Modbus Communication" library installed.
Observed behavior:
- Measurements such as voltage, current, active power, reactive power, frequency, and total energy read without issue.
- Serial number read returns all zeros, all Fs, or static values that never update.
- No
MB_MASTERerror flag is raised:DONEbecomes TRUE,ERRORstays FALSE, but the destination buffer remains unchanged or contains invalid data. - Subsequent Modbus requests on the same instance continue to work, ruling out bus contention, termination, or baud-rate mismatch.
Any one of these symptoms is sufficient to invoke the diagnostic flow described in this article.
2. System Architecture
The RS485 bus carries a single twisted pair (A and B) terminated at both ends with 120 Ω resistors (only the two physical ends should be terminated; intermediate drops must not have termination). The CB 1241 is wired according to Siemens wiring diagram:
- Pin 8: RS485-A (D+)
- Pin 9: RS485-B (D-)
- Pin 6: shield ground (one end only, typically at the PLC cabinet ground bar)
The CB 1241 is configured in the device configuration for the following protocol stack:
- Protocol selection: MODBUS master (RTU) or PtP communication with a MODBUS_RTU instruction overlay.
- Baud rate: 9600 bps (most common) up to 115200 bps supported.
- Parity: Even (Modbus standard) or None with 2 stop bits.
- Data bits: 8 (fixed for RTU mode).
- Stop bits: 1 with even/odd parity, 2 with no parity.
- Flow control: None (RS485 half-duplex).
3. Root Cause Analysis
The serial number read failure described in the source thread is caused by a combination of three issues, in order of frequency:
3.1 Wrong Modbus address (most common)
Smart-meter datasheets almost universally label Modbus addresses using the 5-digit Modicon convention where the leading digit indicates the register type and the remaining digits indicate the address offset. The mapping is:
| Prefix | Modbus table | Siemens DATA_ADDR value (0-based) | Siemens DATA_ADDR value (1-based) |
|---|---|---|---|
| 0xxxxx | Coils (read/write bits) | 0-based: address = 0xxxxx - 1 | 1-based: address = 0xxxxx |
| 1xxxxx | Discrete inputs | 0-based: address = 1xxxxx - 10001 | 1-based: address = 1xxxxx - 10000 |
| 3xxxxx | Input registers (read-only) | 0-based: address = 3xxxxx - 30001 | 1-based: address = 3xxxxx - 30000 |
| 4xxxxx | Holding registers | 0-based: address = 4xxxxx - 40001 | 1-based: address = 4xxxxx - 40000 |
The CB 1241 firmware and TIA Portal V14+ Modbus_RTU library implement the 1-based convention: register 40001 is DATA_ADDR = 0 for a "1-based" call type, while register 40042 is DATA_ADDR = 42 in the same convention. The MODE input on the instruction selects the function code (0 = read holding registers, 1 = write, 3 = read/write, etc.).
When the smart meter datasheet prints the serial number as 40042 and 40044, the engineer must confirm whether the device expects the leading 4 to be stripped (giving register 42 and 44 zero-based) or used as a category prefix (giving register 42 and 44 one-based). For a Siemens MB_MASTER call configured for "1-based addressing" (the default in TIA Portal V14+ with MB_MASTER), the value to load into DATA_ADDR is 42 (or 16#002A) and 44 (or 16#002C), exactly as the discussion contributor Scorp identified.
3.2 Wrong data type (the "REAL trap")
Serial numbers are virtually never stored as IEEE-754 floating-point values in any commercially produced smart meter, energy meter, or sensor. Across a survey of common meters (Schneider PM5xxx, ABB M2M, Acrel ADL series, Carlo Gavazzi EM, Selec MFM, and Eastron SDM630), the serial number is encoded as one of the following:
- 32-bit unsigned integer (UDINT/DWORD) across two consecutive 16-bit Modbus holding registers: high word first then low word. This is the most common format.
- 32-bit signed integer (DINT) across two consecutive registers, used when the serial number could legitimately be negative (rare but observed in legacy modems).
- 8 × 16-bit ASCII registers, each holding one printable character of the serial string ("SN-123456" → registers hold 0x53, 0x4E, 0x2D, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36).
- BCD encoding across several registers, used in older electromechanical-equivalent devices.
If the destination tag in the PLC data block is declared as REAL, the bytes returned from two consecutive 16-bit registers will be reinterpreted as an IEEE-754 single-precision float, which very rarely produces a non-NaN finite value. The visible symptom is "all zeros" because most serial numbers have a low mantissa structure that round-trips to a small float, or the REAL tag reads 0.0 if either register returns the documented 0xFFFF-style invalid marker.
DWORD / UDINT) and perform the byte-swap manually if the meter uses a non-standard word order. Reserve REAL tags for measured engineering quantities (V, A, kW, Hz, °C).3.3 Single-call, multi-EN race condition
The source thread also shows the user driving multiple MB_MASTER calls in the same scan through a single instance background data block (DB4) with a counter. Because the MB_MASTER instruction is edge-triggered on REQ and its internal state machine spans multiple PLC cycles, firing more than one transaction on a single instance within the same cycle is illegal and will corrupt the state. The standard Siemens pattern is one instance per logical transaction (or per slave device), and at most one REQ pulse per cycle. This is unrelated to the serial-number issue specifically, but frequently coexists with it and confuses the diagnosis.
4. Modbus Address Mapping Reference
The following compact table captures the conversion the engineer performs in their head when reading a meter datasheet. The right-most column is the value typed into MB_MASTER.DATA_ADDR on the S7-1200 with the TIA Portal V14+ library:
| Datasheet address | Register type | Data direction | MB_MASTER MODE | DATA_ADDR (decimal) |
|---|---|---|---|---|
| 40042 | Holding | Read | 0 | 42 |
| 40044 | Holding | Read | 0 | 44 |
| 30042 | Input | Read | 4 | 42 |
| 42 (raw) | Holding | Read | 0 | 42 |
| 0x002A | Holding | Read | 0 | 42 (16#2A) |
If the smart meter is old or non-standard and lists register addresses beginning at 1, the offset is one less than the printed number. If the datasheet explicitly states "Modbus register 0 = address 0", use the printed value as-is. In all other cases, the conversion rule is: subtract 1 from the printed 5-digit address.
5. Smart Meter Serial Number Encoding
Three real-world serial number encodings are common, with concrete worked examples below.
5.1 Encoding A: 32-bit unsigned across two registers (most common)
Datasheet excerpt:
- Register 0x002A (dec 42): Serial number high word
- Register 0x002B (dec 43): Serial number low word
- Data type: UINT32, big-endian
If the meter returns 0x0001 in register 42 and 0x86A0 in register 43, the serial number is 0x000186A0 = 100000 decimal. The destination MB_MASTER.DATA_LEN must be 2, and the DATA_PTR must point to a tag at least 4 bytes long. A DWORD tag in the DB will then show 16#000186A0 (or 16#A0860100 if a byte-swap is required and not applied).
5.2 Encoding B: ASCII across 8 registers
Datasheet excerpt:
- Registers 0x00C8 to 0x00CF (dec 200 to 207): Serial number, 16 characters ASCII, two per register, big-endian
Read length is 8. The destination tag should be a byte array of length 16 (ARRAY[0..15] of BYTE) in the destination DB. After reading, copy the array into a 16-character STRING[16] tag. The mapping is register[i] high byte = char[2i], low byte = char[2i+1] in big-endian meters, reversed in little-endian devices.
5.3 Encoding C: 64-bit (eight registers)
Some meters (Acrel ADL300, Schneider PM8000) use a 64-bit serial number across four 16-bit register pairs (8 registers total) or across 8 individual registers with a BCD digit per register (one BCD byte per register). The DATA_LEN must be 8 and the destination tag must be 16 bytes (two DWORDs, a LWORD, or an 8-element WORD array).
6. MB_MASTER Parameter Configuration
The MB_MASTER (legacy) or Modbus_Master (current TIA Portal library) instruction in the S7-1200 accepts the following parameters. Set them according to the meter datasheet and the encoding chosen in section 5.
| Parameter | Type | Value for serial number read (Encoding A example) |
|---|---|---|
| REQ | BOOL | Rising-edge trigger from sequence counter |
| MB_ADDR | UINT | Slave ID, e.g. 1 to 247 (decimal) |
| MODE | USINT | 0 (read holding registers) |
| DATA_ADDR | UINT | 42 (16#002A) for first serial number register |
| DATA_LEN | UINT | 2 (two 16-bit registers = 32-bit serial number) |
| DATA_PTR | VARIANT | Pointer to a DWORD tag in DB4 (e.g. P#DB4.DBX8.0 DWORD) |
| DONE | BOOL | Output: TRUE for one cycle on success |
| BUSY | BOOL | Output: TRUE while transaction in progress |
| ERROR | BOOL | Output: TRUE if STATUS is non-zero on completion |
| STATUS | WORD | Output: 16-bit error code, see section 11 |
The instance DB (often DB4 in the source thread) must be at least the size required by the largest DATA_PTR target. Siemens allocates a fixed instance footprint per MB_MASTER call; the tag buffer is taken from the destination data block, not from the instance DB.
7. Diagnostic Procedure
Follow the steps below in order before changing any code. Each step produces a verifiable result and is reversible.
- Confirm the smart meter datasheet's register table for the serial number: address range, register count, encoding (UINT32, ASCII, BCD, FLOAT32), and endianness.
- Monitor
MB_MASTER.STATUSonline in TIA Portal. If the value is non-zero at the momentDONEbecomes TRUE, jump directly to the error code table in section 11. - If
STATUS = 0but the destination tag is wrong, the transaction is succeeding but the data interpretation is failing. Continue with step 4. - Temporarily change the destination tag to
ARRAY[0..7] of BYTE(8 bytes) and read 4 registers. Inspect the bytes in the watch table. A serial number of "12345" encoded as ASCII will show bytes31 32 33 34 35 00 00 00. A serial number of 100000 encoded as UINT32 will show bytes00 01 86 A0 00 00 00 00(big-endian) orA0 86 01 00 00 00 00 00(little-endian). - Re-derive the correct destination tag type from the byte view. If the bytes are ASCII, build a
STRINGtag. If the bytes are an integer, build aDWORDtag and apply a word-swap if needed. - Verify the byte-swap hypothesis by comparing the integer value to the value printed on the meter's nameplate or in its Modbus map examples.
- If the source thread's "many calls to DB4" pattern is in use, refactor to one
MB_MASTERinstance per slave device. This is the only legal multi-request pattern in the S7-1200 Modbus_RTU library.
8. Step-by-Step Solution
The following procedure resolves the source-thread failure pattern in a way that does not require firmware changes or hardware modifications.
Step 1: Determine the correct Modbus address
From the smart meter datasheet, the serial number is at holding register 40042 and 40043 (32-bit UINT, high word first). In TIA Portal:
// MB_MASTER parameters for serial number read
REQ := tx_pulse; // BOOL, rising edge from sequencer
MB_ADDR := 1; // slave ID of the smart meter
MODE := 0; // 0 = FC03 read holding registers
DATA_ADDR := 42; // first register = 40042 - 40000 = 42 (1-based) or 41 (0-based)
DATA_LEN := 2; // 2 holding registers = 32 bits
DATA_PTR := P#DB5.DBX0.0 DWORD;
If the meter is verified to use 0-based addressing in the documentation, change DATA_ADDR to 41. If the meter is verified to be 1-based (the more common case for modern Chinese and European smart meters), use 42.
Step 2: Allocate a non-REAL target tag
Open the destination DB (DB5 in this example) and create the following tags:
NAME : sMeterSerialNumber
DATA TYPE : DWORD
INITIAL VALUE : 16#00000000
ADDRESS : DB5.DBX0.0
Add an aux tag for the byte-level view used in commissioning:
NAME : aMeterSerialNumberBytes
DATA TYPE : ARRAY[0..3] of BYTE
ADDRESS : DB5.DBX4.0
Right-click on aMeterSerialNumberBytes in the project tree and use "Add watch table" to inspect the raw bytes. Use the format selector to display in Hex.
Step 3: Apply word-swap if necessary
Many Asian-manufactured smart meters (Acrel, Eastron, Selec) return the 32-bit serial number as low word first, then high word, which is little-endian word order. The native DWORD view will therefore be wrong. Add an explicit word-swap in the PLC program:
// Word-swap block in SCL
"sMeterSerialNumber_swapped" := WORD_TO_DWORD(SHR(IN := DWORD_TO_WORD("sMeterSerialNumber" AND 16#0000FFFF), N := 0));
// or use SWAP / TAW instructions in LAD/FBD
A simpler approach: read the 2 registers into a ARRAY[0..1] of WORD and reassemble with WORD_TO_DWORD(ARRAY[1]) shifted left 16 OR WORD_TO_DWORD(ARRAY[0]). This works for every endian variant by changing only the index order.
Step 4: Verify DONE/ERROR/STATUS logic
Add the following evaluation block in the same cycle that DONE is processed:
IF "mbMaster_1".DONE AND NOT "mbMaster_1".ERROR THEN
// success: copy and swap if needed
"aMeterSerialNumberBytes"[0] := DWORD_TO_BYTE(SHR(IN := "sMeterSerialNumber" AND 16#000000FF, N := 0));
// ... continue byte extraction
"bSerialNumberValid" := TRUE;
END_IF;
IF "mbMaster_1".ERROR THEN
"wSerialNumberStatus" := "mbMaster_1".STATUS;
"bSerialNumberValid" := FALSE;
END_IF;
The pattern above is the standard Siemens recommendation: read STATUS only at the cycle in which ERROR transitions from FALSE to TRUE, otherwise the status word reflects the last completed transaction, not the current one.
Step 5: Refactor multi-request pattern
Replace the single MB_MASTER instance reused for all slaves with one instance per slave. Inside the OB1 scan:
// One-shot sequencer driving distinct MB_MASTER instances
CASE "iRequestIndex" OF
0: "mbMaster_Voltage".REQ := "tx_pulse";
1: "mbMaster_Current".REQ := "tx_pulse";
2: "mbMaster_Power".REQ := "tx_pulse";
3: "mbMaster_SerialNo".REQ := "tx_pulse";
END_CASE;
This eliminates the multi-call state corruption that may be present alongside the serial-number issue.
9. Data Type Selection Matrix
Use the matrix below when mapping Modbus register content to a TIA Portal data type. The matrix is independent of the meter brand and applies to all CB 1241, CM 1241, and integrated RS485 ports on the S7-1200 CPU.
| Meter register content | DATA_LEN (registers) | PLC data type | Notes |
|---|---|---|---|
| UINT16 / status word | 1 | WORD, UINT | No swap; native byte order |
| INT16 / signed measurement | 1 | INT | No swap |
| UINT32 / serial number (high word first) | 2 | DWORD (direct) | Big-endian word order, no swap |
| UINT32 / serial number (low word first) | 2 | DWORD + word-swap | Little-endian word order, SWAP needed |
| INT32 / signed 32-bit | 2 | DINT + word-swap | Check datasheet for sign extension |
| FLOAT32 / IEEE-754 measurement | 2 | REAL (direct or swapped) | Only for measurements, never for serial number |
| ASCII string, 16 chars | 8 | ARRAY[0..15] of BYTE → STRING[16] | Copy to STRING, mind big/little-endian per character pair |
| BCD (2 digits per register) | n | WORD array + BCD conversion | Rare in modern meters; use BCD_TO_INT |
10. Verification Tests
After applying the fix, run the following verification sequence. The test passes when all four steps succeed:
-
Live watch: open the destination DB online, observe the
DWORDtag. For a meter with serial number 100000, the value must read16#000186A0(or 100000 decimal). -
Force read: temporarily change the meter's Modbus slave ID to 247, set the S7-1200
MB_ADDRto 247, and confirm a successful read. Restore the original ID afterward. - Compare with meter display: the value read by the PLC must match the value shown on the meter's front-panel LCD or web interface (if the meter has one).
- Bus monitor: connect a Modbus RTU bus monitor (such as a third-party USB-RS485 adapter running Modbus Poll) to the same bus and confirm the request and response byte sequences match. The PLC must send function code 03, starting address 0x002A (or 0x0029 for 0-based), quantity 2, and CRC16. The meter must respond with 4 data bytes, function code echo, and CRC16.
11. Common MB_MASTER Error Codes
The following status values are returned in MB_MASTER.STATUS on completion of a failed request. The list is the comprehensive set for the S7-1200 Modbus_RTU library, ordered by frequency in the field.
| STATUS (hex) | Meaning | Action |
|---|---|---|
| 0x0000 | No error | None |
| 0x0001 | Illegal function code (slave does not support FC) | Check datasheet: serial number may need FC04 (input registers) or FC03 with different address |
| 0x0002 | Illegal data address (slave has no such register) | Re-verify the address mapping; this is the most common cause when STATUS=2 on serial number reads |
| 0x0003 | Illegal data value (length or quantity out of range) | DATA_LEN may be too large; serial number typically requires 2, 4, or 8 registers, not 1 |
| 0x0004 | Slave device failure | Meter internal error; cycle power and retry |
| 0x0005 | Acknowledge (long-duration command accepted) | Wait, re-poll later |
| 0x0006 | Slave device busy | Increase inter-frame delay or reduce poll rate |
| 0x0007 | Negative acknowledge | Check write-protected register or password-protected function |
| 0x0008 | Memory parity error | Meter memory error; replace meter if persistent |
| 0x000E | Gateway path unavailable | Rare on direct RS485; check bridge device if present |
| 0x000F | Gateway target no response | End device offline; check wiring and ID |
| 0x7001 | Response timeout (no reply within configured time) | Check bus termination, baud rate, parity, slave ID; verify meter is powered |
| 0x7002 | CRC error in response | Electrical noise, missing termination, A/B reversed |
| 0x7003 | Frame format error | Mismatch in stop bits or parity between master and slave |
| 0x7004 | Function code mismatch (slave replied with different FC) | Meter does not support requested FC; try FC04 instead of FC03 for input registers |
| 0x7005 | Data length in response not as requested | Slave protocol violation; cycle power |
| 0x8001 | Requested port not configured for Modbus master | Check CB 1241 device configuration in TIA Portal |
| 0x8002 | Master busy with another transaction | Sequencer fired two requests; refactor to one instance per slave |
| 0x8003 | Cancel requested by MB_MASTER_CANCEL | Normal after explicit cancel; ignore |
If the status word shows 0x0002 (illegal data address) on the serial number read but not on the measurement reads, the address is wrong, not the wiring. If the status word shows 0x7001 (timeout), the wiring or the slave ID is the issue and affects all reads equally.
12. Best Practices for Modbus RTU on S7-1200
- One MB_MASTER instance per slave device. Re-using a single instance for multiple slaves works in theory but is fragile in the field; allocate per-slave instance DBs and a sequencer in OB1.
-
Edge-trigger REQ with a one-shot pulse from a clock or a counter; do not hold
REQ = TRUEcontinuously, otherwise the instruction re-fires immediately and overwrites the result. -
Use a 4-byte integer or byte array for serial numbers; never use
REALfor identification values. - Capture STATUS only on the rising edge of ERROR; reading it every cycle gives the last completed status, not the current one.
-
Verify endianness with the datasheet; meters from different vendors use both big-endian and little-endian word order. Read into a
WORDarray, inspect online, then build the final tag. - Terminate both ends only. A 120 Ω resistor at the meter end and a 120 Ω at the CB 1241 end. Intermediate nodes must not have a termination resistor.
- Use shielded twisted pair with the shield grounded at one end (typically the cabinet ground bar). Avoid running RS485 in the same conduit as VFD output cables.
- Configure 9600/8E1 as the default for industrial Modbus RTU unless the meter requires higher. Most Chinese-made meters default to 2400/8N2 or 9600/8N2 — verify the exact value with the meter vendor.
- Poll serial number only at startup or on diagnostic trigger. There is no value in reading the serial number at the same rate as instantaneous measurements.
- Document the address map in the project. Use a separate DB with comments per register that mirror the meter datasheet; this is invaluable for the next commissioning engineer.
13. Field Commissioning Checklist
Use this checklist during the next meter swap or new installation.
- Confirm the meter model and firmware version with the vendor; record the revision.
- Download the meter Modbus map (PDF or XLS) and attach to the project documentation.
- Identify the serial number register, register count, and encoding (UINT32, ASCII, BCD, FLOAT32). Annotate the datasheet with the page number.
- Wire A to A, B to B, shield to ground at one end only.
- Configure CB 1241 baud/parity/stop bits to match the meter default.
- Test with a Modbus RTU bus monitor first; confirm the request and response are correct before launching TIA Portal.
- In TIA Portal, build one
MB_MASTERinstance per slave and a sequencer OB1 block. - Validate each register read against the datasheet values for a known state (for example, force the meter current to 0 A and confirm the read matches).
- Trigger the serial number read once at startup; latch the result in a retentive tag so it survives CPU restart.
- Save a project snapshot, label all instance DBs, and export the watch table to PDF for the commissioning report.
14. Troubleshooting Matrix
When the serial number read still fails after applying the fix, use this matrix to triage.
| Symptom | Likely cause | Action |
|---|---|---|
| STATUS = 0x0002, measurement reads OK | Wrong register address for serial number | Re-check datasheet, apply 1-based or 0-based rule |
| STATUS = 0x7001, all reads fail | No response, wiring or slave ID | Verify meter power, A/B polarity, slave ID, baud rate |
| STATUS = 0x0001 | FC not supported at this address | Try FC04 (read input registers) instead of FC03 (read holding registers) |
| STATUS = 0, all reads return 0 | DATA_PTR is a REAL tag | Change to DWORD or BYTE array |
| STATUS = 0, value is wrong by word | Little-endian word order not handled | Add explicit word-swap |
| STATUS = 0x8002 | Multiple requests on one instance | Refactor to one instance per slave |
| STATUS = 0x8001 | Port not configured for Modbus master | Check CB 1241 device configuration |
| Intermittent CRC errors (0x7002) | Missing or wrong termination, EMI | Add 120 Ω at both ends, separate from VFD cables |
15. Related Configuration References
Additional reference material in the Siemens SIMATIC documentation set:
- S7-1200 Programmable Controller System Manual — chapter on Modbus RTU communication with the CB 1241 and CM 1241 modules, including the
MB_MASTERandMB_SLAVEinstruction set and the supported function codes. - TIA Portal Help — "MODBUS (RTU) Master" library (legacy) and "PtP/Modbus Communication" library (current): the instruction names changed in TIA Portal V14 SP1 from
MB_MASTERtoModbus_Master; both are functionally identical, withModbus_Masterbeing the maintained instruction for new projects. - CB 1241 (6ES7241-1CH30-1XB0) device manual — pin assignment, wiring, supported baud rates (300 to 115200 bps), and Modbus protocol selection in the device configuration of TIA Portal.
- S7-1200 Easy Book — recommended for engineers starting a first Modbus RTU integration; provides a worked example with the energy meter pattern.
All values, error codes, and parameter fields documented above are taken from the official Siemens S7-1200 Modbus RTU library reference and the CB 1241 device manual. Refer to those documents for revision-specific variations and for the exact instruction signatures in TIA Portal V14, V15, V15.1, V16, V17, V18, and V19.
Why does my S7-1200 read all measured values correctly but the serial number is always zero?
Three causes are most common: the Modbus address for the serial number is different from the address for measurements (strip the leading 4 from 4xxxx and apply 1-based or 0-based mapping to get the value for MB_MASTER.DATA_ADDR), the destination tag in the destination DB is a REAL which cannot represent most integer serial numbers, or the meter returns the 32-bit serial number in little-endian word order and a word-swap is required. Change the destination tag to a DWORD or ARRAY[0..3] of BYTE and re-inspect.
What is the correct DATA_ADDR for a serial number at register 40042 in the meter datasheet?
For the S7-1200 MB_MASTER or Modbus_Master instruction in TIA Portal V14 and later (1-based addressing), enter 42 (decimal) or 16#002A. If the meter uses 0-based addressing, enter 41. Verify by checking the MB_MASTER.STATUS value: a status of 0x0002 confirms a wrong address; a status of 0x0000 with a still-wrong value confirms a data-type or endianness issue.
Why are there multiple Modbus registers for a single serial number?
A Modbus holding register is 16 bits. A serial number up to 65535 fits in one register, but most modern meters use 32-bit (two registers) or 64-bit (four registers) serial numbers, or store the serial number as printable ASCII (8 or 16 registers for a 16-character string). The datasheet must be consulted for the encoding. Two consecutive registers covering a 32-bit value is the most common pattern.
What does MB_MASTER status 0x0002 mean and how do I fix it?
Status 0x0002 means the slave returned an "Illegal Data Address" exception (Modbus exception code 02). The address in DATA_ADDR is not a valid register on the meter. Re-verify the datasheet, apply the 5-digit prefix stripping rule (subtract 40000 for holding registers), and confirm 1-based vs 0-based. If the address is correct, the meter may require FC04 (input registers) instead of FC03 (holding registers) — change MB_MASTER.MODE from 0 to 4.
Should I use one MB_MASTER instance for all Modbus devices or one per device?
One MB_MASTER instance per slave device is the recommended and most reliable pattern. The instruction's internal state machine tracks a single outstanding transaction; re-using an instance for multiple slaves requires careful sequencing and is fragile. A pattern of one instance per slave plus a sequencer in OB1 (round-robin or scheduled) is standard in the field and isolates failures to a single device.