All exercises

Coffee Machine Control

Control a coffee machine via a 5-state machine: Idle, Heating, Grinding, Brewing, and Ready.

intermediate

Parameters

NameTypeUsageDescription
In_StartButtonBOOLInputInput to start the coffee machine process.
In_ResetButtonBOOLInputInput to reset the machine to Idle state and clear all outputs.
In_WaterHeatedBOOLInputIndicates the water heating process is complete.
In_GrindDoneBOOLInputIndicates the coffee grinding process is complete.
In_BrewDoneBOOLInputIndicates the coffee brewing process is complete.
Out_WaterHeatingBOOLOutput1 when the machine is heating water.
Out_GrinderRunningBOOLOutput1 when the grinder is running.
Out_BrewingBOOLOutput1 when the machine is brewing coffee.
Out_CoffeeReadyBOOLOutput1 when the coffee is ready.

Behavior

  1. If In_ResetButton is 1, set State to 0 and all outputs to 0.
  2. If State is 0, all outputs are 0; if In_StartButton is 1, set State to 1.
  3. If State is 1, set Out_WaterHeating to 1 and all other outputs to 0; if In_WaterHeated is 1, set State to 2.
  4. If State is 2, set Out_GrinderRunning to 1 and all other outputs to 0; if In_GrindDone is 1, set State to 3.
  5. If State is 3, set Out_Brewing to 1 and all other outputs to 0; if In_BrewDone is 1, set State to 4.
  6. If State is 4, set Out_CoffeeReady to 1 and all other outputs to 0; remain in State 4 until reset.

Edge Cases

  • In_ResetButton pressed during any state.
  • Inputs arriving simultaneously with state transitions.
  • Incorrect input sequences (e.g., In_BrewDone before In_GrindDone).

Constraints

  • State transitions must be prioritized such that In_ResetButton overrides all other state transitions.
  • The AOI must maintain State as an internal integer for the state machine.

Ready to start?

Open this exercise in Rungs Studio, write your solution, then click Test in the toolbar to verify your work against the built-in test cases.