Regenerating PPM signal based on distances from ultrasonic sensors, ESP8266 for connectin via wifi. Autonomous quadcopter behaviour, autonomou height holding. Flying direction based on front and back ultrasonic sensors.

Dependencies:   ConfigFile HCSR04 PID PPM2 mbed-rtos mbed

Committer:
edy05
Date:
Thu Oct 26 16:07:21 2017 +0000
Revision:
3:6c9f80f5e865
Parent:
2:d172c9963f87
Child:
6:c81abfa61bce
Child:
8:b5128641d4cf
Cleaning

Who changed what in which revision?

UserRevisionLine numberNew contents of line
edy05 0:5cefadfd5898 1 #include "mbed.h"
edy05 2:d172c9963f87 2 #include "rtos.h"
edy05 2:d172c9963f87 3 #include "hardware.h"
edy05 2:d172c9963f87 4 #include "Server.h"
edy05 1:3a5a074b39e0 5 #include "PpmRegen.h"
edy05 2:d172c9963f87 6 #include "distanceRegulation.h"
edy05 2:d172c9963f87 7 #include "hcsr04.h"
edy05 2:d172c9963f87 8 #include "PID.h"
edy05 0:5cefadfd5898 9
edy05 0:5cefadfd5898 10
edy05 2:d172c9963f87 11 //VARIABLES
edy05 2:d172c9963f87 12 uint16_t ppmInChannelsValue[CHANNELS];
edy05 2:d172c9963f87 13 volatile uint16_t distance = 0;
edy05 0:5cefadfd5898 14
edy05 0:5cefadfd5898 15 //FUNCTIONS
edy05 0:5cefadfd5898 16 void print_ppmIn(void);
edy05 0:5cefadfd5898 17
edy05 0:5cefadfd5898 18 int main(){
edy05 2:d172c9963f87 19
edy05 3:6c9f80f5e865 20 // INITIALIZE CLASSES
edy05 2:d172c9963f87 21 _ppmRegen = new PpmRegen(_interruptPort);
edy05 2:d172c9963f87 22 _sonic = new HCSR04(p29, p30);
edy05 2:d172c9963f87 23 _groundDistance = new PID(10, 0, 0, 2);
edy05 1:3a5a074b39e0 24
edy05 3:6c9f80f5e865 25 // STARTING THREADS
edy05 2:d172c9963f87 26 serverThread.start(serverRun);
edy05 2:d172c9963f87 27 distanceThread.start(distanceRegulationThread);
edy05 2:d172c9963f87 28
edy05 2:d172c9963f87 29 wait(1);
edy05 3:6c9f80f5e865 30
edy05 0:5cefadfd5898 31 while(1){
edy05 3:6c9f80f5e865 32 Thread::wait(osWaitForever);
edy05 0:5cefadfd5898 33 }
edy05 0:5cefadfd5898 34
edy05 0:5cefadfd5898 35 }
edy05 0:5cefadfd5898 36
edy05 2:d172c9963f87 37
edy05 0:5cefadfd5898 38 void print_ppmIn(){
edy05 2:d172c9963f87 39 _ppmRegen->getAllChannels(ppmInChannelsValue);
edy05 2:d172c9963f87 40 for(uint8_t channel= 0; channel < CHANNELS; channel++){
edy05 0:5cefadfd5898 41 pc.printf("PPM In Channel %d: %d \n\r", channel, ppmInChannelsValue[channel]);
edy05 0:5cefadfd5898 42 }
edy05 0:5cefadfd5898 43 pc.printf("\n\r");
edy05 0:5cefadfd5898 44 }