Week - 4
Q1. 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 completed turn on the finished LED
Aim:- Implementation of control logic chart for Washing Machine using Stateflow
Theory:-
- The working principle for the washing machine is "Centrifugation". Centrifugation is a separation process that uses the action of centrifugal force to promote the accelerated settling of particles in a solid-liquid mixture. The washing machine consists of a centrifuge for this purpose. A centrifuge is a piece of equipment that puts an object in rotation around a fixed axis, applying a force perpendicular to the axis of spin that can be very strong.
- A washing machine (laundry machine, clothes washer, or washer) is a home appliance used to wash laundry. The term is mostly applied to machines that use water as opposed to dry cleaning (which uses alternative cleaning fluids and is performed by specialist businesses) or ultrasonic cleaners. The user adds laundry detergent, which is sold in liquid or powder form, to the wash water.
- The requirements to run the machine are the Power Supply and Water Supply. And it performs the cleaning process of clothes by soaking, washing, rinsing and drying, and many more process

Inside the Washing machine, few processes are carried out in a successive period such as,
a) Soaking
b) Washing
c) Rinsing
d) Drying
process:-
1. Start Simulink and create a blank model.
2. Search for chart block in the Stateflow category of the library browser.
3. Open the chart block and select the junction feature from the Stateflow window.
4. Control logic for washing m/c is such that it should soak the water for the first 200sec followed by a washing time of 100sec. Rinsing the water for the next
20sec followed by a drying time of 50sec.
- After finishing the control logic run the STATEFLOW and check the sequence of operation for 370sec.
Blocks Used:-
- Chart
A finite state machine is a representation of an event-driven (reactive) system. In an event-driven system, the system responds to an event by making a transition
from one state (mode) to another. This transition occurs if the condition defining the change is true.

- Display
The Display block shows the value of the input data. You can specify the frequency of the display. For numeric input data, you can also specify the format of the
display.
- Constant
The Constant block generates a real or complex constant value signal. Use this block to provide a constant signal input.
- Lamp
The Lamp block displays a colour indicating the value of the input signal. You can use the Lamp block with other Dashboard blocks to build an interactive
dashboard of controls and indicators for your model. You can specify pairs of input values and colours to provide the information you want during the simulation.


- Rocker Switch:
The Rocker Switch block toggles the value of the connected block parameter between two values during simulation. For example, you can connect the Rocker Switch block to a Switch block in your model and change its state during simulation

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 status & 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 timing 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 the water supply is on, then the machine will get activated and start the next process of operation.
The next 4 Operation states have been created in flow order Soaking, Washing, Rinsing, Drying with their time of operation as 200sec for a soak,100sec for wash,20
sec for rinse & 50sec for dry. Entry and exit conditions of the state are kept as 0 & i.e at the entry of operation states it is 0 and as operation completes it is 1 for every state.
After all, the process has been done washing machine is completed LED will glow and we can shut the machine off.
Complete Simulink Model, Showing that the washing process is completed.

Here all LED glow as Green means all process has been completed and all display output as 1.
Simulink Model, Showing that the washing process is completed & Rinsing is going on.

Here Red light means operation is not completed and the green LED shows operation is completed which is also check from the display box as output 1.
Q2. Make a Simulink chart for the “Gear shift” logic as per the 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
Aim:- Implementation of control logic for gear shift using Stateflow.
Theory:-
- A transmission is a machine in a power transmission system, which provides a controlled application of power. Often the term 5-speed transmission refers simply to the gearbox, that uses gears and gear trains to provide speed and torque conversions from a rotating power source to another device.

As shown in the above figure, Manual transmission has synchronous gears or continuously meshed gears are kept. (In Automatic Transmission Planetary gears are used) Based on the speed requirement the gear is shifted using the Gear knob, which in turn makes the collar gear get meshed with the appropriate gears. The output shaft is connected to the collar gear, hence whichever gear gets meshed with the collar gear will be the output shaft.
During the gear shifting process, the input shaft must be disengaged from the engine. This is done with the help of the clutch plate (Torque convertor in case of the Automatic Transmission).
Blocks Used:-
- Constant – The Constant block generates a real or complex constant value signal.
- Slider Gain – The Slider Gain block performs a scalar gain that you can modify during simulation.
- StateFlowChart – Stateflow provides a graphical language that includes state transition diagrams, flow charts, state transition tables, and truth tables. You can use Stateflow to describe how MATLAB® algorithms and Simulink models react to input signals, events, and time-based conditions.
- Scope – Display signals generated during simulation.
- Circular Gauge – Display an input value on a customized gauge.
- Display – The Display block shows the signal value as text.
State Flow Chart:-

Here as per the question, the gears are arranged with the condition on the speed range. For example, Speed above 0 till 15 will fall under first gear and the chart is also designated in such a way to satisfy the condition
Simulink Block:-

Here 2 input blocks are kept, one is the constant and the other is the "Slider Gain" Block. The Slider Gain block performs a scalar gain that you can modify during the simulation. The block supports fixed-point data types. The value given in the constant block get's multiplied with the Slider gain value during the simulation.
To determine the gear value required for the particular speed, a "Display" block is placed. The lamp is also placed whose parameters are set in a way that for each gear it will produce individual colours. The colour inputs are shown below

Results:-
a. For the First Gear Speed 0 to 15 kmph.

b. For the Second Gear Speed 16 to 25 kmph.

c. For the Third Gear Speed 26 to 40 kmph.

d. For the Fourth Gear Speed 41 to 60 kmph.

d. For the fifth Gear Speed above 61 kmph.

The Following Graph shows the simulation for the gear changes according to their speed.
