Challenge

(a) To implement control logic of a "washing machine" using Stateflow for the given sequence. (b) To make a Simulink chart for the "Gear shift" logic for the given conditions.

Aim:

Implement control logic of a "washing machine" using Stateflow as per given conditions.

Objective:

• 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

Explanation:

1. For making the model we have to create a Stateflow chart with power, water, soak time, washing time, Rinsing, Dry and end of the cycle.

2. To start with the charts we require a breakpoint added with chart Power (we can name the chart with any name to define the chart for our reference).

3. From power to water we make a loop with conditions if power is one the flow of current goes to engage the water and when the water has one condition the washing machine cycle runs from soak till the end.

Flow chart notation uses connective junctions to represent common code structures like loops and (if-else) constructs without the use of states.

4. I have given soak time entry A=O and exit A=1 with this we set breakpoint flow of water is for 200 seconds and once it reaches above 200 seconds it will go to next process washing, the washing, rinsing and dry are set as per the given time.

4. Here have input end-1 so the lamp will indicate when the display is one.

5. After creating the charts we have to check the input and output through the symbols tool which is visible on the left side of the chart page.

5. After creating the charts we have to check the input and output through the symbols tool which is visible on the left side of the chart page. In the type column, we have to define the input and output.

6. After giving the input and out we will be connecting the power and water to two constant and all the five outputs to display.

7. I have connected inputs power and water to switch and lamps, all four cycles are then connected to display and lamps to indicate the washing cycle

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 water supply is on, then machine will get activated and start the next process of operation.
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 condition of the state are kept as O & i.e at entry of operation states it is O and as operation completes it is 1 for every states.
After all process has done washing machine completed LED will glow and we can shut the machine off.
SYMBOLS PANAL:

Here P(powerswitch) & W (water supply) is input givEN while all others are WASHING STATE,DRYER,WASHING,SOAKING,RINSING,WASHING COMPELETED are all out.

COMPLETE SIMULINK MODEL:

LED GREEN means process is completed and all display out as 1. and LED ORANGE OPERATION IS NOT COMPLETED.

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.

Ans=>

Part II: IMPLEMENTATION OF CONTROL LOGIC FOR GEAR SHIFT USING STATEFLOW

PROCESS:

1.Start simulink and create a blank model.

2. Search for CHART block in the stateflow category of library browser. 3. Open the chart block and select the various features from the stateflow window.

4.Control logic for gear shift is such that it should change the gear when the speed increases of decreases automatically.

5.After finishing the control logic run the stateflow and check the gear shift operation for an infinite time.

Blocks Used

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

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

3. Constant

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

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

LOGIC EXPLANATION:

The speed ranges from 0 to 100 and the slider is used to send the input. The 1st gear has speed values from 0 to 15 so the entry condition for the Ist gear is O<-speed and speed<-15 and the exit condition is when the speed greater than 15.

Similarly for 2nd gear, the entry condition is 16<-speed and speed<-25 the exit condition is when speed<16 and speed>25. In the same way for each gear, the entry and the exit condition are specified and the out is mapped to the lamp and the display block.

1. In the above control logic, first Engine is started from input switch E=0/1 through Rocker switch which is power switch to make engine ON.Then next Gear_Shift_logic implemented through following states.

2. Five Gear State is created with state condition of gear (G) 1,2,3,4 and 5 respectively and their transition is connected with speed range

condition as shown.

3.The transitions condition for the 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 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, Engine [E==1] condition given with various speed change values.

SYMBOLS PANEL:

SIMULINK MODEL:

REST is in the file sir

REFERENCE:

1. SIMULINK SIR FROM SKILL-LYNC

2. WIKI

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.