The online monitor shows %MW0 = -6, yet a comparison against zero remains TRUE. Start by separating a simulator defect from a controller-runtime result. The reported mismatch reproduces in the Machine Expert Basic V1.4 simulator, does not reproduce in the V1.3 simulator, and has not been established on a physical M221 running firmware 1.14.1.
Commissioning Decision Path
- Read the execution target. Record whether the project is running in the V1.4 simulator, the V1.3 simulator, or a physical M221. If it is V1.4 simulation, continue with the conversion test. If it is V1.3 simulation, investigate project typing and writes because that simulator did not show the reported fault. If it is a controller, record its firmware and run the isolated hardware test below.
-
Read the operand at the comparison. Monitor
%MW0immediately before the comparison executes. Do not move on until the displayed value is stable at-6and no force, animation table, communication client, or other network writes to that address. -
Read the Boolean result. Evaluate the expression using the project’s original operand and zero. For
%MW0 >= 0, a signed value of-6must produce FALSE. A TRUE result with a stable negative operand identifies a signed-interpretation failure rather than normal comparison logic. -
Run an explicit conversion. Replace only the diagnostic expression with
DWORD(%MW0) >= 0. In the reported V1.4 simulator case, this expression returned the correct result. If the result changes from TRUE to FALSE, continue to the corrective procedure. If it does not change, recheck the monitored value, declaration, write sources, and executed network.
Runtime Target Separation
| Execution target | Observed status | Next action |
|---|---|---|
| Machine Expert Basic V1.4 simulator | Signed comparison fault reproduced | Apply the explicit DWORD conversion test and build a boundary-value verification matrix. |
| Machine Expert Basic V1.3 simulator | Fault did not occur in the reported test | Compare the same minimal project against V1.4 without changing the logic. |
| Physical M221 | Result not established | Download the minimal test, record the firmware, and compare controller results with simulation. |
M221 firmware 1.14.1
|
Specifically identified as untested | Run the negative, zero, and positive cases on the controller before accepting the workaround. |
A simulator and a physical PLC are separate execution engines. Matching project logic does not prove matching type promotion, conversion, or comparison behavior. Treat a simulation-only failure as a development-tool defect until the same expression fails on the controller. Conversely, never approve production logic solely because a workaround behaves correctly in simulation.
Operand Type and Sign Check
A memory word stores a bit pattern; the instruction interpreting that pattern determines whether the high-order bit represents a sign or magnitude. The suspected V1.4 simulator path promotes the word for a wider comparison without propagating its sign. The negative word is then handled like a UINT, so its bit pattern represents a nonnegative magnitude and >= 0 evaluates TRUE.
The online display and comparison engine can therefore disagree without the stored bits changing. The monitor formats %MW0 as -6, while the comparison evaluates the promoted operand as unsigned. This explains why watching the value alone is insufficient; the diagnostic must include both the raw operand and the Boolean result.
- Open the variable declaration or symbol definition associated with
%MW0and record its declared data type. - Inspect both comparison operands. A literal zero can participate in implicit type promotion, so confirm the type selected for the full expression rather than relying on the monitor’s display format.
- Search all writes to
%MW0. The failure also reproduced in a project containing only the test network, which rules out address overlap for that isolated case, but the full application still requires a write-source check. - Remove forces and external writes, then repeat the comparison. A changing word is a data-path problem; a stable
-6with TRUE from>= 0is a comparison-path problem.
Explicit Conversion Test
Use the reported working expression as a controlled diagnostic:
DWORD(%MW0) >= 0
Change no other network element during this test. If the explicit conversion makes -6 evaluate FALSE, it bypasses the faulty implicit-promotion path in the affected simulator. Keep the conversion at the comparison boundary so reviewers can see where representation changes.
Do not generalize one successful zero comparison to all arithmetic. Conversion changes the operand representation presented to subsequent operators. Retest every operation that depends on signed ordering, including comparisons between two variables and any limit logic using negative thresholds. Use the project’s declared types and tool documentation to decide the intended representation; do not infer it from one displayed value.
Corrective Procedure
- Create a minimal project containing one assignment or controlled write to
%MW0, the original comparison, and a visible Boolean result. - Run it in the V1.4 simulator with
%MW0 = -6. Confirm that the original comparison%MW0 >= 0remains TRUE before changing the expression. - Apply
DWORD(%MW0) >= 0. Confirm that the result becomes FALSE for-6. - Run the unchanged minimal project in the V1.3 simulator when that version is available. A correct V1.3 result combined with an incorrect V1.4 result isolates the regression to the newer simulator path.
- Download the same logic to the physical M221. Record the controller firmware, including whether it is
1.14.1, and observe the original and converted expressions separately. - If only the V1.4 simulator fails, retain the workaround only after application-level testing and report the reproducible project through an official Schneider Electric support channel. Include the software version, controller firmware, original expression, converted expression, and value/result matrix.
Verification Matrix
| Test value | Expected result for signed >= 0
|
Purpose |
|---|---|---|
-6 |
FALSE | Confirms that the negative sign survives conversion and comparison. |
0 |
TRUE | Checks the comparison boundary. |
| Known positive value | TRUE | Confirms the nonnegative branch still operates. |
Execute the matrix on every target used for commissioning: V1.4 simulation, any comparison V1.3 simulation, and the physical M221. Watch the operand and result in the same scan context. Do not accept a fix when only the negative case passes; a forced FALSE output could conceal a broken comparison unless zero and a positive value also return TRUE.
Frequently Asked Questions
Why does an M221 comparison say -6 is greater than or equal to zero?
The V1.4 simulator can promote %MW0 for comparison without carrying the word’s sign, causing the bit pattern to be treated like a UINT. The monitor can still display -6 while %MW0 >= 0 returns TRUE.
Why does the signed comparison work in V1.3 but fail in V1.4?
The reported simulator regression occurs in Machine Expert Basic V1.4 and did not occur in V1.3. Run the same minimal project in both versions so project changes do not contaminate the comparison.
How do I verify the M221 signed comparison workaround?
Test DWORD(%MW0) >= 0 with -6, 0, and a known positive value in the simulator and on the physical M221. Do not move on until the controller returns FALSE at -6, TRUE at 0, and TRUE for the positive test value.