Challenge

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

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.

Goals ( 2 to 3 points)

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

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.

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.

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.

/*
* prac_84.c
*
* Created on: 18-Aug-2022
* Author: RA
*/

/*in the program we,
* Implement the Code for controlling the
* retraction and extension of Airplane’s
* landing gear.
*/

/*
* Assumption: Gear is in condition
* 'gear_down' means aircraft is on run-way
* and started engines
*
*/

/*BASIC OUTLINE:
* STAGE1: gear down
* STAGE2: check for takeoff condition
* STAGE3: if takeoff, then start raising gear(retraction)
* STAGE4: gear up
* STAGE5: check for landing condition
* STAGE6: if landing, then start lowering gear(extension)
*/


#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
*/

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.