Week - 4
AIM: 1) To implement the control logic of a “washing machine” using Stateflow according to given conditions.
2) To build a Simulink chart for the “Gear shift” logic according to conditions.
CONDITIONS:
1) For Washing Machine:-
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 a Washing time of 100s.
Then rinsing happens for the next 20s & the dryer runs for the 50s
After all the processes have completed turn on the finished LED
2) For Gear Shifter:-
Speed Range(kmph) Gear
0 to 15 1
16 to 25 2
26 to 40 3
41 to 60 4
Above 61 5
Give speed input while the simulation is running & display the gear number.
1) WASHING MACHINE MODEL:-
To create a flow chart in Simulink, basically, the 'chart' block is used. When the chart block is opened, it appears in a different environment than that of a regular one which contains various commands which can be used to build a flowchart according to conditions.
Here, to build a washing machine Stateflow chart, 'state' blocks are used to execute each condition. First of all, 2 state blocks are used with names 'Power' and 'Water'. According to the basic working of the washing machine, two input variables are created for power supply and water supply with the name 'Power_supply & Water_Supply' respectively. For both the inputs, some conditions are applied in terms of constant 0 & 1 to execute the whole flow chart. If the condition is equal to 1, then the flow will continue to complete the task and if the condition is equal 0 then the loop will be terminated using the 'junction' provided in the chart. The constants 1 & 0 will work as ON & OFF conditions for the machine respectively.
Now, 5 state blocks are used out of which 4 are for processes that are to be done on the cloths and 1 for ending the task condition. The 4 processes are - Soaking(for 200 sec), Washing(for 100 sec), Rinsing(for 20 sec), Drying(for 50 sec). Here timings are assigned using the 'after' condition which acts as a delay period for the next block
Once the condition for the ON state is satisfied for both power supply and water supply, 4 processes will execute further according to distributed time for a total of 370 seconds, and at the last End_Task state block will execute to end the whole process. Also, entry and exit parameters will use to recognize the on-off conditions through the lamp.
Finally, all the variables are assigned for different conditions of the states are taken as output to the chart which is provided display block. The lamps are connected to each variable for denoting the particular conditions/processes assigned to it.
Stateflow Chart:

INPUTS:
Here two inputs 'power supply and water supply' are provided through constant blocks that can be controlled by a toggle switch for ON-OFF purpose.
OUTPUTS:
For Condition 1:- When power supply = 1 and water supply =1

After completing the all processes, End LED will be on which is acts as a finished LED.
Complete Process:-
1) Power Supply Off.

2) Water supply ON.

3) Process of Soaking for 200 sec.

4)Process of washing for 100 sec.

5)Process of Rinsing for 20 sec.

6) Process of Drying for 50 sec.

7) Process will finish.

For Conditions 2:- When power supply = 1 and water supply = 0

In this condition, the loop will be terminated using the junction as there is no water supply for further execution.
Complete Process:-
1) Power supply ON.

2) Termination of the further loop due to unavailable water supply.

2) GEAR SHIFTER MODEL:
For the gear shifter model, 5 state blocks are used and every state is provided with a gear number that will act according to the speed limit condition. By providing different speeds, the respective gear number will be shown in the display block, and LED will on with different colors after the change of a particular gear.
Here two consecutive state blocks are connected with reversed connection to set the limits for speed. For Ex; for a speed range of 0 to 15, gear 1 will be active. When the speed will increase above 15, the gear will change to 2, but if the speed will be decreased below 15 then again gear will be changed to 1. Same process will happen for all the states with a change in speed.
Stateflow Chart:-

OUTPUTS:
1) For speed 0 to 15 - The 1st gear will be used.

2) For speed 16 to 25 - The 2nd gear will be used.

3) For speed 26 to 40 - The 3rd gear will be used.

4) For speed 40 to 60 - The 4th gear will be used.

4) For speed greater than 61 - The gear will switch to 5

CONCLUSION: From the washing machine model, it is concluded that the control logic is implemented with the help of the Stateflow chart for various conditions applied. Also, the gear shifter model is built for different speed range and gear number is displayed according to limits.