Challenge

Control logic using state flow

Aim

Simulation in simulink by implementing control logic using state flow for a washing machine and for gear shifting system

Objectives

  1. Implement control logic of a washing machine using state flow as per conditions
  2. Make a simulink chart for the gear shift logic as per conditions

Theory

A finite state machine is a representation of an event driven system. In an event driven system, the system responds to an event by making a transition one state to another. This transition occurs if the condition defining the change is true.

A state flow chart is a graphical representation of a finite state machine, states and transitions from the basic elements of the system. We can also represent state less flow chart. A state flow chart can use mat lab as the action language to implement control logic.

  1. Washing Machine

A simulation must be performed using simulink by implementing above mentioned control logic using state flow. For that, we are provided with some conditions. They are mentioned below.

If the power supply is available, the system gets activated. If the water supply is not available, stop the process and indicate through LED. Soaking time should be 200 seconds followed by washing time of 100 seconds. Then rinsing happens for next 20 seconds and dryer runs for 50 seconds. After all the process has been completed turn on finished LED. Model for these conditions are given below.

Model and Chart

Explanation

Chart, terminator, slider switch, lamp and constant block are the main blocks used in this model. We provide slider switch for power supply and for water supply. Two lamps are also provided to indicate those supplies. A constant block is used to connect the switch and lamp. Terminator is used to connect the output lamps and it will give us the indications from the chart.

We provide our conditions as logic inside the chart block. State block will define the state and transition arrows are used to give changes in the state. Input transition provides our external input into the state. If any condition that we provide is true, then the output value will be one and if the condition is not satisfied or condition is false, then output will be zero. Graphical blocks from dash board also show the output according to inputting zero and one.

When power is on, the process will get initiated. Next state is water supply. If water supply is zero or if there is no water supply, then the process will get terminated. From output port ‘a’ true signal will be shown. If there is water supply, then process will get continued to next block. Soaking block will run for the next 200 seconds because we have given that as transition condition. During this time output signal port ‘b’ will be active. When this state is complete, it will transit into washing state. There also we are provided a transition condition, which is after 100 seconds. So washing state will continue for 100 seconds and ‘c’ port will be on. Similarly rinsing and soaking will get performed according to our provided conditions and it will be shown in respected output ports. We have already connected lamp blocks to these ports. So e will be able to see the output as light signals externally.

Conditions and Stages

When power is on and there is no water supply,

Stateflow got terminated and LED connected to no water state turned on.

Step wise simulation for each process

For the first 200 seconds, soaking process continued. State block for soaking is highlighted and LED connected to soaking output is displayed.

Washing was carried out for 100 seconds and the output LED indicated that process for hundred seconds.

After washing, rinsing process were done and it was displayed through LED.

As per conditions, the drying process was performed after rinsing.

Result

When power supply and water supply were given into the system, the whole process were carried out and finally LED corrresponding to finished got turned on. Hence, the stste flow simulation was completed.

  1. Gear Shift

Here, we have to make a simulink chart for the gear shift logic as per below conditions

Model should be capable to take speed inputs while simulation is running and should display the corresponding gear.

Model and Chart

Explanation

Here, we are simply giving a speed input to the chart block and out is displayed through display block and gauge block from dash board. We have a condition that, a varying speed input should be given into the system. For that, a slider gain block is used. Block parameter is given below.

We implement the given conditions as control logic using state flow. As mentioned in above simulation, we use state block and transition conditions for this.

From zero to fifteen kilometres per hour, the gear will be in first gear. When the speed exceeds the limit, gear will be changed to second through first transition condition. If speed increase more than twenty five, then second transition condition will be true. So state will get changed to third state which is third gear. Similarly fourth and fifth gear will be selected according to speed conditions given.

Conditions and Results

During simulation, we can change the speed input using slider gain block. So the different input conditions and corresponding result is given below.

Speed = 17 km/hr

Hence the speed is between 15 and 25 km/hr, the display showed second gear in running. Odometer connected to speed represented the speed.

Speed = 36 km/hr

As we can see from the display, the control logic using stateflow worked correctly and showed the third gear.

Speed = 49 km/hr

When the speed was changed to 49 km/hr, the gear also got changed to fourth gear.

Speed = 80 km/hr

Odometer showed the input speed and gear changed accoedingly. Hence the simulation done was completed.

Conclusion

Washing machine and gear shift system were modelled according to given conditions. It was evaluated with different input conditions and results were observed.

Reference

https://in.mathworks.com/help/stateflow/ref/chart.html

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.