AVRboy
11.08.2006, 21:00
Hi Leute,
ich habe mir nen kleinen Code gebastelt der nen DS18S20 abfägt und das dan auf ein LCD gibt.Doch Bascom bringt immer den fehler das es irgend was mit if-then nich blickt.
Der Fehler lautet:
error: 7 Line:0 IF Then expected (94)
Error: 123 Line: 0 End If expected
Aber wenn ich drauf klicke passiert nix.Und ich finde Auch keine Line 0.
Hier mein Quelltext (ein bischen zusammen geschnipselt):
$regfile = "m8def.dat"
$crystal = 4000000
$baud = 19200
Config 1wire = Portb.0
Const Ds1820 = &H10
Const Skiprom = &HCC
Const Read_rom = &H33
Const Convertt = &H44
Const Read_ram = &HBE
Const Write_ram = &H4E
Const Copy_ram = &H48
Const Recall_ee = &HB8
Const Read_power = &HB4
Dim Family_code As Byte
Dim Serial_number(6) As Byte
Dim Crc As Byte
Dim Scratch(9) As Byte
Dim I As Byte
Dim Temp As Word
Dim Temp1 As Integer
Dim Stemp As Single
Config Portd.7 = Output
Lcd_rw Alias Portd.7
Lcd_rw = 0
Config Lcdbus = 4
Do
Cls
Initlcd
1wreset
If Err = 1 Then
Lcd "DS 1820 Error"
1wwrite Read_rom
Family_code = 1wread()
For I = 1 To 6
Serial_number(i) = 1wread()
Next
Crc = 1wread()
If Family_code <> Ds1820 Then
Exit Do
1wwrite Convertt
Do
Temp = 1wread()
Loop Until Temp = &HFF
1wreset
If Err = 1 Then
Locate 1 , 1
Lcd " DS 1820 Error"
1wwrite Skiprom
1wwrite Read_ram
For I = 1 To 9
Scratch(i) = 1wread()
Next
Temp = Scratch(2)
Shift Temp , Left , 8
Temp = Temp + Scratch(1)
Temp1 = Temp
Locate 1 , 1
Lcd "Der Temp.wert ist" ; Temp ; "Counts."
Temp1 = Temp1 / 2
Locate 2 , 1
Lcd "Die gemessen Temp.ist" ; Temp1 ; "Grad"
Stemp = Scratch(8) - Scratch(7)
Stemp = Stemp / Scratch(8)
Stemp = Stemp + Temp1
Stemp = Stemp - 0.25
Locate 3 , 1
Lcd "Und exakt";
Lcd Fusing(stemp , "#.##");
Locate 4 , 1
Lcd "Grad Celsius"
Wait 2
Loop
Locate 1 , 1
Lcd "Kein Sensor aktiv"
End If
End If
End
Edit : + Code-tags (PicNick)
Es wäre toll wenn ihr mal drüber kucken könntet.
MFG
Marius
](*,) ](*,)
ich habe mir nen kleinen Code gebastelt der nen DS18S20 abfägt und das dan auf ein LCD gibt.Doch Bascom bringt immer den fehler das es irgend was mit if-then nich blickt.
Der Fehler lautet:
error: 7 Line:0 IF Then expected (94)
Error: 123 Line: 0 End If expected
Aber wenn ich drauf klicke passiert nix.Und ich finde Auch keine Line 0.
Hier mein Quelltext (ein bischen zusammen geschnipselt):
$regfile = "m8def.dat"
$crystal = 4000000
$baud = 19200
Config 1wire = Portb.0
Const Ds1820 = &H10
Const Skiprom = &HCC
Const Read_rom = &H33
Const Convertt = &H44
Const Read_ram = &HBE
Const Write_ram = &H4E
Const Copy_ram = &H48
Const Recall_ee = &HB8
Const Read_power = &HB4
Dim Family_code As Byte
Dim Serial_number(6) As Byte
Dim Crc As Byte
Dim Scratch(9) As Byte
Dim I As Byte
Dim Temp As Word
Dim Temp1 As Integer
Dim Stemp As Single
Config Portd.7 = Output
Lcd_rw Alias Portd.7
Lcd_rw = 0
Config Lcdbus = 4
Do
Cls
Initlcd
1wreset
If Err = 1 Then
Lcd "DS 1820 Error"
1wwrite Read_rom
Family_code = 1wread()
For I = 1 To 6
Serial_number(i) = 1wread()
Next
Crc = 1wread()
If Family_code <> Ds1820 Then
Exit Do
1wwrite Convertt
Do
Temp = 1wread()
Loop Until Temp = &HFF
1wreset
If Err = 1 Then
Locate 1 , 1
Lcd " DS 1820 Error"
1wwrite Skiprom
1wwrite Read_ram
For I = 1 To 9
Scratch(i) = 1wread()
Next
Temp = Scratch(2)
Shift Temp , Left , 8
Temp = Temp + Scratch(1)
Temp1 = Temp
Locate 1 , 1
Lcd "Der Temp.wert ist" ; Temp ; "Counts."
Temp1 = Temp1 / 2
Locate 2 , 1
Lcd "Die gemessen Temp.ist" ; Temp1 ; "Grad"
Stemp = Scratch(8) - Scratch(7)
Stemp = Stemp / Scratch(8)
Stemp = Stemp + Temp1
Stemp = Stemp - 0.25
Locate 3 , 1
Lcd "Und exakt";
Lcd Fusing(stemp , "#.##");
Locate 4 , 1
Lcd "Grad Celsius"
Wait 2
Loop
Locate 1 , 1
Lcd "Kein Sensor aktiv"
End If
End If
End
Edit : + Code-tags (PicNick)
Es wäre toll wenn ihr mal drüber kucken könntet.
MFG
Marius
](*,) ](*,)