Week - 4
1.
AIM:-
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
If all the processes have completed turn on the finished LED.
PROCESS:-
The first step is to create a stateflow chart in the simulink environment. It is done by double clicking on the simulink environment and searching for 'chart' or draging it from the simulink library.
Then double click on chart a new window will apper with yellow colour.
Then we can create states as per the sequence by dragging the below shown icon (i.e. icon is annotation for better understanding).
As per the sequence need I have designed simulink file and save to run.
EXPLANATION:-
Here the input signals provided into the chart are 2. One is for the power supply (i.e. input_1) and the other is for the water supply (i.e. input_2).
We create the first default state is the power supply_on state, followed by power supply_off state. The sequence has been numbred 1 for the later state .It will be executed if input_1 signal becomes 0.
Then we attach the power supply ON state to the power supply on state directly, then it will go and check for water supply. The condition for that is input_2==1 and if input_2=-0, then it meas no water supply present.
Now we will define the processes such as soaking for 200sec, washing for 100sec, rinsing for 20sec, dryer for 50sec and at last the end state is also defined. The condition for transition from water supply_on to soaking state is input_2==1.
Then we have to give the defined variables inside the chart its scope and type (i.e. p,w,a,b,c,d and e). It can be given from the signal pane window.
Now we will define the input and output blocks for the chart.
Also we have to indicate each process using a lamp for better understanding. Hence we defined 9 lamps and have connected them to their respective sates and has been labelled.
OUTPUT:-
WHEN POWER SUPPLY AND WATER SUPLLY IS GIVEN, FOLLOWED BY SOAKING PROCESS, WASHING PROCESS, RINSING PROCESS DRYER PROCESS ENDS AND THE PROCESS EXECUTES THE 'END' STATE
Here the END and the output power supply is in ON state, because power is neede for these lamps to work.
RESULT:-
The washing machine logic is successfully implemented and executed.
2.
EXPLANATION :-
1. To create a Simulink model of gear shift create a Stateflow chart and start with the power block which is connected to the breakpoint and a junction with power-O condition and connected to speed block(state) power--1 so that when the speed is above 1 the process will start flowing to gears
2. Here I have mentioned speed to Conway our conditions as above speed greater than zero the gear shift should start the cycle of changing
3. In gear 0ne the break point is mentioned up to 16 then it is respectively changing till speed 61.
4. From gear5 till gear1 there up arrow(breaking point) the speed is decreased toll zero so that we can shift our gear not only increasing it can be co to
5. Additional state mentioned as TopSpeed' So that if the speed is been increased above 80 there is a lamp which indicates over speed in our Simulink block.
6. After completion of our chart, we can see the inputs power and speed, outputs gear and top speed(Z).
7. I have connected the two constants to power and speed so that when the switch is on the power will be indicated from the lamp which is green in color Speed is connected to a slider which requires manually increasing the speed.
8. From the output of gear, I have connected terminator so that it stops the data flow and to view the gear shifts I have connected to the gear shift inficer, and top speed(z) is connected to display and the display is connected to a lamp which shows over speed so that the lamp will indicate when the speed increased above 80.
9. I have connected it to the slider to the speedometer to view the speed in the speedometer.
RESULT:-
Results varys depending on the condition