Skip to main navigation Skip to search Skip to main content

DEVELOPMENT OF A CODELESS MODEL FOR MODEL-BASED AUTOMATIC UNIT TESTING OF COMBINATORIAL AND SEQUENTIAL CODE IN SIEMENS PLCS

  • Andy Seniow

    Student thesis: Master's Thesis

    Abstract

    This research focuses on developing aModel-Based Testing prototype for Siemens S7 series PLCs, aiming to automate the testing of the functional correctness of combinatorial and sequential logic. The motivation for this research is that manual testing of PLC code is time-consuming and can lead to missed test cases. Current testing methods are often inadequate and require expertise, limiting their feasibility for students or PLC programmers. An exploratory inquiry among various organizations indicates a need for standardization, efficiency, and better support for testing methods in Siemens PLC environments.
    The central research question is: "How can an intuitive, codeless model and algorithm be developed within a Model-Based Testing approach to automatically test the functional correctness of combinatorial and sequential Siemens PLC code?".
    To achieve this, four supporting research questions have been formulated, focusing on the development of themodel and algorithm, communication with the PLC, and validation of the prototype.
    A modified Moore machine has been developed, where state transitions are determined by input values and states correspond to expected output values. To support time-dependent elements, a time component has been integrated. The algorithm generates test cycles by iteratively constructing paths and converting combinatorial transitions into sequential transitions, ensuring that all 2n possible input combinations are tested. Loops in sequential models are executed a maximum of two times to reduce redundancy.
    The S7Comm protocol, implemented via the Moka7 library, facilitates communication between the prototype and the Siemens S7 PLC. The prototype supports various Siemens S7 data types, including BIT, BYTE, WORD, DWORD, INT, DINT, and REAL. Test cycles are executed based on a sequence of state and transition IDs, ensuring a controlled alternation between reading outputs in the PLC and writing inputs to the PLC.
    A case study with four test cases was conducted to validate the prototype. The test cases include combinatorial logic, logic with timing functions, logic with different data types, and sequential logic. The results demonstrate that the prototype effectively detects errors in PLC code and confirms the correctness of error-free code. Experimental tests show that the generated information output contains essential data to assess the test results.
    The developed prototype provides an intuitive, codeless approach to automatically testing the functional correctness of Siemens PLC code. The modified Moore machine and the developed algorithm can generate and execute test cycles while considering time-dependent elements and different data types. Validation through a case study confirms that the prototype effectively detects errors and verifies correct code.
    No formal verification techniques have been applied, meaning the reliability of the prototype cannot be fully guaranteed. Future research could focus on validation using formal verification techniques, testing by different users, and extending the prototype to test beyond functional correctness, including error handling and safety aspects.
    Date of Award22 Apr 2025
    Original languageEnglish
    SupervisorStefano Schivo (Examiner) & Freek Verbeek (Co-assessor)

    Master's Degree

    • Master Software Engineering

    Cite this

    '