Job search
Controls Engineering Portfolio: Show a PLC Sequence and Its Failure Handling
An executed offline PLC-style sequence model shows command/feedback rules, timed logical faults and deliberate recovery, with independent trace checks.
A controls engineering portfolio should show what a sequence commands, which feedback allows the next step, what happens when that feedback fails and how recovery is permitted. Include the input/output contract, executable source and complete normal and fault traces. A green test result alone cannot show that a machine is safe or that an actual PLC program works.
This guide uses an original offline PLC-style Python model, actually run in Python 3.9.6. It is not compiled ladder logic, Structured Text, a vendor PLC simulator or a physical controller. Each call advances an authored 100-millisecond logical step; those timestamps are not measured wall-clock response times. LandOffer publishes this guide; use LandOffer.ai to find roles whose controls responsibilities match the evidence you can honestly present.

Describe the process before showing the program
The teaching scenario is a fictional tabletop clamping cycle: accept a new start request, command a clamp, confirm closed feedback, hold for a modeled dwell, release and confirm open feedback. No actuator, fieldbus, sensor or industrial installation was connected. The test fixtures supply authored Boolean input snapshots; they do not measure a moving mechanism.
State that scope before describing the sequence results. A reviewer can inspect the decision rules without assuming you commissioned equipment. Name the process, its normal starting condition and the required outcome before presenting a language or software logo. Then identify which parts of the evidence are model execution, vendor documentation and untested implementation work.
AutomationDirect describes its Do-more simulator as providing virtual inputs, outputs and memory for testing without connected hardware, including replicated faults. That is a documented vendor capability. We did not run Do-more; its description does not turn this Python exercise into a validated Do-more project.
CODESYS similarly documents simulation on a simulated target, with differences from a physical controller. Its simulation runs at normal process priority and does not update physical I/O channels or evaluate fieldbus stacks. Even a vendor simulator has limits; an authored Python model needs an especially clear scope statement.
Worked asset one: a complete input, state and command contract
The runnable sample contains sequence_model.py, run_cases.py and review_trace.py, plus saved JSON observations. The model separates requests and feedback from derived commands. It does not equate a command with successful movement.
| Signal | Meaning in this exercise | Declared use |
|---|---|---|
| start | Boolean operator request | A new false-to-true edge can start from IDLE |
| reset | Boolean recovery request | A new edge can clear FAULT only under stated conditions |
| permit | Functional demonstration flag | False causes a modeled fault; not a safety-rated emergency stop |
| opened / closed | Authored position feedback | Both true is contradictory; neither can represent intermediate travel |
| clamp_command / release_command | Boolean modeled output requests | Derived from state; never both true in the tested traces |
The initial state is IDLE, with opened true and closed false in the default fixture. A valid start edge enters CLAMP. CLAMP asserts the clamp command and waits for closed feedback; absent feedback faults after 500 logical milliseconds in that state. Closed feedback moves the sequence into DWELL, which retains the clamp command.
DWELL requires closed feedback to remain true. After 300 logical milliseconds there, the model enters RELEASE and asserts only the release command. Open feedback advances RELEASE to DONE; without it, RELEASE faults after 500 logical milliseconds. DONE returns to IDLE when start is false. IDLE, DONE and FAULT assert neither command.
The 300-millisecond dwell and 500-millisecond feedback timeouts are authored requirements for this exercise. They are not recommended actuator settings. The code supplies no pneumatic, electrical, mechanical or safe-stop design. Removing a Boolean command in a model does not establish what stored energy or a physical actuator would do.
The order of evaluation is also visible in source. Permit loss and contradictory feedback are checked before the ordinary state transitions. An unknown state faults. In CLAMP and RELEASE, the model checks the expected feedback before the timeout branch, so feedback present on the evaluated boundary can take precedence. That is a code-defined choice requiring review, not a universal PLC timer convention.
The contract and source together let a reviewer ask useful questions: should a missing initial open signal prevent starting? Which condition has priority when two things change together? Should a fault clear automatically? Those questions expose design decisions that a screenshot of a sequence diagram may conceal.
Preserve the complete normal trace
The first actual fixture supplies eight successive input snapshots. At logical time zero, the model remains IDLE. At 100, start rises while open feedback is true, entering CLAMP. At 200, closed becomes true and opened becomes false, entering DWELL.
The fixture keeps closed feedback true through logical times 300, 400 and 500. At 500, the three dwell increments have accumulated 300 logical milliseconds, and the state becomes RELEASE. At 600, open feedback is true and closed is false, producing DONE. At 700, start is false and the sequence returns to IDLE.
| Logical timestamp | Observed state after evaluation | Clamp command | Release command |
|---|---|---|---|
| 0 | IDLE | False | False |
| 100 | CLAMP | True | False |
| 200, 300, 400 | DWELL | True | False |
| 500 | RELEASE | False | True |
| 600 | DONE | False | False |
| 700 | IDLE | False | False |
The trace stores the state before evaluation, complete input snapshot, resulting state, state-local elapsed value, fault code and both commands at every step. Keeping the inputs beside each resulting state lets a reviewer trace the transition rule. It also makes the difference between absolute logical timestamp and time spent in a state explicit.
The 600 timestamp does not mean a real clamp completed a cycle in 600 milliseconds. The test runner iterates supplied rows without waiting for that time to pass. It does not model input sampling hardware, operating-system scheduling, controller scan jitter, communication delay or actuator travel.
Worked asset two: failed feedback and deliberate recovery
The second completed case starts normally at logical 100 but never supplies closed feedback. After entering CLAMP, five additional evaluations accumulate 500 logical milliseconds. At logical timestamp 600, the observed result is FAULT with CLAMP_TIMEOUT, and both modeled commands are false.
The fault explanation stays narrow: the fixture did not receive the expected closed indication before its authored timeout. It does not identify a broken sensor, obstructed mechanism or failed valve. Different physical problems can produce missing feedback; this model has no measurements that distinguish them.
The saved recovery fixture then deliberately tries actions that should not restart the sequence. At logical 700, start and reset are both true. Reset is rejected because start remains asserted. At 800, start becomes false but reset is still held true; there is no new reset edge, so FAULT remains.
At 900, reset is released. At 1,000, a fresh reset edge arrives with start false, opened true, closed false and permit true. The model returns to IDLE with neither command asserted. It remains IDLE at 1,100. Only a new start edge at 1,200 enters CLAMP again.
This completed path distinguishes acknowledging a fault from requesting new motion. It also shows why “press reset” is an incomplete recovery explanation. The entry should display the required position feedback, request states and edge behavior beside the observed recovery, rather than leaving those rules buried in code.

Check other failures without claiming exhaustive coverage
The actual run includes eight named fixtures: normal completion, missing closed feedback, permit loss, contradictory feedback, lost closed feedback during dwell, missing open feedback during release, an unknown state and the reset/restart path. All declared runner assertions passed in two original executions and our separately saved rerun. The test inventory names finite scenarios, not a percentage of every possible machine condition.
Permit loss produced PERMIT_LOST; simultaneous opened and closed produced CONTRADICTORY_FEEDBACK. Losing closed feedback in DWELL produced CLOSED_FEEDBACK_LOST. Missing open feedback in RELEASE produced RELEASE_TIMEOUT. Starting the object with an invalid state produced UNKNOWN_STATE. Each observed fault removed both modeled output requests.
A separate reviewer script reads the saved JSON without importing the sequence model. It checks the case inventory, logical step progression, normal path, missing-feedback timeout and reset/restart states. Across the traces, it rejects simultaneous output requests and any FAULT row that still asserts a command.
To challenge that reviewer, the script copies the trace in memory and deliberately changes the timed-out clamp row to leave its clamp command true. The independent check rejects that altered observation for leaving a modeled command asserted in FAULT. This is an intentionally authored negative control, not a newly discovered PLC defect or a real machine incident. The original saved observations remain unchanged.
The initial two executions and our fresh-process rerun produced identical trace bytes. That repeatability identifies what this model did for the supplied fixtures. It does not prove every transition combination is covered. The independent reviewer also checks selected properties rather than independently deriving every vendor-specific runtime behavior.
Show the difference between modeled timing and a timer block
Do not label the Python elapsed counter a tested TON instruction. The model adds 100 to a state-local integer when specified branches execute. It has not instantiated a PLC library function block or validated how a runtime updates timer outputs.
CODESYS's Structured Text function-block example distinguishes declaring an instance, calling it with inputs and reading its output. Its separate TON test example uses an actual standard-library testee and table columns including IN, PT, Q and ET, with expected-versus-actual comparisons. These documents describe work that was not executed here.
If an opening asks specifically for CODESYS, Studio 5000 or another PLC environment, present this as sequence-model and trace-analysis evidence. Identify the remaining work: implement the agreed contract in that environment, build it, run the relevant timer and sequence tests and record the actual version and target. Do not replace that work with uncompiled Structured Text pasted into a portfolio page.
CODESYS's simulation testing instructions require a program without compiler errors before the documented simulation workflow. A Python pass cannot establish that prerequisite. Label each evidence layer by the tool that actually ran it.
Package the source, traces and remaining limits together
Put the process description and I/O contract before the code. Then show the normal trace, one fault and its recovery, followed by the additional case inventory. Preserve the complete machine-readable observations so a reviewer can inspect inputs alongside outputs instead of trusting selected screenshots.
Include the interpreter version and exact commands. In this sample, Python's standard library is sufficient; no controller login, vendor installation, network service or physical equipment is needed. Give fresh reruns separate filenames so a later execution cannot erase the original evidence. Keep source and trace hashes with the run instructions; they identify the files, not the correctness of the process requirements.
Our QA automation portfolio guide demonstrates a software formatter defect and correction. This controls example instead concerns stateful command/feedback sequencing, fault priority and recovery. Both need repeatable evidence, but a unit-test habit does not automatically establish industrial commissioning or safety expertise.
End the project with the result you can defend: the authored sequence followed the recorded normal path, faulted under the supplied failure conditions and required deliberate reset and restart actions. No safety function, physical response, vendor runtime or site acceptance was validated. Choose a relevant role on LandOffer.ai, then submit this evidence under its accurate scope and the employer's requested format.
Download the worked example files
Download the curated educational companion. Read PUBLICATION-README.md after extraction for the public file layout, replay commands and requirements. The listed offline Python checks were rerun from the extracted archive in a disposable directory. The earlier local report and commands describe the original evidence environment; use the companion README for the portable layout. No whole evidence directory, credentials or compiler binaries are included.
Sources and Further Reading
- AutomationDirect: Do-more built-in simulator — documented virtual I/O and fault-testing capability; not executed here.
- CODESYS: Simulation command and physical-controller differences — runtime, I/O and fieldbus limits.
- CODESYS: Testing in Simulation Mode — compiler prerequisite and simulation workflow.
- CODESYS: ST Function Block Call — instance, inputs and output access.
- CODESYS: Testing the TON Function Block — actual library-test example, separate from the Python counter.


