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
Ans:
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.
1.Here controlling the retraction and extension of Airplanes landing gear:
- State_Type
- Switch_Status
- Pilot_Lever_Status
- Hydraulic_Mechanis
- 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
- CHECK_BEFORE TAKE OFF-pilots lever up/Direction valve =UP,light= RED to RAISING_GEAR.
- 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.
- GEAR_UP-pilots lever falling /control enabled,light =RED to GEAR_UP and CHECKING_ BEFORE _LANDING.GEAR_UP and
- CHECKING_ BEFORE _LANDING-pilots lever down/direction valve =DOWN to LOWERING_GEAR.
- 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 ( 2 to 3 points)
- Controlling the direction Valve.
- 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: (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.
- 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:
- GEAR_DOWN
- CHECK_BEFORE TAKE OFF
- RAISING_GEAR
- GEAR_UP
- CHECKING_ BEFORE _LANDING
- LOWERING_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.
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 ::1 0
Expected Outcomes: (4 to 5 points)
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 ::1 0
Current State: Checking Before Take Off
Light Status:Green
programs:
MAIN.C
#include
#include "states.h" //header//
static void (*state_table[])(void) = {Gear_Down,Checking_Before_Takeoff,Raising_Gear,
Gear_Up,Checking_Before_Landing,Lowering_Gear}; //inputs based some condition//
int main()
{
Init_State_Machine(); //while loop start hear//
while(1)
{
state_table[current_state]();
}
}
states.h
#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 // A type def means declaring the alternative names//
{
GR_DWN, //here calling the different states //
CHK_BFR_TKFF,
RSING_GR,
GR_UP,
CHK_BFR_LND,
LWRNG_GR
}State_Type;
typedef enum Switch
{
Open, //here calling the different switch//
Close
}Switch_Status;
typedef enum Pilot_Lever
{
Rising,
Falling, //here calling the different pilot_lever//
UP,
DOWN
}Pilot_Lever_Status;
typedef enum Hydraulic_Mechanism
{
Working,
Malfunctioning //here calling the different hydraulic_ machanism//
}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 struct//
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] = { //calling the 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_ */ //end//
Init_State_Machine
#include"States.h"//header//
void Init_State_Machine() //function declaration//
{
current_state = GR_DWN; //In GEAR_DOWN light =GREEN//
printf("\nState Machine is initialized & Program is in Gear_Down State & Light_Status : %s\n",State_Machine[current_state].light_Status);
}
Gear_Down
#include "States.h" //header//
#include
void Gear_Down(void) //function delcaration//
{
current_state = GR_DWN; //gear down starts//
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) //GEAR_down =rising -(0) and open-(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);
}
else
{
Gear_Down();
}
}
Checking_Before_Takeoff
#include "States.h" //header//
#include
void Checking_Before_Takeoff()//function declarartion//
{
current_state = CHK_BFR_TKFF;
printf("\n Enter the Pilot's Lever Position,Squat Switch Status and Hydraulic Mechanism Status:");//console//
fflush(stdout);
scanf("%d %d %d",&pilot_lever,&squat_switch,&hydraulic_mechanism);//reads the address//
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)
{ //chk_bfr_tkf= up(2),squat_switch=(0) and working=(0)//
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)
{ //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]);
}
}
Raising_Gear
#include "States.h" //header//
#include
void Raising_Gear() //function declarartion//
{
current_state = RSING_GR;
printf("\n Enter the Limit Switch Status, Pilot's Lever Position :");// enter the console of t limt switch and pilot lever posistions//
fflush(stdout);
scanf("%d %d",&limit_switch,&pilot_lever); // read the address//
printf("\nWait for 1 sec\n");
if(pilot_lever == Falling && limit_switch == Open) //if statment will starts//
{
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();
}
}
Gear_Up
#include "States.h" // header//
#include
void Gear_Up() //function declaration//
{
current_state = GR_UP;
printf("\n Enter the Pilot's Lever Position:"); //enter the cosole pilot lever position//
fflush(stdout);
scanf("%d",&pilot_lever); //reads the address//
if(pilot_lever ==Falling) // if statement will starts// //pilot_lever == falling means "1"//
{
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();
}
}
Checking_Before_Landing
#include "States.h" //header//
#include
void Checking_Before_Landing() //function declaration//
{
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:"); // print the console//
fflush(stdout);
scanf("%d %d",&pilot_lever,&hydraulic_mechanism); //reads the address//
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 if(pilot_lever == DOWN && hydraulic_mechanism == Malfunctioning) // pilot_ lever= down(3)and hydr_mech=malfun(1)//
{
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);
printf("Gas Pressurized Spring System Status:%s\n",State_Machine[current_state].gas_pressurized_spring_status[hydraulic_mechanism]);
}
if(pilot_lever == (UP || Rising || Falling))
{
Checking_Before_Landing();
}
}
Lowering_Gear
#include "States.h" //header//
#include
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();
}
}
output:
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
Enter the Pilot's Lever Position,Squat Switch Status and Hydraulic Mechanism Status:0 2 0
Wait for 2 secs
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
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
Enter the Pilot's Lever Position:1
Current State:Checking Before Landing
Light Status:Red
Hydraulic Control for Landing Gear Status:Enabled
Current State : Checking Before Landing
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
Enter the Limit_Switch Status,Pilot_Lever Status ::1 0
Current State: Checking Before Take Off
Light Status:Green
Enter the Limit_Switch Status,Pilot_Lever Status ::

