update with altimeter, swimfile.txt endleg.txt, etc see changes_13sep.txt also reset_PI()

Dependencies:   mbed MODSERIAL FATFileSystem

Committer:
joel_ssc
Date:
Fri Sep 13 16:51:48 2019 +0000
Revision:
102:0f430de62447
Child:
103:45b554df05bd
changes of the 2019_15may code  that worked,  altimeter code,; swimfile code,  altimeter logic

Who changed what in which revision?

UserRevisionLine numberNew contents of line
joel_ssc 102:0f430de62447 1 # new version 13sep2019
joel_ssc 102:0f430de62447 2 has changes to implement altimeter blank_m - turned off and ignored
joel_ssc 102:0f430de62447 3 and altim_abort_m distance to bottom that aborts dive
joel_ssc 102:0f430de62447 4 present code takes TWO near approaches to end a leg. only one and it forces a rise, and starts counting.
joel_ssc 102:0f430de62447 5
joel_ssc 102:0f430de62447 6 IMplement swimfile.txt reading in swim parameters.
joel_ssc 102:0f430de62447 7 swimfile parameters:
joel_ssc 102:0f430de62447 8
joel_ssc 102:0f430de62447 9 #the swim file parameters
joel_ssc 102:0f430de62447 10 bce_dive_mm=10.1
joel_ssc 102:0f430de62447 11 bce_rise_mm=11.2
joel_ssc 102:0f430de62447 12 bmm_dive_mm=12.3
joel_ssc 102:0f430de62447 13 bmm_rise_mm=13.0
joel_ssc 102:0f430de62447 14 altimeter_blank_m=4.40
joel_ssc 102:0f430de62447 15 altimeter_abort_m=7.70
joel_ssc 102:0f430de62447 16 fn_timeout=405.0
joel_ssc 102:0f430de62447 17 max_mbed_runtime_hr=2.50
joel_ssc 102:0f430de62447 18
joel_ssc 102:0f430de62447 19 implement writing out endleg_reason into endleg.txt file
joel_ssc 102:0f430de62447 20 # EndLeg reason set here
joel_ssc 102:0f430de62447 21 [values]
joel_ssc 102:0f430de62447 22 endleg_reason=4
joel_ssc 102:0f430de62447 23
joel_ssc 102:0f430de62447 24 reasons:1 = normal timeout 2=yo_timeout 3= altim_abort 4=no_find_neutral
joel_ssc 102:0f430de62447 25 5=still inverted 6=yo_timeout+too slow 7=no_find_neutral+altim_abort
joel_ssc 102:0f430de62447 26 8=mbed_max_runtime_hr limit
joel_ssc 102:0f430de62447 27
joel_ssc 102:0f430de62447 28
joel_ssc 102:0f430de62447 29 implement altimeter reading of altim.txt for slope and offset.
joel_ssc 102:0f430de62447 30 altim.txt NOT named alt.txt. hated that name.
joel_ssc 102:0f430de62447 31
joel_ssc 102:0f430de62447 32 # Linear regression parameters for altimeter
joel_ssc 102:0f430de62447 33
joel_ssc 102:0f430de62447 34 slope=0.0371
joel_ssc 102:0f430de62447 35 intercept=-9.7413
joel_ssc 102:0f430de62447 36
joel_ssc 102:0f430de62447 37 Present code has not yet switched to really use max_mbed_runtime_hr yet.
joel_ssc 102:0f430de62447 38 here is the code at line 539 of main.cpp
joel_ssc 102:0f430de62447 39
joel_ssc 102:0f430de62447 40 CODE
joel_ssc 102:0f430de62447 41 if(tNow == 90000) { // don't wait forever -remove this for real operations!!
joel_ssc 102:0f430de62447 42 // if(tNow == 1000 * configFileIO().swimConstants.max_mbed_runtime_hr * 3600) { //replace with this real runtime
joel_ssc 102:0f430de62447 43 keeprunning=0;
joel_ssc 102:0f430de62447 44 ....
joel_ssc 102:0f430de62447 45 CODE
joel_ssc 102:0f430de62447 46
joel_ssc 102:0f430de62447 47 Typical block using altimeter info is in Statemachine()
joel_ssc 102:0f430de62447 48 line 810 inStatemachine().cpp
joel_ssc 102:0f430de62447 49 CODE exit from LEG_POSITION_DIVE logic
joel_ssc 102:0f430de62447 50 else if( (depthLoop().getPosition() > configFileIO().swimConstants.altim_blank_m) // ending on altimieter abort - bad, endleg, etc
joel_ssc 102:0f430de62447 51 && (fabs(imu().getRoll()) < 45) && (altimLoop().getPosition() < configFileIO().swimConstants.altim_abort_m)) {
joel_ssc 102:0f430de62447 52 //just go to leg_position_rise unless it is the second time
joel_ssc 102:0f430de62447 53 if(configFileIO().swimConstants.altim_abort_count >= 2) { // more than one altimeter abort
joel_ssc 102:0f430de62447 54 _state = EMERGENCY_CLIMB;
joel_ssc 102:0f430de62447 55 finish_leg =1;
joel_ssc 102:0f430de62447 56 sprintf(buf, "LEG POS DIVE: ALTIMETER ABORT - more than one!: depth=%f altimeter=%f - go to emergency climb\n\n\r",
joel_ssc 102:0f430de62447 57 depthLoop().getPosition(), altimLoop().getPosition() );
joel_ssc 102:0f430de62447 58 mbedLogger().appendDiagFile(buf,3);
joel_ssc 102:0f430de62447 59 configFileIO().swimConstants.endleg_reason = 3; // altimeter abort
joel_ssc 102:0f430de62447 60 _fsm_timer.reset();
joel_ssc 102:0f430de62447 61 _isTimeoutRunning = false;
joel_ssc 102:0f430de62447 62
joel_ssc 102:0f430de62447 63 }
joel_ssc 102:0f430de62447 64 // just go to leg_position_rise unless it is the second time
joel_ssc 102:0f430de62447 65 if(configFileIO().swimConstants.altim_abort_count < 2) {
joel_ssc 102:0f430de62447 66 _state = LEG_POSITION_RISE;
joel_ssc 102:0f430de62447 67 _fsm_timer.reset();
joel_ssc 102:0f430de62447 68 printf(buf, "LEG POS DIVE: ALTIMETER ABORT first one: ONLY go to leg_postiion_rise -depth=%f altimeter=%f - go to emergency climb\n\n\r",
joel_ssc 102:0f430de62447 69 depthLoop().getPosition(), altimLoop().getPosition() );
joel_ssc 102:0f430de62447 70 mbedLogger().appendDiagFile(buf,3);
joel_ssc 102:0f430de62447 71 _isTimeoutRunning = false;
joel_ssc 102:0f430de62447 72 configFileIO().swimConstants.altim_abort_count += 1;
joel_ssc 102:0f430de62447 73 }
joel_ssc 102:0f430de62447 74 }
joel_ssc 102:0f430de62447 75 END CODE
joel_ssc 102:0f430de62447 76 The test is: deeper than atimeter blanking depth? also NOT inverted (roll test) also altimeter measure is smaller than swimConstants.altim_abort_m
joel_ssc 102:0f430de62447 77 the second time ; Emergency climb and end the leg
joel_ssc 102:0f430de62447 78
joel_ssc 102:0f430de62447 79 the first time - just end the yo and start conunting approaches
joel_ssc 102:0f430de62447 80
joel_ssc 102:0f430de62447 81
joel_ssc 102:0f430de62447 82
joel_ssc 102:0f430de62447 83 implement inverted.txt
joel_ssc 102:0f430de62447 84 # Still Inverted after START_SWIM yo timeout timeout
joel_ssc 102:0f430de62447 85 yo_time=45
joel_ssc 102:0f430de62447 86 inverted_roll_value=173.936401