Challenge

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

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

Overview of the Project: (5 to 6 lines)

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.

Goals ( 2 to 3 points)

  • Controlling the direction of Valve.
  • Controlling the retraction and extension of Airplane’s landing gear.

Key Highlights of the Project: (4 to 5 points)

A direction valve is controlled by the software to allow the hydraulic pressure to either raise or lower the landing gear.

Deliverables of this project: (4 to 5 points)

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

Expected Outcomes: (4 to 5 points)

Problem Statement
Implement the Code for controlling the retraction and
extension of Airplane’s landing gear
Description of the Hardware
Actually 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.
Limit switches
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.

A direction valve is controlled by the software to allow the
hydraulic pressure to either raise or lower the landing gear

Every gear has one light. According to the state of the
gear,color of light is changing

Consider this cases
• There is a possibility that the plane is about to take off and
an emergency comes where pilot has to abort the take off
• When taking off,to ensure that its right time to raising the
gear,check for at least 4 seconds that squat switch is open• When the airplane is parked at the bay and nose gear is
down,then the nose gear is always experiencing a pressure
on it due to airplane weight,weight of luggage and weight
of passengers boarding on the airplane.Hydraulic
mechanism is monitoring the pressure exerted on the
nose gear and to neutralize that pressure its applying a
pressure on the opposite direction• Hydraulic Control can detect the rising edge and falling
edge of pilot’s lever
• In case of Hydraulic system failure,there are two gas
pressurized springs by which gears can be extended
• The case of failure of Squat Switch is ignored

Code

Airplane.c//main.c

#include<stdio.h>

#include"Airplane.h"

//int pilot_lever;

//int limit_switch;

//int squat_switch;

//static volatile

static void(*state_table[])(void)={GearDown_A, CheckingBeforeTakeOff_B, RaisingGear_C, GearUP_D, CheckingBeforeLanding_E,LoweringGear_F};

int main()

{

Init_state_Airplane();

while(1)

{

state_table[current_state]();

}

}

Airplane.h//header.c

#ifndef AIRPLANE_H_

#define AIRPLANE_H_

#endif /* AIRPLANE_H_ */

void Init_state_Airplane();

void GearDown_A();

void CheckingBeforeTakeOff_B();

void RaisingGear_C();

void GearUP_D();

void CheckingBeforeLanding_E();

void LoweringGear_F();

typedef enum states

{

STATE_A,//GearDown_A

STATE_B,//CheckingBeforeTakeOff_B

STATE_C,//RaisingGear_C

STATE_D,//GearUP_D

STATE_E,//CheckingBeforeLanding_E

STATE_F,//LoweringGear_F

}State_Type;

State_Type current_state;

typedef enum {

OPENED,CLOSED,

}Switches_status;

typedef enum {

PilotleverRising,

PilotleverUP,

PilotleverFalling,

PilotleverDOWN,

}Pilot_Lever;

typedef enum {

working, notworking,

}Hydraulic_pump;

static volatile Switches_status limit_switch;

static volatile Switches_status squat_switch;

static volatile Pilot_Lever pilot_lever;

static volatile Hydraulic_pump hydraulic_pump;

typedef struct

{

char *Airplane_state;

char *Hydraulic_pump;

char *light_indication;

char *Direction_valve;

char *spring_condition[2];

}State;

// state_table;

static State state_Machine[]={{"GearDown_A","Enable","GREEN","DOWN",{"NULL","NULL"}},

{"CheckingBeforeTakeOff_B","Enable","GREEN","Down",{"NULL","NULL"}},

{"RaisingGear_C","Enable","Red","UP",{"Disable","Enable"}},

{"GearUP_D","Disable","OFF","NULL",{"NULL","NULL"}},

{"CheckingBeforeLanding_E","Enable","Red","DOWN",{"NULL","NULL"}},

{"LoweringGear_F","Enable","Red","DOWN",{"Disable","Enable"}}};

Init_state.c

#include<stdio.h>

#include"Airplane.h"

void Init_state_Airplane()

{

{current_state=STATE_A;}

printf("Airplane is in the GearDOWN state\n");

printf("print current_state :- %s\n", state_Machine[current_state].Airplane_state);

printf("print Hydraulic_pump:- %s\n", state_Machine[current_state].Hydraulic_pump);

printf("print light status:- %s\n", state_Machine[current_state].light_indication);

printf("print Direction_valve:- %s\n", state_Machine[current_state].Direction_valve);

printf("print GasPressurized spring_status:-%s\n", state_Machine[current_state].spring_condition[hydraulic_pump]);

printf("Pilot_lever=PL,Squat_switch=SS,Limit_switch=LS\n");

printf("Airplane:- GearDown_A [PL=0 , SS=0]CheckingBeforeTakeOff_B,CheckingBeforeTakeOff_B[PL=2 , SS=1]GearDown_A,CheckingBeforeTakeOff_B[PL=1 , SS=0]RaisingGear_C[PL=2 , LS=0]LoweringGear_F,RaisingGear_C[PL=1 , LS=1] GearUP_D[PL=2 , SS=0]CheckingBeforeLanding_E[PL=3 , SS=0]LoweringGear_F[PL=0 , LS=1]CheckingBeforeTakeOff_B,LoweringGear_F[PL=3 , LS=0]GearDown_A\n");

}

GearDown.c

#include<stdio.h>

#include"Airplane.h"

void GearDown_A()

{

printf("Enter the value of pilot lever position\n");

fflush(stdout);

scanf("%d",&pilot_lever);

printf("Enter the squat switch condition\n");

fflush(stdout);

scanf("%d",&squat_switch);

{

if(pilot_lever==PilotleverRising && squat_switch==OPENED)

{

current_state=STATE_B;

printf("Airplane is moving from GearDown_A state to CheckingBeforeTakeOff_B state\n");

printf("print Hydraulic_pump:- %s\n", state_Machine[current_state].Hydraulic_pump);

printf("print current_state:- %s\n", state_Machine[current_state].Airplane_state);

printf("print light status:- %s\n", state_Machine[current_state].light_indication);

printf("print Direction_valve:- %s\n", state_Machine[current_state].Direction_valve);

printf("print GasPressurized spring_status:- %s\n", state_Machine[current_state].spring_condition[hydraulic_pump]);

}

else{

void GearDown_A();

}

}}

CheckingBeforeTakeOff.c

#include<stdio.h>

#include"Airplane.h"

void CheckingBeforeTakeOff_B()

{

printf("Enter the pilot lever position\n");

fflush(stdout);

scanf("%d",&pilot_lever);

printf("Enter the squat switch condition\n");

fflush(stdout);

scanf("%d",&squat_switch);

printf("Enter the Hydraulic_pump condition\n");

fflush(stdout);

scanf("%d",&hydraulic_pump);

if(pilot_lever==PilotleverUP && squat_switch==OPENED)

{

current_state=STATE_C;

printf("Airplane is moving from CheckingBeforeTakeOff_B state to RaisingGear_C state\n");

printf("print Hydraulic_pump:- %s\n", state_Machine[current_state].Hydraulic_pump);

printf("print current_state:- %s\n", state_Machine[current_state].Airplane_state);

printf("print light status:- %s\n", state_Machine[current_state].light_indication);

printf("print Direction_valve:- %s\n", state_Machine[current_state].Direction_valve);

fflush(stdout);

printf("print GasPressurized spring_status:- %s\n", state_Machine[current_state].spring_condition[hydraulic_pump]);

}

else{

if(pilot_lever==PilotleverFalling || squat_switch==CLOSED)

{

void GearDown_A();

}

}}

RaisingGear.c

#include<stdio.h>

#include"Airplane.h"

void RaisingGear_C()

{

printf("Enter the pilot lever position\n");

fflush(stdout);

scanf("%d",&pilot_lever);

printf("Enter the limit_switch condition\n");

fflush(stdout);

scanf("%d",&limit_switch);

if(pilot_lever==PilotleverUP && limit_switch==CLOSED)

{

current_state=STATE_D;

printf("Airplane is moving from RaisingGear_C state to GearUP_D state\n");

printf("print Hydraulic_pump:- %s\n", state_Machine[current_state].Hydraulic_pump);

printf("print current_state:- %s\n", state_Machine[current_state].Airplane_state);

printf("print light status:- %s\n", state_Machine[current_state].light_indication);

printf("print Direction_valve:- %s\n", state_Machine[current_state].Direction_valve);

printf("print GasPressurized spring_status:- %s\n", state_Machine[current_state].spring_condition[hydraulic_pump]);

}

else

{

if(pilot_lever==PilotleverFalling && limit_switch==OPENED)

{

current_state=STATE_E;

}

}

}

GearUP.c

#include<stdio.h>

#include"Airplane.h"

void GearUP_D()

{

printf("Enter the pilot lever position\n");

fflush(stdout);

scanf("%d",&pilot_lever);

printf("Enter the squat switch condition\n");

fflush(stdout);

scanf("%d",&squat_switch);

if(pilot_lever==PilotleverFalling && squat_switch==OPENED)

{

current_state=STATE_E;

printf("Airplane is moving from GearUP_D state to CheckingBeforeLanding_E state\n");

printf("print Hydraulic_pump:- %s\n", state_Machine[current_state].Hydraulic_pump);

printf("print current_state:- %s\n", state_Machine[current_state].Airplane_state);

printf("print light status:- %s\n", state_Machine[current_state].light_indication);

printf("print Direction_valve:- %s\n", state_Machine[current_state].Direction_valve);

printf("print GasPressurized spring_status:- %s\n", state_Machine[current_state].spring_condition[hydraulic_pump]);

}

else{

void RaisingGear_C();

}

}

CheckingBeforeLanding.c

#include<stdio.h>

#include"Airplane.h"

#include<string.h>

void CheckingBeforeLanding_E()

{

printf("Enter the pilot lever position\n");

fflush(stdout);

scanf("%d",&pilot_lever);

printf("Enter the squat switch condition\n");

fflush(stdout);

scanf("%d",&squat_switch);

printf("Enter the Hydraulic_pump condition\n");

fflush(stdout);

scanf("%d",&hydraulic_pump);

if(pilot_lever==PilotleverDOWN && squat_switch==OPENED)

{

current_state=STATE_F;

printf("Airplane is moving from CheckingBeforeLanding_E state to LoweringGear_F state\n");

//printf("print Hydraulic_pump:- %s\n", state_Machine[current_state].Hydraulic_pump);

printf("print current_state:- %s\n", state_Machine[current_state].Airplane_state);

printf("print light status:- %s\n", state_Machine[current_state].light_indication);

printf("print GasPressurized spring_status:- %s\n", state_Machine[current_state].spring_condition[hydraulic_pump]);

}

else{

void GearUP_D();

}

}

LoweringGear.c

#include<stdio.h>

#include"Airplane.h"

void LoweringGear_F()

{

printf("Enter the pilot lever position\n");

fflush(stdout);

scanf("%d",&pilot_lever);

printf("Enter the limit_switch condition\n");

fflush(stdout);

scanf("%d",&limit_switch);

if(pilot_lever==PilotleverDOWN && limit_switch==OPENED)

{

current_state=STATE_A;

printf("Airplane is moving from LoweringGear_F state to GearDown_A state\n");

printf("print Hydraulic_pump:- %s\n", state_Machine[current_state].Hydraulic_pump);

printf("print current_state:- %s\n", state_Machine[current_state].Airplane_state);

printf("print light status:- %s\n", state_Machine[current_state].light_indication);

printf("print Direction_valve:- %s\n", state_Machine[current_state].Direction_valve);

printf("print GasPressurized spring_status:- %s\n", state_Machine[current_state].spring_condition[hydraulic_pump]);

}

else

{

if(pilot_lever==PilotleverRising && limit_switch==CLOSED)

{

current_state=STATE_B;

}

else {

void LoweringGear_F();

}

}

}

OUTPUT

Airplane is in the GearDOWN state

print current_state :- GearDown_A

print Hydraulic_pump:- Enable

print light status:- GREEN

print Direction_valve:- DOWN

print GasPressurized spring_status:-NULL

Pilot_lever=PL,Squat_switch=SS,Limit_switch=LS

Airplane:- GearDown_A [PL=0 , SS=0]CheckingBeforeTakeOff_B,CheckingBeforeTakeOff_B[PL=2 , SS=1]GearDown_A,CheckingBeforeTakeOff_B[PL=1 , SS=0]RaisingGear_C[PL=2 , LS=0]LoweringGear_F,RaisingGear_C[PL=1 , LS=1] GearUP_D[PL=2 , SS=0]CheckingBeforeLanding_E[PL=3 , SS=0]LoweringGear_F[PL=0 , LS=1]CheckingBeforeTakeOff_B,LoweringGear_F[PL=3 , LS=0]GearDown_A

Enter the value of pilot lever position

0

Enter the squat switch condition

0

Airplane is moving from GearDown_A state to CheckingBeforeTakeOff_B state

print Hydraulic_pump:- Enable

print current_state:- CheckingBeforeTakeOff_B

print light status:- GREEN

print Direction_valve:- Down

print GasPressurized spring_status:- NULL

Enter the pilot lever position

1

Enter the squat switch condition

0

Enter the Hydraulic_pump condition

0

Airplane is moving from CheckingBeforeTakeOff_B state to RaisingGear_C state

print Hydraulic_pump:- Enable

print current_state:- RaisingGear_C

print light status:- Red

print Direction_valve:- UP

print GasPressurized spring_status:- Disable

Enter the pilot lever position

1

Enter the limit_switch condition

1

Airplane is moving from RaisingGear_C state to GearUP_D state

print Hydraulic_pump:- Disable

print current_state:- GearUP_D

print light status:- OFF

print Direction_valve:- NULL

print GasPressurized spring_status:- NULL

Enter the pilot lever position

2

Enter the squat switch condition

0

Airplane is moving from GearUP_D state to CheckingBeforeLanding_E state

print Hydraulic_pump:- Enable

print current_state:- CheckingBeforeLanding_E

print light status:- Red

print Direction_valve:- DOWN

print GasPressurized spring_status:- NULL

Enter the pilot lever position

3

Enter the squat switch condition

0

Enter the Hydraulic_pump condition

1

Airplane is moving from CheckingBeforeLanding_E state to LoweringGear_F state

print current_state:- LoweringGear_F

print light status:- Red

print GasPressurized spring_status:- Enable

Enter the pilot lever position

3

Enter the limit_switch condition

0

Airplane is moving from LoweringGear_F state to GearDown_A state

print Hydraulic_pump:- Enable

print current_state:- GearDown_A

print light status:- GREEN

print Direction_valve:- DOWN

print GasPressurized spring_status:- NULL

Enter the value of pilot lever position

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.