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.
Procedure:
In simulink click on charts and the interface appears where we need to write the control logic.
According to the given sequence and time, the state flow is as below.

Here we need to give 2 inputs and get 7 outputs.
Inputs: 1. power supply, 2. water supply
Outputs: 1. Power1 2. water, 3.soak, 4.wash, 5.rinse, 6.dry, 7.End

If the process output is 1 then the process is completed and 0 if it is to be done.
The block diagram is as follows.

We need to connect the output ports to the display to get the result, also lamp is conncetd to know whether the process is completed.
The input ports are connected to the slider switch for ON/OFF mode selection.
Lamp Connection:

When we double click on the lmap we can set the lamp colour according to the output signals. We are also required to select the input signal and click on apply. This is done for all the other signals also.
Slider switch:

We need to select the input signal for the block and also set the labels.
State1 - When the power supply is OFF
In this state the process doesn't take place.

State2 - When the water supply is OFF
In this state we observe a redlight at the water supply indicating its absence. In this case the other process are not completed as can be seen through the red lamps.

State3 - When power supply is ON and water supply is also ON.

All the process is completed as can be seen through the green lamps. The end of the whole process is indicated by a blue light at the end point.
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.
Procedure:
We need to create a chart and according to the conditions we need to design the state points where the input is speed and the output is the gear number. The chart is as follows.

We need to give the input speed for which we connect the slide block and also a key block to switch ON/OFF the engine. We also connect lamps to indicate in which gear the vehicle is running.
The connection is made as below.

When the vehicle is ON, according to the given speed input the gear of the vehcile changes. The lamps at the gear numbers are adjusted according to the output signal.

State1 - When the speed is less than 15 kmph
We see here at low speed the car is in gear 1.

State2 - When the speed is between 15 and 25 kmph
We see here at this speed the car is in gear 2.

State3 - When the speed is between 25 and 40 kmph
We see here that at this speed the car is in gear 3

State4 - When the speed is between 40 and 60 kmph.
We see here that at this speed the car is in gear 4.

State5 - When the speed is greater than 60kmph.
Here at this speed the car is in gear 5.

Hence according to the logic as the speed of the vehicles increased the gear on the which in which the vehicle should drive also increases.