Mercurial > public > mk2
changeset 222:638f8e17bd51
Prototyping deco_gas_volumes() to compute gas consumption per tank with decoplanning.
author | JeanDo |
---|---|
date | Tue, 01 Mar 2011 14:41:10 +0100 |
parents | 448478ceccea |
children | 2a0a446fa6c0 |
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 code_part1/OSTC_code_c_part2/p2_definitions.h code_part1/OSTC_code_c_part2/shared_definitions.h |
diffstat | 5 files changed, 109 insertions(+), 36 deletions(-) [+] |
line wrap: on
line diff
--- a/code_part1/OSTC_code_asm_part1/divemode.asm Tue Mar 01 11:48:11 2011 +0100 +++ b/code_part1/OSTC_code_asm_part1/divemode.asm Tue Mar 01 14:41:10 2011 +0100 @@ -264,18 +264,18 @@ call calc_average_depth ; calculate average depth call calc_velocity ; calculate vertical velocity and display if > threshold (every two seconds) - ; calculate ppO2 in 0.1Bar (e.g. 150 = 1.50Bar ppO2) - movff amb_pressure+0,xA+0 + ; calculate ppO2 in 0.01Bar (e.g. 150 = 1.50 Bar ppO2) + movff amb_pressure+0,xA+0 ; P_amb in milibar (1000 = 1.000 bar). movff amb_pressure+1,xA+1 movlw d'10' movwf xB+0 clrf xB+1 - call div16x16 ; xC=p_amb/10 + call div16x16 ; xC=p_amb/10 (100 = 1.00 bar). movff xC+0,xA+0 movff xC+1,xA+1 movff char_I_O2_ratio,xB+0 clrf xB+1 - call mult16x16 ; char_I_O2_ratio * p_amb/10 + call mult16x16 ; char_I_O2_ratio * (p_amb/10) movff xC+0,xA+0 movff xC+1,xA+1 movlw d'100' @@ -360,27 +360,27 @@ read_int_eeprom d'118' ; read gas_change_depth Gas1 btfss sorted_gaslist_active,0 ; Apply depth? clrf EEDATA ; No, clear! - movff EEDATA,char_I_deco_gas_change5 ; Yes! + movff EEDATA,char_I_deco_gas_change+4 ; Yes! read_int_eeprom d'119' ; read gas_change_depth Gas2 btfss sorted_gaslist_active,1 ; Apply depth? clrf EEDATA ; No, clear! - movff EEDATA,char_I_deco_gas_change4 ; Yes! + movff EEDATA,char_I_deco_gas_change+3 ; Yes! read_int_eeprom d'120' ; read gas_change_depth Gas3 btfss sorted_gaslist_active,2 ; Apply depth? clrf EEDATA ; No, clear! - movff EEDATA,char_I_deco_gas_change3 ; Yes! + movff EEDATA,char_I_deco_gas_change+2 ; Yes! read_int_eeprom d'121' ; read gas_change_depth Gas4 btfss sorted_gaslist_active,3 ; Apply depth? clrf EEDATA ; No, clear! - movff EEDATA,char_I_deco_gas_change2 ; Yes! + movff EEDATA,char_I_deco_gas_change+1 ; Yes! read_int_eeprom d'122' ; read gas_change_depth Gas5 btfss sorted_gaslist_active,4 ; Apply depth? clrf EEDATA ; No, clear! - movff EEDATA,char_I_deco_gas_change1 ; Yes! + movff EEDATA,char_I_deco_gas_change+0 ; Yes! ; Debugger ; call enable_rs232 @@ -420,11 +420,11 @@ reset_decompression_gases: ; reset the deco gas while in NDL ostc_debug 'F' ; Sends debug-information to screen if debugmode active clrf lo - movff lo,char_I_deco_gas_change5 - movff lo,char_I_deco_gas_change4 - movff lo,char_I_deco_gas_change3 - movff lo,char_I_deco_gas_change2 - movff lo,char_I_deco_gas_change1 ; clear + movff lo,char_I_deco_gas_change+4 + movff lo,char_I_deco_gas_change+3 + movff lo,char_I_deco_gas_change+2 + movff lo,char_I_deco_gas_change+1 + movff lo,char_I_deco_gas_change+0 ; clear return calc_deko_divemode2:
--- a/code_part1/OSTC_code_c_part2/p2_deco.c Tue Mar 01 11:48:11 2011 +0100 +++ b/code_part1/OSTC_code_c_part2/p2_deco.c Tue Mar 01 14:41:10 2011 +0100 @@ -1264,30 +1264,30 @@ deco_gas_change5 = 0; // Gas are selectable if we did not pass the change depth by more than 1.50m: - if(char_I_deco_gas_change1) + if(char_I_deco_gas_change[0]) { - if( int_temp > 100 *(short)char_I_deco_gas_change1 ) - deco_gas_change1 = char_I_deco_gas_change1; + if( int_temp > 100 *(short)char_I_deco_gas_change[0] ) + deco_gas_change1 = char_I_deco_gas_change[0]; } - if(char_I_deco_gas_change2) + if(char_I_deco_gas_change[1]) { - if( int_temp > 100 *(short)char_I_deco_gas_change2 ) - deco_gas_change2 = char_I_deco_gas_change2; + if( int_temp > 100 *(short)char_I_deco_gas_change[1] ) + deco_gas_change2 = char_I_deco_gas_change[1]; } - if(char_I_deco_gas_change3) + if(char_I_deco_gas_change[2]) { - if( int_temp > 100 *(short)char_I_deco_gas_change3 ) - deco_gas_change3 = char_I_deco_gas_change3; + if( int_temp > 100 *(short)char_I_deco_gas_change[2] ) + deco_gas_change3 = char_I_deco_gas_change[2]; } - if(char_I_deco_gas_change4) + if(char_I_deco_gas_change[3]) { - if( int_temp > 100 *(short)char_I_deco_gas_change4 ) - deco_gas_change4 = char_I_deco_gas_change4; + if( int_temp > 100 *(short)char_I_deco_gas_change[3] ) + deco_gas_change4 = char_I_deco_gas_change[3]; } - if(char_I_deco_gas_change5) + if(char_I_deco_gas_change[4]) { - if( int_temp > 100 *(short)char_I_deco_gas_change5 ) - deco_gas_change5 = char_I_deco_gas_change5; + if( int_temp > 100 *(short)char_I_deco_gas_change[4] ) + deco_gas_change5 = char_I_deco_gas_change[4]; } const_ppO2 = char_I_const_ppO2 * 0.01; @@ -2165,11 +2165,83 @@ // output is int_I_temp // // Used to compute NoFly remaining time. - +// void deco_calc_percentage(void) { RESET_C_STACK - int_I_temp = (unsigned short)(((float)int_I_temp * (float)char_I_temp) / 100.0); + + int_I_temp = (unsigned short)(((float)int_I_temp * (float)char_I_temp) * 0.01 ); +} + + +////////////////////////////////////////////////////////////////////////////// +// deco_gas_volumes +// +// new in v.111 +// +// calculates volumes for each gas. +// +// Input: char_I_bottom_depth, char_I_bottom_time for planned dive. +/// Gas list. First gas is the bottom gas. +// decoplan (char_O_deco_depth, char_O_deco_time). +// CF#56 == bottom deci-liters/minutes (0.5 .. 50.0) +// CF#57 == deco deci-liters/minutes (0.5 .. 50.0). +// Output: char_O_gas_volumes[0..4] in litters x 100. +// +void deco_gas_volumes(void) +{ + overlay float volumes[5]; + overlay float ascent_usage; + overlay unsigned char i, j; + RESET_C_STACK + + //---- initialize with bottom consumption -------------------------------- + volumes[0] = (char_I_bottom_depth*0.1 + 1.0) // Use Psurface = 1.0 bar. + * char_I_bottom_time // in minutes. + * read_custom_function(56) // In deci-liter/minutes. + * 0.1; // deci-liters --> liters. + + for(i=1; i<5; ++i) // Nothing yet... + volumes[i] = 0.0; + + //---- Ascent usage ------------------------------------------------------ + + ascent_usage = read_custom_function(57) * 0.1; // In liter/minutes. + + // Usage to the first stop: + // - computed at mean depth (triangular integration), + // - with an ascent speed of 10m/min. + // - with ascent liter / minutes. + // - still using bottom gas: + volumes[0] += (0.05 * (char_I_bottom_depth + char_O_first_deco_depth) + 1.0) + * (char_I_bottom_depth - char_O_first_deco_depth) * 0.1 + * ascent_usage; + + for(i=0; i<32 && char_O_deco_depth[i] > 0; ++i) + { + // Gas switch depth ? + for(j=4; j>0; --j) + { + if( char_O_deco_depth[i] <= char_I_deco_gas_change[j] ) + break; + } + + // usage during stop: + volumes[j] += (char_O_deco_depth[i]*0.1 + 1.0)// Use Psurface = 1.0 bar. + * char_O_deco_time[i] // in minutes. + * ascent_usage + // Plus usage during ascent to the next stop, at 10m/min. + + (0.05*(char_O_deco_depth[i] + char_O_deco_depth[i+1]) + 1.0) + * (char_O_deco_depth[i] - char_O_deco_depth[i+1]) * 0.1 + * ascent_usage; + } + + //---- convert results for the ASM interface ----------------------------- + for(i=0; i<5; ++i) + if( volumes[i] > 25499.0 ) + char_O_gas_volumes[i] = 255; + else + char_O_gas_volumes[i] = (unsigned char)((volumes[i] + 99.0)*0.01); } //////////////////////////////////////////////////////////////////////////////
--- a/code_part1/OSTC_code_c_part2/p2_definitions.h Tue Mar 01 11:48:11 2011 +0100 +++ b/code_part1/OSTC_code_c_part2/p2_definitions.h Tue Mar 01 14:41:10 2011 +0100 @@ -91,6 +91,7 @@ extern void deco_clear_CNS_fraction(void); extern void deco_push_tissues_to_vault(void); extern void deco_pull_tissues_from_vault(void); +extern void deco_gas_volumes(void); // *********************************************** // ** Allow compile on VisualC **
--- a/code_part1/OSTC_code_c_part2/shared_definitions.h Tue Mar 01 11:48:11 2011 +0100 +++ b/code_part1/OSTC_code_c_part2/shared_definitions.h Tue Mar 01 14:41:10 2011 +0100 @@ -100,6 +100,8 @@ VAR_UINT (int_O_DBG_post_bitfield); VAR_UCHAR (char_O_NDL_at_20mtr); +TAB_UCHAR (char_O_gas_volumes, 5); // Volumes evaluation for each gas tank, in 100's of liters. + TAB_UCHAR (char_O_hash, 16); #ifdef __18CXX @@ -131,12 +133,10 @@ VAR_UCHAR (char_I_deco_ppO2); // new in v.101 VAR_UCHAR (char_I_depth_last_deco); // new in v.101 unit: [m] VAR_UCHAR (char_I_deco_model); // new in v.102. 0 == ZH-L16, 1 = ZH-L16-GF (Grandiant facttor) +VAR_UCHAR (char_I_bottom_depth); // Bottom depth for planning (used in gas volume evaluation). +VAR_UCHAR (char_I_bottom_time); // Bottom time for planning (used in gas volume evaluation). -VAR_UCHAR (char_I_deco_gas_change1); // new in v.101 -VAR_UCHAR (char_I_deco_gas_change2); // new in v.109 -VAR_UCHAR (char_I_deco_gas_change3); // new in v.109 -VAR_UCHAR (char_I_deco_gas_change4); // new in v.109 -VAR_UCHAR (char_I_deco_gas_change5); // new in v.109 +TAB_UCHAR (char_I_deco_gas_change, 5); // new in v.101 VAR_UCHAR (char_I_deco_N2_ratio1); // new in v.101 VAR_UCHAR (char_I_deco_He_ratio1); // new in v.101