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

[Szukam] Kod napisany w Bascomie do kitu AVT-2623

pmiko 26 Mar 2011 16:38 2568 2
REKLAMA
  • #1 9325260
    pmiko
    Poziom 12  
    Poszukuję kodu źródłowego do kitu AVT-2623. Koniecznie wersję tekstową, nie żaden gotowy wsad. W opisie pisze że program jest udostępniany w Elportalu ale po długich poszukiwaniach nie znalazłem go. Jeśli ktoś go posiada to bardzo prosiłbym o wysłanie go mi na maila.
  • REKLAMA
  • Pomocny post
    #2 9325305
    ^Rachel
    Poziom 21  
    
    $crystal = 8000000
    Config Lcd = 16 * 1a
    Config Int0 = Falling
    Config Timer0 = Timer , Prescale = 256
    Config Watchdog = 2048
    Config Pind.0 = Input
    Config Pind.1 = Input
    Config Pind.3 = Output
    Config Pind.4 = Output
    Config Pind.5 = Output
    Dim Regulation_counter As Byte
    Dim On_off_flag As Bit
    Dim Regulation_type_flag As Byte
    Dim Int_counter As Byte
    Dim Phase_counter As Word
    Dim Regulation_step_flag As Bit
    Dim T$ As String * 10
    Declare Sub Regulation
    Declare Sub Regulation10
    Declare Sub Ddisplay
    On Timer0 Sub_tim
    Enable Interrupts
    On Int0 Sub_int
    Cls
    Cursor Off
    Regulation_counter = 0
    On_off_flag = 0
    Set Portd.5
    Regulation_type_flag = 0
    T$ = "GROUP100"
    Start Watchdog
    Regulation
    
    Sub Regulation
    Ddisplay
    'Waitms 100
    Do
    
    Reset Watchdog
    Reset Portd.0 : Reset Portd.1
    If Pind.0 = 1 And Pind.1 = 0 Then
    Do
    If Pind.1 = 1 Then Exit Do
    Loop
    
    Do
    If Pind.0 = 0 Then Exit Do
    Loop
    
    Select Case Regulation_type_flag
    Case 0 : Incr Regulation_counter
    Case 1 : Incr Regulation_counter
    Case 2 : Regulation_counter = Regulation_counter + 10
    End Select
    If Regulation_counter > 100 Then Regulation_counter = 100
    Ddisplay
    
    End If
    
    Reset Portd.0 : Reset Portd.1
    If Pind.0 = 0 And Pind.1 = 1 Then
    Do
    If Pind.0 = 1 Then Exit Do
    Loop
    
    Do
    If Pind.1 = 0 Then Exit Do
    Loop
    Select Case Regulation_type_flag
    Case 0 : Decr Regulation_counter
    Case 1 : Decr Regulation_counter
    Case 2 : Regulation_counter = Regulation_counter - 10
    End Select
    If Regulation_counter > 100 Then Regulation_counter = 0
    Ddisplay
    
    End If
    
    Reset Portd.4
    If Pind.4 = 1 Then
    Regulation_counter = 0
    On_off_flag = 0
    Incr Regulation_type_flag
    If Regulation_type_flag = 3 Then Regulation_type_flag = 0
    Waitms 200
    Select Case Regulation_type_flag
    Case 0:
    Disable Timer0
    T$ = "GROUP100"
    Case 1:
    Enable Timer0
    T$ = "PHASE       "
    Case 2:
    Disable Timer0
    T$ = "GROUP10  "
    End Select
    Regulation
    End If
    
    Reset Portd.3
    If Pind.3 = 1 Then
    On_off_flag = Not On_off_flag
    If On_off_flag = 1 Then
    Enable Int0
    Else
    Disable Int0
    Set Portd.5
    
    End If
    Ddisplay
    Waitms 200
    'Regulation
    End If
    Phase_counter = Regulation_counter * 1.5
    Phase_counter = Phase_counter - 6
    If On_off_flag = 0 Then Set Portd.5
    Loop
    
    End Sub
    
    
    Sub Ddisplay
    Cls
    Lcd T$
    Locate 2 , 2
    Lcd "     "
    Locate 2 , 2
    Lcd Regulation_counter ; "%"
    Locate 2 , 6
    If On_off_flag = 1 Then
    Lcd "ON "
    Else
    Lcd "OFF"
    End If
    End Sub
    
    
    Sub_int:
    Reset Watchdog
    If Regulation_type_flag = 0 Or Regulation_type_flag = 2 Then
    Disable Int0
    Incr Int_counter
    If Regulation_type_flag = 2 Then Int_counter = Int_counter + 9
    If Int_counter = Regulation_counter Then Set Portd.5
    If Int_counter = 100 Then Int_counter = 0
    If Int_counter = 0 Then
    If Regulation_counter <> 0 Then
    If On_off_flag = 1 Then
    Reset Portd.5
    End If
    End If
    End If
    Enable Int0
    Enable Interrupts
    End If
    
    If Regulation_type_flag = 1 Then
    Timer0 = Phase_counter
    Start Timer0
    End If
      If On_off_flag = 0 Then Set Portd.5
    Return
    
    
    Sub_tim:
    If On_off_flag = 1 Then
    Reset Portd.5
    Waitus 100
    Set Portd.5
    End If
    
    Return
    



    Pozdrawiam.

    Dodano po 4 [minuty]:

    lub cały plik :
    https://www.elektroda.pl/rtvforum/topic9529.html#6454803
  • #3 9325332
    pmiko
    Poziom 12  
    Serdecznie dziękuję.

    Pojawiła mi się pewna wątpliwość. Układ taktowany 8MHz, jako timer pracuje zegar 8-bitowy, czyli zlicza do 255. Jednocześnie regulacja ma być w zakresie 0-100%.
    Moje pytanie brzmi: czy jest tu jakiś błąd?

    "Phase_counter = Regulation_counter * 1.5
    Phase_counter = Phase_counter - 6 "

    Wychodzi, że jeśli Regulation_counter=100 to timer0=144 , czyli zostaje 111*32us=3,5ms. Aby regulacja była w 100% ten czas powinien wynosić teoretycznie 10ms - detekcja przejścia przez "0" x 2 daje 100Hz czyli między jednym przerwaniem od Int0 a drugim upływa 10ms.

    Czy ktoś pomógłby w zrozumieniu?
REKLAMA