Challenge

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 an Airplane’s landing gear

Overview of the Project:

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.

Goals

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

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.

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.

Expected Outcomes:

The student will be getting Knowledge of the Finite State Machine algorithm which is used to achieve control over the retraction and extension of the Airplane’s landing gear using the switch and gear states of the Airplane.

State Table

Current States

Input

Output

Next State

Gear Down

Pilot’s Lever Rising && Squat Switch Open

Lights = Green

Checking before Take off Delay 3s

Checking before Take off Delay 3s

Pilot’s Lever UP && Hydraulic Mechanism working && Squat Switch Open

Lights = RED

Raising Gear

Checking before Take off Delay 3s

Squat Switch Close || Pilot’s Lever falling

Lights = RED

Gear Down

Raising Gear

Limit Switch Closed && Pilot lever up

Lights OFF

Gear UP

Raising Gear

Pilot’s Lever Falling && limit switch open

Lights = RED

Checking before Landing

Gear UP

Pilot’s Lever falling / Control enabled

Lights = Red

Checking before Landing

Checking before Landing

Pilot’s Lever Down/ Direction Valve = DOWN

Lights = Red

Lowering Gear

Lowering Gear

Pilot’s Lever Raising

Lights = RED

Checking before Take off Delay 3s

Lowering Gear

Limit Switch Opened

Lights = Green

Gear Down

SWITCH

Pilot_Lever

Hydraulic_Mechanism

Open 0

Rising, 0

Working, 0

Close 1

Falling, 1

Malfunctioning 1

UP, 2

Down 3

/*
* plane.c
*
* Created on: 14-Jan-2023
* Author: Rakesh
*/

#include <stdio.h> //header//
#include "states.h" //header for states //

static void (*state_table[])(void) = {Gear_Down,Checking_Before_Takeoff,Raising_Gear,
Gear_Up,Checking_Before_Landing,Lowering_Gear}; //Various states //
int main()
{
Init_State_Machine(); //while loop start hear//
while(1)
{
state_table[current_state]();
}
}

void Init_State_Machine() //Intialize the state machine//
{
current_state = GR_DWN; //current state is geardown//
printf("\nState Machine is initialized & Program is in Gear_Down State & Light_Status : %s\n",State_Machine[current_state].light_Status);

}
//header//

void Gear_Down(void) //function for Gear down//
{
current_state = GR_DWN;
printf("\n Enter the Pilot's Lever Position and Squat Switch Status:");
fflush(stdout);
scanf("%d %d",&pilot_lever,&squat_switch);

if (pilot_lever == Rising && squat_switch == Open)
{
printf("\nWait for 4 sec\n");
current_state = CHK_BFR_TKFF;
printf("\n Current State:%s\n",State_Machine[current_state].current_state_indication);
printf("Light Status:%s\n",State_Machine[current_state].light_Status);

}
else
{
Gear_Down();
}
}


void Checking_Before_Takeoff()//function for check before takeoff//
{
current_state = CHK_BFR_TKFF;
printf("\n Enter the Pilot's Lever Position,Squat Switch Status and Hydraulic Mechanism Status:");
fflush(stdout);
scanf("%d %d %d",&pilot_lever,&squat_switch,&hydraulic_mechanism);
printf("\n Wait for 2 secs\n");
if(pilot_lever == Falling || squat_switch == Close)
{
Gear_Down();
}
else if (pilot_lever == UP && squat_switch == Open && hydraulic_mechanism == Working)
{
current_state = RSING_GR;
printf("\n Current State: %s\n",State_Machine[current_state].current_state_indication);
printf("Light Status:%s\n",State_Machine[current_state].light_Status);
printf("Direction Value Status:%s\n\n",State_Machine[current_state].direction_value_status);
}
else if (pilot_lever == UP && squat_switch == Open && hydraulic_mechanism == Malfunctioning)
{
printf("\n Current State: %s\n",State_Machine[current_state].current_state_indication);//chk_bfr_tkf= up(2),squat_switch=(0) and working=(1)//
printf("Light Status:%s\n",State_Machine[current_state].light_Status);
printf("Direction Value Status:%s\n",State_Machine[current_state].direction_value_status);
printf("Gas Pressurized Spring System Status:%s\n",State_Machine[current_state].gas_pressurized_spring_status[hydraulic_mechanism]);
}
}


void Raising_Gear() //function for rising gear //
{
current_state = RSING_GR;
printf("\n Enter the Limit Switch Status, Pilot's Lever Position :");// enter the console of limit switch and pilot lever posistions//
fflush(stdout);
scanf("%d %d",&limit_switch,&pilot_lever);
printf("\nWait for 1 sec\n");
if(pilot_lever == Falling && limit_switch == Open)
{
current_state = CHK_BFR_LND;
printf ("\n Current State: %s\n",State_Machine[current_state].current_state_indication);
printf ("Light Status:%s\n",State_Machine[current_state].light_Status);
printf ("Hydraulic Control for Landing Gear Status:%s\n",State_Machine[current_state].hydraulic_pump_control_status);
}
else if (limit_switch == Close && pilot_lever == UP) //chk_bfr_lnd= close(1) and pilot_lever =(2)//
{
current_state = GR_UP;
printf ("\n Current State: %s\n",State_Machine[current_state].current_state_indication);
printf ("Light Status:%s\n",State_Machine[current_state].light_Status);
printf ("Hydraulic Control for Landing Gear Status:%s\n",State_Machine[current_state].hydraulic_pump_control_status);
}
else
{
Raising_Gear();
}
}

void Gear_Up() //function for gear up//
{
current_state = GR_UP;
printf("\n Enter the Pilot's Lever Position:");
fflush(stdout);
scanf("%d",&pilot_lever);
if(pilot_lever ==Falling)
{
current_state = CHK_BFR_LND;
printf("\n Current State:%s\n",State_Machine[current_state].current_state_indication);
printf("Light Status:%s\n",State_Machine[current_state].light_Status);
printf("Hydraulic Control for Landing Gear Status:%s\n",State_Machine[current_state].hydraulic_pump_control_status);
}
else
{
Gear_Up();
}
}


void Checking_Before_Landing() //function for checking before landing //
{
current_state = CHK_BFR_LND;
printf("\nCurrent State : %s\n",State_Machine[current_state].current_state_indication);
printf("\nEnter the Pilot's Lever Position and Status of Hydraulic Mechanism:");
fflush(stdout);
scanf("%d %d",&pilot_lever,&hydraulic_mechanism);
if(pilot_lever == DOWN && hydraulic_mechanism == Working)
{
current_state = LWRNG_GR;
printf("\nCurrent State : %s\n",State_Machine[current_state].current_state_indication);
printf("Light Status:%s\n",State_Machine[current_state].light_Status);
printf("Direction Valve Status:%s\n",State_Machine[current_state].direction_value_status);
}
else
{
Checking_Before_Landing();
}
}

void Lowering_Gear() //function declarartion//
{
current_state = LWRNG_GR;
printf("\n Enter the Limit_Switch Status,Pilot_Lever Status ::"); //enter the console//
fflush(stdout);
scanf("%d %d",&limit_switch,&pilot_lever); //reads the address//
if( limit_switch == Close && pilot_lever == Rising) // limit_switch =close(1) and pilot__ lever=rising(0)//

{
current_state = CHK_BFR_TKFF;
printf("\n Current State: %s\n",State_Machine[current_state].current_state_indication);
printf("Light Status:%s\n",State_Machine[current_state].light_Status);
}
if(limit_switch == Open && pilot_lever == DOWN)
{
current_state = GR_DWN;
printf ("\n Current State: %s\n",State_Machine[current_state].current_state_indication);
printf ("Light Status:%s\n",State_Machine[current_state].light_Status);
printf ("Hydraulic Control for Landing Gear Status:%s\n",State_Machine[current_state].hydraulic_pump_control_status);
}
else
{
Lowering_Gear();
}
}

/*
* states.h
*
* Created on: 13-Jan-2023
* Author: Rakesh
*/

#ifndef STATES_H_
#define STATES_H_
void Init_State_machine(); //function delcarartion// // void is used to function return type//
void Gear_Down();
void Checking_Before_Takeoff();
void Raising_Gear();
void Gear_Up();
void Checking_Before_Landing();
void Lowering_Gear();

typedef enum State // Enum function for various states //
{

GR_DWN,
CHK_BFR_TKFF,
RSING_GR,
GR_UP,
CHK_BFR_LND,
LWRNG_GR
}State_Type;

typedef enum Switch // Enum function for switches //
{
Open,
Close
}Switch_Status;

typedef enum Pilot_Lever // Enum function for switches //
{
Rising,
Falling,
UP,
DOWN
}Pilot_Lever_Status;

typedef enum Hydraulic_Mechanism //Enum for hydralic mechanism//
{
Working,
Malfunctioning
}Hydraulic_Mechanism_Status;

static volatile Switch_Status squat_switch; //A function that has a scope that is limited to its object file//
static volatile Switch_Status limit_switch;
static volatile Pilot_Lever_Status pilot_lever;
static volatile Hydraulic_Mechanism_Status hydraulic_mechanism;

State_Type current_state;

typedef struct
{
char* current_state_indication; //calling the status of the lights,valves //
char* light_Status;
char* direction_value_status;
char* hydraulic_pump_control_status;
char* gas_pressurized_spring_status[2];
}State_Table;

static State_Table State_Machine[6] = { //state_ Table//
{"GearDown","Green","Down","Enabled",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 /* STATES_H_ */

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.