changeset 237:55178aa1f972

Hunting for NoFly bug... + Asserts for NoFly range. + Bugfix surface pressure in simulator mode.
author JeanDo
date Sun, 20 Mar 2011 10:19:19 +0100
parents 3dbeacf42e9e
children 9581e48a914f
files code_part1/OSTC_code_asm_part1/divemode.asm code_part1/OSTC_code_c_part2/p2_deco.c code_part1/OSTC_code_c_part2/p2_deco.o
diffstat 3 files changed, 41 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/code_part1/OSTC_code_asm_part1/divemode.asm	Sat Mar 19 15:15:17 2011 +0100
+++ b/code_part1/OSTC_code_asm_part1/divemode.asm	Sun Mar 20 10:19:19 2011 +0100
@@ -461,7 +461,7 @@
 
 ;-----------------------------------------------------------------------------
 
-divemode_prepare_flags_for_deco:	
+divemode_prepare_flags_for_deco:
 	movff	amb_pressure+0,int_I_pres_respiration+0		; lo  and copy result to deco routine
 	movff	amb_pressure+1,int_I_pres_respiration+1		; hi
 	GETCUSTOM8	d'11'                           ; Saturation multiplier %
@@ -771,8 +771,8 @@
 	call	PLED_display_velocity_clear
 	return
 
-check_ppO2:								; check current ppO2 and display warning if required
-	btfsc		FLAG_const_ppO2_mode		; ignore in ppO2 mode....
+check_ppO2:							    ; check current ppO2 and display warning if required
+	btfsc		FLAG_const_ppO2_mode    ; ignore in ppO2 mode....
 	return
 
 check_ppO2_bail:						; In CC mode but bailout active!
@@ -1598,16 +1598,29 @@
 	
 	call	get_free_EEPROM_location	; get last position in external EEPROM, may be up to 2 secs!
 
-	movff	last_surfpressure_30min+1,int_I_pres_surface+1	; HIGH copy surfacepressure to deco routine
+    btfss   simulatormode_active
+    bra     diveloop_boot_1
+    ; Normal mode = Surface pressure is the pressure 30mn before dive.
 	movff	last_surfpressure_30min+0,int_I_pres_surface+0	; LOW copy surfacepressure to deco routine
-	movff	temperature+0,mintemp+0						; Reset Min-Temp registers
-	movff	temperature+1,mintemp+1						; Reset Min-Temp registers
+	movff	last_surfpressure_30min+1,int_I_pres_surface+1	; HIGH copy surfacepressure to deco routine
+    bra     diveloop_boot_2
+
+diveloop_boot_1:
+    ; Simulator mode: Surface pressure is 1bar.
+    movlw   LOW .1000
+	movff	WREG,int_I_pres_surface+0   ; LOW copy surfacepressure to deco routine
+    movlw   HIGH .1000
+	movff	WREG,int_I_pres_surface+1   ; HIGH copy surfacepressure to deco routine
+
+diveloop_boot_2:
+	movff	temperature+0,mintemp+0     ; Reset Min-Temp registers
+	movff	temperature+1,mintemp+1     ; Reset Min-Temp registers
 
 ; Init profile recording parameters	
-	GETCUSTOM8	d'20'			; sample rate
-	movwf	samplesecs_value	; to avoid EEPROM access in the ISR
+	GETCUSTOM8	d'20'                   ; sample rate
+	movwf	samplesecs_value            ; to avoid EEPROM access in the ISR
 	GETCUSTOM8	d'21'
-	movwf	divisor_temperature			; load divisors for profile storage
+	movwf	divisor_temperature         ; load divisors for profile storage
 	GETCUSTOM8	d'22'
 	movwf	divisor_deco				
 	GETCUSTOM8	d'23'
--- a/code_part1/OSTC_code_c_part2/p2_deco.c	Sat Mar 19 15:15:17 2011 +0100
+++ b/code_part1/OSTC_code_c_part2/p2_deco.c	Sun Mar 20 10:19:19 2011 +0100
@@ -646,7 +646,7 @@
 	{
         // Recompute leading gas limit, at current depth:
         overlay float depth = (temp_deco - pres_surface) / 0.09995;
-        assert( depth >= -0.01 );       // -epsilon tolerance.
+        assert( depth >= -0.2 );        // Allow for 200mbar of weather change.
         assert( low_depth < 255 );
 
         if( depth > low_depth )
@@ -1262,6 +1262,7 @@
     assert( 0.00 <= N2_ratio && N2_ratio <= 1.00 );
     assert( 0.00 <= He_ratio && He_ratio <= 1.00 );
     assert( (N2_ratio + He_ratio) <= 0.95 );
+    assert( 0.800 < pres_respiration && pres_respiration < 14.0 );
 
     if (char_I_const_ppO2 == 0)													// new in v.101
   		pres_diluent = pres_respiration;										// new in v.101
@@ -1652,15 +1653,12 @@
         //       Actual values are in the 1.5 .. 1.0 range (for a GF=30%),
         //       so that can change who is the leading gas...
         // Note: Also depends of the GF_current...
-        //       *BUT* calc_tissue() is used to compute bottom time,
-        //       hence what would happend at surface,
-        //       hence at GF_high.
         if( char_I_deco_model == 1 )
             p = ( p - var_N2_a * GF_current) * var_N2_b
               / (GF_current + var_N2_b * (1.0 - GF_current));
         else
             p = (p - var_N2_a) * var_N2_b;
-        if( p < 0 ) p = 0;
+        if( p < 0.0 ) p = 0.0;
 
         sim_pres_tissue_limit[ci] = p;
         if( p > sim_lead_tissue_limit )
@@ -1671,7 +1669,7 @@
     } // for ci
 
     assert( sim_lead_tissue_no < 16 );
-    assert( 0.0 <= sim_lead_tissue_limit && sim_lead_tissue_limit <= 14.0);
+    assert( 0.0 <= sim_lead_tissue_limit && sim_lead_tissue_limit <= 14.0 );
 }
 
 //////////////////////////////////////////////////////////////////////////////
@@ -1744,7 +1742,9 @@
 static void calc_gradient_factor(void)
 {
     overlay float gf;
+
     assert( char_O_gtissue_no < 16 );
+    assert( 0.800 <= pres_respiration && pres_respiration < 14.0 );
 
 	// tissue > respiration (entsaettigungsvorgang)
 	// gradient ist wieviel prozent an limit mit basis tissue
@@ -1813,7 +1813,7 @@
     assert( 800 < int_I_pres_surface && int_I_pres_surface < 1100 );
     assert( 0 < char_I_desaturation_multiplier && char_I_desaturation_multiplier <= 100 );
 
-    N2_ratio = 0.7902; // FIXED sum as stated in b"uhlmann
+    N2_ratio = 0.7902; // FIXED sum as stated in bühlmann
     pres_surface = int_I_pres_surface * 0.001;
     ppN2 = N2_ratio * (pres_surface - ppWVapour);
     int_O_desaturation_time = 0;
@@ -2035,6 +2035,7 @@
 void deco_clear_CNS_fraction(void)
 {
     RESET_C_STACK
+
     CNS_fraction = 0.0;
     char_O_CNS_fraction = 0;
 }
@@ -2055,6 +2056,9 @@
     overlay float actual_ppO2;
     RESET_C_STACK
 
+    assert( 0.0 <= CNS_fraction && CNS_fraction <= 2.5 );
+    assert( char_I_actual_ppO2 > 15 );
+
     actual_ppO2 = (float)char_I_actual_ppO2 / 100.0;
 
     if (char_I_actual_ppO2 < 50)
@@ -2115,7 +2119,9 @@
 //
 void deco_calc_CNS_decrease_15min(void)
 {
-    RESET_C_STACK    
+    RESET_C_STACK
+    assert( 0.0 <= CNS_fraction && CNS_fraction <= 2.5 );
+
     CNS_fraction =  0.890899 * CNS_fraction;
     char_O_CNS_fraction = (char)(CNS_fraction * 100.0 + 0.5);
 }
@@ -2134,7 +2140,12 @@
 {
     RESET_C_STACK
 
+    assert( 60 <= char_I_temp && char_I_temp <= 100 );
+    assert(  0 <= int_I_temp  && int_I_temp  < 2880 );      // Less than 48h...
+
     int_I_temp = (unsigned short)(((float)int_I_temp * (float)char_I_temp) * 0.01 );
+
+    assert( int_I_temp < 1440 );                            // Less than 24h...
 }
 
 
Binary file code_part1/OSTC_code_c_part2/p2_deco.o has changed