Challenge

Project 2 - Implement the Code for controlling the retraction and extension of Airplane’s landing gear

In this project, controlling the retraction and extension of the Airplane’s landing gear can be implemented using Finite State Machine (FSM). FSM is the most efficient algorithm which is a mathematical model of computation. In this project, we control the Airplane landing gear by verifying the various parameters for safety reasons. This procedure is followed for proper landing and take off 

Goals  

  • Controlling the direction of Valve. 

The system directly controls the valve and controls the direction of the wheel by verifying the other system    

  • They are controlling the retraction and extension of the Airplane’s landing gear. 

Retraction and extension of the Airplane are controlled by the lever and its proper check height for landing or takeoff. 

The software controls a directional valve to allow the hydraulic pressure to raise or lower the landing gear. 

Deliverables of this project:  

Implementing the control for the retraction and extension of the Airplane’s landing gear using the Finite state machine with the knowledge of various states of switch and gear.

#include // header file
#include //library file
#include // integer file
#include //string header
void Gear_down(); //function calls for operation
void Checking_Before_TakeOFF_delay_3s();
void Raising_Gear();
void Gear_up();
void Checking_before_landing();
void Lowering_gear();
typedef enum //declaring number of state machine 1
{
GEAR_DOWN,
CHECKING_BEFORE_TAKEOFF_DELAY_3S,
RAISING_GEAR,
GEAR_UP,
CHECKING_BEFORE_LANDING,
LOWERING_GEAR
}State_Types;
typedef enum //declaring switch state machine 2
{
open,
close
}Switch;
typedef enum //declaring pilot lever state machine 3
{
raising,
falling,
up,
down
}pilot_Lever;
typedef enum //declaring hydraulic operation state machine 4
{
Working,
Not_working
}hydraulic;
static volatile Switch limit_switch,Squat_switch; //static declare
static volatile pilot_Lever pil;
static volatile hydraulic operation;
State_Types current_state;
 
typedef struct //declaring structure state machine 5
{
char* currentstate;
char* lightvalue;
char* directionValve;
char* hydrauliccontrol;
}state; //array of function pointer
static void(*state1[])
(void)={Gear_down,Checking_Before_TakeOFF_delay_3s,
Raising_Gear,Gear_up,Checking_before_landing,Lowering_gear}; //state table formation
state state_machine[6]= {{"GearDown", "Green", "Down", "Enabled"},
{"Checking before take off", "Green","Down", "Enabled"},
{"Raising Gear", "Red", "Up", "Enabled"},
{"Gear up", "off", "Null", "Disabled"},
{"Checking before landing", "Red","Down", "Enabled"},
{"Lowering gear", "Green", "Down", "Enabled"}};
int main() // main function
{
current_state=GEAR_DOWN;
while(1) //while condition statement
{
state1[current_state]();
}
}
void Gear_down() //function call operation
{
current_state=GEAR_DOWN;
printf("\nEnter the values of pil and squat switch:\n ");
fflush(stdout);
scanf("%d %d",&pil,&Squat_switch);
if(pil==raising && Squat_switch==close) //if..else condition statement - 1
{
current_state=CHECKING_BEFORE_TAKEOFF_DELAY_3S;
printf("\n status of current state is %s",state_machine[current_state].currentstate);
printf("\n status of light value is %s",state_machine[current_state].lightvalue);
printf("\n status of direction Valve is %s",state_machine[current_state].directionValve);
printf("\n status of hydraulic control is %s",state_machine[current_state].hydrauliccontrol);
}
else
{
Gear_down();
}
}
void Checking_Before_TakeOFF_delay_3s() //function call operation
{
current_state= CHECKING_BEFORE_TAKEOFF_DELAY_3S;
printf("\n Enter the values of pil and squat switch and operation:\n");
fflush(stdout);
scanf("%d %d",&pil,&Squat_switch);
if(pil==falling && Squat_switch==close) //if condition statement - 1
{
current_state=GEAR_DOWN;
printf("\n status of current state is %s",state_machine[current_state].currentstate);
printf("\n status of light value is %s",state_machine[current_state].lightvalue);
printf("\n status of direction Valve is %s",state_machine[current_state].directionValve);
printf("\n status of hydraulic control is %s",state_machine[current_state].hydrauliccontrol);
}
if(pil==up && operation==Working) //if..else condition statement - 2
{
current_state=RAISING_GEAR;
printf("\n status of current state is %s",state_machine[current_state].currentstate);
printf("\n status of light value is %s",state_machine[current_state].lightvalue);
printf("\n status of direction Valve is %s",state_machine[current_state].directionValve);
printf("\n status of hydraulic control is %s",state_machine[current_state].hydrauliccontrol);
}
else
{
Checking_Before_TakeOFF_delay_3s();
}
}
void Raising_Gear() //function call operation
{
current_state=RAISING_GEAR;
printf("\n Enter the values of pil and limit_switch \n");
fflush(stdout);
scanf("%d %d",&pil,&limit_switch);
if(pil==falling) //if condition statement - 2
{
current_state=CHECKING_BEFORE_LANDING;
printf("\n status of current state is %s",state_machine[current_state].currentstate);
printf("\n status of light value is %s",state_machine[current_state].lightvalue);
printf("\n status of direction Valve is %s",state_machine[current_state].directionValve);
printf("\n status of hydraulic control is %s",state_machine[current_state].hydrauliccontrol);
}
if(limit_switch==close) //if..else condition statement - 3
{
current_state=GEAR_UP;
printf("\n status of current state is %s",state_machine[current_state].currentstate);
printf("\n status of light value is %s",state_machine[current_state].lightvalue);
printf("\n status of direction Valve is %s",state_machine[current_state].directionValve);
printf("\n status of hydraulic control is %s",state_machine[current_state].hydrauliccontrol);
}
else
{
Raising_Gear();
}
}
void Gear_up() //function call operation
{
current_state=GEAR_UP;
printf("\n Enter the values of pil \n");
fflush(stdout);
scanf("%d",&pil);
if(pil==falling) //if condition statement - 3
{
current_state=CHECKING_BEFORE_LANDING;
printf("\n status of current state is %s",state_machine[current_state].currentstate);
printf("\n status of light value is %s",state_machine[current_state].lightvalue);
printf("\n status of direction Valve is %s",state_machine[current_state].directionValve);
printf("\n status of hydraulic control is %s",state_machine[current_state].hydrauliccontrol);
}
else
{
Gear_up();
}
}
void Checking_before_landing() //function call operation
{
current_state=CHECKING_BEFORE_LANDING;
printf("\n Enter the values of pil and operation \n");
fflush(stdout);
scanf("%d %d",&pil,&operation);
if(pil==down || operation==Not_working) //if..else condition statement - 4
{
current_state=LOWERING_GEAR;
printf("\n status of current state is %s",state_machine[current_state].currentstate);
printf("\n status of light value is %s",state_machine[current_state].lightvalue);
printf("\n status of direction Valve is %s",state_machine[current_state].directionValve);
printf("\n status of hydraulic control is %s",state_machine[current_state].hydrauliccontrol);
}
else
{
Checking_before_landing();
}
}
void Lowering_gear() //function call operation
{
current_state=LOWERING_GEAR;
printf("\n Enter the values of pil and limit_switch \n");
fflush(stdout);
scanf("%d %d",&pil,&limit_switch);
if(limit_switch==close) //if condition statement - 4
{
current_state=GEAR_DOWN;
printf("\n status of current state is %s",state_machine[current_state].currentstate);
printf("\n status of light value is %s",state_machine[current_state].lightvalue);
printf("\n status of direction Valve is %s",state_machine[current_state].directionValve);
printf("\n status of hydraulic control is %s",state_machine[current_state].hydrauliccontrol);
}
if(pil==raising) //if..else condition statement - 5
{
current_state=CHECKING_BEFORE_TAKEOFF_DELAY_3S;
printf("\n status of current state is %s",state_machine[current_state].currentstate);
printf("\n status of light value is %s",state_machine[current_state].lightvalue);
printf("\n status of direction Valve is %s",state_machine[current_state].directionValve);
printf("\n status of hydraulic control is %s",state_machine[current_state].hydrauliccontrol);
}
else
{
Lowering_gear();
}
}

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.