Week - 4
Question 1: Implement stateflow of washing machine.
Answer:
The blocks used are
Chart: used to build the stateflow
Display:used to display the result
Lamp:from the dashboard and is used as an indicator.
x - power input
y - water input
X - Power ouput indicator
Y - water output indicator
S- soaking,W-washing,R-rinsing,D-drying,F-finish
Working:
Here the inputs are x and y where x is assumed as power an is y assumed as water. When the power is zero that is x is less than or equal to zero the it will enter the no power state and will return zero as output and and the lamp will turn red and if the power is on that is 1 then it enters the power on state and will give the output as X=1 which will make the lamp glow in green colour.Next it enters water supply state if y is equal to 1 and will give Y=1 as output and the lamp associated with it will glow in green colour and will give 1 as ouput in display.Otherwise (if y not equal to one ) it will enter the no water supply state and the machine will not work.when the water supply is correct then it will move to the other state that is soaking where it will soak the clothes in water for a time delay of 200 sec. When soaking state is entered ouput s will be zero and when it leaves the soaking state it will give ouptput s as 1 and lamp will glow in green colour.After 200sec the washing state is reached and similarly after entring the state output w will be zero and after leaving the state, ouput w will be 1 making the lamp glow in green colour.After 100 sec the next state is reached that is rinsing where it will perform rinsing for 20 seconds aYnd will give the ouput as R=0 during entry and R=1 during exit .The lamp associated with rinsing will glow green after exiting the block that is when R=1.After 20 sec the state will be changed to drying and will perform the function for 50 sec as defined and the lamp will glow green when exited from the state.After performing drying for 50 sec the state is changed to finish and the simulation will stop.
Question 2:Gear shift
Answer: The blocks used are
Constant:used to provide consant
Slider gain: used to provide a varying input while running simulation.
Chart:used to build the state flow
Display :to analyse the result
Gear: output of chart
Speed: input of chart
Working:
The chart block is used to build the state flow.The input port speed is connected from slider gain . The state gear 1 is entered when the input speed is less than or equal to 15 otherwise it will enter the gear 2 state if speed is greater than 15 or less than or equal to 25 and will show the gear as 2 in the display..When the input speed becomes greater than 25 or less than or equal to 40 it will be changed to gear 3 and display will show the output as 3 which means third gear.It is like when a specific state of gear is entered for example if it enters gear 3 state the output gear=3 where gear is output port and gear number 3 is displayed.When the input speed is above 40 and less than or equal to 60 then it will move to gear 4 state and output is displayed as 4.when the input is above 60 it will enter the state gear 5 and will show 5 in display which means fifth.The above process is shifting gears up.similarly is the case with shifting down.for example if the speed input is 35 it is below 40 and above 25 then the state is changed to gear 3 and it will show 3 in display when that state is entered.Here the simulation stop time is infinite and slider gain is used to get the varying output while running the simulation.