Project

Implement control logic of a “washing machine” using Stateflow & Make a Simulink chart for the “Gear shift” logic.

Aim:-

  1. To implement control logic of a “washing machine” using Stateflow as per given sequence
  2. Make a Simulink chart for the “Gear shift” logic.

Introduction:-

State Flow- State Flow is a technique to convert a flow-chart or logic into a systematical arrangement.
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.

Stateflow enables you to design and develop supervisory control, task scheduling, fault management, communication protocols, user interfaces, and hybrid systems.

State Machine- Model of systems whose behavior can be modeled as a set of states and transitions between states. These systems are sometimes called reactive systems.

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.

A Stateflow chart is a graphical representation of a finite state machine. States and transitions form the basic elements of the system. You can also represent stateless flow charts.

States- Stages include used in a system, or operating modes of the system

#Part-1:- control logic of a “washing machine"

Objective:-

Using the control logic of a “washing machine” in a 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

Procedure:-
States of Washing Machine includes-
After providing the electric supply and Check for the water availability...
1. Soaking- Soaking the clothes into the water for 200 seconds as per the requirement.
2. Washing- Motor runs forward and backward direction to wash the clothes 100 seconds.
3. Rinsing- Draining of water from the washing machine for 20 seconds.
4. Drying- After Draining of water, a Dryer is used for 50 seconds to dry the clothes.

For the above processes, I am using the State Flow chart method,
- As per the requirement, I am using two inputs, one is Power supply and the other is Water supply to check the given condition.
- I use 2 slider switch to switch on/off the power & water supply and connect to the constant block to provide the conditions to the washing machine by toggling the switches
- In the state flow chart, we first apply the condition for the Motor_on by putting 'power==1'
we check the power supply here, if it is off then the process is terminated if it is on then it moves to the other process.
- In the next process, I made a logic to check the water availability, if there is no water condition[water==0], it shuts the process by reaching the termination block, and if the water is available[water==1], it proceeds to the other processes.
- After fulfilling the condition of water supply, all the process proceeds one by one with given time delays, for time delay, I use after() command/condition.
For Soaking(200 sec), Washing(100 sec), Rinsing(20 sec) & drying(50 sec).
- After completing all the stages, it goes to the termination block.
- The logic is made in such a way that if there is any false input condition provided, it shuts the process and terminates the system.

Simulink- State Flow Chart
-Logic of Washing Machine-

Variable Chart- In Symbol Pane, we can assign what are the inputs and outputs in the logic


1. Condition when both, the power supply and water supply are off.

2. Condition when the power supply is on and the water supply is off.

3. Condition when both, the power supply and water supply are on.

#Part:-2- Make a Simulink chart for the “Gear shift” logic.

Objective:-

1. Make a Simulink chart for the “Gear shift” logic as per below conditions:

Speed Range(km/h) Gear

0 to 15 1

16 to 25 2

26 to 40 3

41 to 60 4

Above 61 5

2. Give speed input while the simulation is running & display the gear number.

Procedure:-
-In this Gear shifting case, we need to provide a continuous variable value for the input as a speed, for that, I use a Slider block as an accelerator for the speed change.
-As per our Requirement, we need to display the gear number to be visible on the Display block at the time of acceleration, so I use infinite time(inf) for compilation and change the speed manually on the Slider block.
- I configure the slider block by providing the values min=0 max=160, as the speed pf the vehicle
- Same values I configure to the Gaude block (speedometer), to show the input.
- I use Lamp block to show if the system is on or off, for economy mode, and for the Overspeed.
- For the Overspeed, I use an image to pop up as a sign of over speed on the MultiStateImage block.

Slider Block Configuration-

Gauge Block Configuration-

- Both Slider Block & Gauge Block is connected to the input (accelerator), slider block will be used to determine the speed and the Gauge block displays the speed
- I use the Toggle Switch block to connected to the input to on/off the system.
- As per the requirement, the gear number should be visible as the speed changes, for that I use Display block as the result.

Simulink Model when the system is OFF-
-Here I use the condition as, if there is suplly==0, it follows the condition is true and it flows the circuit to Engine off

Simulink Model when the system is ON
- Here I use the condition as, if there is suplly==1, it follows the condition is true and it flows the circuit to Engine ON
- Green lamp is pop up when is system is ON

State Flow Chart or the logic used in the system
- In State Flow Chat the logic I used
- As per the requirement, after providing the supply, I provide the condition as if the speed is greater than and equal to a particular speed it will change the gear block, so on increasing/ decreasing the speed as an input, it proceeds to the next stage.
- I added a stage to show the economy mode on a particular speed range. In that particular range of 50 to 80 speed, it blinks the green light on the lamp as output.
- Same concept I use to show the Overspeed sign on exceeding the speed above 120.
- I use MultiStateImage block to popup the display the alert sign on overspeeding the limit.




Variable used in logic


Shifting Gears-
-I put the run time to infinite(inf), we can change the speed while the simulation is running, On putting the engine condition ON, we change the speed limit on the slider block. as pe given speed range

Speed Range(km/h) Gear

0 to 15 1

16 to 25 2

26 to 40 3

41 to 60 4

Above 61 5

- To provide the above condition and get the gears as result, the speed should lie in between the range for the particular gear.
- On Sliding the Slide bar(for increasing/decreasing the speed), below are the output we get.

Model showing Gear 1 for speed range 0 to 15

Model showing Gear 2 for speed range 16 to 25

Model showing Gear 3 for speed range 26 to 40

Model showing Gear 4 for speed range 41 to 60

Model showing Gear 5 for speed range Above 60

Model showing Economy Mode in range of 50 to 60
- I provided a stage on which, lamb block shows the green light as output, which resembles the economy mode.
- This economy mode lies in the 4 & 5 gear. so it popup green light on the lamp on both the gear.
.


Model showing Overspeed warning
-
I use a new stage for showing the Overspeed warning on exceeding the 120 speed.
-The Warning, as a result, is shown on the MultiStateImage as output, and the red color on the lamp block

Learning Outcome:-
- To understand the basics of State Flow, State machines, Stages of the system.
- We learn How Logic is made and apply the condition to fulfill the requirement.
- We learn the Logic used in Processing the washing machine.
- We learn the Logic used in Shifting the gear on changing the speed.

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.