SIWAREX WP241: Reading Data Records via CMD_A/CMD_B Commands
The Siemens SIWAREX WP241 is a single-channel, high-precision weighing electronics module designed for automatic scales, fillers, checkweighers, and totalizing scales in ET 200SP. All weighing parameters, calibration data, process values, totalizers, and status information are grouped into Data Records (DR) that are exchanged between the PLC and the module over the backplane bus. A clear understanding of the command architecture (CMD_A, CMD_B, CMD1, CMD2, CMD3) and the trigger/status flag behavior of the Siemens Function Block (FB) is essential to read DRs reliably without entering service mode and without corrupting the cyclic data exchange.
1. SIWAREX WP241 Module Overview and Command Architecture
The WP241 occupies one slot in an ET 200SP station and exchanges process data with the S7-1200 / S7-1500 IO controller. The official SIWAREX WP241 Equipment Manual (A5E33713528A-01) defines the parameter set as numbered data records. Each DR has a fixed length and a fixed command code used to trigger the read or write. The module supports three command levels, and the example project shipped by Siemens uses an additional two internal command codes (CMD_A, CMD_B) to drive CMD3 from a cyclic OB.
1.1 Command Levels (CMD1, CMD2, CMD3)
| Level | Typical User | Typical Use | Trigger Source |
|---|---|---|---|
| CMD1 | S7 user program | Direct, non-cyclic commands (single-shot read/write of any DR) | User FB, single trigger pulse |
| CMD2 | HMI panel (WinCC Comfort / TIA Portal) | Operator-triggered commands (calibration, zero, reset) | HMI tag change, single trigger pulse |
| CMD3 | FC30 / cyclic OB | Continuous, parallel read of up to two DRs (e.g. DR 30 + DR 33) | OB35 toggling CMD_A / CMD_B every 100 ms |
1.2 CMD_A and CMD_B – The Cyclic Toggle Mechanism
CMD_A and CMD_B are not independent command levels. They are simply two command-code variables that the FC30/OB example code alternately writes into the CMD3 command word. The behaviour is:
- OB35 fires every 100 ms (configurable in the CPU properties under Cyclic Interrupts).
- On the first call, FC30 reads
s_CMD_Aand copies it tos_CMD3in DB241. - On the next OB35 call, FC30 reads
s_CMD_Band copies it tos_CMD3. - On the third call, FC30 toggles back to
s_CMD_A, and so on.
This means the user only has to write the desired command codes into CMD_A (DB241.DBW468) and CMD_B (DB241.DBW470) once. The module then sees command 2033 (Read DR 33) alternating with command 2030 (Read DR 30) at a 5-second composite cycle (each DR is read every 200 ms cycle pair, with 100 ms between alternations), giving you two parallel cyclic data streams from CMD3.
s_CMD3 while the example FC30/OB35 is active, your value will be overwritten on the next OB35 call. Either disable the OB35 instance or use CMD_A / CMD_B instead of fighting the FC30.2. Reading a Data Record – Step-by-Step Procedure
2.1 Prerequisites
- SIWAREX WP241 (6AG1135-1AA01-1AA0 or current catalog number) installed in ET 200SP with HSP installed in TIA Portal.
- S7-1200 (CPU V2.2, V3, or V4 supported by the Siemens "Ready for use" example) or S7-1500 IO controller.
- Siemens WP241 Function Block imported into the project (downloadable from the Siemens Support site as part of the "Ready for use" project).
- DB241 instantiated (this is the standard instance DB the FB works against).
- Module configured in device view, base addresses noted (default inputs start at a slot-dependent offset).
2.2 Trigger Pulse Rules
The Siemens FB handles trigger discipline for you:
-
Trigger input:
bo_CMD_trigger(BOOL) at the FB input. - Behaviour: Set the trigger for exactly one PLC cycle. The FB detects the rising edge, launches the command on the backplane, and automatically resets the trigger to FALSE internally.
- Consequence: You should never hold the trigger TRUE. A held trigger will be ignored after the first cycle and will not cause re-triggering.
2.3 Status Flag Semantics
The FB exposes three status BOOLs. Unlike the trigger, these are latched:
| Status BOOL | Set TRUE when… | Reset when… |
|---|---|---|
bo_CMD_Inprogress |
The command has been accepted by the WP241 and is currently being executed. | The command terminates (either OK or with error). The flag goes FALSE the same cycle the finished flag goes TRUE. |
bo_CMD_FinishedOK |
WP241 acknowledges the command with status word 0 / no error. | The next command is triggered (rising edge of bo_CMD_trigger). |
bo_CMD_FinishedError |
WP241 rejects the command (e.g. wrong service mode, illegal DR number, module in wrong operating state). | The next command is triggered. |
bo_CMD_FinishedOK stays TRUE until the next trigger, do not pulse it in ladder logic and assume it is a one-shot. If you need an edge for downstream logic, generate it with a positive-edge contact on the flag in your consumer FB.2.4 Reading DR 33 (Totalizers) – Concrete Example
DR 33 holds all totalizer registers and is the most commonly read DR for totalizing-scale applications. The command code is 2033 decimal.
2.4.1 One-shot read via CMD1
- Write the constant
2033toi_CMD_Code(INT) at the FB input. - Pulse
bo_CMD_triggerTRUE for one cycle. - Monitor
bo_CMD_FinishedOK. When it goes TRUE, the totalizers in DB241 are valid. - Read Totalizer 2 from
DB241.DBD506(DWORD, signed 32-bit, scaled in the unit configured in DR 30 / DR 31).
2.4.2 Cyclic read via CMD_A / CMD_B
- Open DB241.
- Set
CMD_A(DBW468) to a different DR, e.g.2030for DR 30 (process values). - Set
CMD_B(DBW470) to2033for DR 33 (totalizers). - Ensure OB35 is configured for 100 ms and FC30 is called inside it.
- The module alternates 2030 / 2033 every 100 ms; the DB is always current within 200 ms.
3. Data Record Reference (DR numbers used in this article)
| DR | Content | Cmd Code (read) | Cmd Code (write) | Notes |
|---|---|---|---|---|
| DR 3 | General scale parameters (unit, resolution, etc.) | 2003 | 4003 | Write requires service mode. |
| DR 8 | Date and time (hardware clock of module) | 2008 | 4008 | Date/time is set from CPU or read from module. |
| DR 30 | Process values (gross, net, tare, status) | 2030 | — | Common choice for CMD_A. |
| DR 33 | All totalizers S1, S2, S3 (and per-scale) | 2033 | — | Totalizer 2 at DBD506. |
| DR 80 | SIWAREX DB process status / messages | 2080 | — | Auto-read by FB on change; not required to poll cyclically. |
The full DR list is published in chapter 6 of the SIWAREX WP241 Equipment Manual and the SIWAREX WP241 FAQ / Siwatool Calibration document.
4. Totalizer Reset Commands
Totalizers are cleared with dedicated command codes. Service mode is not required for reset of totalizers — it is only required for adjustment commands (calibration). The relevant codes:
| Action | Command Code | Command Level | Service Mode Required? |
|---|---|---|---|
| Reset Totalizer S1 | 660 | CMD1 or CMD2 | No |
| Reset Totalizer S2 | 670 | CMD1 or CMD2 | No |
| Reset Totalizer S3 | 680 | CMD1 or CMD2 | No |
| Reset all Totalizers | 690 | CMD1 or CMD2 | No |
| Start Initial Zero Calibration | 701 | CMD2 only | Yes |
| Start Span Calibration (test weight) | 711 | CMD2 only | Yes |
5. Cyclic OB Architecture and Timing
The "Ready for use" example project ships two cyclic OBs:
| OB | Cycle Time | Used For |
|---|---|---|
| OB30 | 5 000 ms (5 s) | Default cyclic task in older "Ready for use" projects (CPU V2.2 era). |
| OB35 | 100 ms | Default cyclic task in current "Ready for use" projects (CPU V3 / V4). Used by FC30 to alternate CMD_A / CMD_B. |
The OB cycle must be ≥ the module's command processing latency. 100 ms gives a comfortable margin for both DR 30 and DR 33 reads. If you read more than two DRs, insert an additional counter in FC30 to expand the rotation cycle — do not chain commands back-to-back without a gap.
5.1 Sample FC30 Toggle Logic (Structured Text, equivalent to the example FB)
// FC30 – called from OB35 every 100 ms
IF "Toggle" THEN
"DB241".CMD3 := "DB241".CMD_A; // first half-cycle
"Toggle" := FALSE;
else
"DB241".CMD3 := "DB241".CMD_B; // second half-cycle
"Toggle" := TRUE;
END_IF;
// CMD_A = 2030 (Read DR 30 process values)
// CMD_B = 2033 (Read DR 33 totalizers)
6. Reading the Hardware Clock (DR 8) and Process Status (DR 80)
The SIWAREX WP241 manual documents DR 8 as the gateway to the module's hardware clock. If you log batches with a legal-for-trade timestamp, the time on the WP241 — not the CPU clock — is the legally relevant value. Read it with command code 2008, write it with 4008.
DR 80 carries the SIWAREX DB process status, including error bits, maintenance events, and the operating-mode byte. Per the TIA Portal SIMATIC ET 200SP Manual Collection (DR 80 reference page), the function block automatically reads DR 80 when a status change is detected. Cyclic polling of DR 80 from user code is therefore redundant and wastes command slots.
7. Service Mode – When It Is Required
Service mode is a module-level operating state that protects calibration data. Activate it by writing a password / entering the level before issuing certain commands. The complete rules are:
- Service mode required: writing DR 3 to the module; starting zero calibration (701); starting span calibration (711); starting linearity test (721); writing calibration-relevant parameters.
- Service mode not required: reading any DR (including DR 3); resetting totalizers (660 / 670 / 680 / 690); writing non-calibration parameters such as date/time (DR 8).
A common production integration error is to wrap all WP241 commands in a service-mode prologue. This forces the operator to know the service password, blocks HMI operation during calibration, and slows down cyclic reads. Strip the service mode out of the read path and the totalizer-reset path; keep it only on the calibration path.
8. Verification Checklist
- In TIA Portal, go online and open DB241 in monitor mode. Confirm
CMD3toggles between the two codes you set in CMD_A and CMD_B every 100 ms. - Watch
bo_CMD_FinishedOKon a single-shot CMD1 trigger: it must go TRUE on the same cycle the WP241 acknowledges, and stay TRUE until the next trigger. - Read
DB241.DBD506after a known quantity has been weighed and confirm the value increments in the configured unit. - Force the totalizer to a known value with command 670 (Reset S2) and verify DBD506 returns to 0 within 200 ms.
- Trigger a deliberate error (e.g. command code 9999) and confirm
bo_CMD_FinishedErrorlatches TRUE whilebo_CMD_FinishedOKstays FALSE. - Check the WP241 diagnostic buffer in the device view — the error code from the module should match a documented code in the equipment manual.
9. Common Pitfalls and Field-Proven Caveats
| Symptom | Likely Cause | Fix |
|---|---|---|
bo_CMD_FinishedError latches TRUE immediately |
Module in wrong operating mode (e.g. service mode still active) or command code out of range | Check DR 80 status; verify command code in DR table; check the operating-mode byte. |
| Totalizer does not change | DR 33 is not being refreshed (FC30 / OB35 disabled, or CMD_B left at 0) | Set CMD_B to 2033; verify OB35 is running; watch CMD3 toggle online. |
| Trigger has no effect | Trigger was held TRUE for more than one cycle and the FB already consumed the edge | Pulse the trigger for exactly one cycle; never assign a latched tag directly. |
| CMD3 keeps reverting to old value | User writes to CMD3 while FC30 is also writing | Use CMD_A / CMD_B and let FC30 drive CMD3; remove any direct writes to CMD3. |
| Calibration values not retained after restart | Service mode was not entered; DR 3 write was rejected | Enter service mode; verify FinishedOK (not FinishedError) before power-cycle. |
| HMI shows old data after reset | HMI reads from a local copy, not the refreshed DB | Make HMI tags point to DB241 directly; refresh on DB241-variable change. |
10. Sizing and Throughput Considerations
Each OB35 cycle issues one CMD3. With 100 ms OB35 and two alternating codes, you get a 200 ms composite cycle for two DRs. To estimate command throughput:
Throughput [cmd/s] = 1000 ms / OB35_ms / (number of alternating commands)
Example: 1000 / 100 / 2 = 5 cmd/s per DR
If the application requires a tighter update of DR 33 (e.g. fast batching where the totalizer must reflect the last gram within 50 ms), reduce OB35 to 50 ms and limit the CMD_A/CMD_B alternation to a single DR. Note: WP241's backplane latency is typically 10–30 ms, so the 50 ms floor leaves no headroom and is not recommended for noisy industrial environments.
11. Integration with the ET 200SP and CPU Variants
The "Ready for use" example project is published in three CPU variants:
- CPU V2.2 (S7-1200 legacy)
- CPU V3 (S7-1200, TIA Portal V12 SP1 minimum)
- CPU V4 (S7-1200, current)
For S7-1500 IO controllers, re-import the FB into the TIA Portal project; the backplane interface and the DB241 layout are identical. Verify the HSP version matches the firmware of the WP241 in your station (read the firmware version in the device properties of the module in the TIA Portal device view).
12. Step-by-Step Commissioning Recipe
- Install the SIWAREX HSP for TIA Portal matching your WP241 firmware.
- Drag the WP241 from the catalog to the ET 200SP slot.
- Import the "Ready for use" project (or the FB + DB241 + FC30 + OB35 bundle) into your project.
- Wire the FB instance in OB1 (or in a dedicated user FB) — call it once per cycle.
- Configure DB241:
CMD_A = 2030,CMD_B = 2033. - Configure OB35 to 100 ms and confirm FC30 is called inside it.
- Download to the PLC; go online; monitor CMD3 — it must alternate 2030 / 2033 every 100 ms.
- Place a test weight on the scale; confirm the gross / net value in DR 30.
- Run a totalization cycle; confirm DBD506 increments.
- Trigger command 670 to reset S2; confirm DBD506 returns to 0.
- Trigger an intentional error (e.g. command 9999) and verify FinishedError latches.
How do I trigger a data record read on the SIWAREX WP241 without entering service mode?
Write the read command code (for example 2033 for DR 33) to i_CMD_Code and pulse the bo_CMD_trigger input TRUE for exactly one PLC cycle. The Siemens FB detects the rising edge, sends the command, and clears the trigger automatically. No service mode is required for any read operation.
What is the difference between CMD_A, CMD_B, and CMD3 on the WP241?
CMD_A and CMD_B are user-defined command codes stored at DB241.DBW468 and DB241.DBW470. The example FC30 toggles them into the CMD3 command word every 100 ms, so the module reads up to two DRs continuously in parallel. The user writes the command codes once and lets the FC30 handle the cycling.
Does bo_CMD_FinishedOK stay TRUE after the command completes?
Yes. bo_CMD_FinishedOK and bo_CMD_FinishedError are latched flags. They remain in their last state until the next bo_CMD_trigger rising edge clears them and re-arms the FB. If your consumer logic needs an edge, generate it from a positive-edge contact on the flag.
Which command code resets Totalizer S2 on the WP241?
Use command code 670 for resetting Totalizer S2. Totalizer S1 uses 660, S3 uses 680, and 690 resets all totalizers. None of these reset commands require service mode.
Why does my value written directly to s_CMD3 keep getting overwritten?
The example FC30 in OB35 is alternately writing CMD_A and CMD_B into the CMD3 word every 100 ms. To drive two cyclic DRs reliably, set the codes in CMD_A and CMD_B and let the FC30 toggle them — do not fight the FC30 by writing CMD3 from user code.
Do I need to poll DR 80 process status cyclically?
No. Per the SIMATIC ET 200SP Manual Collection, the WP241 function block automatically reads DR 80 when a status change is detected. Cyclic polling of DR 80 is redundant and should be removed to free command slots for the data records the application actually needs.