![]() |
ME507 Airheads Project v1.1.0
Flight Stabilization for Glider
|
Main file for ME 507 Airheads project. Safely lands an unpowered model airplane. More...
#include <Arduino.h>
#include "shares.h"
#include "taskshare.h"
#include "PrintStream.h"
#include <time.h>
#include <network.h>
#include "DRV8871.h"
#include "ultrasonic.h"
#include "potentiometer.h"
#include "PIDController.h"
#include "IMU.h"
Functions | |
Share< bool > | near_ground ("Near Ground") |
A share boolean that reads true if the glider is near ground. | |
Share< uint8_t > | tc_state ("Task Controller State") |
A share integer for finite state machine. | |
Share< int16_t > | rudder_duty ("Rudder motor duty cycle") |
A share containing the duty cycle for rudder motor. | |
Share< int16_t > | elev_duty ("Elevator motor duty cycle") |
A share containing the duty cycle for elevator motor. | |
Share< float > | yawC ("Current yaw from IMU") |
A share containing current yaw of the glider. | |
Share< float > | pitchC ("Current pitch from IMU") |
A share containing current pitch of the glider. | |
void | task_ultrasonic (void *p_params) |
Ultrasonic sensor measures distance to the ground. More... | |
void | task_controller (void *p_params) |
Controller for both rudder and elevator control surfaces. More... | |
void | task_rudder_motor (void *p_params) |
More... | |
void | task_elevator_motor (void *p_params) |
More... | |
void | task_IMU (void *p_params) |
Task function to interface with IMU. More... | |
void | setup (void) |
The Arduino setup function. More... | |
void | loop (void) |
The Arduino loop function. More... | |
Main file for ME 507 Airheads project. Safely lands an unpowered model airplane.
Includes ultrasonic sensor, potentiometer, motor driver, and flight controller tasks.
void loop | ( | void | ) |
The Arduino loop function.
This function is called periodically by the Arduino system. It runs as a low priority task. On some microcontrollers it will crash when FreeRTOS is running, so we usually don't use this function for anything.
void setup | ( | void | ) |
The Arduino setup function.
This function is used to set up the microcontroller by starting the serial port and creating the tasks.
void task_controller | ( | void * | p_params | ) |
Controller for both rudder and elevator control surfaces.
Retrieves IMU, potentiometer, and ultrasonic sensor data and writes motor duty cycles to shares. The motor tasks use the duty cycles to move the rudder and elevator control surfaces. The states within this task are set internally and by the webpage task.
p_params | An unused pointer to (no) parameters passed to this task |
< Period of controller task (ms)
< Controller for rudder angle based on yaw
< Controller for duty cycle based on rudder angle
< Controller for elevator angle based on pitch
< Controller for duty cycle based on elevator angle
< Desired yaw (deg)
< Desired pitch (deg)
< Rudder position at previous time (deg)
< Elevator position at previous time (deg)
< Desired rudder angle (deg)
< Current rudder angle (deg)
< Minimum allowable rudder angle (deg)
< Maximum allowable rudder angle (deg)
< Desired elevator angle (deg)
< Current elevator angle (deg)
< Minimum allowable elevator angle (deg)
< Maximum allowable elevator angle (deg)
< Rudder motor duty cycle (-100% to 100% incl.)
< Elev motor duty cycle (-100% to 100% incl.)
< Current amount of time (ms) in inactive delay
void task_elevator_motor | ( | void * | p_params | ) |
p_params | A pointer to parameters passed to this task. This pointer is ignored; it should be set to NULL in the call to xTaskCreate() which starts this task |
void task_IMU | ( | void * | p_params | ) |
Task function to interface with IMU.
This task reads from the IMU to get pitch, yaw, and roll measurements. It then puts the data into shaes for the controller to use.
p_params | A pointer to parameters passed to this task. This pointer is ignored; it should be set to NULL in the call to xTaskCreate() which starts this task |
void task_rudder_motor | ( | void * | p_params | ) |
p_params | A pointer to parameters passed to this task. This pointer is ignored; it should be set to NULL in the call to xTaskCreate() which starts this task |
void task_ultrasonic | ( | void * | p_params | ) |
Ultrasonic sensor measures distance to the ground.
Ultrasonic sensor mounted on the airplane measures the distance from the airplane to the ground. When the airplane is within 1 foot of the ground, the airplane's control surfaces will move into "landing configuration" where the pitch will be x degrees up for a soft landing.
p_params | A pointer to parameters passed to this task. This pointer is ignored; it should be set to NULL in the call to xTaskCreate() which starts this task |