![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
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
Diff: distanceRegulation.h
- Branch:
- DistanceRegulation
- Revision:
- 34:5dca557e982f
- Parent:
- 33:a2f9fea05cb9
- Child:
- 35:b09e19c855f6
--- a/distanceRegulation.h Sun Feb 18 17:10:48 2018 +0000 +++ b/distanceRegulation.h Sun Feb 25 18:32:13 2018 +0000 @@ -24,7 +24,8 @@ //pc.printf("Flight controller task started\r\n"); uint16_t channels[CHANNELS]; - int distance=0; + int distance1=0; + int distance2=0; float groundDistancePIDValue; int regulatedThrottle; @@ -47,15 +48,20 @@ } } + //distance1 = _sonic->getDistan1(); + //pc.printf("%d \n\r", distance1); + if(_groundRegulation){ //timer.reset(); //timer.start(); _ppmRegen->getAllChannels(channels); - distance = _sonic->getDistan(); - //pc.printf("distance: %d \n\r", distance); - _groundDistance->setProcessValue(distance); + distance1 = _sonic->getDistan1(); + //distance2 = _sonic->getDistan2(); + //pc.printf("%d \n\r", distance1); + //pc.printf("distance2: %d \n\r", distance2); + _groundDistance->setProcessValue(distance1); groundDistancePIDValue = _groundDistance->compute(); //groundDistancePIDValue += _bias; @@ -65,13 +71,12 @@ if(channels[AUX2] < 1500){ channels[THROTTLE] = 1010; } - if(regulatedThrottle > 2000) - regulatedThrottle = 2000; + if(regulatedThrottle > THROTTLE_LIMIT) + regulatedThrottle = THROTTLE_LIMIT; if(regulatedThrottle < 1010) regulatedThrottle = 1010; - //pc.printf("Sonic distance: %d \n\r", distance); //pc.printf("channel throttle pid value: %f \n\r", groundDistancePIDValue); //pc.printf("channel throttle original value: %d \n\r", channels[THROTTLE]); //pc.printf("channel throttle final value: %d \n\r", regulatedThrottle);