Error Detecting Codes

2025-08-31

Error Detecting Codes

Error Detecting Codes

What is it?

Error detecting codes are mathematical techniques that add extra redundancy bits to digital information. These codes allow a system to check whether data has been corrupted during transmission or storage. Common examples include parity bits, checksums, Hamming codes, and cyclic redundancy checks (CRC). In functional safety, their purpose is not to correct errors but to prevent faulty data from being used in safety-critical decisions.

When to use

  • Safety-related communication between sensors, controllers, and actuators.
  • Protecting memory contents in embedded controllers or safety PLCs.
  • Serial communication links exposed to noise or interference.
  • Any case where corrupted data could cause a dangerous or unintended actuation.

Inputs & Outputs

Inputs

  • Raw data to be stored or transmitted
  • Coding scheme (e.g., CRC polynomial, Hamming parameters)

Outputs

  • Encoded data with redundancy bits
  • Detection status (valid / corrupted)

Procedure

  1. Select an appropriate error detection code (parity, CRC, Hamming, etc.) based on required safety integrity level.
  2. Encode outgoing data by adding redundancy bits.
  3. Transmit or store the data with the code attached.
  4. At the receiver (or during retrieval), recompute and verify the code.
  5. If valid → accept data.
  6. If invalid → apply a safe reaction (discard, hold last safe value, or enter safe state).

Worked Example

High-level

A temperature sensor sends data to a safety controller over a noisy bus. A CRC is appended to each data frame. If corruption occurs, the controller rejects the frame and keeps the last safe reading, avoiding a spurious shutdown command.

Code-level

def transmit(data):
    crc = compute_crc(data)
    return data, crc

def receive(data, crc):
    if compute_crc(data) == crc:
        return data
    else:
        # SAFE REACTION: discard frame, hold last safe value
        return last_safe_value

Result: The controller only acts on verified, uncorrupted sensor data.

Quality criteria

  • Coding scheme selected must match the SIL/ASIL target.
  • Coverage against single-bit and burst errors must be justified.
  • Safe reaction on error must be specified, tested, and documented.

Common pitfalls

  • Using error correction instead of detection → unsafe mis-corrections. Mitigation: always discard or enter safe state on detection.
  • Weak codes (e.g., simple parity) missing multi-bit errors. Mitigation: use strong CRCs or Hamming codes where required.
  • Not testing safe reaction paths. Mitigation: include error injection in verification.

References

FAQ

Why not correct errors instead of just detecting them?

Correction may produce an incorrect but valid-looking value, which is unsafe. Functional safety favors discarding over guessing.

Are CRCs enough for SIL 3/4?

CRCs with sufficient length and carefully chosen polynomials can provide very high diagnostic coverage, but justification is required.

This article explains Error Detecting Codes in general functional-safety practice. Always consult applicable standards for normative requirements.


Back to all news

We use cookies
Cookie preferences
Below you may find information about the purposes for which we and our partners use cookies and process data. You can exercise your preferences for processing, and/or see details on our partners' websites.
Analytical cookies Disable all
Functional cookies
Other cookies
We use cookies to personalize content and ads, to provide social media features and to analyze our traffic. Learn more about our cookie policy.
Accept all Decline all Change preferences
Cookies