1. Overview of SIWAREX U Weighing Integration
The SIWAREX U (order numbers 7MH4950-1AA01 for the single-channel variant and 7MH4950-2AA01 for the dual-channel variant) is a SIMATIC function module (FM) that integrates strain-gauge load cell acquisition directly into a SIMATIC S7-300 CPU or an ET 200M distributed I/O station. The module exposes its parameters, process values, and command interface through Data Records (DS) accessed over the backplane/PROFIBUS-DP using the standard SIMATIC SFCs SFC58 WR_REC (write record) and SFC59 RD_REC (read record).
This reference explains how to use SFC58 and SFC59 to:
- Read gross/net process values from Data Record 32 (DS32, RECNUM
B#16#20). - Trigger the zeroing command (tare/zero set) by writing Data Record 3 (DS3, RECNUM
B#16#3) and the command byte within Data Record 12 (DS12, RECNUMB#16#C). - Trigger the span calibration command and write the adjustment digit 0 / digit 1 values for the calibration weight (Calibration Weight 1 / 2).
- Verify command acceptance by re-reading DS32 and the status bits in DS3 / DS12.
All record layouts and command codes below are taken from the official SIWAREX U Device Manual (Edition 38, 06/2010) and the Siemens Industry Online Support portal.
2. Prerequisites
Before implementing the SFC58 / SFC59 interface, verify the following:
- SIMATIC S7-300 CPU (e.g.
CPU 315-2 DP) with STEP 7 V5.5 or TIA Portal V13+ and the SIWAREX U HSP / GSD file installed. - SIWAREX U FM inserted in the S7-300 rack (or ET 200M IM 153) with PROFIBUS address 3..32 assigned in HW Config. The slot must match the configured FM type:
7MH4950-1AA01(1-channel) or7MH4950-2AA01(dual-channel). - Load cells wired to the SIWAREX U D-sub connector following the 4-wire / 6-wire sense-line conventions in chapter 3 of the Device Manual. The shield must be terminated on the grounding bar of the cabinet.
- Supply voltage 24 V DC on the FM and stable 5 V / 6 V excitation to the load cells.
- Logical base address of the FM in HW Config. This is the input to
IOID/LADDRinSFC58andSFC59and is required for every call. - Data blocks in the user program sized to the record lengths shown in the table below:
| Data Record | RECNUM (hex) | Direction | Length (bytes) | Typical DB |
|---|---|---|---|---|
| DR3 — Parameters / Status | B#16#3 |
read / write | 32 | DB801 |
| DR4 — Process Values (raw) | B#16#4 |
read | 16 | DB (local) |
| DR12 — Commands / Adjustment | B#16#C |
read / write | 10 | DB802 |
| DR32 — Process Values Ch.1 / Ch.2 (user units) | B#16#20 |
read | 10 per channel | DB802 (Ch.2) / DB803 (Ch.1) |
| DR130 — Trace (optional) | B#16#82 |
read / write | variable | DB (local) |
7MH4950-1AA01 for 7MH4950-2AA01), the calibration data stored on the FM is not automatically transferred. Plan for a full re-calibration via SIWATOOL U or via the SFC58 sequence below after the swap. See the Siemens Support Portal note on module replacement.3. SFC58 / SFC59 Call Signature
Both SFCs operate on the basis of the PROFIBUS-DP Record service. The relevant input parameters are:
| Parameter | Type | SFC58 (WR_REC) | SFC59 (RD_REC) |
|---|---|---|---|
REQ |
BOOL | Rising edge starts write | Rising edge starts read |
IOID |
BYTE |
B#16#54 for output / mixed I/O access |
B#16#54 for output / mixed I/O access |
LADDR |
WORD | Logical base address of the FM (input side) | Logical base address of the FM (input side) |
RECNUM |
BYTE | Data record number (see table above) | Data record number |
RECORD |
ANY | Pointer to source DB area to write | Pointer to destination DB area for read data |
RET_VAL |
INT | SFC return value (error code, see §10) | SFC return value |
BUSY |
BOOL | Operation in progress | Operation in progress |
DONE |
BOOL | Write completed without error | Read completed without error |
ERROR |
BOOL | Error flag | Error flag |
Use IOID = B#16#54 when calling on the input (input-side) base address of the FM, which is the convention for SIWAREX U.
4. Data Record Layout for Reading (DR32)
Data Record 32 returns the user-unit process values for the two channels of the dual-channel module. Per the Device Manual, the record is 10 bytes per channel with the following layout (big-endian, word-aligned):
| Offset | Length | Meaning |
|---|---|---|
| 0.0 | 2 bytes | Status word (bit-encoded: Bit 0 = limit 1, Bit 1 = limit 2, Bit 4 = weight stable, Bit 5 = above max, Bit 6 = below min, Bit 7 = tare active, Bit 8 = calibration invalid, Bit 9 = command error, Bit 10 = parameter error, Bit 14 = gross/net flag) |
| 2.0 | 4 bytes | Gross / Net process value, 32-bit signed integer (DINT) in 0.1 kg / count resolution |
| 6.0 | 4 bytes | Tare value, 32-bit signed integer (DINT) |
An example SFC59 call to read channel 2 into DB802:
// ST (SCL) — read process value Ch.2
CALL SFC 59 (
REQ := TRUE, // triggered by OB1 cycle or HMI button
IOID := B#16#54,
LADDR := W#16#100, // example: input base address 256
RECNUM := B#16#20, // DR32
RECORD := P#DB802.DBX 0.0 BYTE 10,
RET_VAL:= MW100,
BUSY := M101.0,
DONE := M101.1,
ERROR := M101.2);
The RECNUM = B#16#20 and RECORD = P#DB802.DBX0.0 BYTE 10 arguments are exactly those referenced in the original integration question — the FM returns one 10-byte block per channel; for the dual-channel variant (7MH4950-2AA01) a second SFC59 call is required to read the second channel.
5. Data Record Layout for Writing Commands (DR12)
DR12 is the command and adjustment interface. The 10-byte layout is:
| Offset | Length | Meaning |
|---|---|---|
| 0.0 | 1 byte | Command code (see §6) |
| 1.0 | 1 byte | Command qualifier (channel 1 / 2 / both) |
| 2.0 | 4 bytes | Adjustment digit 0 (zero / cal-weight 1 low word) |
| 6.0 | 4 bytes | Adjustment digit 1 (zero / cal-weight 2 low word) |
The SFC58 call to write DR12 is therefore:
// ST (SCL) — write command + adjustment digits
CALL SFC 58 (
REQ := M50.0, // rising edge from HMI button
IOID := B#16#54,
LADDR := W#16#100,
RECNUM := B#16#C, // DR12
RECORD := P#DB80.DBX 10.0 BYTE 10,
RET_VAL:= MW102,
BUSY := M103.0,
DONE := M103.1,
ERROR := M103.2);
Where the RECORD ANY pointer P#DB80.DBX10.0 BYTE 10 matches the source integration question: command byte at DB80.DBX10.0, qualifier at DB80.DBX11.0, adjustment digit 0 at DB80.DBD12.0, and adjustment digit 1 at DB80.DBD16.0. Some integrations split digit 0 / digit 1 into adjacent bytes (DBX12.0 / DBX16.0); the word-aligned interpretation above is the one used in the Device Manual and Siemens sample FB FB250 SIW_U.
6. Command Code Reference
The command byte in DR12 is decoded by the FM as follows (decimal values shown with the equivalent hex):
| Code (dec / hex) | Function | Adjustment digits used |
|---|---|---|
0 / 00
|
No command (idle) | — |
1 / 01
|
Zero set (current weight → 0) | none |
2 / 02
|
Zero reset (clear zero) | none |
3 / 03
|
Tare (current weight → tare memory) | none |
4 / 04
|
Tare reset | none |
5 / 05
|
Calibration weight 1 — span with adjustment digit 0 | Adjustment digit 0 |
6 / 06
|
Calibration weight 2 — span with adjustment digit 1 | Adjustment digit 1 |
7 / 07
|
Calibration weight 3 — span with adjustment digit 0 + 1 (multi-stage) | Adjustment digit 0 + 1 |
10 / 0A
|
Service command: write all parameters (DR3 → FM) | — |
11 / 0B
|
Service command: read all parameters (FM → DR3) | — |
20 / 14
|
Factory reset (wipes calibration) | — |
The qualifier byte selects the target channel on the dual-channel module: 0 = both channels, 1 = channel 1 only, 2 = channel 2 only.
7. Step-by-Step: Zeroing from an HMI
- Pre-load the command record in
DB80:
// DB80 layout
DB80.DBX 10.0 BYTE := 1; // command 1 = zero set
DB80.DBX 11.0 BYTE := 0; // qualifier 0 = both channels (single-channel: 1)
DB80.DBD 12.0 DINT := 0; // digit 0 (not used for zero set)
DB80.DBD 16.0 DINT := 0; // digit 1 (not used for zero set)
- Raise the HMI button flag
DB80.DBX18.0(TRUE for one cycle) to triggerSFC58 REQ. - Wait for
DONE = TRUEandERROR = FALSE. The zeroing is finished in < 100 ms; poll the command-pending bit in DR12 command byte — it returns to0when the FM has accepted the command. - Read DR32 again (
SFC59withRECNUM = B#16#20) and confirm the gross weight is now within 1 count of 0. - If
ERROR = TRUE, storeRET_VALin the HMI diagnostic view and reference the error code table in §10.
8. Step-by-Step: Span Calibration from an HMI
Yes — span adjustment is also written with SFC58, but to a different combination of code and adjustment digit. The span (the kg/count slope) is not written directly; instead the FM is told "command 5 (or 6) and the calibration weight in 0.1 kg / count units". The FM then internally recomputes and stores the new characteristic.
- Set command code =
5(Calibration weight 1) or6(Calibration weight 2). The example below uses code 5 (single-stage span calibration). - Write the actual calibration weight that is currently on the scale (in 0.1 kg) into adjustment digit 0 (
DB80.DBD12.0). For a 250.0 kg test weight, writeL#2500. - Trigger
SFC58exactly as in §7. - After
DONE = TRUE, re-read DR3 withSFC59 RECNUM = B#16#3to confirm the calibration valid bit is now set; if it is cleared, the FM rejected the command and the previous calibration remains active.
// Span calibration: code 5, calibration weight 250.0 kg on Ch.1
DB80.DBX 10.0 BYTE := 5; // command 5 = calibration weight 1
DB80.DBX 11.0 BYTE := 1; // qualifier 1 = channel 1
DB80.DBD 12.0 DINT := L#2500; // 250.0 kg expressed in 0.1 kg
DB80.DBD 16.0 DINT := 0; // not used for single-stage cal
For a two-stage calibration (recommended by Siemens for installations with a high dead load and a small live load), first issue command 5 with the larger calibration weight (digit 0), then issue command 6 with the smaller calibration weight (digit 1). The FM combines both into the final characteristic curve.
9. Alternative Implementation: Reusable FB (SCL)
The following SCL function block wraps the SFC58 call and is safe to call from a cyclic OB. It includes the rising-edge handling the SFC requires and returns a structured status word.
FUNCTION_BLOCK FB_SIWAREX_CAL
VAR_INPUT
iLADDR : WORD; // FM base address
iReqZero : BOOL; // 1-cycle TRUE = perform zero set
iReqSpan : BOOL; // 1-cycle TRUE = perform span cal
iCalWeight : DINT; // calibration weight in 0.1 kg
iQualifier : BYTE; // 0=both, 1=Ch1, 2=Ch2
END_VAR
VAR_OUTPUT
oDone : BOOL;
oBusy : BOOL;
oError : BOOL;
oStatus : WORD; // SFC RET_VAL
oCmdEcho : BYTE; // last command sent
END_VAR
VAR
sTrig : BOOL; // edge memory
sBusy : BOOL;
sDone : BOOL;
sError : BOOL;
sRet : INT;
sCmd : BYTE;
sDB12 : ARRAY[0..9] OF BYTE;
END_VAR
BEGIN
// Edge detection — issue command only on 0 -> 1 of the HMI flag
IF (iReqZero OR iReqSpan) AND NOT sTrig THEN
sTrig := TRUE;
IF iReqZero THEN
sCmd := 1; // zero set
ELSIF iReqSpan THEN
sCmd := 5; // calibration weight 1
END_IF;
sDB12[0] := sCmd; // command
sDB12[1] := iQualifier; // channel select
// pack calibration weight into adjustment digit 0 (bytes 2..5)
sDB12[2] := BYTE(SHR(IN:=WORD(iCalWeight), N:=24) AND 16#FF);
sDB12[3] := BYTE(SHR(IN:=WORD(iCalWeight), N:=16) AND 16#FF);
sDB12[4] := BYTE(SHR(IN:=WORD(iCalWeight), N:= 8) AND 16#FF);
sDB12[5] := BYTE( WORD(iCalWeight) AND 16#FF);
sDB12[6] := 0; sDB12[7] := 0; sDB12[8] := 0; sDB12[9] := 0;
sBusy := TRUE;
CALL SFC 58 (
REQ := TRUE,
IOID := B#16#54,
LADDR := iLADDR,
RECNUM := B#16#C,
RECORD := P##sDB12,
RET_VAL:= sRet,
BUSY := sBusy,
DONE := sDone,
ERROR := sError);
ELSIF NOT (iReqZero OR iReqSpan) THEN
sTrig := FALSE;
END_IF;
oDone := sDone;
oBusy := sBusy;
oError := sError;
oStatus := WORD(sRet);
oCmdEcho := sCmd;
END_FUNCTION_BLOCK
For TIA Portal users, the same logic applies; the FB SIW_U shipped with the SIWAREX U HSP contains pre-built SFC58 / SFC59 wrappers and can be inspected instead of writing a new one.
10. SFC58 / SFC59 Return Value (RET_VAL) Decoding
Common error codes returned in RET_VAL when working with SIWAREX U:
| RET_VAL (hex) | Meaning | Remedy |
|---|---|---|
0000 |
No error | — |
7000 |
No job active | Wait for next call |
7001 |
First call, job in progress | Wait for DONE/BUSY |
7002 |
Subsequent call, job still in progress | Wait |
8085 |
LADDR wrong (base address not assigned / wrong IOID) |
Re-check HW Config; use IOID = B#16#54 for the input address of the FM |
8086 |
RECNUM invalid for the addressed module |
Check data record table (§2) |
8087 |
Module reports busy (e.g. firmware is currently performing a command) | Retry after > 100 ms |
8090 |
DP slave failure / FM pulled / bus error | Check PROFIBUS diagnostics, LED on FM |
80A1 – 80A3
|
Negative acknowledgement from FM (command rejected) | Check weight-stable bit; verify calibration-valid bit in DR3 |
80B1 – 80B5
|
Protocol error / length mismatch | Verify RECORD ANY length matches record |
80C0 – 80C3
|
Resource contention on the FM | Re-serialize SFC58 / SFC59 calls (only one outstanding job at a time) |
11. Verification Procedure
- After every zero command, read DR32 with
SFC59 RECNUM = B#16#20. The gross weight must read 0 ± 1 count and the "weight stable" bit (DR32 status bit 4) must be 1. - After every span command, read DR3 with
SFC59 RECNUM = B#16#3. The "calibration valid" bit must be 1 and the "calibration changed" bit must be 0 (i.e. the FM has stored the new characteristic). - Place a known test weight on the scale and verify the displayed weight in the HMI matches the test weight within the rated accuracy. For trade-legal installations the permissible error is defined in OIML R76 and must be confirmed by an authorized metrology inspector.
- Cycle power to the FM and re-read DR3 / DR32. The zero and span values must persist — they are stored in non-volatile memory on the FM.
12. Troubleshooting Matrix
| Symptom | Likely cause | Fix |
|---|---|---|
RET_VAL = 8085 immediately on every call |
IOID = B#16#55 instead of B#16#54
|
Use the input-side base address with IOID = B#16#54
|
RET_VAL = 8086
|
RECNUM for a record the FM does not support (e.g. B#16#C against a 1-channel 7MH4950-1AA01 is OK; but a non-listed RECNUM is not) |
Compare with §2 table |
| DONE = TRUE, but calibration did not change | Weight not stable at the moment of the command, or the "Calibration via PLC" bit in DR3 is cleared | Wait for stability bit, then enable PLC-calibration in SIWATOOL U |
| DR32 returns a constant value regardless of load | Sense-line not connected (6-wire mode) or load cell wiring inverted | Re-wire per the Device Manual wiring diagram |
| Status bit "calibration invalid" set after module replacement | New module not yet calibrated | Run zero + span procedure |
RET_VAL = 8090 intermittently |
PROFIBUS cable shield not terminated, or FM seated loosely | Re-seat the module and re-terminate the connector |
| Command code byte is reset to 0 by the FM immediately | Write accepted and executed; this is the FM's normal echo behaviour | No action — read DR3 / DR32 to confirm effect |
13. Notes on Platform Variants
- STEP 7 V5.5 / V5.6: SFC58 / SFC59 are part of the standard library "Standard Library → Communication Blocks". No additional library is required.
-
TIA Portal V13+: SFC58 / SFC59 are inside the "Communication" → "Other" folder. The SIWAREX U HSP also installs the sample FB
SIW_Uthat exposes typed methodscmdZero,cmdSpan, etc., and should be used in preference to hand-written SFC calls where possible. - ET 200M with PROFIBUS: identical procedure; the FM is a DP slave and the CPU sends the SFC58 / SFC59 records over PROFIBUS-DP using the slot/index mechanism.
-
ET 200SP / PROFINET: SIWAREX U is not natively PROFINET-capable. It is supported over PROFINET only when the FM is installed in an ET 200M behind an
IM 153-4 PN. The SFC58 / SFC59 call signature does not change.
14. Frequently Asked Questions
Does the SFC59 call with RECNUM B#16#20 read both channels at once on a 7MH4950-2AA01?
No. DR32 returns one 10-byte block per channel. A second SFC59 call with the same RECNUM but a different RECORD destination must be issued to read the second channel, with the channel selected by the qualifier byte in the request frame.
What is the difference between "zero set" (command 1) and "tare" (command 3)?
Zero set permanently shifts the zero of the scale (modifies DR3) and the change survives a power cycle. Tare stores the current weight in a separate tare memory and is reset by command 4 or by a power cycle on most configurations. Use zero set for the install-time empty-scale calibration and tare for recipe-by-recipe container taring.
Why is the calibration weight multiplied by 10 in the adjustment digit?
The DR12 / DR32 process values use a fixed-point resolution of 0.1 kg per count. A 250.0 kg test weight must therefore be written as the DINT value 2500. The FM performs the unit conversion internally; do not write a REAL or any floating-point representation into the DINT.
Can the span be written directly without the FM performing the internal calculation?
No. The SIWAREX U does not expose a raw kg/count slope register. The FM always derives the slope from the difference between the current characteristic and the calibration weight value passed in command 5 / 6. Attempting to write to non-listed data records returns RET_VAL = 80A1 (negative acknowledgement).
After replacing a damaged module with a new 7MH4950-2AA01, do the calibration values transfer automatically?
No. Calibration data is stored on the FM itself, not on a plug-in card. A replacement module must be recalibrated either with SIWATOOL U on a PC or with the SFC58 zero + span sequence described in §7 and §8. The replacement procedure is documented in the Siemens Support Portal note on module replacement for 7MH4950-1AA01 / 7MH4950-2AA01.