comparison code_part1/OSTC_code_c_part2/p2_deco.c @ 488:7c48692dd17c

BUGFIX Missed surface pressure for CNS in decoplan.
author JeanDo
date Mon, 17 Oct 2011 21:39:48 +0200
parents fd8266b511cc
children 68aa097f0062
comparison
equal deleted inserted replaced
487:4c93c2154f18 488:7c48692dd17c
516 #endif 516 #endif
517 517
518 ////////////////////////////////////////////////////////////////////////////// 518 //////////////////////////////////////////////////////////////////////////////
519 // Read CF values from the C code. 519 // Read CF values from the C code.
520 520
521 #ifdef CROSS_COMPILE
522 // Full description of the OSTC EEPROM map, including CF values.
523 # include "OSTC_eeprom.h"
524 #endif
525
521 static short read_custom_function(PARAMETER unsigned char cf) 526 static short read_custom_function(PARAMETER unsigned char cf)
522 { 527 {
523 #ifdef CROSS_COMPILE 528 #ifdef CROSS_COMPILE
524 extern unsigned short custom_functions[]; 529 return (cf & 32) ? eeprom.bank1_CF[cf-32].value
525 return custom_functions[cf]; 530 : eeprom.bank0_CF[cf ].value;
526 #else 531 #else
527 extern unsigned char hi, lo; 532 extern unsigned char hi, lo;
528 extern void getcustom15(); 533 extern void getcustom15();
529 _asm 534 _asm
530 movff cf,WREG 535 movff cf,WREG
2382 } 2387 }
2383 2388
2384 ////////////////////////////////////////////////////////////////////////////// 2389 //////////////////////////////////////////////////////////////////////////////
2385 // deco_calc_CNS_planning 2390 // deco_calc_CNS_planning
2386 // 2391 //
2387 // Input: 2392 // Compute CNS during predicetd ascent.
2388 // Output: 2393 //
2394 // Note: Needs a call to deco_push_tissues_to_vault(),
2395 // deco_pull_tissues_from_vault() to avoid trashing everything...
2396 //
2397 // Input: CNS_fraction, char_O_deco_time[], char_O_deco_depth[]
2398 // Output: CNS_fraction, char_O_CNS_fraction
2399 // Trashed: char_I_actual_ppO2
2400 //
2389 void deco_calc_CNS_planning(void) 2401 void deco_calc_CNS_planning(void)
2390 { 2402 {
2391 RESET_C_STACK 2403 RESET_C_STACK
2392 2404
2393 // Uses 1min CNS period: 2405 // Uses 1min CNS period:
2413 overlay unsigned char time, t; 2425 overlay unsigned char time, t;
2414 2426
2415 //---- Ascent to surface delay 2427 //---- Ascent to surface delay
2416 // NOTE: count as if time is spent with bottom pressure, 2428 // NOTE: count as if time is spent with bottom pressure,
2417 // AND the bottom gas 2429 // AND the bottom gas
2418 actual_ppO2 = (char_I_bottom_depth * METER_TO_BAR - ppWater) 2430 actual_ppO2 = (pres_surface + char_I_bottom_depth * METER_TO_BAR - ppWater)
2419 * (1.0 - calc_N2_ratio - calc_He_ratio); 2431 * (1.0 - calc_N2_ratio - calc_He_ratio);
2420 if( actual_ppO2 < 0.0 ) actual_ppO2 = 0.0; 2432 if( actual_ppO2 < 0.0 ) actual_ppO2 = 0.0;
2421 if( actual_ppO2 > 2.50 ) actual_ppO2 = 2.55; 2433 if( actual_ppO2 > 2.50 ) actual_ppO2 = 2.55;
2422 char_I_actual_ppO2 = (unsigned char)(100.0 * actual_ppO2 + 0.5); 2434 char_I_actual_ppO2 = (unsigned char)(100.0 * actual_ppO2 + 0.5);
2423 2435
2438 //---- Gas Switch ? 2450 //---- Gas Switch ?
2439 if( char_O_deco_depth[i] & 0x80 ) 2451 if( char_O_deco_depth[i] & 0x80 )
2440 gas_switch_deepest(); 2452 gas_switch_deepest();
2441 2453
2442 //---- Convert Depth and N2_ratio to ppO2 2454 //---- Convert Depth and N2_ratio to ppO2
2443 actual_ppO2 = (temp_depth_limit * METER_TO_BAR - ppWater) 2455 actual_ppO2 = (pres_surface + temp_depth_limit * METER_TO_BAR - ppWater)
2444 * (1.0 - calc_N2_ratio - calc_He_ratio); 2456 * (1.0 - calc_N2_ratio - calc_He_ratio);
2445 if( actual_ppO2 < 0.0 ) actual_ppO2 = 0.0; 2457 if( actual_ppO2 < 0.0 ) actual_ppO2 = 0.0;
2446 if( actual_ppO2 > 2.50 ) actual_ppO2 = 2.55; 2458 if( actual_ppO2 > 2.50 ) actual_ppO2 = 2.55;
2447 char_I_actual_ppO2 = (unsigned char)(100.0 * actual_ppO2 + 0.5); 2459 char_I_actual_ppO2 = (unsigned char)(100.0 * actual_ppO2 + 0.5);
2448 2460
2449 //---- Apply the stop 2461 //---- Apply the stop
2450 for(t=0; t<time; ++t) 2462 for(t=0; t<time; ++t)
2451 deco_calc_CNS_fraction(); 2463 deco_calc_CNS_fraction();
2452 } 2464 }
2453 } 2465 }
2466
2467 // Back to normal mode...
2468 char_I_step_is_1min = 0;
2454 } 2469 }
2455 2470
2456 ////////////////////////////////////////////////////////////////////////////// 2471 //////////////////////////////////////////////////////////////////////////////
2457 // deco_calc_CNS_decrease_15min 2472 // deco_calc_CNS_decrease_15min
2458 // 2473 //