Week - 4
1. AIM: To implement control logic of a “washing machine” using Stateflow as per given sequence:
- If the power supply is available, the system gets activated
- If the Water supply is not available, stop the process & indicate through LED
- Soaking time should be 200s followed by Washing time of 100s.
- Then rinsing happens for the next 20s & dryer runs for 50s
- After all the processes have been completed turn on the finished LED
INPUT MODEL: The Simulink model using Stateflow for the washing machine is shown below.


CONSTRUCTION:
- Constant: Outputs a constant specified by the 'Constant value' parameter.
- Lamp: Displays ON/OFF conditions.
- Display: Executes the output.
- Chart: Implements control logic with finite state machine
OBSERVATION:
- When Power_Supply=1 and Water_Supply=1, both the input lamps turn ON (Green) and the Soaking process takes place. Here we have taken the Stop Time=200sec

- After 200 sec, the Washing process takes place for a duration of 100 sec indicated by the output lamp (Green)

- After 300 sec, the Rinsing process takes place for a duration of 20 sec indicated by the output lamp (Green)

- After 320 sec, the Drying process takes place for a duration of 50 sec indicated by the output lamp (Green)

- At the end of Stop Time=400 sec, i.e. after all the processes have been completed, the Washing Machine OFF lamp (Green) turns on to indicate to the user that the Machine can be turned OFF now.

- When the Power_Suply=0 and Water_Supply=0, both the input lamps turn Red and none of the above processes take place.

2. AIM: To make a Simulink chart for the “Gear shift” logic as per the below conditions. Give speed input while the simulation is running & display the gear number.
| Speed Range(kmph) | Gear |
| 0 to 15 | 1 |
| 16 to 25 | 2 |
| 26 to 40 | 3 |
| 41 to 60 | 4 |
| Above 61 | 5 |
INPUT MODEL: The Simulink model using Stateflow for the Gear shift logic is shown below.


CONSTRUCTION:
- Accelerator_Reference: Outputs the constant specified by the 'Constant value' parameter which is taken as a reference to the Accelerator slider.
- Engine_Start: Outputs the constant specified by the 'Constant value' parameter. This block is assigned to constant 1 when the ignition=1.
- Speedometer: Monitors the speed of the vehicle.
- Display: Displays the gear number w.r.t speed.
- Chart: Implements control logic with a finite state machine.
OBSERVATION:
- The Ignition of the vehicle is turned ON by assigning Engine_Start=1 while the vehicle is in neutral with speed=0 as it is at a halt.

- As the speed of the vehicle varies between 0 to 15 kmph, the gear is shifted to 1.

- As the speed of the vehicle varies between 16 to 25 kmph, the gear is shifted to 2.

- As the speed of the vehicle varies between 26 to 40 kmph, the gear is shifted to 3.

- As the speed of the vehicle varies between 41 to 60 kmph, the gear is shifted to 4.

- As the speed of the vehicle goes beyond 60 kmph, the gear is shifted to 5.
.