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

Dependencies:   mbed MODSERIAL FATFileSystem

changes_13sep2019.txt

Committer:
joel_ssc
Date:
2019-09-13
Revision:
102:0f430de62447
Child:
103:45b554df05bd

File content as of revision 102:0f430de62447:

# new version  13sep2019
has changes to implement altimeter blank_m  - turned off and ignored
and altim_abort_m  distance to bottom that aborts dive
present code  takes TWO  near approaches to end a leg. only one and it forces a rise, and starts counting.

IMplement swimfile.txt reading in swim parameters.
swimfile parameters:

#the swim file parameters
bce_dive_mm=10.1
bce_rise_mm=11.2
bmm_dive_mm=12.3
bmm_rise_mm=13.0
altimeter_blank_m=4.40
altimeter_abort_m=7.70
fn_timeout=405.0
max_mbed_runtime_hr=2.50

implement  writing out endleg_reason  into endleg.txt  file
# EndLeg reason set here
[values]
endleg_reason=4

reasons:1 = normal timeout  2=yo_timeout  3= altim_abort 4=no_find_neutral  
5=still inverted 6=yo_timeout+too slow 7=no_find_neutral+altim_abort
     8=mbed_max_runtime_hr  limit
     
     
implement altimeter reading of altim.txt  for slope and offset.
altim.txt  NOT named alt.txt.         hated that name.

# Linear regression parameters for altimeter 

slope=0.0371
intercept=-9.7413

Present code has not yet switched to really use max_mbed_runtime_hr  yet.
here is the code at line 539 of main.cpp

CODE
if(tNow ==  90000) {  // don't wait forever  -remove this for real operations!!
  // if(tNow == 1000 * configFileIO().swimConstants.max_mbed_runtime_hr * 3600) {  //replace with this real runtime    
                keeprunning=0;
....
CODE

Typical block using altimeter info is in Statemachine()
line 810 inStatemachine().cpp
CODE      exit from LEG_POSITION_DIVE    logic
else if( (depthLoop().getPosition() > configFileIO().swimConstants.altim_blank_m)    //  ending on altimieter abort - bad, endleg, etc
                     && (fabs(imu().getRoll()) < 45) && (altimLoop().getPosition() < configFileIO().swimConstants.altim_abort_m)) {
                //just go to leg_position_rise unless it is the second time
                    if(configFileIO().swimConstants.altim_abort_count  >= 2) {  // more than one altimeter abort
                       _state = EMERGENCY_CLIMB;
                       finish_leg =1;
                       sprintf(buf, "LEG POS DIVE: ALTIMETER ABORT - more than one!: depth=%f altimeter=%f - go to emergency climb\n\n\r",
                                      depthLoop().getPosition(), altimLoop().getPosition() );
                    mbedLogger().appendDiagFile(buf,3);
                       configFileIO().swimConstants.endleg_reason = 3;  // altimeter abort
                       _fsm_timer.reset();
                       _isTimeoutRunning = false;
                       
                    }
                // just go to leg_position_rise unless it is the second time
                    if(configFileIO().swimConstants.altim_abort_count  < 2) {
                       _state = LEG_POSITION_RISE;
                       _fsm_timer.reset();
                       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",
                                      depthLoop().getPosition(), altimLoop().getPosition() );
                       mbedLogger().appendDiagFile(buf,3);
                       _isTimeoutRunning = false;
                       configFileIO().swimConstants.altim_abort_count += 1;
                    }
                }
END CODE
The test is:  deeper than atimeter blanking depth?  also  NOT inverted (roll test)  also  altimeter measure is smaller than swimConstants.altim_abort_m
     the second time ;  Emergency climb and end the leg

     the first time - just end the yo and start conunting approaches
     


implement inverted.txt
# Still Inverted after START_SWIM yo timeout timeout
 yo_time=45
inverted_roll_value=173.936401