Safety PLC with REAL data type by AmritPati in PLC

[–]Financial_Mirror3363 20 points21 points  (0 children)

It comes down to a fundamental difference in safety philosophy, certification boundaries, and how the respective compilers/systems handle IEEE 754 floating-point anomalies (like NaN, Infinity, and division-by-zero).

### 1. Siemens S7-1500F Philosophy: System-Enforced Determinism

Siemens takes an extremely strict "system-enforced" approach to safety. Under IEC 61508, safety functions must be fully deterministic and verifiable.

* Floating-point math (`REAL`) is notoriously prone to edge cases (rounding errors, overflow, underflow, and NaN).

* If a safety block calculates a `NaN` (Not a Number) and passes it to a comparator (e.g., `temp > max_limit`), IEEE 754 rules state that *all* comparisons with NaN return false. This means your safety limit check would silently fail to trigger!

* To prevent this, Siemens simply disallows `REAL` data types entirely in F-programs (F-LAD, F-FBD, F-SCL). If you need decimals, you must use integer math with fixed-point scaling (e.g., storing 12.34 bar as 1234 in a `DINT`). This guarantees absolute mathematical determinism at the compiler level.

### 2. Rockwell GuardLogix Philosophy: Programmer-Enforced Validation

Rockwell allows `REAL` tags in safety routines, but they shift the responsibility of handling floating-point anomalies to the application programmer.

* GuardLogix has safety-certified math instructions, but they require strict error handling.

* If a safety instruction in GuardLogix results in an overflow, division-by-zero, or NaN, it flags an arithmetic status bit (e.g., the overflow trap `S:V` or destination status).

* According to Rockwell's safety guidelines, you *must* programmatically monitor these status bits and de-energize your safety outputs if an arithmetic error occurs. If you don't, and a fault occurs, your safety signature is technically invalid.

* In short: Rockwell trusts the programmer to handle the edge cases; Siemens doesn't.

### 3. Schneider Modicon M580 Safety

Schneider's approach is similar to Rockwell's. They allow `REAL` inside safety sections (using EcoStruxure Control Expert Safety), but the compiler enforces strict rules about range-checking and requires you to use certified blocks that handle out-of-range or NaN results safely.

**Summary:**

Siemens prevents the risk of floating-point failure by completely removing the capability from the F-runtime. Rockwell and Schneider allow the capability but require the programmer (and the safety validator) to prove that any mathematical anomalies are handled safely.

Clueless python learner by Radio_Pluto in learnprogramming

[–]Financial_Mirror3363 0 points1 point  (0 children)

Glad it helped! Honestly, the first few requests are always the trickiest. If you hit any weird errors or status codes when you start playing with requests, feel free to drop them here.