All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
Aim: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…
Setlem Yogi Venkata Karishma
updated on 25 May 2022
Aim: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.
a) Initailizing state machine of all condition
b) Gear down
c) Checking before take off
d) raising gear
e) gear up condition
f) Check before landing
g) Lowering gear
Goals:
Highlights and deliverables of the project:
Main.c file:
#include //preprocessor directives
#include "states.h"//preprocessor directives
static void (*state_table[])(void) = {Gear_Down,Checking_Before_takeoff,Raising_Gear,//Calling an different finite state condition inside the void function
Gear_Up,Checking_Before_Landing,Lowering_Gear};
int main()//main function
{
Init_State_Machine();//Initializing the state of an machine
while(1)//calling an while loop to execute an different condition
{
state_table[current_state]();//Initializing an array of an current state inside that of an state table
}
}
Header.h File:
#ifndef STATES_H_//PREPROCESSOR DIRECTIVES
#define STATES_H_//PREPROCESSOR DIRECTIVES
void Init_State_machine();//CHECKING FOR AN STATE FOR AN INITIAL STATE OF THE MACHINE
void Gear_Down();//Calling void for an gear down condition
void Checking_Before_Takeoff();//Calling void for an before takeoff condition
Void Raising_Gear();//Calling void for an raising gear condition
Void Gear_Up();//calling void for an gear up condition
void Checking_Before_Landing();// Calling void for an checking before landing
void Lowering_Gear();//Calling void for an lowering gear
typedef enum State//calling an typedef and an enum for different states
{
GR_DWN,//gear down
CHK_BFR_TKFF,//checking before takeoff
RSING_GR,//raising gear
GR_UP,//gear up
CHK_BFR_LND,//checking before land
LWRNG_GR//lowerung gear
}
State_Type;//end of the typedef enum for an switch case
{
Open,//during an open state
Close,//during an close state
}
Switch_Status;//end of typedef enum function
typedef enum Pilot_Lever//calling an typedef enum for an pilot lever state
{
Rising,//during rising state
Falling,//during falling state
UP,//during up condition
Down,//during down condition
}
Pilot_Lever_Status;//end of typedef enum function
typedef enum Hydraulic_Mechanism//calling an typedef enum for an Hydraulic_Mechanism state
{
Working,//during working state
Malfunctioning////during Malfunctioning state
}
Hydraulic_Mechanism_Status;//end of typedef enum function
static volatile Switch_Status squat_switch;//static volatile switch state condition for an squat switch
static volatile Switch_Status limit_switch;//static volatile switch state condition for an limit switch
static volatile Pilot_Lever_Status Pilot_Lever;//static volatile switch state condition for an Pilot_Lever
Static volatile Hydraulic_Mechanism_Status hydraulic_Mechanism;//static volatile switch state condition for hydraulic_Mechanism_status
State_Type current_state;//end of state type loop
typedef struct//calling an structure inside an typedef''
{
char* current_state_indication;//calling pointer char for current state indication
char* light_status;//calling pointer char for light status
char* direction_value_status;//calling pointer char for direction_pump_control_status
char* hydraulic_pump_control_status;//calling pointer char for hydraullic_pump_control_status
}
State_Table;
static State_Table State_Machine[6] = {//an different state of an state machine
is called in an array of an state table with an static data type
{"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",00},
{"Checking Before Landing","Red","Down","Enabled",00},
{"Lowering Gear","Green","Down","Enabled",{"Disabled","Enabled"}}
};
#endif /*STATES_H_*///end of an headerfile.
Checking before landing.s File:
#include "States.h"//preprocessor directives
#include<stdio.h>//preprocessor directives
void Checking_Before_landing ()//calling an cgeck before landing condition
{
current_state = CHK_BFR_LND;//checking for current state in check before land
printf("nCurrent state : %sn",State_Machine[current_state].current_state_indication);//console inut output statements
printf("nEnter the Pilot's Lever position and status of hydraullic Mechanism");
fflush(stdout);
scanf("%d %d",&pilot_lever,&hydraulic_mechanism);//console input output tatements
if(pilot_levver == DOWN && hydraulic_Mechanism == Working)// execution of if loop
{
current_state = LWRNG_GR;
printf("ncurrent state : %sn",state_Machine[current_state].current_state_indication);
printf("light status:%sn",statea-machine[current_state].light_status);
printf("Direction Valve Status:%sn",State_machine[current_status].direction_valve_status);
}
else if(pilot_lever == DOWN & hydraulic_mechanism == Mal functioning//execution of if else loop for pilot lever and also to an hydraiullic mechanism
{
current_state = LWRNG_GR;//lowering gear sent to an current state of the gear
printf("ncurrent state : %sn",state_Machine[current_state].current_state_indication);
printf("light status:%sn",statea-machine[current_state].light_status);
printf("Direction Valve Status:%sn",State_machine[current_status].direction_valve_status);
Printf("Gas Pressurized sppring system status:%sn",status:%sn",State_Machine[current_state].gas_pressurized_spring_status[hyraulic_mechanism]);
}
//console input statements
if(pilot_lever == (UP || Rising || Falling))//ending an if loop statements
{
Checking_Before_Landing();
}
Checking before takeoff.s File:
#include "States.h"//Preprocessor directives
#include<stdio.h>//preprocessor directives
void Checking_Before_Takeoff()//calling an void for checking_Before_Takeoff
state
{
current_state = CHK_BFR_TKFF;//Checking _Before_Takeoff state to an current state
printf("n Enter the pilot's Lever Position, Squat Switch Status and Hydraulic status:");//console input output statement
fflush(stdout);//to clear unwanted memory
scanf("%d %d %d", &pilot_lever, &squat_switch, &hydraaulic_mechanism)://console input output statement
printf("n wait for 2 secsn");//console input output statement
if(pilot_lever == Falling || squat_switch == Close)// execution of if loop
{
Gear_Down();
}
elseif(pilot_lever == UP && squat_switch == Open && hydraulic_mechanism == working//execution of an else if in other state condition
{
current_state = RISING_GR;
printf("ncurrent state : %sn",state_Machine[current_state].current_state_indication);
printf("light status:%sn",statea-machine[current_state].light_status);
printf("Direction Valve Status:%sn",State_machine[current_status].direction_valve_status);
}
else if(pilot_lever == UP & squat_switch == Open && hydraulic_mechanism == Mal functioning//execution of an else if in other state condition
{
current_state = LWRNG_GR;//lowering gear sent to an current state of the gear
printf("ncurrent state : %sn",state_Machine[current_state].current_state_indication);
printf("light status:%sn",statea-machine[current_state].light_status);
printf("Direction Valve Status:%sn",State_machine[current_status].direction_valve_status);
Printf("Gas Pressurized sppring system status:%sn",status:%sn",State_Machine[current_state].gas_pressurized_spring_status[hyraulic_mechanism]);
}
}
Gear down.s File:
#include "States.h"//Preprocessor directives
#include<stdio.h>//preprocessor directives
current_state =GR_DWM;//Checking _Before_Takeoff state to an current state
printf("n Enter the pilot's Lever Position, Squat Switch Status:");//console input output statement
fflush(stdout);//to clear unwanted memory
scanf("%d %d", &pilot_lever, &squat_switch)://console input output statement
if(pilot_lever == Rising && squat_switch == Open)// calling an if loop condition for raising and open state of an pilot gear
{
current_state = CHK_BFR_TKFF;
printf("ncurrent state : %sn",state_Machine[current_state].current_state_indication);//console input output statements
printf("light status:%sn",statea-machine[current_state].light_status);
}
else
{
Gear_Down();//end of an if else statement
}
}
Initial state.s File:
#include "States.h"//Preprocessor directives
void Init_State_Machine()//calling an void for initial satte machine
{
current_state = GR_DWN;//them geardown state is put to an current state of the machine
printf("nstate machine is initialized & program is in Gear_Down state & Light_status: %sn", State_Machine[current_state].light_status);//console output statements)
}
Lowering gear.s File:
#include "States.h"//Preprocessor directives
#include<stdio.h>//preprocessor directives
void Lowering_Gear();//Calling void for an lowering gear
{
current_state = LWRNG_GR;//Calling an void for LWRNG_GR state
printf("n Enter the Limit Switch Status, pilot's Lever Position:");//console input output statement
fflush(stdout);//to clear unwanted memory
scanf("%d %d", &Limit_switch, &pilot_lever)://console input output statements
if( squat_switch == CLose && pilot_lever == Rising )// calling an if loop condition for an close an raising state for limit switch and pilot lever for if statement
{
current_state = CHK_BFR_TKFF;
printf("ncurrent state : %sn",state_Machine[current_state].current_state_indication);//console input output statements
printf("light status:%sn",state_machine[current_state].light_status);//console input output statements
}
if(limit_switch == Open && pilot_lever == DOWN)// calling an if else statement
{
current_state =GR_DWM;//gear down initialized to an current state
printf("ncurrent state : %sn",state_Machine[current_state].current_state_indication);
printf("light status:%sn",statea-machine[current_state].light_status);
printf("Hydraulic control for landing Gear status:%sn", state_machine[currrent_state].hydraulic_pump_control_status);}
else{
Lowering_Gear();//end of else statement for an lowering gear state
}
}
Lowering gear.s File
#include "States.h"//Preprocessor directives
#include<stdio.h>//preprocessor directives
void Raising_Gear();
current_state = RISING_GR;
printf("n Enter the Limit Switch Status, pilot's Lever Position:");//console input output statement
fflush(stdout);//to clear unwanted memory
scanf("%d %d", &Limit_switch, &pilot_lever)://console input output statements
printf("nWait for 1 secn");//console input output statement
if(pilot_lever == Falling && limit_switch == Open)// execution of an if in other state condition of an pilot liver and an limit switch
{
current_state = CHK_BFR_TKFF;
printf("ncurrent state : %sn",state_Machine[current_state].current_state_indication);//console input output statements
printf("light status:%sn",state_machine[current_state].light_status);//console input output statements
printf("Hydraulic contaol for Landing Gear status:", State-machine[current_state].hydraulic_pump_control_status);
}
else if(limit_switch == Close && pilot_lever == UP)//executionof an else if in other state condition
{
current -state = GR_UP;
printf("ncurrent state : %sn",state_Machine[current_state].current_state_indication);//console input output statements
printf("light status:%sn",state_machine[current_state].light_status);//console input output statements
printf("Hydraulic contaol for Landing Gear status:", State-machine[current_state].hydraulic_pump_control_status);
}
else
{
Raising_Gear();//end of else statement for an Raising_Gear state
}
}
Expected Outputs:
Leave a comment
Thanks for choosing to leave a comment. Please keep in mind that all the comments are moderated as per our comment policy, and your email will not be published for privacy reasons. Please leave a personal & meaningful conversation.
Other comments...
Project 1 - Interfacing a 16*2 LCD with Arduino using I2C protocol
Aim: Overview of the Project: In this project implementing the Code for “Interfacing a 16*2 LCD with two Arduino’s (one for Master and one for Slave) using Inter-Integrated Circuit (I2C) communication protocol” by sending the message to LCD using I2C communication protocol and display the message…
15 Jun 2022 09:49 AM IST
Project 2
Objective: Design an interleaving DC/DC converter system for a data centre application with the following specifications: • Input voltage: 45 – 60 v• Output voltage: 3 V• Output current: 100A• Efficiency > 85% (extra credit for efficiency higher than 90% on a spice-based software simulation…
04 Jun 2022 09:32 AM IST
Project 1
Project:1 Choose any three topologies and develop the models in Simulink. The project design report should include the following:1- A Design report to show the reasoning behind your choices of inductance and capacitance levels in your design.2- The full schematics of your converter including gate drivers, PWM chips,…
03 Jun 2022 11:36 AM IST
Project 2 - Implement the Code for controlling the retraction and extension of Airplane’s landing gear
Aim: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…
25 May 2022 06:57 AM IST
Related Courses
0 Hours of Content
Skill-Lync offers industry relevant advanced engineering courses for engineering students by partnering with industry experts.
© 2025 Skill-Lync Inc. All Rights Reserved.