Practice module 5 of 5 · Ladder + Siemens SCL
Make each transition explicit.
Build a three-state simulated conveyor sequence. Prove transitions and find scan-order bugs.
05 / Capstone: own the fault
What you will be able to prove
- Turn a machine requirement into states, transitions and output ownership.
- Latch a diagnosable timeout and design deliberate recovery.
- Prove first cycle, repeat cycle, interrupted cycle and invalid-state handling.
Before this module: Modules 01–04. Complete the timed independent sequence before this capstone.
Core: 25–30 min · Capstone: 60–90 min. These are planning estimates; work at your pace.
Your deliverable: A virtual-cell functional specification, state diagram, tag list, program and signed-off personal test sheet.
Predict → trace → challenge → explain. The written labs are self-assessed. Use paper or your own compatible simulation. The browser workshop supports a limited training subset; these SCL excerpts are not import-ready or TIA-compiled blocks.
Your next step
Start small. Build from there.
New to this topic? Read the three state names first. Follow just one transition before looking at the full sequence.
Optional hint: the idea in plain words
State describes where the sequence is now. NextState holds the proposed next step. The example commits that new state once, after evaluating transitions.
Work in one language first, then compare the other. After the prediction, open step 3 for guidance or step 4 for an independent challenge.
Before you reveal: write your answer and one sentence explaining it. Use a notebook or your own editor. These pages do not execute code, auto-grade answers, or save progress.
A three-state simulated transfer.
Build a tabletop simulation: 0 Idle → 10 Feed → 20 Complete → Idle. A fresh StartPulse enters Feed. AtStation finishes feeding. Ack clears Complete. StopOK=FALSE returns to Idle. This is a simplified process sequence, not a machine-safety design.
Inputs Start, AtStation, Ack, StopOK: BOOL. Static State: INT, initially 0; Static StartEdge: R_TRIG. Temps NextState: INT and StartPulse: BOOL, assigned every call. Outputs ConveyorCmd and CompleteLamp: BOOL. Call every scan. For these traces, initialize State to 0 and StartEdge history to FALSE. Start=TRUE on the first call can produce StartPulse; this is not restart or power-loss protection.
#StartEdge(CLK := #Start, Q => #StartPulse);
#NextState := #State;
IF NOT #StopOK THEN
#NextState := 0;
ELSE
CASE #State OF
0: IF #StartPulse THEN
#NextState := 10;
END_IF;
10: IF #AtStation THEN
#NextState := 20;
END_IF;
20: IF #Ack THEN
#NextState := 0;
END_IF;
ELSE
#NextState := 0;
END_CASE;
END_IF;
#State := #NextState;
#ConveyorCmd := #StopOK AND (#State = 10);
#CompleteLamp := (#State = 20);LAD equivalent: use an R_TRIG block and MOVE/comparison blocks in the following network order. Each transition reads State and writes NextState; only network 7 writes State.
N1 R_TRIG StartEdge: CLK=Start, Q=StartPulse
N2 MOVE State -> NextState (unconditional)
N3 [StopOK] [State = 0] [StartPulse]
-> MOVE 10 to NextState
N4 [StopOK] [State = 10] [AtStation]
-> MOVE 20 to NextState
N5 [StopOK] [State = 20] [Ack]
-> MOVE 0 to NextState
N6 NOT StopOK OR invalid State
-> MOVE 0 to NextState
N7 MOVE NextState -> State (unconditional)
N8 [StopOK] [State = 10] -> (ConveyorCmd)
N9 [State = 20] -> (CompleteLamp)The working copy prevents separate LAD networks from advancing through several states after an earlier network changes State. A single SCL CASE already selects only one branch; it does not fall through. We keep NextState here so both representations have the same transition and output order.
Old state decides. New state drives.
Start State=0. Assume StartPulse is supplied as shown and StopOK=1. For each row, predict State after the commit and both outputs.
| Scan | StartPulse | AtStation | Ack | State / Conveyor / Lamp? |
|---|---|---|---|---|
| 1 | 1 | 1 | 0 | ? |
| 2 | 0 | 1 | 1 | ? |
| 3 | 0 | 1 | 1 | ? |
Reveal the answer and why
Scan 1: 10 / 1 / 0. The old state is Idle, so only the Start transition applies, even though AtStation is already TRUE. Scan 2: 20 / 0 / 1. The old state is Feed; Ack does not also clear Complete in this scan. Scan 3: 0 / 0 / 0. The old state is Complete and Ack returns it to Idle. This deliberately simple sequence produces a one-scan Conveyor command when AtStation is already TRUE at start. That is a requirement to challenge, not a desirable property to hide.
03 · FINISH THE SOLUTIONPrevent feeding into an occupied station.
Change only the Idle transition: accept a fresh StartPulse when AtStation is FALSE. Complete the condition in SCL and add the corresponding ladder contact.
0: IF #StartPulse AND ______ THEN
#NextState := 10;
END_IF;Reveal the answer and why
Use NOT #AtStation, and add [/AtStation] in series in N3. If Start is pressed while AtStation=1, the request is rejected. Clearing the sensor while Start stays held does not create a new StartPulse; release and press Start again. R_TRIG must keep running every scan, including while stopped.
04 · INDEPENDENT VARIANTAdd a stable-arrival delay.
Use the station-clear start rule. While in Feed, require AtStation to stay TRUE for 500 ms before entering Complete. Stop must reset the timer. Use Static ArrivalDelay: TON_TIME; Temp ArrivalDone: BOOL; Temp Elapsed: TIME. Put the unconditional timer call before the state transitions. Draw its LAD network and update the SCL sequence.
Compare the timed sequence
#StartEdge(CLK := #Start, Q => #StartPulse);
#ArrivalDelay(
IN := #StopOK AND (#State = 10) AND #AtStation,
PT := T#500ms,
Q => #ArrivalDone,
ET => #Elapsed);
#NextState := #State;
IF NOT #StopOK THEN
#NextState := 0;
ELSE
CASE #State OF
0: IF #StartPulse AND NOT #AtStation THEN
#NextState := 10;
END_IF;
10: IF #ArrivalDone THEN
#NextState := 20;
END_IF;
20: IF #Ack THEN
#NextState := 0;
END_IF;
ELSE
#NextState := 0;
END_CASE;
END_IF;
#State := #NextState;
#ConveyorCmd := #StopOK AND (#State = 10);
#CompleteLamp := (#State = 20);LAD: after StartEdge, execute ArrivalDelay with IN driven by series StopOK, State=10 and AtStation tests. Connect Q to ArrivalDone. Add a negated AtStation test to Idle→Feed. Replace AtStation with ArrivalDone in Feed→Complete. Keep one State commit and decode outputs after it. On the scan that completes the delay, the state commits to 20 and ConveyorCmd becomes FALSE; on the next scan, the timer receives FALSE because State is no longer 10.
05 · ACCEPTANCE TESTProve more than the first successful run.
Run these as paper traces, then in a compatible simulation. For each, record starting state, input sequence, expected result, observed result, and any mismatch. These pages do not run the tests for you.
| Test | Expected result for the independent variant |
|---|---|
| Start while station occupied | Remain Idle; require a new Start edge after the station clears. |
| Normal arrival | Feed begins; 500 ms of continuous AtStation while Feed/StopOK are TRUE enters Complete. |
| Sensor chatters before 500 ms | FALSE resets the delay; no early Complete. |
| Normal stop during timing | Return Idle, ConveyorCmd=0, timer receives FALSE and resets. |
| Start held through stop/recovery | No new Start edge on release of stop; no restart from that held level. Assumes the edge block was called continuously. |
| Ack held before completion | Complete is visible for one scan, then Ack returns Idle next scan. If a fresh acknowledgement is required, use an Ack edge design. |
| Second full cycle | Ack, clear AtStation, release then press Start; the whole sequence works again. |
| Invalid State, e.g. 99 | Commit to Idle; ConveyorCmd=0. A production design would also consider explicit fault reporting. |
06 · MIXED RETRIEVALFind the scan-order fault.
IF #State = 0 AND #StartPulse THEN
#State := 10;
END_IF;
IF #State = 10 AND #AtStation THEN
#State := 20;
END_IF;Start at State=0 with both inputs TRUE. Predict the final state. Why is this different from a single CASE? Fix the design in words, then sketch the matching ladder networks.
Reveal the answer and why
The final state is 20: the second IF sees State=10 written by the first. A single CASE chooses one matching branch and does not cascade into the next branch. The paired-language fix is to evaluate every transition from the unchanged current State, write NextState, then commit once. State your priority rules and decode outputs in the same place in both languages.
CAPSTONE / REQUIREMENTS TO EVIDENCE
Capstone: transfer cell with a fault that stays visible
Extend the timed transfer example above into a four-state virtual cell: 0 Idle, 10 Feed, 20 Complete, 90 Fault. Use the station-clear start rule. During Feed, AtStation must qualify continuously for 500 ms. A separate 5 s travel watchdog detects a transfer that does not finish. These values are exercise parameters, not recommendations for real machinery.
Write the contract before the code
- Call StartEdge, a new AckEdge and both timer instances every cyclic call. Keep each instance separate and persistent.
- Evaluate transitions from the current State. Commit NextState once. Decode all outputs after that commit.
- ConveyorCmd is TRUE only when StopOK is TRUE and committed State=10. CompleteLamp is TRUE only in State=20; FaultLamp only in State=90.
- Watchdog IN is StopOK AND State=10. Its duration includes the stable-arrival delay. Arrival-timer IN is StopOK AND State=10 AND AtStation.
- Fault is latched in State=90 even though leaving Feed resets the timers. A normal stop must not erase an existing fault.
| Current state | Decision in priority order |
|---|---|
| 90 Fault | Stay Fault. A fresh Ack edge with StopOK TRUE and AtStation FALSE returns Idle. This never starts a transfer. |
| Invalid state | Enter Fault; output decode keeps conveyor off. |
| 0, 10 or 20 with StopOK FALSE | Return Idle; conveyor off. This priority wins over a simultaneous timeout. |
| 0 Idle | Fresh Start edge AND station clear → Feed; otherwise stay Idle. |
| 10 Feed | Watchdog done → Fault; else arrival delay done → Complete; else remain Feed. Timeout wins if both are observed TRUE together. |
| 20 Complete | Fresh Ack edge → Idle; otherwise remain Complete. |
For this exercise initialize State=0 and edge memories FALSE, with Start and Ack initially FALSE. Startup/retentive behavior and a held input at first execution need their own specification; this lab is not a machine-safety design.
Fault injection and acceptance
- Normal: clear station, new Start, arrival stable for 500 ms, new Ack. Repeat three times.
- Occupied start: Start while AtStation=TRUE. Remain Idle; clearing the station with Start held must not start.
- No arrival: hold AtStation=FALSE through 5 s of Feed. Enter Fault, conveyor off, FaultLamp on.
- Chatter: interrupt arrival before 500 ms. Qualification resets; watchdog continues while Feed remains active.
- Fault persistence: drop StopOK, release it, and clear the sensor after a timeout. Fault remains until the specified new Ack.
- Held acknowledgement: hold Ack before the fault. It must not acknowledge the later fault; release and press again under valid conditions.
- Interrupted cycle: stop during Feed. Return Idle without a completion; restore permits with Start held and verify no new start.
- Boundary: inject both timer-done conditions on the same transition evaluation. Fault must win.
- Invalid state: in a disposable simulation, begin at 99. Enter Fault with conveyor off.
Review rubric: prove it instead of counting green lights
For each test record: starting state, input sequence/timestamps, expected next state and outputs, observed result, and defect/fix. Check the timer outputs before the transition calculation, then confirm that output decode uses the committed state. A cleared watchdog is not evidence that its fault should clear.
Mastery gate: every test passes twice, the second run is not copied from the first trace, and you can explain why each transition has its priority. If a test fails, keep the failed evidence and rerun the whole affected group after repair. This is self-assessed practice, not certification or authorization to modify production equipment.
Portfolio handoff: keep a clean simulation-only project, tag contract, state diagram, test sheet and a one-page explanation of one defect you found. Remove workplace names, real addresses and private machine data before sharing it.
Move on when: you can solve the independent variant in both representations, explain the edge cases, and fix any error without copying. A correct guess is a review item.