Hallow,
Ik wil dus een programma schrijven die de temperatuur kan meten en weergeven op een lcd scherm, ik werk met een bordje van elcom.
Nu is mijn probleem dat ik altijd 0 graden meet...
Hier heb ik 2 programma's met altijd hetzelfde resultaat:
baud = 9600
Dim Tempmsb As Byte
Dim Templsb As Byte
Config Sda = Portd.6
Config Scl = Portd.5
I2cstart
I2cwbyte &H90
I2cwbyte &HAC ; Write To Config
I2cwbyte &H0A ; Continuous Mode(h0b Voor Oneshot)
I2cstop
$lib "lcd4.lbx"
'Begin programma
Cls
Upperline
Lcd "temperatuur"
Loop:
'start convert
I2cstart
I2cwbyte &H90
I2cwbyte &HEE
I2cstop
Waitms 1000
'-------------
'read temperature
I2cstart
I2cwbyte &H90
I2cwbyte &HAA
I2cstop
Waitms 1000
I2cstart
I2cwbyte &H91
I2crbyte Tempmsb , Ack
I2crbyte Templsb , Nack
I2cstop
Waitms 1000
Lowerline
Lcd Tempmsb ; Templsb
Lcd " graden"
Waitms 1000
Goto Loop
End 'end program
2de programma:
'Begin configuraties en declaraties
Config Sda = Portd.6
Config Scl = Portd.5
Config I2cdelay = 5
Const Badreswrite = &H90
Const Badresread = &H91
Const Breadtempcommand = &HAA
Const Bstartconvert = &HEE
Const Bstopconvert = &H22
Const Bconfig = &HAC
Const Bcontinuousmode = 8
Dim Bmsb As Byte
Dim Blsb As Byte
Dim Btemp As Byte
$lib "lcd4.lbx"
'Begin programma
Cls
Upperline
Lcd "temperatuur"
I2cstart
I2cwbyte Badreswrite
I2cwbyte Bconfig
I2cwbyte Bcontinuousmode
I2cstop
I2cstart
I2cwbyte Badreswrite
I2cwbyte Bstartconvert
I2cstop
Do
I2cstart
I2cwbyte Badreswrite
I2cwbyte Breadtempcommand
I2cstart
I2cwbyte Badresread
I2crbyte Bmsb , Ack
I2crbyte Blsb , Nack
I2cstop
Lowerline
Lcd Bmsb
Lcd " graden"
Loop
End
Bedankt voor alle hulp!!