update with altimeter, swimfile.txt endleg.txt, etc see changes_13sep.txt also reset_PI()
Dependencies: mbed MODSERIAL FATFileSystem
Diff: main.cpp
- Revision:
- 15:2a8cfd3f1cf5
- Parent:
- 14:85b64a4d08e8
- Child:
- 16:3363b9f14913
--- a/main.cpp Tue Oct 31 17:06:52 2017 +0000 +++ b/main.cpp Tue Oct 31 22:19:20 2017 +0000 @@ -45,6 +45,12 @@ - added oversampling and a tare function to the depth sensor. - updated main and keyboard to include tare in setup() and a keyboard tare option. - looks like the piston isn't zeroing correctly, unclear why, should be unrelated to depth sensor. + Modified 2017-10-31 (again) by Dan, Matt, and Troy + - POOL TESTED! + - Tuned the PID gains with magic. Works to hold mostly level during BCE runs. Dive is awesome. + - Neutral won't do what we want ... without large depth P, it won't get to depth. + - Dive with just P doesn't overshoot depth at 0.0 deg, but does with -20 deg. Timeout should probably be RISE. + - Files depth/pitch updated with tuned defaults. */ #include "mbed.h" @@ -75,12 +81,13 @@ float pitchTolerance = 1.0; // pitch angle tolerance for neutral finding exit criteria float bceFloatPosition = 300; // bce position for "float" states float battFloatPosition = 50; // batt position for "broadcast" state -float depthCommand = 3.5; // user keyboard depth -float pitchCommand = 0.0; // user keyboard depth + +float depthCommand = 3.5; // user keyboard depth +float pitchCommand = -20.0; // user keyboard depth void setup() { - pc().printf("\n\n\r\rFSG 2017-10-26 revA\n\r"); + pc().printf("\n\n\r\rFSG 2017-10-31\n\r"); pc().baud(57600); // start up the system timer @@ -414,6 +421,8 @@ pc().printf(" E to initiate emergency climb\r\n"); pc().printf(" H to run homing sequence on both BCE and Batt\r\n"); pc().printf(" T to tare the depth sensor\r\n"); + pc().printf("[/] to change bce neutral position\r\n"); + pc().printf("</> to change batt neutral position\r\n"); pc().printf("Q/W to decrease/increase pitch setpoint: %3.1f\r\n",pitchLoop().getCommand()); pc().printf("A/S to decrease/increase depth setpoint: %3.1f\r\n",depthLoop().getCommand()); pc().printf("+/- to decrease/increase timeout: %d s\r\n",timeout); @@ -469,6 +478,24 @@ depth().tare(); // tares to ambient (do on surface) pc().printf("Post-tare: press: %3.3f psi, depth: %3.3f ft\r\n", depth().getPsi(), depth().getDepthFt()); } + + else if (userInput == '[' or userInput == '{') { + depthLoop().setOutputOffset(depthLoop().getOutputOffset() - 1); // decrease the bce neutral setpoint + pc().printf("Adjusting bce neutral position. new: %3.1f\r\n",depthLoop().getOutputOffset()); + } + else if (userInput == ']' or userInput == '}') { + depthLoop().setOutputOffset(depthLoop().getOutputOffset() + 1); // increase the bce neutral setpoint + pc().printf("Adjusting bce neutral position. new: %3.1f\r\n",depthLoop().getOutputOffset()); + } + else if (userInput == '<' or userInput == ',') { + pitchLoop().setOutputOffset(pitchLoop().getOutputOffset() - 1); // decrease the batt neutral setpoint + pc().printf("Adjusting batt neutral position. new: %3.1f\r\n",pitchLoop().getOutputOffset()); + } + else if (userInput == '>' or userInput == '.') { + pitchLoop().setOutputOffset(pitchLoop().getOutputOffset() + 1); // increase the batt neutral setpoint + pc().printf("Adjusting batt neutral position. new: %3.1f\r\n",pitchLoop().getOutputOffset()); + } + else if (userInput == '?') { pc().printf("\n\n\n>>> Resetting MBED <<<\n\n\n"); wait(0.5); @@ -660,7 +687,7 @@ // how exit? if (timer > timeout) { pc().printf("timed out\r\n"); - state = FLOAT_LEVEL; + state = EMERGENCY_CLIMB; timer.reset(); isTimeoutRunning = false; } @@ -770,7 +797,8 @@ timer.reset(); isTimeoutRunning = false; } - if (abs(bce().getPosition_mm() - bce().getSetPosition_mm()) < bce().getDeadband()) { + if ( (abs(bce().getPosition_mm() - bce().getSetPosition_mm()) < bce().getDeadband()) and + (abs(batt().getPosition_mm() - batt().getSetPosition_mm()) < batt().getDeadband()) ) { pc().printf("position: %3.1f mm, set pos: %3.1f mm, deadband: %3.1f mm\r\n",bce().getPosition_mm(), bce().getSetPosition_mm(), bce().getDeadband()); state = SIT_IDLE; timer.reset();