10.4 Software Quality Assurance, Code Review & Validation Documentation

Key Takeaways

  • Software Quality Assurance (SQA) in automation enforces defect prevention through formal lifecycle governance, structured coding standards, peer code reviews, and bidirectional traceability.

  • The GAMP 5 V-Model framework establishes direct verification and validation linkages: User Requirements Specifications (URS) link to Performance Qualification (PQ), Functional Specifications (FS) link to Operational Qualification (OQ), and Design Specifications (DS) link to Installation Qualification (IQ) and unit testing.

  • Static code analysis detects memory bounds violations, dead code, unreachable logic states, uninitialized variables, and unbounded execution loops prior to code deployment.

  • A Requirements Traceability Matrix (RTM) maps every individual requirement from user specification through design specifications, software source modules, and qualification test scripts, verifying 100% test coverage.

  • Regulated automation systems (such as life sciences under FDA 21 CFR Part 11) mandate immutable, computer-generated, time-stamped audit trails and secure electronic signatures adhering to ALCOA+ data integrity principles.

Last updated: October 2026

Software Quality Assurance, Code Review & Validation Documentation

In Domain 4 (Development) of the ISA Certified Automation Professional body of knowledge, delivering robust industrial code requires formalized Software Quality Assurance (SQA). While ad-hoc programming and informal testing may suffice for non-critical hobby projects, industrial automation systems govern massive kinetic energies, toxic chemicals, high-pressure steam, and life-critical pharmaceutical manufacturing. In these environments, software failures can result in catastrophic environmental pollution, personal injury, regulatory product recalls, or millions of dollars in downtime.

SQA is not merely testing software at the end of a project; it is a systematic lifecycle discipline focused on defect prevention through structured methodologies, peer code reviews, static code analysis, coding standard enforcement, and rigorous validation documentation.


The Software V-Model Lifecycle and GAMP 5

In regulated life-sciences manufacturing, the dominant framework for computerized system validation is ISPE's GAMP 5: A Risk-Based Approach to Compliant GxP Computerized Systems (Second Edition, 2022), which uses a specification-and-verification V-model and also accommodates iterative and agile development.

THE GAMP 5 SOFTWARE VALIDATION V-MODEL:

 SPECIFICATION & DESIGN (Verification)                  TESTING & QUALIFICATION (Validation)

+------------------------------------+                  +------------------------------------+
| User Requirements Spec (URS)       |=================>| Performance Qualification (PQ)     |
| (What the business/process needs)  |    Validation    | (Verifies process under live load) |
+------------------------------------+    Traceability  +------------------------------------+
        |                                                       ^
        v                                                       |
+------------------------------------+                  +------------------------------------+
| Functional Specification (FS / FDS)|=================>| Operational Qualification (OQ)     |
| (What the automation system does)  |    Functional    | (Verifies functions, alarms, ranges|
+------------------------------------+    Traceability  +------------------------------------+
        |                                                       ^
        v                                                       |
+------------------------------------+                  +------------------------------------+
| Design Specification (HDS / SDS)   |=================>| Installation Qualification (IQ)    |
| (How the system is built/coded)    |    Structural    | (Verifies hardware, firmware, media|
+------------------------------------+    Traceability  +------------------------------------+
        |                                                       ^
        v                                                       |
+--------------------------------------------------------------------------------------------+
| MODULE DESIGN, CODING & UNIT / INTEGRATION TESTING                                         |
| (IEC 61131-3 logic routines, static analysis, peer code review, internal module bench test)|
+--------------------------------------------------------------------------------------------+

Verification vs. Validation

An automation professional must maintain a clear distinction between verification and validation:

  • Verification ("Are we building the product right?"): Evaluating software artifacts during the development lifecycle to determine whether they satisfy the conditions imposed by the preceding design stage. Verification activities include static code analysis, peer reviews, electrical schematic checking, and unit testing against the Design Specification.
  • Validation ("Did we build the right product?"): Establishing documented evidence that provides a high degree of assurance that the fully integrated automation system consistently operates in accordance with its intended operational use and user requirements. Validation activities occur on the right-hand arm of the V-Model (IQ, OQ, PQ) under real or simulated operating conditions.

GAMP 5 Software Categorization

GAMP 5 establishes five software categories to determine the required level of validation rigor:

  • Category 1: Infrastructure Software: Operating systems, hypervisors, standard database engines (e.g., Microsoft Windows Server, SQL Server). Validated through record of version, service packs, and installation qualification.
  • Category 2: (Deprecated in GAMP 5; originally covered standard firmware).
  • Category 3: Non-Configured Standard Software: Off-the-shelf software packages used as-is without configuration (e.g., smart digital temperature transmitter firmware, fixed-function controllers). Requires vendor audit/qualification and basic verification of standard functions.
  • Category 4: Configured Software: Standard software packages configured by application engineers to match specific plant processes (e.g., standard SCADA/HMI packages, commercial batch management software, standard DCS function block algorithms). Requires functional testing (OQ) and configuration specification documentation.
  • Category 5: Custom Software (Bespoke Code): Custom-developed application logic (e.g., user-written Ladder Diagram, Structured Text, C#/Python communication drivers, proprietary complex algorithms). Requires the highest level of validation rigor, including complete lifecycle documentation, formal SDS, unit testing, 100% peer review, static code analysis, and end-to-end qualification.

Static Code Analysis and Peer Code Reviews

Quality assurance mandates that defects be identified as close to their point of creation as possible. Two primary static techniques—analysis performed without running the compiled executable—are static analysis and peer code reviews.

1. Automated Static Code Analysis

Modern Programmable Automation Controller (PAC) development environments and third-party quality tools incorporate automated static analysis linters that inspect code against formal structural rules:

  • Memory Boundary Violations: Detecting array indexing where dynamic array pointers could exceed declared bounds (e.g., attempting to read Recipe_Array[Index] where Index > 100), which causes fatal CPU memory access faults.
  • Uninitialized Variables: Flagging internal tags or variables read prior to being assigned an explicit initial value.
  • Dead / Unreachable Code: Identifying rungs, blocks, or CASE branches that can never execute due to logically impossible boolean conditions (e.g., IF Valve_Open AND NOT Valve_Open THEN...).
  • Unbounded Execution Loops: Flagging WHILE or REPEAT loops in Structured Text that lack guaranteed deterministic exit conditions, which would exceed the RTOS cyclic task watchdog timer and fault the processor.
  • Memory Overlap in Direct Addressing: In legacy systems utilizing direct memory mapping (e.g., Modbus registers %MW100 or Rockwell N7:0), static analyzers detect overlapping word/double-word assignments that corrupt data.

2. Formal Peer Code Reviews (Fagan Inspections)

Static tools cannot evaluate whether the code correctly implements the process control narrative. Formal peer code review—governed by the four-eyes principle—requires an independent, qualified automation engineer to inspect the code before it is released for integration testing.

PEER REVIEW CHECKLIST FOR INDUSTRIAL AUTOMATION LOGIC:

[ ] 1. NAMING CONVENTIONS: Adheres strictly to ISA-5.1 tag naming and project variable standards.
[ ] 2. MEMORY BOUNDARIES: Arrays indexed safely; no direct non-symbolic memory addressing.
[ ] 3. POU SEGREGATION: Inputs, logic solving, and physical outputs separated into distinct routines.
[ ] 4. DOCUMENTATION: Every POU contains a complete header block; every rung has a narrative comment.
[ ] 5. INTERLOCK INTEGRITY: Safety interlocks coded as de-energize to trip; no unauthorized bypasses.
[ ] 6. WATCHDOG COMPLIANCE: No unbounded iterative loops in cyclic real-time execution tasks.
[ ] 7. FIRST-SCAN RESET: All retentive Set/Reset (Latch/Unlatch) bits initialized safely on FirstScan.
[ ] 8. ERROR TRAPPING: Division operations protected against zero-divisor faults (DIV / 0).

Coding Standards Enforcement

Industrial automation software must be maintainable by plant technicians and third-party engineers ten to twenty years after original commissioning. Coding standards enforce consistency across disparate engineering teams:

  1. Tag Naming Conventions: Combining ISA-5.1 instrument standards with camelCase or snake_case descriptors and explicit data type prefixes:
    • bTank101_HighLevel_Sw (b = BOOL)
    • rReboiler_Steam_Temp_PV (r = REAL floating-point)
    • nActive_Recipe_ID (n = INT / DINT)
    • tAgitator_Purge_Duration (t = TIME duration)
  2. Modular Architecture: Logic must be partitioned into modular Program Organization Units (POUs) reflecting physical plant hierarchy (per ISA-88 / ISA-95):
    • IO_Mapping_Routine: Reads physical hardware words, handles scaling, debouncing, and assigns raw values to engineering tags.
    • Regulatory_Control_Routine: Contains PID blocks, cascade summation, and lead/lag filters.
    • Sequence_Logic_Routine: Implements state machines and batch step transitions.
    • Alarm_Generation_Routine: Handles trip traps, first-out logic, and priority flags.
    • Output_Mapping_Routine: Gathers all automated commands, interlocks, and manual overrides to write exclusively to physical output points in a single, predictable location.
  3. Preserving Documentation Integrity: Code must contain narrative comments explaining the engineering intent behind the logic, not merely describing the syntax (e.g., commenting "Inhibit feed pump until suction pressure stabilizes above 15 psig to prevent impeller cavitation" rather than "Examine PT101 > 15 then energize coil").

Test Incident Reporting and the Defect Lifecycle

When a functional failure or software discrepancy is identified during unit testing, integration testing, FAT, or SAT, it must be handled through a formal, auditable Defect Lifecycle:

THE FORMAL DEFECT RESOLUTION LIFECYCLE:

   [ DEFECT LOGGED ]  (Captured in auditable incident management database)
           |
           v
   [ TRIAGE & SEVERITY ASSESSMENT ]  (Assigned Critical / Major / Minor priority)
           |
           v
   [ ROOT CAUSE ANALYSIS ]  (Investigate logic flaw, timing race, or hardware bug)
           |
           v
   [ REMEDIATION / CODE FIX ]  (Developer edits code in isolated development branch)
           |
           v
   [ PEER CODE REVIEW ]  (Independent engineer reviews delta changes & comments)
           |
           v
   [ REGRESSION TESTING ]  (Re-execute test case AND all related adjacent functions)
           |
           v
   [ FORMAL CLOSURE & VERIFICATION ]  (Signed off by QA Lead & Client Representative)

The Absolute Requirement for Regression Testing

When an automation engineer modifies code to resolve a specific defect, there is a high probability that the modification will inadvertently introduce secondary bugs into existing, previously verified logic.

Important

A defect cannot be marked as closed merely by confirming that the immediate bug was fixed. Regression testing is mandatory: the engineer must re-execute the specific failed test case AND rerun all previously passed test scripts governing related subsystems to prove that no unintended side-effects were introduced.


Requirements Traceability Matrix (RTM)

The Requirements Traceability Matrix (RTM) is the primary auditing backbone of software validation. It is a bidirectional matrix that links every single requirement from the User Requirements Specification (URS) through to functional design documents, specific software code modules, and final qualification test cases.

BIDIRECTIONAL REQUIREMENTS TRACEABILITY MATRIX (RTM) ARCHITECTURE:

+---------+--------------------+----------------+------------------+-----------------+
| URS ID  | Requirement Text   | FDS Section    | Software POU     | Test Script ID  |
+---------+--------------------+----------------+------------------+-----------------+
| URS-101 | Reactor high-temp  | FDS Sec 4.2.1  | POU_Interlocks   | FAT-TC-INT-014  |
|         | trip at > 120 deg C| Temp Interlock | Rung 12 (TRIP_14)| OQ-SIF-002      |
+---------+--------------------+----------------+------------------+-----------------+
| URS-102 | Flow totalizer roll| FDS Sec 5.1.3  | POU_Totalizers   | FAT-TC-ANA-088  |
|         | over at 1,000,000 L| Mass Blending  | ST Block 4       | OQ-BLD-019      |
+---------+--------------------+----------------+------------------+-----------------+
| URS-103 | Redundant CPU fail-| FDS Sec 2.4.0  | Firmware Engine  | FAT-TC-RED-001  |
|         | over in < 20 ms    | Architecture   | Redundancy Task  | SAT-TC-RED-001  |
+---------+--------------------+----------------+------------------+-----------------+

Critical Functions of the RTM:

  1. Proves 100% Verification Coverage: Guarantees that not a single user or regulatory requirement is left untested during FAT, SAT, or OQ.
  2. Prevents "Gold Plating": Identifies unrequested, undocumented software routines introduced by developers that have no corresponding URS justification, eliminating unauthorized features that introduce unvalidated operational risks.
  3. Facilitates Impact Analysis during Change Management: When an engineering change order (ECO) is proposed to modify a user requirement, the RTM instantly reveals every affected design section, software module, and qualification test protocol that must be updated and re-validated.

Software Validation Documentation: IQ, OQ, and PQ

In regulated industries governed by FDA 21 CFR, cGMP, or European EMA regulations, software validation produces three progressive qualification packages:

Qualification PhaseFormal Definition & PurposeTypical Execution Scope & Test Methods
Installation Qualification (IQ)Documented verification that the automation hardware, system wiring, software binaries, operating system patches, and communications infrastructure are installed in conformance with design specifications and manufacturer recommendations.Hardware model numbers, serial numbers, and module slots matched to drawings; Firmware revisions across all PACs, I/O modules, and VFDs verified; Software installation media, license keys, and checksum hashes logged; Cable schedules, terminal labeling, and cabinet grounding verified.
Operational Qualification (OQ)Documented verification that the integrated automation system operates in accordance with its Functional Design Specifications across all specified operating ranges, operational modes, boundary conditions, and failure modes.100% I/O point-to-point functional loop checks; Alarm actuation setpoints, priority banners, and audible horns verified; Safety interlocks, permissives, and emergency stops tested; Controller redundancy, power supply failover, and network ring break verified; Automated recipe sequence step-through and boundary limit tests executed.
Performance Qualification (PQ)Documented verification that the fully integrated automated process equipment consistently produces product meeting predetermined quality criteria under actual commercial manufacturing conditions and full production loading.Multi-batch commercial production runs using real process fluids; Environmental chamber mapping and cleanroom pressurization under load; Process analytical technology (PAT) critical quality attributes (CQA) tracked; Sustained cycle time, throughput capacity, and yield verified.

Warning

A frequent regulatory inspection finding is confusing OQ with PQ. OQ tests the automation system functionality (testing alarms, interlocks, and failure modes, often using water or benign test media). PQ tests the manufacturing process performance (proving that the system repeatedly produces compliant commercial product under real production conditions).


Electronic Records and Signatures: 21 CFR Part 11 and ALCOA+

In life sciences, medical device, and biotechnology facilities regulated under FDA 21 CFR Part 11 (and EU GMP Annex 11), electronic records and electronic signatures carry the same legal weight as traditional paper records and handwritten ink signatures. An automation engineer must design supervisory SCADA and batch systems to enforce strict data integrity.

1. Computer-Generated Audit Trails

An audit trail must be secure, computer-generated, time-stamped, append-only, and independent of operator control. It must automatically record every security-significant action or process modification:

  • Exact Date and Time: Sourced from a synchronized, authoritative time source (for example, an NTP server referenced to UTC).
  • Operator Identity: The unique, non-shared username of the individual executing the action.
  • Action Executed: Capturing the specific parameter changed, the Previous Value (Old Value), and the Modified Value (New Value) (e.g., "Reactor 101 Temperature Setpoint changed from 75.0 °C to 82.5 °C").
  • Reason for Change: EU GMP Annex 11, FDA data-integrity guidance and most site procedures expect the reason for a GMP-relevant change to be recorded, so systems are usually configured to require it before the change is committed.
  • Immutability: Audit trail records must be stored securely so that they cannot be altered (for example, in append-only, access-controlled databases). Operators, supervisors, and database administrators must never possess permissions to edit, overwrite, or delete audit trail records.

2. Electronic Signatures

An electronic signature must manifest the signatory’s legal intent. Part 11 mandates:

  • Dual-Factor Identification: Entering a unique username combined with a secret password, token, or biometric credential.
  • Signature Manifestation: The printed record must clearly display the printed name of the signer, the exact date and timestamp, and the formal meaning of the signature (e.g., "Reviewed by", "Approved by", "Authored by").
  • Signature/Record Linking: Signatures must be linked to their records (21 CFR 11.70) so that they cannot be excised, copied or transferred; many systems implement this with cryptographic methods that also reveal any later modification.

3. ALCOA+ Data Integrity Framework

Under international regulatory consensus, automation records must fulfill the ALCOA+ quality framework:

  • A – Attributable: Every record clearly identifies who performed the action.
  • L – Legible: Data must be readable and permanently accessible throughout the asset lifecycle.
  • C – Contemporaneous: Recorded at the exact moment the event or measurement occurs.
  • O – Original: The primary, raw source record (or a certified true copy).
  • A – Accurate: Free from errors, unapproved modifications, or undocumented editing.
  • + Complete, Consistent, Enduring, and Available: All metadata included, chronologically consistent, stored on durable media, and readily accessible to regulatory auditors.

Realistic Industrial Scenario: CIP/SIP System Qualification in a Biopharmaceutical Plant

An automation engineering team is qualifying an automated Clean-in-Place (CIP) and Sterilization-in-Place (SIP) skid for a 20,000-liter20{,}000\text{-liter} cell culture bioreactor:

  1. Installation Qualification (IQ): The validation engineer inspects the control panel, confirms that the PAC processor model number, 24 VDC power supplies, Ethernet switch firmware, and analog I/O module hardware revisions match the Hardware Design Specification (HDS) exactly, and records the SHA-256 hash of the compiled controller runtime binary.
  2. Operational Qualification (OQ): The engineer connects a loop calibrator to simulate temperature transmitter TT-401. During the SIP phase, the specification requires the bioreactor temperature to hold at ≥121.1∘C\ge 121.1^{\circ}\text{C} for a minimum of 30.0 minutes30.0\text{ minutes}.
    • Failure Mode Test: At minute 28, the engineer drops the simulated temperature to 120.5∘C120.5^{\circ}\text{C}. The automation system instantly faults the SIP timer, trips an audible alarm, aborts the cycle, and requires an operator acknowledgment with a formal reason for abort.
    • Audit Trail Verification: The engineer verifies that the abort event, old temperature value, trip threshold, and operator acknowledgment are immutably logged in the 21 CFR Part 11 database.
  3. Performance Qualification (PQ): With live water and bio-burden challenge coupons loaded in the bioreactor, the plant runs three consecutive, successful automated CIP/SIP cycles under full commercial operating conditions. Biological swab tests confirm complete spore kill and zero chemical detergent residues, successfully closing the Performance Qualification.

Common Exam Traps

  1. Conflating Operational Qualification (OQ) with Performance Qualification (PQ): Exam items frequently describe a test and ask which qualification protocol governs it. Remember: Testing equipment functionality, alarm trip points, interlocks, and failure modes across operational boundaries is OQ. Testing whether the system repeatedly produces acceptable product under commercial operating conditions and live production load is PQ.
  2. Skipping Regression Testing after a Defect Fix: A frequent exam scenario describes a bug discovered late in an FAT or OQ. The developer applies a quick one-line logic fix, verifies that the bug is resolved, and immediately signs off the protocol. This is incorrect engineering practice. The correct procedure requires full peer review followed by regression testing across all related subsystem functions.
  3. Misunderstanding GAMP 5 Software Categories: Do not confuse Category 4 (Configured software, such as commercial SCADA or batch engines) with Category 5 (Custom software, such as custom-written PLC code or bespoke scripts). Category 5 software represents the highest risk and demands the most rigorous validation documentation.
  4. Permitting Editable Audit Trails: Any question suggesting that an audit trail can be exported into an editable spreadsheet, modified by a system administrator, or stored in a file that allows record deletion violates 21 CFR Part 11. Audit trails must be automated, immutable, append-only, and tamper-proof.
Test Your Knowledge

In the GAMP 5 risk-based validation lifecycle (V-Model), which formal testing phase directly validates the requirements established in the User Requirements Specification (URS)?

A

Module and Unit Code Testing

B

Operational Qualification (OQ)

C

Performance Qualification (PQ)

D

Installation Qualification (IQ)

Test Your Knowledge

An automation engineer is designing a supervisory SCADA system for a pharmaceutical manufacturing facility subject to FDA 21 CFR Part 11. Which design architecture is mandatory for managing operator setpoint modifications and recipe adjustments?

A

Allowing operators to delete erroneous setpoint log entries, provided that they first obtain verbal authorization from the shift supervisor

B

A computer-generated, time-stamped, append-only audit trail of user ID, old and new values and reason, which users cannot edit or delete

C

Exporting setpoint changes to a monthly spreadsheet file stored in an open network folder without password restrictions

D

Enabling electronic signatures only during quarterly supervisor audits rather than at the time each parameter is modified

Test Your Knowledge

What is the primary engineering purpose of maintaining a bidirectional Requirements Traceability Matrix (RTM) throughout the automation software development lifecycle?

A

To replace formal peer code reviews and automated static analysis with a single tracking spreadsheet

B

To link each requirement through design and code to its tests, proving coverage and exposing gold plating

C

To calculate the total memory footprint and cycle execution time of the compiled controller tasks for sizing

D

To generate electrical wiring schematics and cabinet cable routing schedules automatically from the code

Sections you finish are checked off in the contents.