Placement 2025 Scholarship: Your Future Starts Here | 6 Guaranteed Job Interviews | Limited to 100 seats. Apply Now

00D 00H 00M 00S

Menu

Executive Programs

Workshops

Projects

Blogs

Careers

Placements

Student Reviews


For Business


More

Academic Training

Informative Articles

Find Jobs

We are Hiring!


All Courses

Choose a category

Mechanical

Electrical

Civil

Computer Science

Electronics

Offline Program

All Courses

All Courses

logo

CHOOSE A CATEGORY

Mechanical

Electrical

Civil

Computer Science

Electronics

Offline Program

Top Job Leading Courses

Automotive

CFD

FEA

Design

MBD

Med Tech

Courses by Software

Design

Solver

Automation

Vehicle Dynamics

CFD Solver

Preprocessor

Courses by Semester

First Year

Second Year

Third Year

Fourth Year

Courses by Domain

Automotive

CFD

Design

FEA

Tool-focused Courses

Design

Solver

Automation

Preprocessor

CFD Solver

Vehicle Dynamics

Machine learning

Machine Learning and AI

POPULAR COURSES

coursePost Graduate Program in Hybrid Electric Vehicle Design and Analysis
coursePost Graduate Program in Computational Fluid Dynamics
coursePost Graduate Program in CAD
coursePost Graduate Program in CAE
coursePost Graduate Program in Manufacturing Design
coursePost Graduate Program in Computational Design and Pre-processing
coursePost Graduate Program in Complete Passenger Car Design & Product Development
Executive Programs
Workshops
For Business

Success Stories

Placements

Student Reviews

More

Projects

Blogs

Academic Training

Find Jobs

Informative Articles

We're Hiring!

phone+91 9342691281Log in
  1. Home/
  2. Kotesh Mogudala/
  3. 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

1. AIM:       To control 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. CODE: #include <stdio.h> // Functions Declarationvoid Start_State_Machine();void…

    • Kotesh Mogudala

      updated on 10 Jan 2023

    1.

    AIM:

          To control 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.

    CODE:

    #include <stdio.h>

    // Functions Declaration
    void Start_State_Machine();
    void GearDown();
    void CheckingBeforeTakeOFF();
    void RaisingGear();
    void GearUp();
    void CheckBeforeLanding();
    void LoweringGear();

    //Pointer to array function
    // Static -- Makes the function accesible throughout the program
    // Void --- Holds address of any type and can be typecasted to any type.
    static void(*statetable[])(void) = {GearDown, CheckingBeforeTakeOFF, RaisingGear, GearUp,
    CheckBeforeLanding, LoweringGear};

    typedef enum State{
    Gear_Down,
    Checking_Before_Takeoff,
    Raising_Gear,
    Gear_Up,
    Check_Before_Landing,
    Lowering_Gear
    }State_Type;

    typedef enum Switch{
    on,
    off
    }Switch_status;

    typedef enum pilot_lever{
    Raising,
    Falling
    }pilot_lever;

    typedef enum hydraulic_mechanism{
    working,
    not_working
    }hydraulic_mechanism;

    // User-defined data-types declaration
    // Violatile -- Tells the compiler that these variables can change their value anytime in the prog.
    static volatile Switch_status squat_switch;
    static volatile Switch_status limit_switch;
    static volatile pilot_lever p;
    static volatile hydraulic_mechanism h;

    State_Type current_state;

    typedef struct{
    char* current_state_indication;
    char* light;
    char* direction_valve_status;
    char* landing_gear_hydraulic_control;
    char* GPSS_status[2];
    }State_Table;


    static State_Table State_Machine[6]={
    {"GearDown","Yellow","Down","Enabled",{NULL,NULL}},
    {"CheckingBeforeTakeOFF","Yellow","Down","Enabled",{NULL,NULL}},
    {"RaisingGear","Red","Up","Enabled",{NULL,NULL}},
    {"GearUp","Off","NULL","Disabled",{NULL,NULL}},
    {"CheckBeforeLanding","Red","Down","Enabled",{NULL,NULL}},
    {"LoweringGear","Yellow","Down","Enabled",{"Disabled","Enabled"}}
    };


    // Gear down mechanism
    void GearDown(void){

    current_state = Gear_Down;
    printf("\nEnter the status of pilot's lever & squat switch : ");
    // To clear the buffer
    fflush(stdout);

    scanf("%d %d",&p,&squat_switch);

    if(p==Raising && squat_switch==on){

    current_state=Checking_Before_Takeoff;
    printf("Current state: %s\n",State_Machine[current_state].current_state_indication);
    printf("Light is :%s\n", State_Machine[current_state].light);
    }
    else{
    GearDown();
    }
    }

    //CheckingBeforeTakeOFF
    void CheckingBeforeTakeOFF(void){

    current_state = Checking_Before_Takeoff;
    printf("\nEnter the status of pilot's lever and squat switch and hydraulic mechanism : ");
    fflush(stdout);

    scanf("%d %d",&p,&squat_switch,&h);

    if(p==Falling && squat_switch==off){
    GearDown();
    }
    else if(p ==Raising && squat_switch==on && h==working){

    current_state=Raising_Gear;
    printf("Current State: %s\n",State_Machine[current_state].current_state_indication);
    printf("Light is: %s\n",State_Machine[current_state].light);
    printf("Status of Direction valve: %s\n",State_Machine[current_state].direction_valve_status);
    }
    else if(p == Raising && squat_switch==on && h ==not_working){

    current_state=Raising_Gear;
    printf("Current State: %s\n",State_Machine[current_state].current_state_indication);
    printf("Light is: %s\n",State_Machine[current_state].light);
    printf("Status of Direction valve: %s\n",State_Machine[current_state].direction_valve_status);
    printf("Status of gas pressurised Spring System: %s\n",State_Machine[current_state].GPSS_status);
    }
    }

    //Raising Gear mechanism
    void RaisingGear(void){

    current_state=Raising_Gear ;
    printf("\nEnter the status of pilot's lever and limit switch : ");
    fflush(stdout);

    scanf("%d %d",&p,&limit_switch);

    if(p==Falling && limit_switch==on){

    current_state=Check_Before_Landing ;
    printf("Current State: %s\n",State_Machine[current_state].current_state_indication);
    printf("Light is: %s\n",State_Machine[current_state].light);
    printf("Landing Gear Hydraulic Control: %s\n",State_Machine[current_state].landing_gear_hydraulic_control);
    }
    else if(p ==Raising && limit_switch==off){

    current_state=Gear_Up ;
    printf("Current State: %s\n",State_Machine[current_state].current_state_indication);
    printf("Light is: %s\n",State_Machine[current_state].light);
    printf("Landing Gear Hydraulic Control: %s\n",State_Machine[current_state].landing_gear_hydraulic_control);
    }
    else{

    RaisingGear();
    }
    }

    //Gear Up mechanism
    void GearUp(void){

    current_state=Gear_Up;
    printf("\nEnter the status of pilot's lever : ");
    fflush(stdout);
    scanf("%d",&p);
    if(p ==Falling){

    current_state = Check_Before_Landing;
    printf("Current State: %s\n",State_Machine[current_state].current_state_indication);
    printf("Light is: %s\n",State_Machine[current_state].light);
    printf("Landing Gear Hydraulic Control: %s\n",State_Machine[current_state].landing_gear_hydraulic_control);
    }
    else{

    GearUp();
    }

    }

    //CheckBeforeLanding
    void CheckBeforeLanding(void)
    {
    current_state=Check_Before_Landing;
    printf("\nEnter the status of pilot's lever and hydraulic mechanism status :");
    fflush(stdout);

    scanf("%d %d",&p,&h);

    if(p ==Falling && h ==working){

    current_state = Lowering_Gear;
    printf("Current State: %s\n",State_Machine[current_state].current_state_indication);
    printf("Light is: %s\n",State_Machine[current_state].light);
    printf("Status of Direction valve: %s\n",State_Machine[current_state].direction_valve_status);
    }
    else if(p ==Falling && h ==not_working){

    current_state = Lowering_Gear;
    printf("Current State: %s\n",State_Machine[current_state].current_state_indication);
    printf("Light is: %s\n",State_Machine[current_state].light);
    printf("Status of Direction valve: %s\n",State_Machine[current_state].direction_valve_status);
    printf("Status of gas pressurised Spring System: %s\n",State_Machine[current_state].GPSS_status);
    }
    else if(p ==(Raising)){

    CheckBeforeLanding();
    }
    }

    //Lowering Gear mechanism.
    void LoweringGear(void){

    current_state=Lowering_Gear;
    printf("\nEnter the status of pilot's lever and limit switch : ");
    fflush(stdout);

    scanf("%d %d",&p,&limit_switch);

    if(p == Falling &&limit_switch==on){

    current_state=Checking_Before_Takeoff;
    printf("\nCurrent State: %s\n",State_Machine[current_state].current_state_indication);
    printf("Light is: %s\n",State_Machine[current_state].light);
    }
    else if(p ==Raising && limit_switch==off){

    current_state=Gear_Down;
    printf("Current State: %s\n",State_Machine[current_state].current_state_indication);
    printf("Light is: %s\n",State_Machine[current_state].light);
    printf("Landing Gear Hydraulic Control: %s\n",State_Machine[current_state].landing_gear_hydraulic_control);
    }
    if(limit_switch==off){

    LoweringGear();
    }

    }

    //Initiate_State_Machine
    void Start_State_Machine(){

    current_state = Gear_Down;
    printf("\nAeroplane's Landing Gear is Intialized and current the program is in GearDown State & Light is: %s\n",State_Machine[current_state].light);
    }


    // Driver Code
    int main(){
    Start_State_Machine();

    while(1){
    statetable[current_state]();
    }

    return 0 ;
    }

    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.

    Please  login to add a comment

    Other comments...

    No comments yet!
    Be the first to add a comment

    Read more Projects by Kotesh Mogudala (12)

    Project 2

    Objective:

      a)       Max. heat generation of the battery pack is  Heat generation (Wh) = *R*t.I = 0.896 AmpsR = 2m Ωt = 120 secs = 0.03333 hoursHeat generation (W sec) = *0.002*120                                                =…

    calendar

    24 May 2024 01:04 PM IST

      Read more

      Project 1

      Objective:

      1.     Design a battery pack for a car roughly 150 Kw with 120 V. Use 3500 mAh 3.6V nominal NMC chemistry cell.a.     Design the battery pack configuration. b.     Draw the BMS topology for this battery pack.a)      Given, we have…

      calendar

      24 May 2024 12:40 PM IST

        Read more

        Project 1 - Controlling a DC motor using PWM and monitoring its Running status

        Objective:

        Live Batch (Preeti Mallikarjun):  

        calendar

        01 Aug 2023 12:31 PM IST

          Read more

          Project 3

          Objective:

          Live Batch ( Preeti Mallikarjun ):  

          calendar

          22 May 2023 11:26 AM IST

            Read more

            Schedule a counselling session

            Please enter your name
            Please enter a valid email
            Please enter a valid number

            Related Courses

            coursecard

            Design loads considered on bridges

            Recently launched

            10 Hours of Content

            coursecard

            Design of Steel Superstructure in Bridges

            Recently launched

            16 Hours of Content

            coursecard

            Design for Manufacturability (DFM)

            Recently launched

            11 Hours of Content

            coursecard

            CATIA for Medical Product Design

            Recently launched

            5 Hours of Content

            coursecardcoursetype

            Accelerated Career Program in Embedded Systems (On-Campus) Courseware Partner: IT-ITes SSC nasscom

            Recently launched

            0 Hours of Content

            Schedule a counselling session

            Please enter your name
            Please enter a valid email
            Please enter a valid number

            logo

            Skill-Lync offers industry relevant advanced engineering courses for engineering students by partnering with industry experts.

            https://d27yxarlh48w6q.cloudfront.net/web/v1/images/facebook.svghttps://d27yxarlh48w6q.cloudfront.net/web/v1/images/insta.svghttps://d27yxarlh48w6q.cloudfront.net/web/v1/images/twitter.svghttps://d27yxarlh48w6q.cloudfront.net/web/v1/images/youtube.svghttps://d27yxarlh48w6q.cloudfront.net/web/v1/images/linkedin.svg

            Our Company

            News & EventsBlogCareersGrievance RedressalSkill-Lync ReviewsTermsPrivacy PolicyBecome an Affiliate
            map
            EpowerX Learning Technologies Pvt Ltd.
            4th Floor, BLOCK-B, Velachery - Tambaram Main Rd, Ram Nagar South, Madipakkam, Chennai, Tamil Nadu 600042.
            mail
            info@skill-lync.com
            mail
            ITgrievance@skill-lync.com

            Top Individual Courses

            Computational Combustion Using Python and CanteraIntroduction to Physical Modeling using SimscapeIntroduction to Structural Analysis using ANSYS WorkbenchIntroduction to Structural Analysis using ANSYS Workbench

            Top PG Programs

            Post Graduate Program in Hybrid Electric Vehicle Design and AnalysisPost Graduate Program in Computational Fluid DynamicsPost Graduate Program in CADPost Graduate Program in Electric Vehicle Design & Development

            Skill-Lync Plus

            Executive Program in Electric Vehicle Embedded SoftwareExecutive Program in Electric Vehicle DesignExecutive Program in Cybersecurity

            Trending Blogs

            Heat Transfer Principles in Energy-Efficient Refrigerators and Air Conditioners Advanced Modeling and Result Visualization in Simscape Exploring Simulink and Library Browser in Simscape Advanced Simulink Tools and Libraries in SimscapeExploring Simulink Basics in Simscape

            © 2025 Skill-Lync Inc. All Rights Reserved.

                        Do You Want To Showcase Your Technical Skills?
                        Sign-Up for our projects.