All exercises

Sandwich Maker

Control a sandwich assembly process based on bread presence and multiple ingredient sensors.

intermediate

Parameters

NameTypeUsageDescription
In_BreadFeederBOOLInput1 when bread is detected.
In_Ingredient1BOOLInput1 when ingredient 1 is present.
In_Ingredient2BOOLInput1 when ingredient 2 is present.
In_Ingredient3BOOLInput1 when ingredient 3 is present.
In_Condiment1BOOLInput1 when condiment 1 is present.
In_Condiment2BOOLInput1 when condiment 2 is present.
Out_ConveyorMotorBOOLOutput1 when conveyor motor is active.
Out_AssembleMotorBOOLOutput1 when assembly motor is active.

Behavior

  1. On the rising edge of In_BreadFeeder, the internal SliceCount is incremented by 1.
  2. Out_ConveyorMotor is set to 1 while In_BreadFeeder is 1.
  3. Out_AssembleMotor is set to 1 if SliceCount is greater than or equal to 2 AND In_Ingredient1 is 1 AND In_Ingredient2 is 1 AND In_Ingredient3 is 1 AND In_Condiment1 is 1 AND In_Condiment2 is 1; otherwise, it is 0.

Edge Cases

  • SliceCount should not increment if In_BreadFeeder is continuously 1.
  • Out_AssembleMotor stays 0 if any ingredient sensor is 0 even if SliceCount >= 2.

Constraints

  • SliceCount must be initialized to 0.
  • SliceCount should persist across AOI scans.
  • BreadFeederPrev must store the state of In_BreadFeeder from the previous scan for edge detection.

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.