Challenge

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

Overview of the 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.

Here controlling the retraction and extension of Airplanes landing gear:

  • State_Type
  • Limit _Switch_Status
  • Pilot_Lever_Status
  • Hydraulic_Mechanis

State Diagram of a Project:

  1. GEAR_DOWN:- pilot's lever rising && squat switch open/light=GREEN it is not satified then it will return to Squat Switch close or pilots lever falling to CHECK_BEFORE TAKE OFF
  2. CHECK_BEFORE TAKE OFF:-pilots lever up/Direction valve =UP,light= RED to RAISING_GEAR.
  3. RAISING_GEAR:-limt Switch closed/light OFF, control for landing gear disabled and (it will check the checking before landing also simultaneously)plots lever falling/ light =RED to GEAR_UP and CHECKING_ BEFORE _LANDING.
  4. GEAR_UP:-pilots lever falling /control enabled,light =RED to GEAR_UP and CHECKING_ BEFORE _LANDING.GEAR_UP and
  5. CHECKING_ BEFORE _LANDING:-pilots lever down/direction valve =DOWN to LOWERING_GEAR.
  6. LOWERING_GEAR:-limt switch opened/light =GREEN after it is go again first to GEAR_ DOWN .if it not satisfied then it will go to CHECKING BEFORE TAKE OFF DELAY 3sec

Goals:

(i)Controlling the direction Valve.

(ii)Controlling the retraction and extension of Airplane’s landing gear.

CONTROLLING DIRECTION VALVE:

  • pilot's lever state is lever UP then its will must be direction will be UP
  • pilot's lever state is lever DOWN then its will must be direction will be DOWN

CONTROLLING AIRPLANE'S GEAR:

  • Limit Switch CLOSED then it is gear is UP
  • limit switch OPEND then it is gear is DOWN

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.

  • Direction valve is DOWN then it will be GEAR DOWN
  • Direction vave is UP then it will be Raising gear (Takeoff)
  • Control of hydraulic pump for the landing gear part is disable then it will be Gear UP(airborne)
  • Direction valve is DOWN then it will be Lowering Gear (Landing)

we have to perfroming the many direction valve controlling:

  1. GEAR_DOWN
  2. CHECK_BEFORE TAKE OFF
  3. RAISING_GEAR
  4. GEAR_UP
  5. CHECKING_ BEFORE _LANDING
  6. LOWERING_GEAR

Deliverables of this project:

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.

State Machine is initialized & Program is in Gear_Down State & Light_Status : Green

Enter the Pilot's Lever Position and Squat Switch Status:0 0

Enter the Pilot's Lever Position,Squat Switch Status and Hydraulic Mechanism Status:2 0 0

Enter the Limit Switch Status, Pilot's Lever Position :1 2

Enter the Pilot's Lever Position:1

Enter the Pilot's Lever Position and Status of Hydraulic Mechanism:3 1

Enter the Limit_Switch Status,Pilot_Lever Status ::3 0

Expected Outcomes:

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.

GR_DWN(0):

State Machine is initialized & Program is in Gear_Down State & Light_Status : Green

Enter the Pilot's Lever Position and Squat Switch Status: 0 0

Current State: Checking Before Take Off
Light Status: Green

CHK_BFR_TKFF(1):

Enter the Pilot's Lever Position,Squat Switch Status and Hydraulic Mechanism Status: 2 0 0

Wait for 2 secs

Current State: Raising Gear
Light Status:Red
Direction Value Status:Up

RSING_GR(2):

Enter the Limit Switch Status, Pilot's Lever Position :1 2

Wait for 1 sec

Current State: Gear Up
Light Status:Off
Hydraulic Control for Landing Gear Status: Disabled

GEAR_UP(3):

Enter the Pilot's Lever Position:1

Current State: Checking Before Landing
Light Status: Red
Hydraulic Control for Landing Gear Status: Enabled

CHK_BFR_LANDING(4):

Enter the Pilot's Lever Position and Status of Hydraulic Mechanism:3 1

Current State : Lowering Gear
Light Status: Green
Direction Valve Status: Down
Gas Pressurized Spring System Status: Enabled

LWRING_GR(5):

Enter the Limit_Switch Status,Pilot_Lever Status :3 0

Current State: Checking Before Take Off
Light Status: Green

PROGRAM:

.h FILE:

/*
* fsm.h
*
* Created on: Aug 9, 2022
* Author: Sharma s
*/

/* Mealy Method: It depends on Current State and as well current input */

#ifndef FSM_H_
#define FSM_H_

#include
void Initial_state_machine(); // Function Declaration
void Gear_down();
void Checking_before_takeoff();
void Raising_gear();
void Gear_up();
void Checking_before_landing();
void Lowering_gear();

typedef enum states // enum is used to giving subsequent value for each states. It gives values from 0 to 5
{
GEAR_DOWN,
CHECK_BEFORE_TAKEOFF,
RAISING_GEAR,
GEAR_UP,
CHECK_BEFORE_LANDING,
LOWERING_GEAR
}state_type;


typedef enum Switch // By using enum It gives values from 0 and 1
{
open, // open=0 close=1
close // Plane is in Ground
}Switch_status;

typedef enum pilot_lever
{
raising, // By using enum raising =0, falling=1, up=2 and down=3 is assumed
falling,
up,
down
}pilot_lever_status;

typedef enum hydraulic_mechanism // By using enum 0 means for working and 1 means for malfunction
{
working,
malfunctioning

}hydraulic_mechanism_status;

/* input used in order to change the state */ // Volatile means compiler can't optimise the variable

static volatile Switch_status squat_switch; // Squat switch applicable only for nose gear
static volatile Switch_status limit_switch; // limit switch applicable for all gears
static volatile pilot_lever_status pilot_lever;
static volatile pilot_lever_status hydraulic_mechanism;

state_type current_state;


typedef struct // Structure is used to have different types of data type
{
char* current_state_status; // Output which we want to visualize are given inside structure as structure member.
char* light_status;
char* direction_value_status;
char* hydraulic_pump_ctrl_status;
char* gas_pressurized_spring_status[2];
}state_table;


/* State Table of the require System*/
static state_table state_machine[6] = {
{"gear down","green","down","enables",{0,0}},
{"checking before take off","green","down","enabled",{0,0}},
{"raising gear","red","up","enabled",{"disabled","enabled"}},
{"gear up","off","NULL","disabled",{0,0}},
{"checking before landing","red","down","enabled",{0,0}},
{"lowering gear","green","down","enabled",{"disabled","enabled"}}
};


#endif /* FSM_H_ */

.C FILE:

#include "fsm.h" // Pre Processor Directives with user defined library

/* Below Statement for represents that how program wants to be perform*/
static void(*State_Table[])(void)={Gear_down,Checking_before_takeoff,Raising_gear,
Gear_up,Checking_before_landing,Lowering_gear};

int main() // Main Function //
{
Initial_state_machine();
while(1)
{
State_Table[current_state]();
}
}

/* Initial State Machine */
void Initial_state_machine()
{
current_state = GEAR_DOWN; // During Initialization, System is at Gear Down.
printf("\n state machine is initials and at first program is in gear down and its light status is:%s\n",state_machine[current_state].light_status);

}

/* Gear Down */
void Gear_down(void)
{
current_state =GEAR_DOWN;
printf("\n Enter the pilot's lever position and squat switch status:\n"); // Getting Pilot Lever and Squat Switch Value from Input
fflush(stdout);
scanf("%d %d",&pilot_lever,&squat_switch);
if(pilot_lever == raising && squat_switch == open) // if pilot lever raising(0) and squar switch is open(0)
{
current_state = CHECK_BEFORE_TAKEOFF;
printf("\n The current state of the machine is: %s\n",state_machine[current_state].current_state_status);// current status value is printed from the state table
printf("\n Light status of the current machine state is:%s\n",state_machine[current_state].light_status);// light status value is taken from state table current state
}
else
{
Gear_down(); //gear down function is called
}
}

/* Checking Before Takeoff */

void Checking_before_takeoff()
{
current_state= CHECK_BEFORE_TAKEOFF; //current state is check before takeoff
printf("\n Enter the pilot lever position, squat switch and hydraulic mechancism:\n");// getting pilot liver, squat switch and hydraulic mechanism as input
fflush(stdout);
scanf("%d %d %d",&pilot_lever, &squat_switch,&hydraulic_mechanism);
printf("\n just wait 2secs\n");
if (pilot_lever == up && squat_switch== close) //pilot lever is up and squat switch is closed it get into the if loop
{
Gear_down(); //gear down function is called
}
else if (pilot_lever== up && squat_switch == open && hydraulic_mechanism == working)//
{
current_state= RAISING_GEAR;
printf("\n Current state: %s\n",state_machine[current_state].current_state_status);
printf("light status: %s\n", state_machine[current_state].light_status);
printf("\n direction status:%s\n\n",state_machine[current_state].direction_value_status);
}
else if (pilot_lever== up && squat_switch == open && hydraulic_mechanism == malfunctioning)
{
current_state= RAISING_GEAR;
printf("\n Current state: %s\n", state_machine[current_state].current_state_status);
printf("\nlight status: %s\n", state_machine[current_state].light_status);
printf("\n direction status:%s\n\n",state_machine[current_state].direction_value_status);
printf("\n Gas pressurised spring status:%s\n",state_machine[current_state].gas_pressurized_spring_status[hydraulic_mechanism]);
}
}

/* Raising Gear */
void Raising_gear()
{
current_state = RAISING_GEAR;
printf("\n Enter the switch status and pilot lever status:\n");
fflush(stdout);
scanf("%d %d",&limit_switch,&pilot_lever);
printf("\n wait for 1 sec\n");
if(pilot_lever == falling && limit_switch == open)
{
current_state = CHECK_BEFORE_LANDING;
printf("\n current state is:%s\n",state_machine[current_state].current_state_status);
printf("\n Light status:%s\n",state_machine[current_state].light_status);
printf("\nHydraulic condition for landing gear status is %s\n",state_machine[current_state].hydraulic_pump_ctrl_status);
}
else if(limit_switch == close && pilot_lever == up)
{
current_state= GEAR_UP;
printf("\n current state is:%s\n",state_machine[current_state].current_state_status);
printf("\n Light status:%s\n",state_machine[current_state].light_status);
printf("\nHydraulic condition for landing gear status is %s\n",state_machine[current_state].hydraulic_pump_ctrl_status);
}
else
{
Raising_gear();
}
}


/* Gear Up/ */

void Gear_up()
{
current_state= GEAR_UP;
printf("\n Enter the pilot lever position :\n");
fflush(stdout);
scanf("%d",&pilot_lever);

if (pilot_lever == falling )
{
current_state= CHECK_BEFORE_LANDING;
printf("\n Current state: %s\n", state_machine[current_state].current_state_status);
printf("\nlight status: %s\n", state_machine[current_state].light_status);
printf("\nHydraulic condition for landing gear status is %s\n",state_machine[current_state].hydraulic_pump_ctrl_status);
}
else
{
Gear_up();
}
}

/* Checking Before Landing */
void Checking_before_landing()
{
current_state= CHECK_BEFORE_LANDING;
printf("\n Enter the pilot lever position, status of hydraulic mechanism :\n");
fflush(stdout);
scanf("%d %d",&pilot_lever, &hydraulic_mechanism);

if(pilot_lever == down && hydraulic_mechanism == working)
{
current_state= LOWERING_GEAR;
printf("\n Current state: %s\n", state_machine[current_state].current_state_status);
printf("\nlight status: %s\n", state_machine[current_state].light_status);
printf("\n direction status:%s\n\n",state_machine[current_state].direction_value_status);
}
else if (pilot_lever== down && hydraulic_mechanism == malfunctioning)
{
current_state= LOWERING_GEAR;
printf("\n Current state: %s\n", state_machine[current_state].current_state_status);
printf("light status: %s\n", state_machine[current_state].light_status);
printf("\n direction status:%s\n\n",state_machine[current_state].direction_value_status);
printf("\n Gas pressurised spring status:%s\n",state_machine[current_state].gas_pressurized_spring_status[hydraulic_mechanism]);
}
if(pilot_lever== (up || raising || falling))
{
Checking_before_landing();
}
}

/* Lowering Gear */
void Lowering_gear()
{
current_state= LOWERING_GEAR;
printf("\n Enter the pilot lever position, limit switch :");
fflush(stdout);
scanf("%d %d",&pilot_lever, &limit_switch);

if (pilot_lever == raising && limit_switch==close)
{
current_state= CHECK_BEFORE_TAKEOFF;
printf("\n Current state: %s\n", state_machine[current_state].current_state_status);
printf("\nlight status: %s\n", state_machine[current_state].light_status);
}
if (pilot_lever== down && limit_switch == open)
{
current_state= GEAR_DOWN;
printf("\n Current state: %s\n", state_machine[current_state].current_state_status);
printf("\n light status: %s\n", state_machine[current_state].light_status);
printf("\n Hydraulic condition for landing gear status is %s\n",state_machine[current_state].hydraulic_pump_ctrl_status);
}
else
{
Lowering_gear();
}
}

OUTPUT:

state machine is initials and at first program is in gear down and its light status is:green

Enter the pilot's lever position and squat switch status:
0 0

The current state of the machine is: checking before take off

Light status of the current machine state is:green

Enter the pilot lever position, squat switch and hydraulic mechancism:
2 0 0

just wait 2secs

Current state: raising gear
light status: red

direction status:up


Enter the switch status and pilot lever status:
1 2

wait for 1 sec

current state is:gear up

Light status:off

Hydraulic condition for landing gear status is disabled

Enter the pilot lever position :
1

Current state: checking before landing

light status: red

Hydraulic condition for landing gear status is enabled

Enter the pilot lever position, status of hydraulic mechanism :
3 1

Current state: lowering gear
light status: green

direction status:down


Gas pressurised spring status:enabled

Enter the pilot lever position, limit switch :3 0

Current state: gear down

light status: green

Hydraulic condition for landing gear status is enables

Enter the pilot's lever position and squat switch status:

PROGRAM SCREENSHOTS:

OUTPUT SCREENSHOTS:

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.