NivaarExam PrepOfficial exam papers ↗

19-Soft-A4 Real-Time Systems · May 2013

Question 5 of 6: State-Transition Design of a Household Washing-Machine Controller

Nivaar worked solution (AI-drafted; not reviewed by a licensed engineer)

Notes on this paper

National Exams — May 2013 — 04-Soft-A4 Real-Time Systems. Three-hour, closed-book exam (Casio or Sharp approved calculators only). Format: six questions of equal value (20% each); any five constitute a complete paper and only the first five as they appear in the answer book are marked. All six are solved below for completeness. Where a doubt exists as to interpretation, the candidate is expected to state assumptions — engineering assumptions used below are flagged in check callouts.

Reference texts: Jane W. S. Liu, Real-Time Systems (Prentice Hall, 2000) — task models, timing requirements, FCFS and EDF scheduling; Giorgio C. Buttazzo, Hard Real-Time Computing Systems: Predictable Scheduling Algorithms and Applications (Springer, 3rd ed.) — preemptive dynamic-priority scheduling and the optimality of EDF; Hermann Kopetz, Real-Time Systems: Design Principles for Distributed Embedded Applications (Springer, 2nd ed.) — distributed real-time control, network-induced delay and time-triggered protocols; Katsuhiko Ogata, Modern Control Engineering (Pearson, 5th ed.) — frequency-domain stability, phase margin and delay margin; Ian Sommerville, Software Engineering (Pearson, 10th ed.) — general software-engineering process context.

Question 5: State-Transition Design of a Household Washing-Machine Controller (20%)

Question text not reproduced: the examination questions are © Engineers and Geoscientists BC. Open the official past paper (linked at the top of this page) to read the question, then follow the worked solution below.

Part (1) — state-transition diagram. Figure 5 models the controller as six states: Idle/Load → Ready (lid closed, start pressed) → Fill (inlet valve open) → Wash (agitate) → Drain → Spin → back to Idle, plus a safety exception edge from Spin directly to Drain.

Idle /Load clothesLid closed,start pressedFill(inlet open)Wash /spin agitateDrainSpin(high speed)lid closed &start pressedlevel sensorreaches set pointfill complete,valve closeswash timerexpireslevel sensor= emptyspin timerexpires ->return to Idlelid openedwhile spinning:stop motor,force Drain
Figure 5 — washing-machine controller FSM. The dashed red edge is the safety-interrupt transition analyzed in Part (4).

Part (2) — transition conditions. Each normal edge fires on a distinct sensed condition:

TransitionCondition
Idle → ReadyLid closed AND start button pressed
Ready → Fill(immediate, sequence entry)
Fill → WashWater-level sensor reaches set point → inlet valve commanded closed
Wash → DrainWash-cycle timer expires
Drain → SpinWater-level sensor reads empty
Spin → IdleSpin timer expires (cycle complete)
Spin → Drain (exception)Lid-open sensor trips while the drum is spinning

Part (3) — sensors needed. An embedded real-time controller for this machine needs: a lid-closed/open switch (safety interlock); a water-level sensor (pressure or float switch, to detect both "full" and "empty"); a door/lid lock-solenoid feedback sensor (confirms the lid is mechanically locked before spin, not just closed); a motor tachometer or Hall-effect speed sensor (confirms actual drum speed, needed to know when it is safe to unlock the lid); a temperature sensor if the model heats water; and a real-time clock/timer source driving each state's dwell time (wash duration, spin duration).

Part (4) — chosen condition: lid opened while spinning. This is the safety-critical exception in Figure 5. The controller's response, in strict order and within a bounded worst-case time:

  1. Interrupt priority. The lid-open sensor is wired to the highest-priority interrupt in the system, pre-empting the Wash/Spin control task immediately — it is not polled on the normal control-loop period, because a high-inertia drum spinning at full speed is a physical hazard the instant the lid is open.
  2. Cut power to the drive motor. The interrupt service routine's first action is to de-energize the motor drive (and, if fitted, apply the mechanical/regenerative brake), so kinetic energy stops being added to the drum.
  3. Force a state transition to Drain. Rather than resuming Spin, the FSM is forced into the Drain state (never directly back to Idle), because the drum may still contain standing water that must be removed before the door can be safely reopened for the user.
  4. Hold the door lock until the drum is stationary. The lock solenoid remains engaged, ignoring the lid switch's "open" reading for user-safety purposes, until the tachometer confirms zero rotational speed — this is itself a small real-time guarantee (unlock latency bounded by the drum's mechanical spin-down time), not an instantaneous action.
Check: the source gives no numeric spin-down time or interrupt-latency budget for this machine, so no specific millisecond figure is asserted for step 1 or step 4 above — the answer specifies the correct ordering and priority of actions, which is what the question asks for.