Challenge

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

NOTE : For better understanding and screenshots please reffer attached word file.

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

AIM :

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.

Goals :

Controlling the direction of Valve.

Controlling the retraction and extension of 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 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.

THEORY

1) Landing gear is the undercarriage of an aircraft that is used for take-off or landing.

2) For aircraft, the landing gear supports the craft when it is not flying, allowing it to take off, land, and taxi safely.

3) To decrease air-drag in flight, gears are folded in body of aircraft such gears called ‘retraction gear’.

4) When aircraft is on run-way the gear is in down(extension) condition.

5) Once aircraft is in air, gear is retracted means folded in body of aircraft(retraction).

6) Before landing, gear is put in extension condition (gear down).

7) Retraction and extension are done by hydraulic mechanism.

8) Basic mechanism is shown in below figure:

Program :

/*

* flight.c

*

* Created on: 09-Feb-2023

* Author: Er Mayur Deokate

*/

#include<stdio.h>

#include<conio.h>

/*libraries included*/




typedef enum

{

gear_down,

check_ready_to_takeoff,

gear_raising,

gear_up,

check_ready_to_landing,

gear_lowering

}state1;

/*in above line we created user

* defined data type by using

* 'enum'

* then, we changed name of

* data type by using

* 'typedef'

* we defined required states in this

* data type

*/




void initialize_FSM(void);

/*defined function for initial

* conditions of FSM

*/




void gear_down1(void);

void check_ready_to_takeoff1(void);

void gear_raising1(void);

void gear_up1(void);

void check_ready_to_landing1(void);

void gear_lowering1(void);

/*in above lines we created different

* functions for each operation state

*/

void (*state_table[])(void);

/*created function table

* array of function pointers

*/

state1 current_state;

/*declared new variable of

* data type 'state1'

*/

int out = 0;

/*declared global variable*/




int main()

{

initialize_FSM();

/*called initialization

* function

*/

while(1)

{

state_table[current_state]();

}

/*in above loop we called 'function_table'

* which is array of function pointers

* which will call defined functions one

* by one by using while loop

*/

return 0;

}




void gear_down1(void)

{

out = 1;

printf("\n\n\n STAGE1: GEAR DOWN");

printf("\n out = %d", out);

if(current_state == gear_down)

{

current_state = check_ready_to_takeoff;

}

}

/*it this function we printed statements

* for indication and variable 'out' to

* check state.

* Check the current state of system and

* if 'if()' condition is satisfied it will

* move to next state or update current

* state

*/

/*below functions are similar to above

* function

*/




void check_ready_to_takeoff1(void)

{

out = 2;

printf("\n\n STAGE2: CHECKING FOR READY TO TAKEOFF");

printf("\n out = %d", out);

if(current_state == check_ready_to_takeoff)

{

current_state = gear_raising;

}

}




void gear_raising1(void)

{

out = 3;

printf("\n\n STAGE3: GEAR RAISING");

printf("\n out = %d", out);

if(current_state == gear_raising)

{

current_state = gear_up;

}

}




void gear_up1(void)

{

out = 4;

printf("\n\n STAGE4: GEAR UP");

printf("\n out = %d", out);

if(current_state == gear_up)

{

current_state = check_ready_to_landing;

}

}






void check_ready_to_landing1(void)

{

out = 5;

printf("\n\n STAGE5: CHECKING FOR READY TO LANDING");

printf("\n out = %d", out);

if(current_state == check_ready_to_landing)

{

current_state = gear_lowering;

}

}




void gear_lowering1(void)

{

out = 6;

printf("\n\n STAGE6: GEAR LOWERING");

printf("\n out = %d", out);

if(current_state == gear_lowering)

{

current_state = gear_down;

}

}




void (*state_table[])(void) =

{ gear_down1, check_ready_to_takeoff1, gear_raising1,

gear_up1, check_ready_to_landing1, gear_lowering1

};

/*in this function table we added functions

* in list to be called

*/




void initialize_FSM(void)

{

out = 0;

printf("\n STAGE0: INITIALIZING FSM");

printf("\n out = %d", out);

current_state = gear_down;

}

/*in this function we will initialize

* initial conditions of system

*/

Program Output :

STAGE1: GEAR DOWN

out = 1

STAGE2: CHECKING FOR READY TO TAKEOFF

out = 2

STAGE3: GEAR RAISING

out = 3

STAGE4: GEAR UP

out = 4

STAGE5: CHECKING FOR READY TO LANDING

out = 5

STAGE6: GEAR LOWERING

out = 6

We can see from output that we started with ‘gear_down’ state and followed to next state by checking each condition.

Conclusion :

We studied and built required program and also observed output.

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.