ok , after hour and hour of reading and trying I got the difference problem solved , it,s still in float
now on my attemt to send the temp to the ph stamp Ive tryed everything again to get they data alined to be send .
like 23.5 <cr>
i moved the data in diferent forms , now I got them in the right spot in the data , but there in the wrong format , there decimal number and need to make it a asci .
can someone please point out wich way I have to look for an anwserrrrrrrrrrrr
Code:
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
buton1 =9 {input buttons }
buton2 =10 {input buttons }
buton3 =11 {input buttons }
buton4 =12 {input buttons }
RS = 0 {lcd control}
RW = 1 {lcd control}
E = 2 {lcd control}
DBLow = 3 {lcd control}
DBHigh = 6 {lcd control}
CR = 13
LF = 10
PSTClearScreen = 16
tempsensor = 14
vlotter = 13
zaza = 10.0
_pHTx = 7 ' Connected to Rx on pH Stamp
_pHRx = 8 ' Connected to Tx on pH Stamp
_DebugTxPin = 30
_DebugRxPin = 31
_PhBaud = 38400
_DebugBaud = 57600
_BufferSize = 50
Target_PH = 7.1
SKIP_ROM = $CC ' 1-wire commands
READ_SCRATCHPAD = $BE
CONVERT_T = $44
CLS = $00 ' clear screen
HOME = $01 ' home
' carriage return
DEG = $B0 ' degree symbol
#8, BKSP, TAB
VAR
byte messageBuffer[_BufferSize]
long tempc ,temp1,temp ,diference,delta ,ph ,ph1 ,a,b,c,d,ee,ff, idx,tc
byte nstr[64]
OBJ
Com : "Parallax Serial Terminal" ' uses two cog
ow : "OneWire"
fp : "FloatString"
f : "FloatMath"
LCD : "LCD_20x4"
PUB Main | localIndex, localAttmpts
ow.start(tempsensor)
LCD.Init( E, RS, RW, DBHigh, DBLow ) {LCD init}
LCD.usDelay( 5_000 ) {LCD init}
LCD.Clear
waitcnt(clkfreq / 4 + cnt)
repeat
getTemperature {get the temperture}
LCD.RawSetPos( $0B ) {set lcd position}
LCD.PrintStr(fp.FloatToFormat(temp1, 5, 1)) {float to sting}
LCD.PrintStr( string(" C" )) {display C after temp}
byte[@tt][0]:=f.FTrunc(f.fmul(temp1,10.0))/100
byte[@tt][1]:=f.FTrunc(f.fmul(temp1,10.0))/10 - ((f.FTrunc(f.fmul(temp1,10.0))/100)*10)
byte[@tt][3]:=f.FTrunc(f.fmul(temp1,10.0))- ((f.FTrunc(f.fmul(temp1,10.0))/10)*10)
a:=byte[@tt][0]
LCD.RawSetPos( $54 ) {set lcd position}
LCD.Printstr( decx(a,2) )
b:=byte[@tt][1]
LCD.RawSetPos( $57 ) {set lcd position}
LCD.Printstr( decx(b,2) )
c:=byte[@tt][2]
LCD.RawSetPos( $5A ) {set lcd position}
LCD.Printstr( decx(c,2) )
d:=byte[@tt][3]
LCD.RawSetPos( $5F ) {set lcd position}
LCD.Printstr( decx(d,2) )
ee:=byte[@tt][4]
LCD.RawSetPos( $64 ) {set lcd position}
LCD.Printstr( decx(ee,2) )
waitcnt(clkfreq/2 + cnt)
DAT
endCmd byte "E", 13, 0
readCmd byte "r", 13, 0
continuousCmd byte "C", 13, 0
tt byte "A","5",".","5",13,0
temp2 long
PUB getTemperature
ow.reset ' send convert temperature command
ow.writeByte(SKIP_ROM)
ow.writeByte(CONVERT_T)
repeat ' wait for conversion
waitcnt(cnt+clkfreq/1000*25)
if ow.readBits(1)
quit
ow.reset ' read DS1822 scratchpad
ow.writeByte(SKIP_ROM)
ow.writeByte(READ_SCRATCHPAD)
temp := ow.readByte + ow.readByte << 8 ' read temperature
temp1 := F.FDiv(F.FFloat(temp), 16.0) ' convert to floating point
PUB decx(value, digits) | div
'' Returns pointer to zero-padded, signed-decimal string
'' -- if value is negative, field width is digits+1
clrstr(@nstr, 64)
digits := 1 #> digits <# 10
if (value < 0) ' negative value?
-value ' yes, make positive
nstr[idx++] := "-" ' and print sign indicator
div := 1_000_000_000 ' initialize divisor
if digits < 10 ' less than 10 digits?
repeat (10 - digits) ' yes, adjust divisor
div /= 10
value //= (div * 10) ' truncate unused digits
repeat digits
nstr[idx++] := (value / div + "0") ' convert digit to ASCII
value //= div ' update value
div /= 10 ' update divisor
return @nstr
PRI clrstr(strAddr, size)
' Clears string at strAddr
' -- also resets global character pointer (idx)
bytefill(strAddr, 0, size) ' clear string to zeros
idx~ ' reset index
I also tryed to convert them one bye one ,like in the code below . works wel for the first digit , second digit is a diferent story sadly enough
Code:
PUB gg
if f.FTrunc(f.fmul(temp1,10.0))/100 == 0
byte[@tt][0]:=48
if f.FTrunc(f.fmul(temp1,10.0))/100 == 1
byte[@tt][0]:=49
if f.FTrunc(f.fmul(temp1,10.0))/100 == 2
byte[@tt][0]:=50
if f.FTrunc(f.fmul(temp1,10.0))/100 == 3
byte[@tt][0]:=50
if f.FTrunc(f.fmul(temp1,10.0))/100 == 4
byte[@tt][0]:=50
if f.FTrunc(f.fmul(temp1,10.0))/100 == 5
byte[@tt][0]:=50
if f.FTrunc(f.fmul(temp1,10.0))/100 == 6
byte[@tt][0]:=50
if f.FTrunc(f.fmul(temp1,10.0))/100 == 7
byte[@tt][0]:=50
if f.FTrunc(f.fmul(temp1,10.0))/100 == 8
byte[@tt][0]:=50
if f.FTrunc(f.fmul(temp1,10.0))/100 == 9
byte[@tt][0]:=50
return
HELLLLLLLLLPPPPPPPPPPPP
Bookmarks