Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: ConfigFile HCSR04 PID PPM2 mbed-rtos mbed
Revision 3:6c9f80f5e865, committed 2017-10-26
- Comitter:
- edy05
- Date:
- Thu Oct 26 16:07:21 2017 +0000
- Parent:
- 2:d172c9963f87
- Child:
- 6:c81abfa61bce
- Child:
- 7:fb972a5f8a57
- Commit message:
- Cleaning
Changed in this revision
| distanceRegulation.h | Show annotated file Show diff for this revision Revisions of this file |
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/distanceRegulation.h Thu Oct 26 15:54:47 2017 +0000
+++ b/distanceRegulation.h Thu Oct 26 16:07:21 2017 +0000
@@ -4,15 +4,12 @@
#include "definitions.h"
void distanceRegulationThread(){
- //_ppmRegen = new PpmRegen(_interruptPort);
- //HCSR04 sonic(p6, p7);
uint16_t channels[CHANNELS];
int distance=0;
float groundDistancePidValue;
int newThrottleValue;
//setup PID
- //_groundDistance = new PID(1, 1, 1, 2);
_groundDistance->setInputLimits(0, 500);
_groundDistance->setOutputLimits(-100, 100);
_groundDistance->setMode(AUTO_MODE);
@@ -30,7 +27,6 @@
_groundDistance->setSetPoint(30);
groundDistancePidValue = _groundDistance->compute();
//Update PWM values
- //channels[THROTTLE] += groundDistancePidValue;
newThrottleValue = channels[THROTTLE] + groundDistancePidValue;
pc.printf("Sonic distance: %d \n\r", distance);
@@ -38,9 +34,6 @@
pc.printf("channel throttle original value: %d \n\r", channels[THROTTLE]);
pc.printf("channel throttle final value: %d \n\r", newThrottleValue);
-
-
-
// Generate PWM
_roll->pulsewidth_us( channels[ROLL]);
_pitch->pulsewidth_us( channels[PITCH]);
--- a/main.cpp Thu Oct 26 15:54:47 2017 +0000
+++ b/main.cpp Thu Oct 26 16:07:21 2017 +0000
@@ -14,40 +14,27 @@
//FUNCTIONS
void print_ppmIn(void);
-void dist(int);
-//HCSR04 sonic(p6, p7);
-//_ppmRegen = new PpmRegen(_interruptPort, _roll, _pitch, _yaw, _throttle, _aux1, _aux2);
int main(){
+ // INITIALIZE CLASSES
_ppmRegen = new PpmRegen(_interruptPort);
_sonic = new HCSR04(p29, p30);
_groundDistance = new PID(10, 0, 0, 2);
+ // STARTING THREADS
serverThread.start(serverRun);
distanceThread.start(distanceRegulationThread);
- //_sonic.startUpdates();
wait(1);
+
while(1){
- //print_ppmIn();
- //_sonic.checkDistance();
- //distance = _sonic.getCurrentDistance();
- //distance = sonic.getDistance();
- //pc.printf("Distance: %d \n\r", distance);
- Thread::wait(100);
-
+ Thread::wait(osWaitForever);
}
}
-void dist(int distan)
-{
- //pc.printf("Distance: %d \n\r", distan);
- distance = distan;
-}
-
void print_ppmIn(){
_ppmRegen->getAllChannels(ppmInChannelsValue);
for(uint8_t channel= 0; channel < CHANNELS; channel++){