Landing Gear
The landing gear is a subsystem designed to assist testing or, more specifically, maintaining the bike upright when beginning and ending testing. The landing gear is controlled via a toggle switch (Channel 5) on the RC that deploys and retracts the wheels.
Contents
Schematic/Design
The landing gear is a DC motor (##) controlled by two relays (from the relay module) and powered by a standard 9V battery. The two relay's input signals (in3 and in4) is connected to the pins 47 and 48, respectively. As seen on the schematic, the relay's normally open (NO) and normally closed (NC) terminals are either connected to directly to the motor or to the COM of one of the limit switches. The best way to understand the schematic is by understanding what occurs when the relays are on NC or NO. Fundamentally, when the relays are on NC, the motor rotates in one direction. If on NO, the motor turns in the opposite direction. The limit switches are connected in the NC configuration, meaning that the circuit between the relay and the motor is normally closed until the limit switch is triggered. Hence, when one of the arms hits the limit switch, it opens the circuit and causes the motor to stop. Note that triggering one of the limit switches does not prevent the motor turning in the other direction.
Code
Channel 6, originally controlled the landing gear, was changed to switch between the navigation modes. Thus, the landing gear had to be routed to the next available channel, Channel 5. The code simply calls a function from the Landing Gear .cpp file and causes the DUE to provide 5V to the pins corresponding to the relay module. Note that Channel 5 is connected to the right throttle (specifically when one pushes it to the bottom left).* This can be an issue if one is braking the bike and deploying the landing gear at the same time.
Currently, the landing gear is controlled by the upper-left, two-way toggle switch, specifically channel 5 (please look at figure _). Under Landing_Gear.cpp of ROS_arduino_wrapper, two functions LandingGearUp() and LandingGearDown() controls the output (either HIGH or LOW) on the DUE's pins 47 and 48. The function for channel 5 (under RC.cpp) functions using interrupts. Interrupts work by assigning a pin to the interrupt and setting a trigger mode. The trigger mode is set to change so that interrupt triggers both when the pin goes from high to low and from low to high. The RC signal transmitted from the controller is a PWM signal so the interrupt will trigger multiple times per cycle of the signal. When the interrupt triggers the attached function is run. The functions used for RC signals calculate how long the pin was high in microseconds and assign that to a global variable called pulsetime. It is important that any variables used in the interrupt are defined as volatile variables so that the variables are loaded form RAM and not the storage register. The value of pulsetime corresponds to 31 specific positions of the RC switches and analog inputs. Additionally, when an interrupt is triggered the code for the main loop pauses, then code for the interrupt runs to completion, then the main loop continues. Since this can happen multiple times per loop the amount of time spent inside the interrupt should be minimized. Therefore we use the interrupts to calculate pulsetime only and later on in the loop use pulsetime to deploy landing gear or preform other tasks. Basically, once pulsetime reaches a certain value, then the function calls on LandingGearUp() or LandingGearDown() to deploy or retract the landing gear.
Electronics
The landing gear system is an assembly of different electrical components, specifically a relay module, limit switches, and a DC motor.
Relay Module
Limit Switch(es)
DC Motor
Past and Current Issues
Arms Bending
One of the common problems that persisted with the landing gear was that the arms would bend inwards every time the bike fell onto its side. Hence, a horizontal beam was implemented so that when the bike fell the beam would absorb the impact (not the landing gear's arms). The 'horizontal kickstand' is a wooden beam inserted in one of the holes near the center of bike and secured by a secondary beam. It is important to note that the horizontal kickstand should be closest to its center of mass to reduce any production of angular momentum when hitting the ground. At the ends of the beam pieces of hard rubber was attached to minimize any shock damage towards the bike when it hits the ground.
Interruption Bug
The DUE sometimes (specifically when the computer was not connected to the DUE) supplied and cut power (to the relays) at a relatively high frequency. This caused the landing gear to deploy and retract at the same, high frequency, preventing the arms to hit the limit switches. It is thought that as the DUE supplies power to the relays, other functions that the bike is processing interrupts the calling of the landing gear’sfunctionLandingGearUp()/LandingGearDown(), causing the relays to flicker rapidly. To solve the issue, the local variablenumTicksHigh(declared in RC.cpp) is a counter that basically assures that the pulse time(time which the toggle switch is on HIGH) is at the desired value to actuate the landing gear*. In addition, the value desired for pulsetime5 was adjusted to best identify the threshold in which the toggle switch is read as HIGH.