SIMULINK: Control Logic for a washing machine and Gear Shift logic
CHALLENGE - 1:
AIM:
To design a control logic for a washing machine using Stateflow in Simulink graphical programming.
OVERVIEW:
A washing machine works on the conditions of time delays. Generally, a timer is used in almost all kinds of washing machines. A time delay is set after every operation, thereafter it proceeds to the next operation.
SIMULINK MODEL:
The above picture snippet shows the Simulink block diagram of the control logic of a washing machine.
- Power switch and the Water faucet is given as a slider gain. So a constant of value 1 is given as inputs to the Power switch and the faucet. The outputs from the slider gain are connected to the Stateflow (Timer) and it is also used as the connection to the Power and Water Supply LEDs.
- The Timer logic for the washing machine is shown below:
The inputs from the Power Switch and Water Faucet is received in the input block. - Then a condition is given to check the Power input as [Power==1]. If this condition is satisfied the control flows to the next action block while a Green LED is shown below the switch. If this condition is not satisfied, the LED will turn Red and the control will not flow to the next action block.
- Similarly, the Water Faucet input is also checked right after the Power input is checked, as shown in the picture snippet above.
- Once the water supply condition is satisfied, the control executes the next block, where the soaking is performed. Then a time delay of 200 seconds is given as after(200,sec) for the soak action.
- After the specified time delay, the control moves to the Wash block. Then a time delay of 100 seconds is given as after(100,sec) for the Wash action.
- The Rinse block is executed after 100 seconds. The rinse process is performed for 20 seconds.
- Then the Dry Block is executed for 50 seconds. after which the washing machine program ends.
Entry and Exit variables are used as shown in the picture snippet above for the Soak, Wash, Rinse, Dry and End blocks so as to operate the respective LEDs.
- The Type for the Entry and Exit variables used in the mentioned blocks are set as output. Hence it is used as output as shown in the picture snippet above.
- Displays are connected to all the outputs and the output connections are used to connect the respective LEDs.
When the program is RUN, first it checks the Power Supply and then the Water Supply. Then it proceeds to the Soak, Wash, Rinse, Dry and End blocks for the specified time of each block and the respective LEDs turn Green as the blocks are executed.
CHALLENGE 2:
AIM:
To design a gear shift logic for a vehicle in Simulink using Stateflow.
OVERVIEW:
The gear in any vehicle is shifted according to the engine speed. In this challenge, however, we use the vehicle speed as the condition, based on which the gear is upshifted or downshifted.
SIMULINK MODEL:
The speed input is given as a Slider Gain and a constant of value 1 is given as the input to the slider gain. The range of the slider gain is set from 0 to 120. The output of the slider gain is given as input to the Gear Shift Module (Stateflow). The output of the Gear Shift Module is given to the Gear Display. In this program, I have used a gear shift module for a 6-speed transmission.
The gear shift logic is shown below.
- When the speed value is changed using the slider gain, it is then compared to the condition given in the picture snippet above.
- If speed>15, the gear will upshift to 2 and if speed<=15, the gear will downshift to 1.
- Similarly, the speed is compared in every Gear block and the output is displayed.
OUTPUT:
The shifted gear with respect to the speed is shown in the picture snippets below.