Pongo
Senior Member
I've used variations of Peter Anderson's 20X2 + Melexis MLX90614 IR sensor code successfully in several projects but now I want to modify one of them and PE6 is choking on a syntax error:
Why am I getting this error now when the projects are working with this code? Could it be because I originally used PE5 and now have PE6?
Full code from phanderson.com follows:
Code:
Hi2cSetup I2CMaster, 45, I2CSlow, I2CByte
^
Syntax error on line 38 at/before position 45
Error: Please use full 8 bit slave address (with bit0 clear)
Full code from phanderson.com follows:
Code:
' MLX90614_1.Bas
'
' Continually measures and displays T_ambient and T_object.
'
' PICAXE-20X2 MLX90614ESF-AAA
'
' Term 11 SCL --------------- SCL
' Term 13 SDA --------------- SDA
'
' 4.7K resistors to +5 VDC on SDA and SCL
'
' Note that this is a direct interface with the PICAXE. The Parallax and
' Sparkfun boards are not required.
'
' copyright, Peter H Anderson, Baltimore, MD, Mar 12, 11
#picaxe 20x2
#Terminal 9600
#No_Table
#No_Data
#freq m4
Symbol Lo = B0
Symbol Hi = B1
Symbol PEC = B2
Symbol Status = B3
Symbol Whole = B4
Symbol Fract = B5
Symbol Val = W3
Symbol TC_100 = W4
Symbol SlaveAdr_2 = B10
Symbol RamLocation = B11
Symbol X = B12
Symbol N = B13
Symbol CRC8 = B14
Top:
Hi2cSetup I2CMaster, 45, I2CSlow, I2CByte
SlaveAdr_2 = $00 * 2 ' use general slave adr
Again:
RamLocation = $06 ' ambient temperature
GoSub ReadRAM
If Status = 1 Then
TC_100 = Val * 2 - 27315
SerTxD ("T_ambient = ")
GoSub DisplayTc
Else
SerTxD ("T_ambient - Error")
End If
SerTxD (", ")
RamLocation = $07 ' ambient temperature
GoSub ReadRAM
If Status = 1 Then
TC_100 = Val * 2 - 27315
SerTxD ("T_object = ")
GoSub DisplayTc
Else
SerTxD ("T_object - Error")
End If
SerTxD (CR, LF)
Pause 1000
GoTo Again
ReadRAM:
Hi2cin [SlaveAdr_2], RamLocation, (Lo, Hi, PEC)
Val = Hi
Val = Val * 256 + Lo
'SerTxD ("Hello ", #TC_100, " ", #PEC, CR, LF)
CRC8 = $00
X = SlaveAdr_2
GoSub CalcCRC8
X = RamLocation
GoSub CalcCRC8
X = SlaveAdr_2 + 1
GoSub CalcCRC8
X = Lo
GoSub CalcCRC8
X = Hi
GoSub CalcCRC8
X = PEC
GoSub CalcCRC8
'SerTxD ("CRC = ", #CRC8, CR, LF)
If CRC8 = 0 Then
Status = 1 ' success
Else
Status = 0
Endif
Return
DisplayTc:
Whole = TC_100 / 100
Fract = TC_100 // 100
SerTxD (#Whole, ".")
If Fract < 10 Then
SerTxD ("0")
Endif
SerTxD (#Fract)
Return
CalcCRC8:
X = X ^ CRC8
For N = 0 to 7
If X > 127 Then
X = X * 2
X = X ^ $07
Else
X = X * 2
Endif
Next
CRC8 = X
Return