Project 2 - Implement the Code for controlling the retraction and extension of Airplane’s landing gear
Implement the Code for controlling the retraction and extension of Airplane’s landing gear
AIM :-
To write a code for controlling the retraction and extension of airplane landing gear.
OVER VIEW OF PROJECT:-
In this project, controlling the retraction and extension of Airplane’s landing gear can be implemented using Finite State Machine (FSM). FSM is the most efficient algorithm which is mathematical model of computation. The project describes the code for the landing of an airplane. we are going to write the code for different states before takeoff and time of landing. There are different switch states for every state. Using the finite state machine we are going to write the code.
OBJECTIVE:-
- Controlling the direction of Valve.
- Controlling the retraction and extension of Airplane’s landing gear.
- Using finite state machine to write a code.
- the understanding of the sequence of the code.
KEY HIGHLIGHTS OF THE PROJECT:-
- A direction valve is controlled by the software to allow the hydraulic pressure to either raise or lower the landing gear.
- Using the static declarations
- use of enum functions
- calling functions.
DELIVERABLES OF THIS PROJECT:-
The student will be getting the Knowledge of Finite State Machine algorithm which is used to achieve the control over the retraction and extension of Airplane’s landing gear using the switch and gear states of Airplane.
- understanding the sequence of the code.
- understanding enum function.
- understanding calling function.
- usage of pointers
EXPECTED OUTCOMES:-
* State_Type:-
GEAR_DOWN
CHECHKING_BEFORE_TAKEOFF
RAISING_GEAR
GEAR_UP
CHECK_BEFORE_LANDING
LOWERING_GEAR
* Switch_status:-
On
Off
* pilot_lever_status:-
Raising
falling
* hydraulic_mechanism_status:-
Working
Notworking
* State_table:-
current_state_indication
light
direction_value_status
Gas_Pressure_Spring_system_status
landing_gear_hydraulic_control
PROGRAM:-
#include<stdio.h>
#include<stdlib.h>
void Initiate_State_Machine();
void GearDown();
void CheckingBeforeTakeOFF();
void RasingGear();
void GearUp();
void CheckBeforeLanding();
void LoweringGear();
typedef enum Sates
{
GEAR_DOWN,
CHECHKING_BEFORE_TAKEOFF,
RAISING_GEAR,
GEAR_UP,
CHECK_BEFORE_LANDING,
LOWERING_GEAR,
}State_Type;
typedef enum Switch
{
On,
Off
}Switch_status;
typedef enum pilot_lever
{
Raising,
falling
}pilot_lever_status;
typedef enum hydraulic_mechanism
{
Working,
Notworking
}hydraulic_mechanism_status;
typedef struct
{
char* current_state_indication;
char*light;
char*direction_value_status;
char*Gas_Pressure_Spring_system_status[2];
char*landing_gear_hydraulic_control;
}State_table;
State_table State_Machine[6]=
{
{"GearDown","Green","Down","Enabled",{NULL,NULL}},
{"CheckingBeforeTakeoff","Green","Down","Enabled",{NULL,NULL}},
{"RaisingGear","Red","Up","Enabled",{"Disabled","Enabled"}},
{"GearUp","Off","Null","Disabled",{NULL,NULL}},
{"CheckBeforeLanding","Red","Down","Enabled",{NULL,NULL}},
{"LoweringGear","Green","Down","Enabled",{"Disabled","Enabled"}}
};
State_Type current_state;
static volatile pilot_lever_status pilot_lever;
static volatile hydraulic_mechanism_status hydraulic_mechanism;
static volatile Switch_status squat_switch;
static volatile Switch_status limit_switch;
State_Type current_state;
static void(*StateTABLE[])(void)={GearDown,CheckingBeforeTakeOFF,RasingGear,GearUp,CheckBeforeLanding,LoweringGear};
int main()
{
Initiate_State_Machine();
while(1)
{
StateTABLE[current_state]();
}
}
void GearDown()
{
current_state=GEAR_DOWN;
printf("Enter the status of pilot lever and squat switch:");
scanf("%d%d",&pilot_lever,&squat_switch);
if(pilot_lever==Raising && squat_switch==On)
{
current_state=CHECHKING_BEFORE_TAKEOFF;
printf("Current state:%s\n",State_Machine[current_state].current_state_indication);
printf("Light is:%s\n",State_Machine[current_state].light);
}
else
{
GearDown();
}
}
void CheckingBeforeTakeOFF()
{
current_state=CHECHKING_BEFORE_TAKEOFF;
printf("Enter the status of pilot lever, squat switch and hydraulic mechanism:");
fflush(stdout);
scanf("%d%d%d",&pilot_lever,&squat_switch,&hydraulic_mechanism);
if(pilot_lever==falling && squat_switch==Off)
{
GearDown();
}
else if(pilot_lever==Raising && squat_switch==On && hydraulic_mechanism==Working)
{
current_state=RAISING_GEAR;
printf("Current state:%s\n",State_Machine[current_state].current_state_indication);
printf("Light is:%s\n",State_Machine[current_state].light);
printf("Status of direction:%s\n",State_Machine[current_state].direction_value_status);
}
else if(pilot_lever==Raising && squat_switch==On && hydraulic_mechanism==Notworking)
{
current_state=RAISING_GEAR;
printf("Current state:%s\n",State_Machine[current_state].current_state_indication);
printf("Light is:%s\n",State_Machine[current_state].light);
printf("Status of direction:%s\n",State_Machine[current_state].direction_value_status);
printf("Status of gas pressurised spring system:%s\n",State_Machine[current_state].Gas_Pressure_Spring_system_status);
}
}
void RasingGear()
{
current_state=RAISING_GEAR;
printf("Enter the status of pilot lever, squat switch and hydraulic mechanism:");
fflush(stdout);
scanf("%d%d",&pilot_lever,&limit_switch);
if(pilot_lever=falling && limit_switch==On)
{
printf("Current state:%s\n",State_Machine[current_state].current_state_indication);
printf("Light is:%s\n",State_Machine[current_state].light);
printf("Landing gear Hydraulic control:%s\n",State_Machine[current_state].landing_gear_hydraulic_control);
}
else if(pilot_lever==Raising && limit_switch==Off)
{
current_state=GEAR_UP;
printf("Current state:%s\n",State_Machine[current_state].current_state_indication);
printf("Light is:%s\n",State_Machine[current_state].light);
printf("Landing gear Hydraulic control:%s\n",State_Machine[current_state].landing_gear_hydraulic_control);
}
else
{
RasingGear();
}
}
void GearUp()
{
current_state=GEAR_UP;
printf("Enter the status of pilot lever:");
scanf("%d",&pilot_lever);
if(pilot_lever==falling)
{
current_state=CHECK_BEFORE_LANDING;
printf("Current state:%s\n",State_Machine[current_state].current_state_indication);
printf("Light is:%s\n",State_Machine[current_state].light);
printf("Landing gear Hydraulic control:%s\n",State_Machine[current_state].landing_gear_hydraulic_control);
}
else
{
GearUp();
}
}
void CheckBeforeLanding()
{
current_state=CHECK_BEFORE_LANDING;
printf("Enter the status of pilot lever and hydraulic mechanism status");
fflush(stdout);
scanf("%d%d",&pilot_lever,& hydraulic_mechanism);
if(pilot_lever==falling && hydraulic_mechanism==Working)
{
current_state=LOWERING_GEAR;
printf("current state :%s\n",State_Machine[current_state].current_state_indication);
printf("Light is ;%s\n",State_Machine[current_state].light);
printf("State of direction valve:%s\n",State_Machine[current_state].direction_value_status);
}
else if(pilot_lever=Raising&& hydraulic_mechanism==Notworking)
{
current_state=LOWERING_GEAR;
printf("current state :%s\n",State_Machine[current_state].current_state_indication);
printf("Light is ;%s\n",State_Machine[current_state].light);
printf("State of direction valve:%s\n",State_Machine[current_state].direction_value_status);
printf("Status of gas pressurised spring system :%s\n",State_Machine[current_state].Gas_Pressure_Spring_system_status);
}
if(pilot_lever==(Raising||falling))
{
CheckBeforeLanding();
}
}
void LoweringGear()
{
current_state=LOWERING_GEAR;
printf("Enter the status of pilot lever and limit switch:");
fflush(stdout);
scanf("%d %d",&pilot_lever,&limit_switch);
if(pilot_lever==Raising && limit_switch==On)
{
current_state=CHECHKING_BEFORE_TAKEOFF;
printf("current state :%s\n",State_Machine[current_state].current_state_indication);
printf("Light is ;%s\n",State_Machine[current_state].light);
}
else if(pilot_lever=Raising && limit_switch==Off)
{
current_state=GEAR_DOWN;
printf("current state :%s\n",State_Machine[current_state].current_state_indication);
printf("Light is ;%s\n",State_Machine[current_state].light);
printf("Landing Gear hydraulic control:%s\n",State_Machine[current_state].landing_gear_hydraulic_control);
}
if (limit_switch==Off)
{
LoweringGear();
}
}
void Initiate_State_Machine()
{
current_state=GEAR_DOWN;
printf("The finite state machine is initialized. The current program is in GearDown state and Light is:%s\n", State_Machine[current_state].light);
}
RESULT:-

CONCLUCTION:-
Hence written the code for controlling the retraction and extension of airplane landing gear