I'm back home. Here is the Pl variance using this code:
Noise needs to be addressed.
Code:
#Picaxe 08M2
#Terminal 4800
#No_Data
; Uncomment the line below to use SERTXD output
'#Define USE_SERTXD
Symbol Pl = w1 : Symbol Pl.msb = b3 : Symbol Pl.lsb = b2
Symbol Ph = w2 : Symbol Ph.msb = b5 : Symbol Ph.lsb = b6
Symbol Xl = w3
Symbol Xh = w4
Symbol Dl = w5
Symbol D_MID= 5000
Symbol CMD_RESET = $1E
Symbol CMD_D1_4096 = $48
Symbol CMD_ADC = $00
symbol Diff=300
Symbol K = 1
PowerOnReset:
HI2cSetup I2CMASTER, %11101110, I2CSLOW, I2CBYTE
MainLoop:
Do
HI2cOut ( CMD_D1_4096 )
Pause 10
HI2cOut ( CMD_ADC )
Pause 10
HI2cIn ( Ph.lsb, Pl.msb, Pl.lsb) : Ph.msb = 0
Pl=Pl - 10000
Select Case Pl
Case > Xl
w0 = Pl - Xl / K : w6=0
Case < Xl
w6 = Xl - Pl / K : w0=0
End Select
SerTxd( #Pl,TAB, #Xl, TAB ,#w0, TAB,#w6,cr,lf)
Xl = Pl
Xh = Ph
Loop