Project 2 - Implement the Code for controlling the retraction and extension of Airplane’s landing gear
PROBLEM STATEMENT:-
Implement the code for controlling the retraction and extension of airplane's landing gear.
Landing Gear of an Airplane:-
- It is the undercarriage of an airplane, which is used for either take off or landing.
- It was also formerly called alighting gear by some manufacturers, such as the Glenn L. Martin company.
- An airplane has 3 gears for landing:- Nose gear, Left gear, Right gear.
- There is a hydraulic pump which is exerting pressure to the gears to bring it down or pull it up and that pump is electrically driven.
- Every leg of the gear has one limit switch.
- Nose gear has one extra squat switch to determine whether the airplane is in ground or not.

Main file.c:
#include "project.h"
int main()
{
Initiate_State_Machine();
while(1)
{
statetable[current_state]();
}
}
Source file.c:
/*
* aero.c
*
* Created on: 07-Aug-2022
* Author: IND
*/
#include "project.h"
void GearDown(void)
{
current_state=GEAR_DOWN;
printf("Enter the status of pilot's lever and squat switch");
fflush(stdout);
scanf("%d %d",&pl,&squat_switch);
if(pl==Raising && squat_switch==on)
{
current_state=CHECKING_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();
}
}
//CheckingBeforeTakeOFF
void CheckingBeforeTakeOFF(void)
{
current_state=CHECKING_BEFORE_TAKEOFF;
printf("Enter the status of pilot's lever and squat switch and hydraulic mechanism:");
fflush(stdout);
scanf("%d %d %d",&pl,&squat_switch,&hm);
if(pl==falling&&squat_switch==off)
{
GearDown();
}
else if(pl==Raising && squat_switch==on && hm==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 valve:%s\n",State_Machine[current_state].direction_valve_status);
}
else if(pl==Raising && squat_switch==on && hm==not_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 valve:%s\n",State_Machine[current_state].direction_valve_status);
printf("Status of gas pressurised Spring System:%s\n",State_Machine[current_state].Gas_Pressurized_Spring_system_status);
}
}
//RaisingGear
void RaisingGear(void)
{
current_state=RAISING_GEAR;
printf("Enter the status of pilot's lever and limit switch:");
fflush(stdout);
scanf("%d%d",&pl,&limit_switch);
if(pl==falling && limit_switch==on)
{
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);
fflush(stdout);
}
else if(pl==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);
fflush(stdout);
}
else
{
RaisingGear();
}
}
//GearUp
void GearUp(void)
{
current_state=GEAR_UP;
printf("Enter the status of pilot's lever:");
fflush(stdout);
scanf("%d",&pl);
if(pl==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);
fflush(stdout);
}
else
{
GearUp();
}
}
//CheckBeforeLanding
void CheckBeforeLanding(void)
{
current_state=CHECK_BEFORE_LANDING;
printf("Enter the status of pilot's lever and hydraulic mechanism status:");
fflush(stdout);
scanf("%d %d",&pl,&hm);
if(pl==falling && hm==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("Status of Direction valve:%s\n",State_Machine[current_state].direction_valve_status);
fflush(stdout);
}
else if(pl==falling && hm==not_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("Status of Direction valve:%s\n",State_Machine[current_state].direction_valve_status);
printf("Status of gas pressurised Spring System:%s\n",State_Machine[current_state].Gas_Pressurized_Spring_system_status);
fflush(stdout);
}
else if(pl==(Raising))
{
CheckBeforeLanding();
}
}
//LoweringGear.
void LoweringGear(void)
{
current_state=LOWERING_GEAR;
printf("Enter the status of pilot's lever and limit switch:");
fflush(stdout);
scanf("%d %d",&pl,&limit_switch);
if(pl==Raising && limit_switch==on)
{
current_state=CHECKING_BEFORE_TAKEOFF;
printf("Current State:%s\n",State_Machine[current_state].current_state_indication);
printf("Light is:%s\n",State_Machine[current_state].light);
fflush(stdout);
}
else if(pl==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);
fflush(stdout);
}
if(limit_switch==off)
{
LoweringGear();
}
}
void Initiate_State_Machine()
{
current_state==GEAR_DOWN;
printf("The Finite State Machine is Intialized and current the program is in"" GearDown State & Light is: %s\n",State_Machine[current_state].light);
}
Header file.h:
/*
* project.h
*
* Created on: 07-Aug-2022
* Author: IND
*/
#ifndef PROJECT_H_
#define PROJECT_H_
#include <stdio.h>
void Initiate_State_Machine();
void GearDown();
void CheckingBeforeTakeOFF();
void RaisingGear();
void GearUp();
void CheckBeforeLanding();
void LoweringGear();
static void(*statetable[])(void)={GearDown, CheckingBeforeTakeOFF, RaisingGear, GearUp, CheckBeforeLanding, LoweringGear};
typedef enum State
{
GEAR_DOWN,
CHECKING_BEFORE_TAKEOFF,
RAISING_GEAR,
GEAR_UP,
CHECK_BEFORE_LANDING,
LOWERING_GEAR,
}State_Type;
typedef enum Switch
{
on,
off//plane is on groung
}Switch_status;
typedef enum pilot_lever
{
Raising,
falling
}pilot_lever;
typedef enum hydraulic_mechanism
{
working,
not_working
}hydraulic_mechanism;
static volatile Switch_status squat_switch;
static volatile Switch_status limit_switch;
static volatile pilot_lever pl;
static volatile hydraulic_mechanism hm;
State_Type current_state;
typedef struct
{
char* current_state_indication;
char* light;
char* direction_valve_status;
char* landing_gear_hydraulic_control;
char* Gas_Pressurized_Spring_system_status[2];
}State_Table;
static 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","Disbled",{NULL,NULL}},
{"CheckBeforeLanding","Red","Down","Enabled",{NULL,NULL}},
{"LoweringGear","Green","Down","Enabled",{"Disabled","Enabled"}}
};
#endif /* PROJECT_H_ */
Output:

OVERVIEW OF THE PROJECT:-
- The project is to know the knowledge of retraction and extensions of landing gear using a code.
- This can be achieved by using finite state machine which is used in the states header file.
- FSM (Finite state machine) is a mathematical model of computation.
- It is the most efficient algorithm which can be used.
- The creation of source file helps us easy to understand the program.
GOALS:-
- The main goals are to control the direction of valve and retraction and extension of landing gear.
- The control of direction valve is controlled by pilot lever which we can see in the program (reference given in attachment provided).
- The retraction and extension of landing gear is controlled by switch states in the program.
- Hence, all the goals are achieved.
KEY HIGHLIGHTS OF PROJECT:-
- We can observe that the direction valve helps us to raise or lower the landing gear.
- The direction valve is controlled by the software.
- With the help of this software we control the hydraulic mechanism.
- The hydraulic pump controls the raising or lowering of the landing gear.
- The hydraulic mechanism helps us to land and take off of the airplane.
DELIVERABLES OF THIS PROJECT:-
- The retraction and extension of landing gears is controlled by various switch and gear.
- The status of these switches and gears are shown below in various tables.
Table1:-
|
Switch State |
State of Gears |
|
Limit Switch CLOSED |
Gear is UP |
|
Limit Switch OPENED |
Gear is DOWN |
|
Switch State |
State of Airplane |
|
Squat Switch CLOSED |
Airplane is grounded and Gears are locked |
|
Squat Switch OPENED |
Airplane is taking off / landing / airborne |
A direction valve is controlled by the software to allow hydraulic pressure to either raise or lower the landing gear.
Table 2:-
|
Status of Direction Valve |
States of landing gear |
|
Direction valve = Down |
(Gear Down)(Parked at bay or Landed) |
|
Direction valve = Up |
Raising Gear(Taking Off) |
|
Control of hydraulic pump for the landing gear part is disabled |
Gear Up(Airborne) |
|
Direction valve = down |
Lowering Gear(Landing) |
INPUT FOR THE DIRECTION VALVE:-
Table 3:-
|
Pilot’s Lever State |
Direction Valve State |
|
Lever UP |
Direction valve = Up |
|
Lever Down |
Direction valve = Down |
Table 4:-
|
Pilot’s Lever State |
Light Status |
|
Lever Rising Edge |
Red |
|
Lever Falling Edge |
Table 5:-
Every gear has one light. According to the state of the gear,color of light is changing.
|
Landing Gear State |
Light Status |
|
Gear is up |
OFF |
|
Gear is down |
Green |
|
Gear in transit(Raising or Lowering) |
Red |
EXPECTED OUTCOMES:-
- In this project we get a good knowledge about the finite state machine algorithm.
- This algorithm helps us to achieve the control over the retraction and extension of airplane's landing gear.
- The switch states and gear states of airplane plays a major role in control of retraction and extension.
- The project has a easy logics which is shown in flowchart diagram which makes it easy and interesting.
- All the .c files, .h file and screenshots of outputs are uploaded for the reference.