Challenge

Week - 4

Implement control logic of a washing machine & Gear Shift using Stateflow

Aim:

  1. To Simulate State flow model of a Washing Machine.
  2. To simulate a state flow model of a Gear Shift logic.

Objectives:-

1 . 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

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.

1 . Implement control logic of a “washing machine” using Stateflow

Theory:

A washing machine is an electronic system used to wash laundry. The term is mostly applied to machine that use water as opposed to dry cleaning.

State flow logic of Washing Machine:

State flow provides the graphical language to describe MATLAB algorithms and Simulink models should react to input signals, events and time based conditions. State flow enables us to design and develop control, task, scheduling, and user interface & hybrid systems.

Model:-

Stateflow:-

Symbol pane:-

Power and water are given as input data.

S,W,R,D and E are given as output data.

Blocks Used :

1 . Slider switch

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

2 . 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.

3 . 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.

4 . Constant

The Constant block generates a real or complex constant value signal. Use this block to provide a constant signal input.

5 . Lamp

The Lamp block displays a color 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 colors to provide the information you want during the simulation.

Description:-

  1. Power and Switch inputs were controlled by the Switch block. These two inputs were directed to the Chart block.
  2. State blocks were used inside charts to create a stateflow according to the given criteria.
  3. The POWER input is get as input in the chart and directed to the POWER State from there, if Power==1(Which is power supply in ON), it is directed to the next WATER block. or if Power==0(Power supply is OFF), it directed to the junction.
  4. {S=2,W=2,R=2,D=2,E=2}this are the condition given to power supply if the power is 0(OFF) then show the output value as 2 so it will help us to display grey color beacuse we given grey color of lamp for the value 2.you can see in figure below.
  5. Next state is WATER and from that if Water==1(Water supply is ON) it moves to the next stage or if Water==0(Water supply is OFF) then it is directed to the junction.
  6. Next to water is Soaking state, entry is given as 0, while exit for LED made to glow which is connected to the state.
  7. After 200 sec it is directed to Washing state, after another 100sec it is directed to Rinsing state, after another 20sec directed to Drying state and after another 50sec it is ended to End state.

When Power supply is OFF and Water Supply is OFF, the state of the washing machine is as shown below:

When Power supply is ON and Water Supply is OFF, the state of the washing machine is as shown below:

When power supply is ON and water supply is ON, cycle time = 200s, the soaking process is as shown below:

After all the processes are completed, the model is as shown below:

2 . Make a Simulink chart for the “Gear shift” logic

Theory:

Manual transmission or a manually operated gearbox is a vital element of an automobile. This gearbox sits after the engine of the automobile and is responsible to regulate the speed and the torque supplied to the transmission shaft. This type of manual gearbox is generally used to regulate the revolutions of the engine. The gearbox helps the automobile to move forward, move backward and shift into neutral before starting the engine.

Model :

here,all the engine components is in off condition beacuse engine is OFF

Stateflow:

Symbol pane :

here, ignition and speed as input and G(gear) is the output

Blocks used

1 . Rocker switch

The Rocker Switch block toggles the value of the connected block parameter between two values during simulation. For example, here we use this switch to connect with ignition (constant block)and so lamp will react according to the value and condition we given.

2 . 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.

3 . 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.

4 . Constant

The Constant block generates a real or complex constant value signal. Use this block to provide a constant signal input.

5 . Lamp

The Lamp block displays a color 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 colors to provide the information you want during the simulation.

6 . Slider

the slider block is use for the manually change the value according to our requirment here we connect it with the constant so when we change the value of slider then constant is also change.

7. Circular guage

the circular guage is show us the input value when we give connected it with the some signal in our case we connected it with the speed constant. You can modify the range and tick values on the Circular Gauge block to fit your data. Use the Circular Gauge block with other dashboard blocks to build an interactive dashboard of controls and indicators for your model.

Description:-

Speed is a constant value, so we can use a constant block to input the value which is not dependent on the time variation. To change the value of the speed, we can use a slider gain and speed constant is connected with circular guage so it will help us to visualize the speed and its work like speedometer in our case. when we change the value of the input speed that we give to the state flow logic and it should be displayed using a ‘Display’ block.

  • In the above control logic , first Engine is started from input switch ignition=0/1 through Rocker switch which is power switch to make engine ON or OFF.Then next Gear shift logic implemented through following states.
  • Five Gear State is created with state condition of gear (G) 1,2,3,4and 5 respectively and their transition is connected with speed range condition as shown.
  • The transitions condition for the gear shift is decided as,Speed>0 shift to G=1, Speed>15 shift to G=2, Speed>25 shift to 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 , ignition==1 condition given with various speed change values.

here,we only started the engine so engine light show green colour and speed is 0.

1st Gear:- when the speed is above 0,it shifts to the first gear and the lamp for 1st gear is on

2nd Gear:- when the speed is above 15,it shifts to the second gear and the lamp for 2nd gear is on

3rd Gear:- when the speed increases more than 25,it shifts to 3th Gear.

4th Gear:- when the speed increases more than 40,it shifts to 4th Gear.

5th Gear:- when the speed increases more than 60,it shifts to 5th Gear.

CONCLUSION:-

  1. The state flow model for the washing machine is simulated successfully.
  2. The state flow model for the gear shift logic is simulated successfully.
  3. Similar concepts and approach can be used to create stateflow for other systems aswell.
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.