hahah, Yea I noticed it a sec later, forgot to change it in the post.
but Im verry happy to say
that your the man of the night
it work like well
now it's like this
with this code I get a temperture compensated reading on my lcd , using a ph stamp of atlas and a ds1820 temp sensor
also I made some calc to get the dierance between the actual Ph and a target Ph later to set
THanks allot, Hope the code will help someone one the milestone
Code:
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
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
_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
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
Com.StartRxTx(_pHRx, _pHTx, 0, _pHBaud)
waitcnt(clkfreq / 4 + cnt)
Com.str(@endCmd)
repeat
getTemperature {get the temperture}
LCD.RawSetPos( $00 ) {set lcd position}
LCD.PrintStr( String("Temperture"))
LCD.RawSetPos( $0B ) {set lcd position}
LCD.PrintStr(fp.FloatToFormat(temp1, 4, 1)) {float to sting}
LCD.PrintStr( string(" C" )) {display C after temp}
Com.str(fp.floattostring(temp1)) {Ask for Reading/ sending temp Thanks "Circuitsoft"}
com.char(13)
Com.StrIn(@messageBuffer) {Getting reading Back/ readin in messagebuffer}
ph1:=fp.StringToFloat(@messageBuffer) {Ph1 = float PH to calculate with}
delta := f.FSub(Target_Ph,ph1 ) {diference = target_ph - PH1 }
LCD.RawSetPos( $40 ) {set lcd position}
LCD.PrintStr( String("Target Ph 7.1 "))
LCD.RawSetPos( $14 ) {set lcd position}
LCD.PrintStr( String("Actual Ph"))
LCD.RawSetPos( $20 ) { diplay Actual PH on lcd }
LCD.PrintStr( @messagebuffer)
LCD.RawSetPos( $54 ) {set lcd position}
LCD.PrintStr( String("Diference"))
LCD.RawSetPos( $60 )
LCD.PrintStr( fp.FloatToFormat(delta, 4, 2)) { display diference from ph and target_ph }
bytefill(@messageBuffer, 0, _BufferSize)
waitcnt(clkfreq/2 + cnt)
DAT
endCmd byte "E", 13, 0
readCmd byte "r", 13, 0
continuousCmd byte "C", 13, 0
tt byte "2","5",".","5",13,0
temp2 byte
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
Bookmarks