Project 2 - Implement the Code for controlling the retraction and extension of Airplane’s landing gear
Project2:Code for controlling the retraction and extension of Airplane’s landing gear
- In an aeroplane a Landing gear is provided for ensuring a safe landing and takeoff of the aircrat.
- Landing gear is one of the critical subsystems of the aircraft. The need to design a landing gear with minimum weight, minimum volume , high performance, improved life and reduced life cycle cost have posed many challenges to landing gear designers and practitioners.
- The purpose of the landing gear in an aircraft is to provide a suspension system during taxi,takeoff and landing.

- There are 3 gears in the aeroplane: 1-Nose Gear ,2 -Left Gear, 3- Right Gear.
- Apart from these gears we have a hydraulic pump present that's used to exert pressure in order to pull it up and pull it down.
- Nose gear has one extra squat switch, other gears has only the limit switch. Nose gear has squat switch in order to check whether the landing gear is pressed or not.
- If the limit switch is closed the gear is up, if the limit switch is opened the gear is down.
- Similarly if the squat switch is closed it means the aeroplane is grounded and
| Switch State | State Of Gears |
| Limit switch Closed. | Gear is up. |
| Limit switch Opened. | Gear is down. |
| Switch State | State Of Aeroplane |
| Squat switch closed. | Aeroplane is grounded and gears are locked. |
| Squat switch open. | Airplane is takine off/landing /air-borne. |
- Direction Valve
A direction valve is controlled by the software to allow the hydraulic pressure to either raise or lower the landing gear.
| Status of direction valve. | States of Landing Gear |
| Direction valve = Down. | (Gear Down) (parked at bay or landed.) |
| Direction valve=up. | Raising gear (Taking off). |
| Control of the hydraulic pump for the landing gear part is disabled. | Gear up(airborne). |
| Direction valve = Down. | Lowering Gear (landing). |
- Input for the direction valve
| Pilot's lever state | Direction Valve state |
| Lever up. | Direction valve = up. |
| Lever down. | Direction valve = down. |
| Pilot's Lever State | Light status |
| Lever Rising edge. | Red. |
| Lever Falling edge. | Red. |
Every Gear has one light. According to the state of the gear the colour of the light is changing.
| Landing gear state | Light Status |
| Gear is up. | OFF |
| Gear is down. | Green |
| Gear in transit(raising or lowering) | Red |
The state flow for the same is as follows:

The functions used are following:
init_state_machine();
1.Void_gear_Down();
2.Void_Check_takeoff();
3.Void Raising_gear();
4.void gear_up();
5. Void check_landing();
6. void Lowering_gear();
The enum state types are defined as follows:
| State_type |
Switch_status Squat and limit switch |
pilot lever status | Hydraulic Mechanism status |
|
GEAR_DOWN CHECK_TAKEOFF RISING_GEAR GEAR_UP CHECK_LANDING LOWERING_GEAR |
Open 0 close 1 |
Rising 0, Falling 1, Up 2, Down 3, |
Working 0, malfunctioning 1 |
1.GEAR_DOWN condition:
- The pilot's lever status and squat switch status need to be entered by the user.
- Check for condition pilot_lever == rising && squat_switch==open.
- And if the condition is satisfied then,
- current state = CHECK_BEFORE_TAKEOFF
- LIGHTS=GREEN.
- Else GEAR_DOWN function is called again inside itself.
2.Checking_Before_takeoff:
- check whether pilot_lever==falling OR squat switch == close
- Gear is Down.
- Else check whether pilot_lever==up && squat_switch==open&& hydraulic_mechanism == working means the gear is rising.
- Else check whether pilot_lever is up and squat switch is open and hydraulic_mechanism is malfunctioning means the gear is rising and the malfunctioning status is printed on the screen.
3.if (pilot_lever==falling && limit_switch==open) then state is check_before_landing;
else if(Limit_switch == close && pilot_lever==UP) then state is GEAR_UP;
4. If pilot_lever is falling then state is check before landing. Else call gear_up itself.
5. If pilot_lever == down && hydraulic mechanism is working then jump to state-Lowering_gear.
6. If limit_switch is close and pilot_lever is rising then jump to state-Check before takeoff.
Else if limit_switch==open && pilot_lever is down then jump to state gear down.