Week - 4
Week 4 Challenge:
Q1.
Aim: Implement control logic of a “washing machine” using Stateflow in Simulink.
Objective:
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
Explanation:
- First I use a stateflow chart. Then open this chart. Then first put default state condition. Then put all the condition according to question.
- Outside the chart I used Simulink slider switch. Slider switch connected with constant block. First switch for power_supply and second switch for water_supply.
- All the output connected with display block. All the display connect with lamp for indication.
- All the output signal is propagated signal.

Fig 1: Block diagram of washing machine using stateflow chart.

Fig 2: Inside the stateflow model chart diagram.
Output AND Input signal:

Fig 3: water, soak, washing, rinsing, dryer, cycle use as a output signal. Power_supply and water_supply is input signal.
Simulation time of model:

Fig 4: I set the 430 sec for as simulation stop time. 430 sec sufficient for cover the total cycle.
OUTPUT:
There are two conditions –
Condition 1:
First I should not provide water supply. Water_supply switch off this condition. Power_supply is ON in this condition.

Fig 5: When water_supply is off then cycle is not completed in this condition . cycle is zero state in this condition. If cycle is completed then showing green light. First condition is satisfied.
Condition 2:
Second condition is water_supply in ON state.

Fig 6: when water_supply is ON state then cycle is showing green light ,that means washing machine all the process is completed. that’s why all the process showing RED light and cycle is showing GREEN light. This condition also satisfied.
Conclusion:
- This Simulink model made by stateflow chart and all the given conditions are satisfied.
Q2.
Aim: To make a stateflow model for gear shift logic.
Objective: 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.
Explanation:
- First I used a stateflow chart. Then open this chart block. Then first put default state condition. Then put all the condition according to question.
- Outside this chart as a input I was connected constant block and slider gain block. Then as a output I was connected display block
- Display block connect with lamp.

Fig 1: Block diagram of Gear shift using stateflow chart.

Fig 2: Inside the stateflow model chart diagram.
Output AND Input signal:

Fig 3: Here I give speed as a Input.
Here I give gear as a Output.
Simulation time of model:

Fig 4: here I simulation stop time is set Inf , for simulation is running when I will stop.
INPUT:

I am changing my speed values from 0 to 100 using slider gain during simulation.
OUTPUT:
According to speed as a output gear no. showing in display block and lamp indicate corresponding color for gear.
Gear 1:
- Speed Range: 0 to 15 Kmph.
- Input speed: 10 Kmph
- Lamp color: Green

Gear 2:
- Speed Range: 16 to 25 Kmph
- Input speed: 20 Kmph
- Lamp Color: Blue

Gear 3:
- Speed Range: 26 to 40 Kmph
- Input Speed: 30 Kmph
- Lamp Color: Red

Gear 4:
- Speed Range: 41 to 60 Kmph
- Input Speed: 50
- Lamp Color: Orange.

Gear 5:
- Speed Range: Above 60 Kmph.
- Input Speed: 65 Kmph.
- Lamp color: Purple.


Fig 5: According to speed Gear Shifted in reverse also.
Conclusion:
- Creating a Gear shift model using stateflow chart, all the input conditions are satisfied.