logo elektroda
logo elektroda
X
logo elektroda
REKLAMA
REKLAMA
Adblock/uBlockOrigin/AdGuard mogą powodować znikanie niektórych postów z powodu nowej reguły.

[Atmega8][bescom]Termostat

gibsonek 24 Cze 2009 01:24 1547 2
REKLAMA
  • #1 6695584
    gibsonek
    Poziom 2  
    Jest to mój pierwszy post na tym forum, więc witam wszystkich:)
    A teraz o co mi chodzi, a wiec:
    robię termostat i mam problem bo wywala mi błąd przy kompilacji.
    Oto kod:
    $regfile = "m8def.dat"
    $crystal = 8000000
    
    Config 1wire = Portb.0
    
    Config Lcd = 16 * 2
    
    Config Lcdpin = Pin , Db4 = Portc.3 , Db5 = Portc.2 , Db6 = Portc.1 , Db7 = Portc.0 , E = Portc.4 , Rs = Portc.5
    
    Config Pinb.1 = Input
    Config Pinb.2 = Input
    Config Pinb.3 = Input
    Config Pinb.4 = Input
    Config Pind.0 = Output
    
    S1 Alias Pinb.1
    S2 Alias Pinb.2
    S3 Alias Pinb.3
    S4 Alias Pinb.4
    
    Przek Alias Portd.0
    
    Dim Dsid1(8) As Byte
    
    Dim Utz1 As Integer
    Dim Uto1 As Integer
    Dim I1 As Integer , Ss As String * 6
    Dim H1 As Integer , H As String * 6
    Dim Utt1 As Integer , Utt As String * 6
    
    Deflcdchar 0 , 14 , 17 , 17 , 14 , 32 , 32 , 32 , 32
    Cursor Off
    
    Declare Sub Ustt
    Declare Sub Usth
    
    Utt1 = 240
    H1 = 5
    
    Cls
    
     Dsid1(1) = 1wsearchfirst()
    
    
    Do
    
    Cls
       1wreset
       1wwrite &H55
       1wverify Dsid1(1)
       1wwrite &HBE
       I1 = 1wread(2)
    
       1wreset
       1wwrite &HCC
       1wwrite &H44
    
     Waitms 750
    
       I1 = I1 * 10
       I1 = I1 / 16
       Utz1 = Utt1 - H1
       Uto1 = Utt1 + H1
       Ss = Str(i1)
       Ss = Format(ss , " 0.0")
       H = Str(h1)
       H = Format(h , " 0.0")
       Utt = Str(utt1)
       Utt = Format(utt , " 0.0")
       Locate 1 , 1
       Lcd "Temp: " ; Ss ; Chr(0) ; "C"
       Locate 2 , 1
       Lcd "Zad temp: " ; Utt ; Chr(0) ; "C"
    
    
       If I1 < Utz1 Then
       Set Przek
       End If
    
    
    
    
    
       If I1 >= Uto1 Then
       Reset Przek
       End If
    
    
    Debounce S1 , 0 , Ustt , Sub
    
    Loop
    End
    
    Ustt:
    
    Do
       If S3 = 0 Then
          Waitms 25
       If S3 = 0 Then
          Incr Utt1
       End If
          If Utt1 > 500 Then
             Utt1 = 100
          End If
       If S4 = 0 Then
          Waitms 25
       If S4 = 0 Then
          Decr Utt1
       End If
       If Utt1 < 100 Then
          Utt1 = 500
       End If
    
    Utt = Str(utt1)
    Utt = Format(utt , " 0.0")
    Cls
    Locate 1 , 1
    Lcd "Temp zad: " ; Utt ; Chr(0) ; "C"
    
    Debounce S1 , 0 , Usth , Sub
    
    If S2 = 0 Then
       Waitms 25
    If S2 = 0 Then
       Exit Do
    End If
    Loop
    Return
    
    Usth:
    
    Do
    
       If S3 = 0 Then
          Waitms 25
       If S3 = 0 Then
          Incr H1
       End If
       If H1 > 50 Then
          H1 = 0
       End If
       If S4 = 0 Then
          Waitms 25
       If S4 = 0 Then
          Decr H1
       End If
       If H1 < 0 Then
          H1 = 50
       End If
    
    H = Str(h1)
    H = Format(h , " 0.0")
    Cls
    Locate 1 , 1
    Lcd "Histereza: " ; H ; Chr(0) ; "C"
    
    If S1 = 0 Then
       Waitms 25
    If S1 = 0 Then
     Exit Do
    End If
    If S2 = 0 Then
       Waitms 25
    If S2 = 0 Then
       Exit Do
    End If
    Loop
    Return


    A to błąd jaki mi się wyświetla:
    Error: 7   Line: 0 IF THEN expected[168],in File:
    Error: 123  Line: 0 END IF expected,in File:


    O co chodzi z tymi błędami?
    Pozdrawiam
  • REKLAMA
  • #2 6695623
    hose2
    Poziom 17  
    gibsonek napisał:
    wywala mi błąd przy kompilacji.
    ...
       If I1 < Utz1 Then
       Set Przek
       End If                 ' tu jest w porządku
    ...
       If S3 = 0 Then
          Waitms 25           ' ale w tym warunku i podobnych trzeba 'zamknąć' oba ify
       End If                 ' na przykład tutaj
       If S3 = 0 Then
          Incr Utt1
       End If
       End If                 ' ALBO tutaj
    


    A to błąd jaki mi się wyświetla:
    Error: 7   Line: 0 IF THEN expected[168],in File:
    Error: 123  Line: 0 END IF expected,in File:


    O co chodzi z tymi błędami?
    Pozdrawiam


    'END IF expected' - spodziewane zakończenie instrukcji warunkowej

    pozdrawiam
  • #3 6695626
    gibsonek
    Poziom 2  
    Dzięki, Ci o wielki:)
    Przeglądałem to tyle razy i tego nie wychwyciłem:/
    Chyba już za późno:)
    Wielkie dzięki
    Pozdrawiam

    P.S.
    Fajnego masz avatara...super bajka:)
REKLAMA