Week - 4
PROJECT NAME – CONTROL LOGIC OF WASHING MACHINE & GEAR SHIFT MECHANISM USING STATEFLOW
AIM -
- Implement control logic of washing machine using Stateflow by giving certain conditions as per power input & water input. As per this input, machine operates and obtain output by lamp light.
- Create the Stateflow for gear shift & vary the speed as input and obtain the output as gear number in display.
OBJECTIVE –
- To implement control logic of washing machine using Stateflow as per given sequence.
-If the power supply is available, the system gets activated.
-If the power supply is not available, stop the process and indicate through LED.
-Soaking time should be 200 seconds.
-The rinsing happens for next 20 seconds and dryer runs for next 50 seconds.
-After all the processes have completed turn ON the finished LED.
- 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 |
|
61 above |
5 |
Give speed input while the simulation is running and display the gear number.
Stateflow - Stateflow provides the graphical language that includes state transition diagrams, flow charts, state transition tables, & truth tables. It is used 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 interface & hybrid systems. with stateflow, you model combinatorial & sequential decision logic that can be simulated as a block within a Simulink model or executed as an object in MATLAB. Graphical animation enables you to analyse & debug your logic while executing. Edit time & run time checks & ensures design consistency and completeness before implementation.
Control Logic – Control logic is a key part of a software program that controls the operations of the program. The control logic responds to commands from the user & it also acts on its own to perform automated tasks that have been structured into the program. Controlled logic can be modelled using a state diagram, which is a form of hierarchical state machine.
SOLUTION – (theory)
A Washing machine is a home application used to wash laundry. The term is mostly applied to machines that use water as opposed to dry cleaning or ultrasonic cleaners. The user adds laundry detergent, which is solid in liquid or powder form, to wash the clothes in the water.
Washing machines are generally of 2 categories as follows-
- Semi –Automatic Washing Machines –
The semi-automatic is needed for your assistance to get the job done & you will have to pour the water manually and need to set up the timer.
- Fully – Automatic Washing Machine –
The fully automatic washing machines are more convenient & offer a great range of functionality. Yopu get fully automatic functions the carry out the washing without any manual interference. They are a little bit budget friendly and to purchase you don’t have to pay hefty amount of money.
Fully Automatic washing machine is further divided into two parts-
3.Front Load Washing Machine –
You get front doors to put load into the drum & the drum washes, rinses & spins the laundry. Here you see the different working principle, the clothes are tossing from one direction to the other as the drum itself is moving. Most of the front load washing machine uses agitator washing style to rinse & wash the clothes.
4.Top Load Washing Machine –
In this machine you load the washing machine from top & the drum does not move from one direction to the other but the base of the machine rotates and moves the clothes thoroughly. Here, the machines base takes clockwise & anti-clockwise rotation to fully wash the dresses.

Working of Washing Machine -
|
1. All the important parts of the clothes washer are electrically controlled, including the inner drum, the valves, the pump, and the heating element. The programmer is like the conductor of an orchestra, switching these things on and off in a sensible sequence that goes something like this: |
|
|
2. You put your clothes in the machine and detergent either in the machine itself or in a tray up above. |
|
|
3. You set the program you want and switch on the power. |
|
|
4. The programmer opens the water valves so hot and cold water enter the machine and fill up the outer and inner drums. The water usually enters at the top and trickles down through the detergent tray, washing any soap there into the machine. |
|
|
5. The programmer switches off the water valves. |
|
|
6. The thermostat measures the temperature of the incoming water. If it's too cold, the programmer switches on the heating element. This works just like an electric kettle or water boiler. |
|
|
7. When the water is hot enough, the programmer makes the inner drum rotate back and forth, sloshing the clothes through the soapy water. |
|
|
8. The detergent pulls the dirt from your clothes and traps it in the water. |
|
|
9. The programmer opens a valve so the water drains from both drums. Then it switches on the pump to help empty the water away. |
|
|
10. The programmer opens the water valves again so clean water enters the drums. |
|
|
11. The programmer makes the inner drum rotate back and forth so the clean water rinses the clothes. It empties both drums and repeats this process several times to get rid of all the soap. |
|
|
12. When the clothes are rinsed, the programmer makes the inner drum rotate at really high speed & around 80 mph (130 km/h). The clothes are flung against the outside edge of the inner drum, but the water they contain is small enough to pass through the drum's tiny holes into the outer drum. Spinning gets your clothes dry using the same idea as a centrifuge. |
|
|
13. The pump removes any remaining water from the outer drum and the wash cycle comes to an end. |
|
|
14. You take your clothes out and marvel at how clean they are. |
|
|
15. But there's still the problem of drying your wet clothes to figure out. |
- Steps -
- Create a chart block for defining the stateflow as per the given conditions.
- Inside it, the circular junction is to terminate the signal flow and return a null value.
- If power is OFF i.e. 0, the process is terminated at the junction else 1 is carry forwarded.
- If water is OFF i.e. 0, the process is terminated at the junction else 1 is carry forwarded.
- After this, at 200 sec Soak block gets activated and soaking action takes place.
- After 300 sec of Soaking, Wash block gets activated and washing action takes place.
- After 320 sec of Washing, Rinse block & gets activated and rinsing action takes place.
- After 370 sec of Rinsing, Dry block gets activated and drying action takes place.
- After then the signal flow in the process and exits the chart.
- Define power and water as inputs whereas soak, wash, rinse, dry, finish as outputs.
- Connect the chart block with; constant blocks for power and water inputs. Input switches connected to them are slider switch and a toggle switch respectively (to distinguish between the two). Attach lamps to observe the ON/OFF condition.
- A common scope block is connected to observe the entire washing process and obtain the output plot. Blue colour in the lamp indicates that the process is complete.
- A Simulink model for operating the washing machine according to given conditions is shown below.
CONTROL LOGIC STRUCTURE -

- In the above control logic first junction is created with 2 conditions for power supply, one is when power supply is available (x > 0) and second without power supply (x == 0). If the power supply at the entry level is 1 or ON - the machine will get activated and start the next process for operation.
- Next 2 power supply state is created with 2 states with one for if Power ON (PS = 1) & another for power OFF (PS = 0).
- After the power supply state next was to select the state for water supply. Two water supply states are created with 2 states one for if water supply is on (WS =1) applicable when (y > 0) & another for water supply OFF (WS = 0) when (WS == 0).
- Next 4 operation states have been created in flow order soaking, washing, rinsing, drying with their time of operation as 200 sec for a soak, 100 sec for wash, 20 sec for rinse & 50 sec for dry. Entry and exit conditions of the states are kept as 1 because of the continuous operations of the process of the washing machine.
- After finishing all the sets of operation the power supply is changed to state PS = 0 which leads to to shut off the machine.
Symbol Pane -

Here,
X & y are input ports.
Dry, PS, Rinse, Soak, WS & Wash are output ports with an initial value of 0.
Flow Chart –
after event creation flow chart is generated using some blocks from the library and their connections are done as mentioned below
a slider switch is used from the Simulink dashboard category to switch ON & OFF the power and water supply and connected with their input supply of x & y respectively.
The display block is connected with each output of states of operation.
The lamp block is dragged from the Simulink dashboard category to represent the LED for various operation performance evaluation.
These lamp blocks are connected to their respective output port in the chart.
When the operation/process is ON it is represented by green colour indication in a lamp when the output is 1 and vice – a – versa for OFF is indicated by red colour when output is 0.

- When Power & water supply is ON & run time is 370 sec.

LED INDICATORS-

- When power supply is ON & Water supply is OFF.

- When Power Supply & Water Supply is ON & run time is 200 sec (Soak State)

- When Power supply & water supply is ON & Run time is 300 sec (Wash State)

- When power supply and water supply is ON & Run time is 320 sec (Rinse State).

- When Power Supply & Water Supply is ON and Run time is 320 sec (Dryer State).

PART II – Implementation of Control Logic for Gear Shift Using Stateflow –STUDY 2 –
GEAR SHIFT
A manual transmission also known as a manual gearbox a standard transmission or colloquially in some countries as a stick shift is a type of transmission used in motor vehicle applications. It uses driver operated clutch, usually engaged or disengaged by a foot pedal or hand lever for regulating torque transfer from the engine to the transmission and the gear selector can be operated by hand.
A conventional 4 or 5 speed manual transmission is often the standard equipment in a modern based model vehicle with 4 speed being more common in non-passenger vehicles such as pickup trucks and light commercial vehicle & higher end vehicles such as sport cars and luxury cars are often ususally equipped with 6 speed transmission for base model.
Gearbox is the second element in the powertrain in an automobile. It is used to change the speed and torque of vehicles according to the variety of road and load conditions. The transmission box changes the engine speed into torque when climbing heels and as per requirement of the vehicle & hence it is also known as torque converter.
Following are the functions of the gearbox-
- Provide the torque needed to move the vehicle under the variety of road and load conditions and doing this by changing the gear ratio between engine crankshaft and vehicle drive wheels.
- To provide assistance to shift backwards/ reverse so that vehicle moves in that direction.
- To help the vehicle to shift into neutral for starting the engine.
Working – In a gearbox the tertiary counter shaft counter shaft is mashed to the clutch with the use of couple of gears so the countershaft is always in running condition. When the tertiary shaft is brought in contact with the main shaft by the use of meshing gears the main shaft starts to rotate according to the gear ratio. When thhe driver wants to change the gear he simply press the clutch pedal which disconnects the tertiary shaft with the engine and connects the main shaft with the tertiary shaft by another gear ratio by the use of gearshift lever.

STEPWISE PROCEDURE -

- Create a chart block for defining the stateflow as per the given conditions.
- If speed is less than or equal to 0, the flow is terminated and gear 0 is activated. at the junction else 1 is carry forwarded.
- If speed is greater than 0 and less than or equal to 15, the flow is terminated and gear 1 is activated.
- If speed is greater than 15 and less than or equal to 25, the flow is terminated and gear 2 is activated.
- speed is greater than 25 and less than or equal to 40, the flow is terminated and gear 3 is activated.
- speed is greater than 40 and less than or equal to 60, the flow is terminated and gear 4 is activated.
- speed is greater than 60, the flow is terminated and gear 5 is activated.
Control Logic Structure –

- In the above logic control first - the default transition is dragged from the browser menu.
- Five gear state is created with the state condition of Gear (G) 1,2,3,4,5 respectively and their transition is connected with speed range condition as shown in the image.
- The transition conditions for gear shift is decided as
speed > 15 shift to G = 2\
speed > 25 shift to G = 3
Speed > 40 shift to G = 4
Speed > 60 shift 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)
Symbol Pane –

Here speed is an input condition and G is output condition
Flow Chart –

after event creation flow chart is generated using some blocks from the library and their connections are done as mentioned below –
A constant block is connected with slider gain block to provide initial input.
Slider gain block is used to define the speed slider to change the speed during simulation is running and it acts as input for speed.
The output port (G) is connected with the Display to indicate the current gear for current speed in the slider gain.
Results –
When the run time is kept as an infinite and slider is made to slide for the speed then we can see the gear number (G) as 4.
By changing the slider position the display value will change simultaneously.

