Week - 4
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
After all the processes have completed turn on the finished LED.
working principle of washing machine:-In our modern-day lives, we use several technological marvels to keep up with the escalating pace of this ever-growing world. Some of them have become so common in our daily use that we hardly ever wonder how these technologies work at their core. One such example is the washing machine that we use to clean our dirty laundry. Just add some water to the washing drum, a few scoops of detergent, turn few nobs, and we have a clean laundry after few minutes. Fairly simple right? It may come as a surprise to you that although washing machines were available since the 19th century, it was not until 2018 that the scientists were able to demystify the working principle of a washing machine. There is a complex interplay of mechanical and chemical actions that makes the cleaning possible inside the washer. Before we understand the working of a washing machine, let’s first try to understand the role of detergent in the cleaning process.it can not pass through the yarn itself specifically the spaces between the interlocked fibers (Intra yarn spaces). In general, the ratio of detergent solution that can penetrate through the intra-yarn spaces is only 0.1 percent to the one which cleans the dirt stuck in the inter-yarn strands. Mathematically
- An inner drum: This is where we put the laundry. One can notice that this drum rotates a bit when you touch it, and there are a lot of holes punched into it. These holes allow the water to come in and wash the clothes.
- Paddles: These are ridges that lie on the edge of the drum and help move your laundry around while being washed.
- Agitator: It is a paddle, more common in top-load machines, in the middle that helps turn the clothes around in the soapy water.
- The outer drum: This drum is not visible when you look inside the washer, but there is another drum that holds the water while the inner drum or agitator rotates. This part is completely water-tight to prevent your machine from leakage.
- Thermostat and heating element: These control the temperature of the water and heats the water to the specified temperature.
- Pump: This removes the water from the drum after the wash.
- Programmer: This controls the washing machine through all the steps from washing to rinsing and spin-drying.
- Pipes and valves: These allow the water in and out of the washer.
DRYER:-He dryer drum is designed to move and tumble the clothes. Without the tumbling motion, the clothes would lie in a huge pile, making air circulation nearly impossible. Almost all dryer drums are turned by a simple pulley system powered by an electric motor. The dryer drum sits on a roller system, and most are supported by an axle.
Some new dryers feature a steam dry feature. The steam feature creates steam in the dryer independent of a traditional drying cycle. Steam drying is used to freshen clothes that are wrinkled or have strong odors. These dryers require a water line or have a water reservoir that must be filled manually and an additional heating element for the water to create the steam mist.
While washing the clothes, we follow the simple steps as mentioned below :
- Wash
- Rinse
- Spin
Wash: We add detergent here to clean the clothes. This serves the purpose of cleaning the dirt from the clothes.
Rinse: Once the clothes are washed, we need water to remove the detergent from the clothes. This process is called Rinsing. It is similar to the way we spray water on the clothes while handwashing them in order to remove the detergent and dirt.
Spin: This process extracts all the moisture from the clothes and dries out excess water.
symbols pane:-
In the Symbols pane, you can view and manage data, events, and messages while working in the Stateflow® Editor. In the Modeling tab, select Symbols Pane.
From the Symbols pane you can:
-
Add and delete data, events, and messages.
-
Set the object type and scope.
-
Change the port number.
-
Edit the name of an object and update all instances of the object name in the chart.
-
Undo and redo changes in type, name, and port number.
-
Detect unused objects.
-
Detect and fix unresolved objects.
-
Trace between objects in the window and where the objects are used in the chart.
-
View and edit object properties in the Property Inspector
- The rows in the Symbols pane display object hierarchy. Expand an object in the window to see data, events, and messages parented by that object. By default, all the nongraphical objects in a chart are listed in the window. To view only the objects that are used at the current level of hierarchy and below, select the icon. To search for specific symbols, type in the Filter search box .
-
In the row for the new object, under TYPE, choose the object type.
-
Edit the name of the object.
-
For input and output objects, under PORT, choose a port number.
-
To view the object in the Property Inspector, right-click the object and select
Inspect. -
In the Property Inspector, modify the object properties.
AIM-
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.
CHART:-
A Stateflow® chart is a graphical representation of a finite state machine consisting of states, transitions, and data. You can create a Stateflow chart to define how a MATLAB algorithm or a Simulink® model reacts to external input signals, events, and time-based conditions. For more information, see Model Finite State Machines.
For instance, this Stateflow chart presents the logic underlying a half-wave rectifier. The chart contains two states labeled On and Off. In the On state, the chart output signal y is equal to the input x. In the Off state, the output signal is set to zero. When the input signal crosses some threshold t0, the chart transitions between these states. The actions in each state update the value of y at each time step of the simulation.
Speed Range(kmph) Gear
0 to 15 1
16 to 25 2
26 to 40 3
41 to 60 4
Above 61 5
The Stateflow Editor is a graphical environment for designing state transition diagrams, flow charts, state transition tables, and truth tables. Before opening the Stateflow Editor, decide on the chart execution mode that best meets your needs.
Add States and Transitions
-
From the object palette, click the State icon and move the pointer to the chart canvas. A state with its default transition appears. To place the state, click a location on the canvas. At the text prompt, enter the state name
Onand the state actiony = x. so figure Example-- -
Add another state. Right-click and drag the
Onstate. Blue graphical cues help you to align your states horizontally or vertically. The name of the new state changes toOff. Double-click the state and modify the state action toy = 0. -
Realign the two states and pause on the space between the two states. Blue transition cues indicate several ways in which you can connect the states. To add transitions, click the appropriate cue.
Alternatively, to draw a transition, click and drag from the edge of one state to the edge of the other state.
-
Double-click each transition and type the appropriate transition condition
x<t0orx>=t0. The conditions appear inside square brackets. -
Clean up the chart:
-
To improve clarity, move each transition label to a convenient location above or below its corresponding transition.
-
To align and resize the graphical elements of your chart, in the Format tab, click Auto Arrange or press Ctrl+Shift+A.
-
To resize the chart to fit the canvas, press the space bar or click the Fit To View icon .
-
Resolve Undefined Symbols
Before you can execute your chart, you must define each symbol that you use in the chart and specify its scope (for example, input data, output data, or local data). In the Symbols pane, undefined symbols are marked with a red error badge . The Type column displays the suggested scope for each undefined symbol based on its usage in the chart.
-
Open the Symbols pane.
-
If you are building a chart in a Simulink model, in the Modeling tab, under Design Data, select Symbols Pane.
-
If you are building a standalone chart for execution in MATLAB, in the State Chart tab, select Add Data > Symbols Pane.
-
-
In the Symbols pane, click Resolve Undefined Symbols .
-
If you are building a chart in a Simulink model, the Stateflow Editor resolves the symbols
xandt0as input data andyas output data . -
If you are building a standalone chart for execution in MATLAB, the Stateflow Editor resolves
t0,x, andyas local data .
-
-
Because the threshold
t0does not change during simulation, change its scope to constant data. In the Type column, click the data type icon next tot0and selectConstant Data. -
Set the value for the threshold
t0. In the Value column, click the blank entry next tot0and enter a value of 0. -
Save your Stateflow chart.
Your chart is now ready for simulation in Simulink or execution in MATLAB.
Simulate the Chart as a Simulink Block
To simulate the chart inside a Simulink model, connect the chart block to other blocks in the model through input and output ports. If you want to execute the chart from the MATLAB Command Window, see Execute the Chart as a MATLAB Object.
-
To return to the Simulink Editor, on the explorer bar at the top of the canvas, click the name of the Simulink model:
rectify. If the explorer bar is not visible, click the Hide/Show Explorer Bar icon at the top of the object palette. -
Add a source to the model:
-
From the Simulink Sources library, add a Sine Wave (Simulink) block.
-
Double-click the Sine Wave block and set the Sample time to 0.2.
-
Connect the output of the Sine Wave block to the input of the Stateflow chart.
-
Label the signal as
x.
-
-
Add a sink to the model:
-
From the Simulink Sinks library, add a Scope (Simulink) block with two input ports.
-
Connect the output of the Sine Wave block to the first input of the Scope block.
-
Connect the output of the Stateflow chart to the second input of the Scope block.
-
Label the signal as
y.
-
Save the Simulink model.
reference- google ,matlab ,wikipidea etc...