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

Jak poprawić dokładność zegara na AT89C2051 [SE-CLOCK-MINI]?

ashpl 17 Mar 2006 16:38 1257 2
REKLAMA
  • #1 2425558
    ashpl
    Poziom 13  
    Posty: 50
    Pomógł: 2
    Ocena: 4
    Witam, dopiero zaczynam przygode z programowaniem i na początek zrobiłem se zegar z tej strony. Problem polega na tym że w ciągu godziny zegar sie puźni pare minut :|. I teraz nie wiem co zmienić w programie (jesli wogóle to coś pomoże).

    PS. Na stronce jest schemat i kod źródłowy programu.
  • REKLAMA
  • Pomocny post
    #2 2426247
    Mariusz Wiśniewski
    Poziom 14  
    Posty: 167
    Pomógł: 4
    Ocena: 13
    Witam,

    jeżeli używasz rezonatora 11.0592 MHz to możesz przerobić mój program na swoje potrzeby. Mój zegar spóźnia się jakiś 8 sekund na dobę, więc można dodatkowo napisać linijkę:

    If G1 = 2 And G2 = 3 Then
       S2 = S2 + 8
    End if


    Cały program zegara:

    Config Timer0 = Timer , Gate = Internal , Mode = 1
    
    Dim A As Byte
    Dim G1 As Byte
    Dim G2 As Byte
    Dim M1 As Byte
    Dim M2 As Byte
    Dim S1 As Byte
    Dim S2 As Byte
    
    On Timer0 Zegar
    Enable Interrupts
    Enable Timer0
    Counter0 = 4150
    Start Timer0
    
    G1 = 0
    G2 = 0
    M1 = 0
    M2 = 0
    S1 = 0
    S2 = 0
    
    Do
    
    Loop
    
    Zegar:
    Counter0 = 4150
    Start Timer0
    Incr A
    
       If A = 15 Then
          A = 0
          Cursor Off
          Cls
          Lcd G1 ; G2 ; ":" ; M1 ; M2 ; ":" ; S1 ; S2
          Incr S2
       End If
    
       If S2 = 10 Then
          S2 = 0
          Incr S1
       End If
    
       If S1 = 6 Then
          S1 = 0
          Incr M2
       End If
    
       If M2 = 10 Then
          M2 = 0
          Incr M1
       End If
    
       If M1 = 6 Then
          M1 = 0
          Incr G2
       End If
    
       If G2 = 10 Then
          G2 = 0
          Incr G1
       End If
    
       If G2 = 4 And G1 = 2 Then
          G1 = 0
          G2 = 0
       End If
    
       If G1 = 3 Then
          G1 = 0
       End If
    
    Return


    Pozdrawiam
  • #3 2429278
    ashpl
    Poziom 13  
    Posty: 50
    Pomógł: 2
    Ocena: 4
    Tak zegar wykorzystuje rezonator 11.0592 MHz. Minuta na tym zegarze trwa 1 min i 2 sek. :| narazie udało mi sie te 2 sekundy zlikwidować poprzez zmiane wartości 2ch stałych:

    If Clock_cent > 99 Then
       Clock_cent = 0
       Incr Clock_second
    End If


    If Icount > 49 Then
       Icount = 0
       Incr Clock_cent
    End If


    Zmieniłem je odpowiednio na 103 i 46. Wydaje mi sie że teraz zegar liczy dobrze. Ale sprawdze po ok 12 godzina o ile sie puźni i zrobie tak jak mówiłeś :] z tą korektą. Dzieki...
REKLAMA