Week - 4
- 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 next 20s & dryer runs for 50s
After all the processes have completed turn on the finished LED
Solutions:
Blocks Used:
1. Chart, 2) Display 3) Constant 4) Lamp 5) Rocker Switch
Logic Explanation: A Rocker Switch from the dashboard library is used with a constant to supply the power and as water supply, A Lamp is used to indicate the power staus and water status. The power status is checked at the entry for every state and the water supply is checked for the soaking and the rinsing process. The timming for each state is as per the given inputs, The status of the running process can be seen by the glowing lamp corresponding to the process name.
Washing Machine Logic:

In the above control logic first state is created with 2 conditions for power supply.
One is with power supply available (PowerSwitch==1) and second with water supply available (W==1)
If the power supply at entry is 1 and water supply is on, then machine wil get activated and start the next process of operation
Next 4 Opeartion states have been created in flow order Soaking, Washing, Rinsing, Drying with their time of operation as 200 sec for soak, 100 sec, for wash, 20sec for rinse & 50 sec for dry, Entry and Exit condition of the state are kept as o & i.e. ar entry of operation states it is o and as operation it is 1 for every states
After all the process has done washing machine completed LED wil glow and we can shut the machine Off.
SYYMBOLS PANE:

Here, Power Switch and water supply is as input given while all the other like washing_State D( Dryer), Wa ( Washing), S (Soaking), R (rinsing), Washing_completed are all ouput given
Complete SImulink Model, Showing that the Washing process is completed.

OUTPUT:
Here all LED glown as Green means all Process has been completed and all display output as Model Showing that washing process is completed & Rinsing is going on.

Red lamp indicates Operation is not completed and Green LED shows operation is completed which is also check from display box as output.
CONCLUSION: A Control Logic of "Washing MAchine" using stateflow for the given sequence is implemented.
2. Make a Simulink chart for the “Gear shift” logic as per below conditions:
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.
Solution:
Process:
1. Start Simulink and create a blank model
2. Search For CHART block in the state flow category of library browser
3. Open the chart block and select the various features from the state flow window
4. Control logic for gear shift is such that it should change the gear when th speed increases of decreases automatically
5. After finishing the control logic run the stateflow and check the gear shift operation for an infinite time.
Block Used
1. Chart 2) Display 3) Constant 4) Lamp 5) Rocker Switch 6) Slider
Logic Explanation:
The speed ranges from 0 to 100 and slider is used to send the input, The 1st gear has speed values form 0 to 15 so the entry condition for the 1st gear is 0<=Speed and Speed<=15 and exit condition is when the greater than 15
Similarly for 2nd gear the entry condition is 16<=speed and speed<=25 the exit condition is when speed <16 and speed >25. In the same way for each gear, the entry and the exit condition are specified and the out is mapped to the lamp and display block.
LOGIC:

1. In the above control logic, first Engine is Started from input switch E=0/1, through rocker switch which is power switch to make engine ON. Then next Gear shift logic implemented through following states.
2. Five gear state is created with state conditio of gear (G) 1,2,3,4 and 5 respectively and their transition is connecetd with speed range condition as shown.
3. The transitions condition for the gear shift is decided as
Speed>15 Shift to G=32
Speed>25 shiftro G=3
Speed>40 shift to G=4
Speed>60 shift to G=5 when the speed is increasing from 0-60 kmph
similarly in reverse direction
Speed <60 shift to G=4
Speed<40 Shift to G=3
Speed <25 Shift to G=2
Speed <15 Shift to G=1 when the speed is decreasing from 60-0 kmph
While simulating Gear shift logic,Engine [E==1] condition given with various speed change values
SYMBOLS PANE"

Here E(Engine on/off) and Speed as the input given while all the other like Power Switch Gear First, Gear Second , Gear third, Gear Fourth Gear Fifth are all as output given.
Simulink Model at different Speeds
At Speed=72 kmph

At Speed 72 kmph which is anove 61 kmph gear 5 is implemented and Gear Fifth LED is glow green and display output as 1.
At Speed=20Kmph

At Speed 20 kmph which is above 16kmph gear 2 is implemented and Gear Second LED is glow green and display output as 1.
At Speed= 48 Kmph

At Speed 48Kmph which is above 40 Kmph Gear 4 is implemented and Gear 4 LED is glow green and display outpt as1.
Finally all the condtion simulated through state flow. and plotted chart successfully.
CONCULSIONS:
1. Thus all the Objectives were achieved successfully.
2. Similar Concepts and approach can be used to create stateflow for other systems.