2N Code help : Replace END by EAD

Legacy OSTC's
Post Reply
6RiL
Posts: 37
Joined: Wednesday 22. August 2012, 09:14

2N Code help : Replace END by EAD

Post by 6RiL »

Hi,

I want to print EAD instead of END in gas setup (OSTC 2N).
I found the code below for calculation of END ( menugassetup.asm L322). But i do not find the equivalent for EAD. Has some one got it ?

Thanks,
6RiL


------------------------------------------------------
; Show END in m
lfsr FSR2, letter
WIN_LEFT .90
OUTPUTTEXTH .298 ; END:
GETCUSTOM8 .18 ; ppO2 warnvalue in WREG
mullw d'10'
movff PRODL,xA+0
movff PRODH,xA+1 ; ppO2 in [0.01bar] * 10
movf divemins+0,W
addlw 0x06
movwf EEADR
call read_eeprom ; O2 value
movff EEDATA,xB+0
clrf xB+1
call div16x16 ; xA/xB=xC with xA as remainder
movlw d'10'
subwf xC+0,F ; Subtract 10m...
movff xC+0,lo
movlw d'0'
subwfb xC+1,F
movff xC+1,hi ; lo:hi holding MOD in meters
movlw d'10'
addwf lo,F
movlw d'0'
addwfc hi,F ; lo:hi holding MOD+10m

movf divemins+0,W
addlw 0x07
movwf EEADR
call read_eeprom ; He value in % -> EEDATA
movlw d'100'
movwf xA+0
movf EEDATA,W ; He value in % -> EEDATA
subwf xA+0,F ; xA+0 = 100 - He Value in %
clrf xA+1
movff lo,xB+0
movff hi,xB+1 ; Copy MOD+10
call mult16x16 ; xA*xB=xC
movff xC+0,xA+0
movff xC+1,xA+1
movlw d'100'
movwf xB+0
clrf xB+1
call div16x16 ; xA/xB=xC with xA as remainder
; xC:2 = ((MOD+10) * 100 - HE Value in %) / 100
movlw d'10'
subwf xC+0,F ; Subtract 10m...
movff xC+0,lo
movlw d'0'
subwfb xC+1,F
movff xC+1,hi
output_16
STRCAT_PRINT TXT_METER3
heinrichsweikamp
Posts: 4446
Joined: Sunday 13. May 2007, 18:07

Re: 2N Code help : Replace END by EAD

Post by heinrichsweikamp »

Hello 6RiL,

Check p2_deco.c line 1199

Regards,
Matthias
6RiL
Posts: 37
Joined: Wednesday 22. August 2012, 09:14

Re: 2N Code help : Replace END by EAD

Post by 6RiL »

I saw it, but it's not an ASM version :-(
If someone has the ASM equivalent for EAD ?

6RiL
heinrichsweikamp
Posts: 4446
Joined: Sunday 13. May 2007, 18:07

Re: 2N Code help : Replace END by EAD

Post by heinrichsweikamp »

While not impossible, coding the following in assembler
[pre]
// EAD : Equivalent Air Dive. Equivalent depth for the same N2 level
// with plain air.
// ppN2 = 79% * (P_EAD - ppWater)
// EAD = (P_EAD - Psurface) * 10
// ie: EAD = (ppN2 / 0.7902 + ppWater -Psurface) * 10
EAD = (ppN2 / 0.7902 + ppWater - pres_surface) * BAR_TO_METER;
if( EAD 245.5 ) EAD = 0.0;
char_O_EAD = (unsigned char)(EAD + 0.5);

With
#define ppWater 0.0627 // Water vapour partial pressure in the lumb.
#define BAR_TO_METER 10.0150 // (1.0/METER_TO_BAR)

[/pre]
is not really fancy, sorry.

regards,
Matthias
6RiL
Posts: 37
Joined: Wednesday 22. August 2012, 09:14

Re: 2N Code help : Replace END by EAD

Post by 6RiL »

Like END is (MOD + 10)x(100-%He)/100 - 10,
is it correct for EAD : (MOD + 10)x(100-%He-%O2)/(100x0.79) - 10 ?

May it easier to code in ASM ?
It needs to substract %O2 in the ASM code above ?

6RiL
Post Reply