- LiFePO4 Speicher Test         
Ergebnis 1 bis 9 von 9

Thema: Ausgabe von Messwerten mit Atmel16

  1. #1
    Benutzer Stammmitglied
    Registriert seit
    27.10.2008
    Beiträge
    50

    Ausgabe von Messwerten mit Atmel16

    Anzeige

    LiFePo4 Akku selber bauen - Video
    Hi

    ich habe ein kleines Problem mit meinem Programm:

    Ich möchte durch ein High auf PINa.1 den Timer starten und durch ein High auf PINa.2 den Timer stoppen. Der Timerwert muss mit einem Wert Multipliziert werden. Dieser wert soll dann an eine 3 Stellige 7 Segment anzeige ausgegeben werden ohne Kommastellen. Die anzeige soll max 5 Sek den Wert anzeigen. Nach stopp des timers sollen die eingänge für 1 sekunde keine Änderungen annehmen.

    Ich komme damit nicht wirklich klar vielleicht kann mir ja jemand helfen
    dieses ist mein bisheriger Code

    Code:
    $regfile "m8def.dat"
    $crystal = 1000000
    
    Dim Test As Integer
    Dim Zeit As Integer
    
    Config Timer0 = Timer , Prescale = 1024
    Stop Timer0
    Timer0 = 0
    
    Config Porta.1 = Input
    Config Porta.2 = Input
    Config Portb = Output
    Config Portc = Output
    Config Portd = Output
    
    
    If Port_a.1 = 1 Then Start Timer0
    If Port_a.2 = 1 Then Stop Timer0
    End If
    
    Read Tcnt0 = Zeit
    
    Zeit / 1757 , 8125 = Test
    
    If Test = 1 Then Portd = &B00000000 Portc = &B00000000 Portb = &B00110000
    If Test = 2 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 0 0 0 0 0 0 0 Portb = &B0 1 1 0 1 1 0 1
    If Test = 3 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 0 0 0 0 0 0 0 Portb = &B0 1 1 1 1 0 0 1
    If Test = 4 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 0 0 0 0 0 0 0 Portb = &B0 0 1 1 0 0 1 1
    If Test = 5 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 0 0 0 0 0 0 0 Portb = &B0 1 0 1 1 0 1 1
    If Test = 6 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 0 0 0 0 0 0 0 Portb = &B0 1 0 1 1 1 1 1
    If Test = 7 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 0 0 0 0 0 0 0 Portb = &B0 1 1 1 0 0 0 0
    If Test = 8 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 0 0 0 0 0 0 0 Portb = &B0 1 1 1 1 1 1 1
    If Test = 9 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 0 0 0 0 0 0 0 Portb = &B0 1 1 1 1 0 1 1
    If Test = 10 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 0 1 1 0 0 0 0 Portb = &B0 1 1 1 1 1 1 0
    If Test = 11 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 0 1 1 0 0 0 0 Portb = &B0 0 1 1 0 0 0 0
    If Test = 12 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 0 1 1 0 0 0 0 Portb = &B0 1 1 0 1 1 0 1
    If Test = 13 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 0 1 1 0 0 0 0 Portb = &B0 1 1 1 1 0 0 1
    If Test = 14 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 0 1 1 0 0 0 0 Portb = &B0 0 1 1 0 0 1 1
    If Test = 15 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 0 1 1 0 0 0 0 Portb = &B0 1 0 1 1 0 1 1
    If Test = 16 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 0 1 1 0 0 0 0 Portb = &B0 1 0 1 1 1 1 1
    If Test = 17 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 0 1 1 0 0 0 0 Portb = &B0 1 1 1 0 0 0 0
    If Test = 18 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 0 1 1 0 0 0 0 Portb = &B0 1 1 1 1 1 1 1
    If Test = 19 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 0 1 1 0 0 0 0 Portb = &B0 1 1 1 1 0 1 1
    If Test = 20 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 1 0 1 1 0 1 Portb = &B0 1 1 1 1 1 1 0
    If Test = 21 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 1 0 1 1 0 1 Portb = &B0 0 1 1 0 0 0 0
    If Test = 22 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 1 0 1 1 0 1 Portb = &B0 1 1 0 1 1 0 1
    If Test = 23 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 1 0 1 1 0 1 Portb = &B0 1 1 1 1 0 0 1
    If Test = 24 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 1 0 1 1 0 1 Portb = &B0 0 1 1 0 0 1 1
    If Test = 25 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 1 0 1 1 0 1 Portb = &B0 1 0 1 1 0 1 1
    If Test = 26 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 1 0 1 1 0 1 Portb = &B0 1 0 1 1 1 1 1
    If Test = 27 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 1 0 1 1 0 1 Portb = &B0 1 1 1 0 0 0 0
    If Test = 28 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 1 0 1 1 0 1 Portb = &B0 1 1 1 1 1 1 1
    If Test = 29 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 1 0 1 1 0 1 Portb = &B0 1 1 1 1 0 1 1
    If Test = 30 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 1 1 1 0 0 1 Portb = &B0 1 1 1 1 1 1 0
    If Test = 31 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 1 1 1 0 0 1 Portb = &B0 0 1 1 0 0 0 0
    If Test = 32 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 1 1 1 0 0 1 Portb = &B0 1 1 0 1 1 0 1
    If Test = 33 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 1 1 1 0 0 1 Portb = &B0 1 1 1 1 0 0 1
    If Test = 34 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 1 1 1 0 0 1 Portb = &B0 0 1 1 0 0 1 1
    If Test = 35 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 1 1 1 0 0 1 Portb = &B0 1 0 1 1 0 1 1
    If Test = 36 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 1 1 1 0 0 1 Portb = &B0 1 0 1 1 1 1 1
    If Test = 37 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 1 1 1 0 0 1 Portb = &B0 1 1 1 0 0 0 0
    If Test = 38 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 1 1 1 0 0 1 Portb = &B0 1 1 1 1 1 1 1
    If Test = 39 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 1 1 1 0 0 1 Portb = &B0 1 1 1 1 0 1 1
    If Test = 40 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 0 1 1 0 0 1 1 Portb = &B0 1 1 1 1 1 1 0
    If Test = 41 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 0 1 1 0 0 1 1 Portb = &B0 0 1 1 0 0 0 0
    If Test = 42 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 0 1 1 0 0 1 1 Portb = &B0 1 1 0 1 1 0 1
    If Test = 43 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 0 1 1 0 0 1 1 Portb = &B0 1 1 1 1 0 0 1
    If Test = 44 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 0 1 1 0 0 1 1 Portb = &B0 0 1 1 0 0 1 1
    If Test = 45 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 0 1 1 0 0 1 1 Portb = &B0 1 0 1 1 0 1 1
    If Test = 46 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 0 1 1 0 0 1 1 Portb = &B0 1 0 1 1 1 1 1
    If Test = 47 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 0 1 1 0 0 1 1 Portb = &B0 1 1 1 0 0 0 0
    If Test = 48 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 0 1 1 0 0 1 1 Portb = &B0 1 1 1 1 1 1 1
    If Test = 49 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 0 1 1 0 0 1 1 Portb = &B0 1 1 1 1 0 1 1
    If Test = 50 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 0 1 1 0 1 1 Portb = &B0 1 1 1 1 1 1 0
    If Test = 51 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 0 1 1 0 1 1 Portb = &B0 0 1 1 0 0 0 0
    If Test = 52 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 0 1 1 0 1 1 Portb = &B0 1 1 0 1 1 0 1
    If Test = 53 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 0 1 1 0 1 1 Portb = &B0 1 1 1 1 0 0 1
    If Test = 54 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 0 1 1 0 1 1 Portb = &B0 0 1 1 0 0 1 1
    If Test = 55 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 0 1 1 0 1 1 Portb = &B0 1 0 1 1 0 1 1
    If Test = 56 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 0 1 1 0 1 1 Portb = &B0 1 0 1 1 1 1 1
    If Test = 57 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 0 1 1 0 1 1 Portb = &B0 1 1 1 0 0 0 0
    If Test = 58 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 0 1 1 0 1 1 Portb = &B0 1 1 1 1 1 1 1
    If Test = 59 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 0 1 1 0 1 1 Portb = &B0 1 1 1 1 0 1 1
    If Test = 60 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 0 1 1 1 1 1 Portb = &B0 1 1 1 1 1 1 0
    If Test = 61 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 0 1 1 1 1 1 Portb = &B0 0 1 1 0 0 0 0
    If Test = 62 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 0 1 1 1 1 1 Portb = &B0 1 1 0 1 1 0 1
    If Test = 63 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 0 1 1 1 1 1 Portb = &B0 1 1 1 1 0 0 1
    If Test = 64 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 0 1 1 1 1 1 Portb = &B0 0 1 1 0 0 1 1
    If Test = 65 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 0 1 1 1 1 1 Portb = &B0 1 0 1 1 0 1 1
    If Test = 66 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 0 1 1 1 1 1 Portb = &B0 1 0 1 1 1 1 1
    If Test = 67 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 0 1 1 1 1 1 Portb = &B0 1 1 1 0 0 0 0
    If Test = 68 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 0 1 1 1 1 1 Portb = &B0 1 1 1 1 1 1 1
    If Test = 69 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 0 1 1 1 1 1 Portb = &B0 1 1 1 1 0 1 1
    If Test = 70 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 1 1 0 0 0 0 Portb = &B0 1 1 1 1 1 1 0
    If Test = 71 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 1 1 0 0 0 0 Portb = &B0 0 1 1 0 0 0 0
    If Test = 72 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 1 1 0 0 0 0 Portb = &B0 1 1 0 1 1 0 1
    If Test = 73 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 1 1 0 0 0 0 Portb = &B0 1 1 1 1 0 0 1
    If Test = 74 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 1 1 0 0 0 0 Portb = &B0 0 1 1 0 0 1 1
    If Test = 75 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 1 1 0 0 0 0 Portb = &B0 1 0 1 1 0 1 1
    If Test = 76 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 1 1 0 0 0 0 Portb = &B0 1 0 1 1 1 1 1
    If Test = 77 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 1 1 0 0 0 0 Portb = &B0 1 1 1 0 0 0 0
    If Test = 78 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 1 1 0 0 0 0 Portb = &B0 1 1 1 1 1 1 1
    If Test = 79 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 1 1 0 0 0 0 Portb = &B0 1 1 1 1 0 1 1
    If Test = 80 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 1 1 1 1 1 1 Portb = &B0 1 1 1 1 1 1 0
    If Test = 81 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 1 1 1 1 1 1 Portb = &B0 0 1 1 0 0 0 0
    If Test = 82 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 1 1 1 1 1 1 Portb = &B0 1 1 0 1 1 0 1
    If Test = 83 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 1 1 1 1 1 1 Portb = &B0 1 1 1 1 0 0 1
    If Test = 84 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 1 1 1 1 1 1 Portb = &B0 0 1 1 0 0 1 1
    If Test = 85 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 1 1 1 1 1 1 Portb = &B0 1 0 1 1 0 1 1
    If Test = 86 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 1 1 1 1 1 1 Portb = &B0 1 0 1 1 1 1 1
    If Test = 87 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 1 1 1 1 1 1 Portb = &B0 1 1 1 0 0 0 0
    If Test = 88 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 1 1 1 1 1 1 Portb = &B0 1 1 1 1 1 1 1
    If Test = 89 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 1 1 1 1 1 1 Portb = &B0 1 1 1 1 0 1 1
    If Test = 90 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 1 1 1 0 1 1 Portb = &B0 1 1 1 1 1 1 0
    If Test = 91 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 1 1 1 0 1 1 Portb = &B0 0 1 1 0 0 0 0
    If Test = 92 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 1 1 1 0 1 1 Portb = &B0 1 1 0 1 1 0 1
    If Test = 93 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 1 1 1 0 1 1 Portb = &B0 1 1 1 1 0 0 1
    If Test = 94 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 1 1 1 0 1 1 Portb = &B0 0 1 1 0 0 1 1
    If Test = 95 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 1 1 1 0 1 1 Portb = &B0 1 0 1 1 0 1 1
    If Test = 96 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 1 1 1 0 1 1 Portb = &B0 1 0 1 1 1 1 1
    If Test = 97 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 1 1 1 0 1 1 Portb = &B0 1 1 1 0 0 0 0
    If Test = 98 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 1 1 1 0 1 1 Portb = &B0 1 1 1 1 1 1 1
    If Test = 99 Then Portd = &B0 0 0 0 0 0 0 0 Portc = &B0 1 1 1 1 0 1 1 Portb = &B0 1 1 1 1 0 1 1
    If Test = 100 Then Portd = &B0 0 1 1 0 0 0 0 Portc = &B0 1 1 1 1 1 1 0 Portb = &B0 1 1 1 1 1 1 0
    If Test = 101 Then Portd = &B0 0 1 1 0 0 0 0 Portc = &B0 0 0 0 0 0 0 0 Portb = &B0 0 1 1 0 0 0 0
    If Test = 102 Then Portd = &B0 0 1 1 0 0 0 0 Portc = &B0 0 0 0 0 0 0 0 Portb = &B0 1 1 0 1 1 0 1
    If Test = 103 Then Portd = &B0 0 1 1 0 0 0 0 Portc = &B0 0 0 0 0 0 0 0 Portb = &B0 1 1 1 1 0 0 1
    If Test = 104 Then Portd = &B0 0 1 1 0 0 0 0 Portc = &B0 0 0 0 0 0 0 0 Portb = &B0 0 1 1 0 0 1 1
    If Test = 105 Then Portd = &B0 0 1 1 0 0 0 0 Portc = &B0 0 0 0 0 0 0 0 Portb = &B0 1 0 1 1 0 1 1
    If Test = 106 Then Portd = &B0 0 1 1 0 0 0 0 Portc = &B0 0 0 0 0 0 0 0 Portb = &B0 1 0 1 1 1 1 1
    If Test = 107 Then Portd = &B0 0 1 1 0 0 0 0 Portc = &B0 0 0 0 0 0 0 0 Portb = &B0 1 1 1 0 0 0 0
    If Test = 108 Then Portd = &B0 0 1 1 0 0 0 0 Portc = &B0 0 0 0 0 0 0 0 Portb = &B0 1 1 1 1 1 1 1
    If Test = 109 Then Portd = &B0 0 1 1 0 0 0 0 Portc = &B0 0 0 0 0 0 0 0 Portb = &B0 1 1 1 1 0 1 1
    If Test = 110 Then Portd = &B0 0 1 1 0 0 0 0 Portc = &B0 0 1 1 0 0 0 0 Portb = &B0 1 1 1 1 1 1 0
    If Test = 111 Then Portd = &B0 0 1 1 0 0 0 0 Portc = &B0 0 1 1 0 0 0 0 Portb = &B0 0 1 1 0 0 0 0
    If Test = 112 Then Portd = &B0 0 1 1 0 0 0 0 Portc = &B0 0 1 1 0 0 0 0 Portb = &B0 1 1 0 1 1 0 1
    If Test = 113 Then Portd = &B0 0 1 1 0 0 0 0 Portc = &B0 0 1 1 0 0 0 0 Portb = &B0 1 1 1 1 0 0 1
    If Test = 114 Then Portd = &B0 0 1 1 0 0 0 0 Portc = &B0 0 1 1 0 0 0 0 Portb = &B0 0 1 1 0 0 1 1
    If Test = 115 Then Portd = &B0 0 1 1 0 0 0 0 Portc = &B0 0 1 1 0 0 0 0 Portb = &B0 1 0 1 1 0 1 1
    If Test = 116 Then Portd = &B0 0 1 1 0 0 0 0 Portc = &B0 0 1 1 0 0 0 0 Portb = &B0 1 0 1 1 1 1 1
    If Test = 117 Then Portd = &B0 0 1 1 0 0 0 0 Portc = &B0 0 1 1 0 0 0 0 Portb = &B0 1 1 1 0 0 0 0
    If Test = 118 Then Portd = &B0 0 1 1 0 0 0 0 Portc = &B0 0 1 1 0 0 0 0 Portb = &B0 1 1 1 1 1 1 1
    If Test = 119 Then Portd = &B0 0 1 1 0 0 0 0 Portc = &B0 0 1 1 0 0 0 0 Portb = &B0 1 1 1 1 0 1 1
    If Test = 120 Then Portd = &B0 0 1 1 0 0 0 0 Portc = &B0 1 1 0 1 1 0 1 Portb = &B0 1 1 1 1 1 1 0
    If Test = 121 Then Portd = &B0 0 1 1 0 0 0 0 Portc = &B0 1 1 0 1 1 0 1 Portb = &B0 0 1 1 0 0 0 0
    If Test = 122 Then Portd = &B0 0 1 1 0 0 0 0 Portc = &B0 1 1 0 1 1 0 1 Portb = &B0 1 1 0 1 1 0 1
    If Test = 123 Then Portd = &B0 0 1 1 0 0 0 0 Portc = &B0 1 1 0 1 1 0 1 Portb = &B0 1 1 1 1 0 0 1
    If Test = 124 Then Portd = &B0 0 1 1 0 0 0 0 Portc = &B0 1 1 0 1 1 0 1 Portb = &B0 0 1 1 0 0 1 1
    If Test = 125 Then Portd = &B0 0 1 1 0 0 0 0 Portc = &B0 1 1 0 1 1 0 1 Portb = &B0 1 0 1 1 0 1 1
    If Test = 126 Then Portd = &B0 0 1 1 0 0 0 0 Portc = &B0 1 1 0 1 1 0 1 Portb = &B0 1 0 1 1 1 1 1
    If Test = 127 Then Portd = &B0 0 1 1 0 0 0 0 Portc = &B0 1 1 0 1 1 0 1 Portb = &B0 1 1 1 0 0 0 0
    If Test = 128 Then Portd = &B0 0 1 1 0 0 0 0 Portc = &B0 1 1 0 1 1 0 1 Portb = &B0 1 1 1 1 1 1 1
    If Test = 129 Then Portd = &B0 0 1 1 0 0 0 0 Portc = &B0 1 1 0 1 1 0 1 Portb = &B0 1 1 1 1 0 1 1
    If Test = 130 Then Portd = &B0 0 1 1 0 0 0 0 Portc = &B0 1 1 1 1 0 0 1 Portb = &B0 1 1 1 1 1 1 0
    If Test = 131 Then Portd = &B0 0 1 1 0 0 0 0 Portc = &B0 1 1 1 1 0 0 1 Portb = &B0 0 1 1 0 0 0 0
    If Test = 132 Then Portd = &B0 0 1 1 0 0 0 0 Portc = &B0 1 1 1 1 0 0 1 Portb = &B0 1 1 0 1 1 0 1
    If Test = 133 Then Portd = &B0 0 1 1 0 0 0 0 Portc = &B0 1 1 1 1 0 0 1 Portb = &B0 1 1 1 1 0 0 1
    If Test = 134 Then Portd = &B0 0 1 1 0 0 0 0 Portc = &B0 1 1 1 1 0 0 1 Portb = &B0 0 1 1 0 0 1 1
    If Test = 135 Then Portd = &B0 0 1 1 0 0 0 0 Portc = &B0 1 1 1 1 0 0 1 Portb = &B0 1 0 1 1 0 1 1
    If Test = 136 Then Portd = &B0 0 1 1 0 0 0 0 Portc = &B0 1 1 1 1 0 0 1 Portb = &B0 1 0 1 1 1 1 1
    If Test = 137 Then Portd = &B0 0 1 1 0 0 0 0 Portc = &B0 1 1 1 1 0 0 1 Portb = &B0 1 1 1 0 0 0 0
    If Test = 138 Then Portd = &B0 0 1 1 0 0 0 0 Portc = &B0 1 1 1 1 0 0 1 Portb = &B0 1 1 1 1 1 1 1
    If Test = 139 Then Portd = &B0 0 1 1 0 0 0 0 Portc = &B0 1 1 1 1 0 0 1 Portb = &B0 1 1 1 1 0 1 1
    If Test = 140 Then Portd = &B0 0 1 1 0 0 0 0 Portc = &B0 0 1 1 0 0 1 1 Portb = &B0 1 1 1 1 1 1 0
    If Test = 141 Then Portd = &B0 0 1 1 0 0 0 0 Portc = &B0 0 1 1 0 0 1 1 Portb = &B0 0 1 1 0 0 0 0
    If Test = 142 Then Portd = &B0 0 1 1 0 0 0 0 Portc = &B0 0 1 1 0 0 1 1 Portb = &B0 1 1 0 1 1 0 1
    If Test = 143 Then Portd = &B0 0 1 1 0 0 0 0 Portc = &B0 0 1 1 0 0 1 1 Portb = &B0 1 1 1 1 0 0 1
    If Test = 144 Then Portd = &B0 0 1 1 0 0 0 0 Portc = &B0 0 1 1 0 0 1 1 Portb = &B0 0 1 1 0 0 1 1
    If Test = 145 Then Portd = &B0 0 1 1 0 0 0 0 Portc = &B0 0 1 1 0 0 1 1 Portb = &B0 1 0 1 1 0 1 1
    If Test = 146 Then Portd = &B0 0 1 1 0 0 0 0 Portc = &B0 0 1 1 0 0 1 1 Portb = &B0 1 0 1 1 1 1 1
    If Test = 147 Then Portd = &B0 0 1 1 0 0 0 0 Portc = &B0 0 1 1 0 0 1 1 Portb = &B0 1 1 1 0 0 0 0
    If Test = 148 Then Portd = &B0 0 1 1 0 0 0 0 Portc = &B0 0 1 1 0 0 1 1 Portb = &B0 1 1 1 1 1 1 1
    If Test = 149 Then Portd = &B0 0 1 1 0 0 0 0 Portc = &B0 0 1 1 0 0 1 1 Portb = &B0 1 1 1 1 0 1 1
    
    If Test > 150 Then Then Portd = &B01111010 Portc = &BB01111010 Portb = &BB01111010
    If Test < 0 Then Then Portd = &B01111110 Portc = &B01111110 Portb = &B01111110
    
    Waitms 1000
    Portd = &B00000000 Portc = &B00000000 Portb = &B00000000
    
    End If
    
    End
    Die Leerzeichen in der Matrix entfallen natürlich noch

  2. #2
    Erfahrener Benutzer Robotik Einstein Avatar von wkrug
    Registriert seit
    17.08.2006
    Ort
    Dietfurt
    Beiträge
    2.188
    Ich würde Dir vorschlagen, an das Thema anders heran zu gehen.

    1. Ich denke es wird dir die Zählzeit des Timers 1 ( 16Bit ) nicht ausreichen.
    Du solltest also eine Timer 1 Overflow Routine einbauen und in der noch einen weiteren Zähler hochzählen.
    Die beriden Werte kannst Du dann zu einer Long Int verrechen.

    2. Die beiden Auslösesignale sollten wenn möglich durch Interrupts getriggert werden. ICP, INT0 und INT1 wären da mögliche Kandidaten.
    Die Pause von 1 Sekunde kannst Du ja dadurch errreichen, das Du den Interrupt für den Start für eine Sekunde sperrst und erst dann wieder freigibst.

    3. Du musst den Timer für deine Messung nicht unbedingt immer auf 0 stellen.
    Beim Start speicherst Du den aktuellen Wert ab, beim Stopp ziehst Du den vorher abgespeicherten Wert vom aktuellen ab.
    Wenn Du dabei Unsigned Variablen verwendest funktioniert das auch nach einem Überlauf eines Zählers noch richtig.
    Der Vorteil ist, das Du das TCNT Register, sowie die Überlauf Variable nicht beeinflussen musst.

    Ein Codebeispiel in Bascom kann ich Dir leider nicht anbieten, progge in "C".

    In "C" hab ich einen funktionierenden Code für eine DCF77 Uhr mit Stoppuhrfunktion, die Deine gewünschten Features enthält.
    6x 7 Segment LED Anzeige
    DCF 77 Uhr mit Vorwärts und Rückwärtsanzeige
    Stoppuhr mit Vorwärts und Rückwärts Anzeige
    Auto Reset.
    Programmierbare Start Retriggerung Sperre.
    Serielle Schnittstelle.

    Das Teil geht auch mit einem ATMEGA 16 mit 8MHz Quarz
    Es soll mal als Stoppuhr beim Cart Rennen eingesetzt werden.

  3. #3
    Erfahrener Benutzer Robotik Visionär
    Registriert seit
    26.11.2005
    Ort
    bei Uelzen (Niedersachsen)
    Beiträge
    7.942
    Für Zeiten bis 5 sekunden könnte der Timer selber reichlich schnell sein, es geht bei 1 MHz aber noch. Für nur 3 Stellen reicht es entweder nur den Timer zu nehmen, oder den Timer nur einen Takt erzeugen zu lassen, und dann in Software hochzählen.
    Man wird hier wohl um die kombination von beidem herumkommen.

    Der einfachere Weg wäre wohl der Timer direkt, geht aber nur bis maximal 60 s bei 1 MHz Takt.


    Für die umrechnung von einer dezimalzahl in den 7 Segmentcode nimmt man besser ein kleine Tabelle (Array) als die vielen IF Statements. Die Aufteilung in die einzelnen Stellen ist ja auch nicht so schwer.

  4. #4
    Benutzer Stammmitglied
    Registriert seit
    27.10.2008
    Beiträge
    50
    Hi

    Die Zeiten die gemessen werden liegen im Bereich zwischen 0,5 und 0,085 Sekunden

    Da ich ziemlich blutiger Anfänger bin ( mein 2. Projekt ) bin ich mir nicht sicher ob ich eure Hinweise auch alle richtig verstehe. Das ganze ist Teil einer Anlage zur Geschwindigkeitsmessung.
    Von C habe ich leider nicht den leisesten Schimmer Baisc an sich hatte ich in der Schule ( lange ist es her) und verstehe ich daher etwas besser.

    Wobei Bascom schon meckert bei den beiden Zeilen.
    Code:
    Config Porta.1 = Input
    Config Porta.2 = Input
    Wobei ich ebenfalls vermute das hier:
    Code:
    If Port_a.1 = 1 Then Start Timer0
    If Port_a.2 = 1 Then Stop Timer0
    End If
    
    Read Tcnt0 = Zeit
    
    Zeit / 1757 , 8125 = Test
    auch noch ein kleiner bug drin ist

    Bei den Arrays habe ich das Problem, das ich Schwierigkeiten habe die dann sauber anzusprechen.

    Ich werde gleich mal versuchen so ein array aufzubauen

  5. #5
    Erfahrener Benutzer Robotik Visionär
    Registriert seit
    26.11.2005
    Ort
    bei Uelzen (Niedersachsen)
    Beiträge
    7.942
    Bei den IF Statemants im kleinen Fenster unten ist zumindestens der Fehler drin, das sich Port_a nicht ändert, denn das ist der Wert der Ausgegeben wird. Den Eingangszustand ließt man über Pina... ein.

  6. #6
    Benutzer Stammmitglied
    Registriert seit
    27.10.2008
    Beiträge
    50
    danke

    ich bin auch schon ene schritt weiter gekommen
    Code:
    $regfile "m16def.dat "
    $crystal = 1000000
    
    Dim Test As Integer
    Dim Zeit As Integer
    Dim Bit00_array(7) As Byte
    Dim Bit01_array(7) As Byte
    Dim Bit02_array(7) As Byte
    Dim Bit03_array(7) As Byte
    Dim Bit04_array(7) As Byte
    Dim Bit05_array(7) As Byte
    Dim Bit06_array(7) As Byte
    Dim Bit07_array(7) As Byte
    Dim Bit08_array(7) As Byte
    Dim Bit09_array(7) As Byte
    Dim Bit10_array(7) As Byte
    Dim Bit11_array(7) As Byte
    Dim Bit12_array(7) As Byte
    Dim Bit13_array(7) As Byte
    Dim Bit14_array(7) As Byte
    Dim Bit15_array(7) As Byte
    Dim Bit16_array(7) As Byte
    Dim Bit17_array(7) As Byte
    Dim Bit18_array(7) As Byte
    Dim Bit19_array(7) As Byte
    Dim Bit20_array(7) As Byte
    Dim Bit21_array(7) As Byte
    
    Bit00_array(2) = 1
    Bit00_array(3) = 1
    Bit00_array(4) = 1
    Bit00_array(5) = 1
    Bit00_array(6) = 1
    Bit00_array(7) = 1
    Bit01_array(5) = 1
    Bit01_array(6) = 1
    Bit02_array(1) = 1
    Bit02_array(3) = 1
    Bit02_array(4) = 1
    Bit02_array(6) = 1
    Bit02_array(7) = 1
    Bit03_array(1) = 1
    Bit03_array(4) = 1
    Bit03_array(5) = 1
    Bit03_array(6) = 1
    Bit03_array(7) = 1
    Bit04_array(1) = 1
    Bit04_array(2) = 1
    Bit04_array(5) = 1
    Bit04_array(6) = 1
    
    
    
    Bit10_array(2) = 1
    Bit10_array(3) = 1
    Bit10_array(4) = 1
    Bit10_array(5) = 1
    Bit10_array(6) = 1
    Bit10_array(7) = 1
    Bit11_array(5) = 1
    Bit11_array(6) = 1
    Bit12_array(1) = 1
    Bit12_array(3) = 1
    Bit12_array(4) = 1
    Bit12_array(6) = 1
    Bit12_array(7) = 1
    Bit13_array(1) = 1
    Bit13_array(4) = 1
    Bit13_array(5) = 1
    Bit13_array(6) = 1
    Bit13_array(7) = 1
    Bit14_array(1) = 1
    Bit14_array(2) = 1
    Bit14_array(5) = 1
    Bit14_array(6) = 1
    
    
    Bit20_array(2) = 1
    Bit20_array(3) = 1
    Bit20_array(4) = 1
    Bit20_array(5) = 1
    Bit20_array(6) = 1
    Bit20_array(7) = 1
    Bit21_array(5) = 1
    Bit21_array(6) = 1
    
    
    Config Timer0 = Timer , Prescale = 1024
    Enable Timer0
    Stop Timer0
    Timer0 = 0
    
    Config Porta.0 = Input
    Config Porta.1 = Input
    Config Portb = Output
    Config Portc = Output
    Config Portd = Output
    
    
    If Pina.0 = 1 Then Start Timer0
    If Pina.1 = 1 Then Stop Timer0
    
    
    Timer0 = Zeit
    
    Zeit \ 1757 = Test
    derzeit hängt es noch an der Berechung Zeit durch faktor

    Die Arrays habe ich noch nicht alle fertig. ICh habe aber noch keine Idee wie ich aus der Variabelen die richtige Array auslese.

  7. #7
    Erfahrener Benutzer Roboter Genie
    Registriert seit
    16.02.2006
    Beiträge
    1.113
    Ich glaube, das ist auch nicht so, wie die anderen es meinten.
    Du hast 3 7-Segment Anzeigen, die jeweils in der gleichen Folge an einem Port angeschlossen sind.
    Dann kannst du die 3 Stellen doch separat setzen.
    Hier hast du die Segmente für die Zahlen von 0-9 angegeben:
    1: Portb = &B00110000
    2: Portb = &B01101101
    3: Portb = &B01111001
    4: Portb = &B00110011
    5: Portb = &B01011011
    6: Portb = &B01011111
    7: Portb = &B01110000
    8: Portb = &B01111111
    9: Portb = &B01111011
    0: Portb = &B01111110

    Diese schreibst du dir jetzt in ein Array. Etwa so:
    Dim seg_array(10) As Byte
    seg_array(1)= &B00110000
    seg_array(2) = &B01101101
    seg_array(3) = &B01111001
    seg_array(4) = &B00110011
    seg_array(5) = &B01011011
    seg_array(6) = &B01011111
    seg_array(7) = &B01110000
    seg_array(8) = &B01111111
    seg_array(9) = &B01111011
    seg_array(10) = &B01111110

    Dabei wirst du bemerken, dass die 0 tatsächlich im Array Element 10 steht. Das liegt daran, dass der Array Index bei 1 beginnt, die 0 also nicht in seg_array(0) geschrieben werden kann. Daher musst du die 0 später gesondert behandeln.

    Wenn du jetzt den Wert 357 auf deiner 7-Segment Anzeige darstellen willst, dann soll die 3 (die Segmente dafür stehen in seg_array(3)) auf den PortD (deine Hunderter Stelle) gesetzt werden. Also
    PORTD = Seg_array(3)
    PORTC = Seg_array(5) und
    PORTB = Seg_array(7)

    Wie du später feststellen wirst, gibt es elegantere Wege an die einzelnen Ziffern zu kommen, aber für den Anfang kannst die Variable Test durch 100 teilen, um so die 3 zu bekommen. Entsprechend für die Zehner und die Einer.

    Versuche dies mal so zu programmieren und melde dich, wenn du nicht weiterkommst.

    Gruß

    Rolf

  8. #8
    Benutzer Stammmitglied
    Registriert seit
    27.10.2008
    Beiträge
    50
    Hi

    vielen dank für deine Hilfe ich bin jetzt schon ein Stück weiter:


    Code:
    $regfile "m16def.dat "
    $crystal = 1000000
    
    Dim Test As Integer
    Dim Zeit As Integer
    Dim Hunderter As Integer
    Dim Zehner As Integer
    Dim Einer As Integer
    Dim Seg_array(10) As Byte
    seg_array(1)= &B00110000
    seg_array(2) = &B01101101
    seg_array(3) = &B01111001
    seg_array(4) = &B00110011
    seg_array(5) = &B01011011
    seg_array(6) = &B01011111
    seg_array(7) = &B01110000
    seg_array(8) = &B01111111
    seg_array(9) = &B01111011
    seg_array(10) = &B01111110
    
    
    Config Timer0 = Timer , Prescale = 1024
    Enable Timer0
    Stop Timer0
    Timer0 = 0
    
    Config Porta.0 = Input
    Config Porta.1 = Input
    Config Portb = Output
    Config Portc = Output
    Config Portd = Output
    
    Do
    
    If Pina.0 = 1 Then Start Timer0
    If Pina.1 = 1 Then Stop Timer0
    
    
    Timer0 = Zeit
    
    Zeit / 1757 = Test                                          '357
    
    Test / 100 = Hunderter                                      '357/100=3,57=3
    (test / 10) -(hunderter * 10) = Zehner                      '357/10=35,7=35- 3*10)=5
    Test -(hunderter * 100) -(zehner * 10) = Einer
    
    
    
    If Hunderter = 1 Then Portd = Seg_array(1)
    If Hunderter = 2 Then Portd = Seg_array(2)
    If Hunderter = 3 Then Portd = Seg_array(3)
    If Hunderter = 4 Then Portd = Seg_array(4)
    If Hunderter = 5 Then Portd = Seg_array(5)
    If Hunderter = 6 Then Portd = Seg_array(6)
    If Hunderter = 7 Then Portd = Seg_array(7)
    If Hunderter = 8 Then Portd = Seg_array(8)
    If Hunderter = 9 Then Portd = Seg_array(9)
    If Hunderter = 0 Then Portd = Seg_array(10)
    If Zehner = 1 Then Portc = Seg_array(1)
    If Zehner = 2 Then Portc = Seg_array(2)
    If Zehner = 3 Then Portc = Seg_array(3)
    If Zehner = 4 Then Portc = Seg_array(4)
    If Zehner = 5 Then Portc = Seg_array(5)
    If Zehner = 6 Then Portc = Seg_array(6)
    If Zehner = 7 Then Portc = Seg_array(7)
    If Zehner = 8 Then Portc = Seg_array(8)
    If Zehner = 9 Then Portc = Seg_array(9)
    If Zehner = 0 Then Portc = Seg_array(10)
    If Einer = 1 Then Portb = Seg_array(1)
    If Einer = 2 Then Portb = Seg_array(2)
    If Einer = 3 Then Portb = Seg_array(3)
    If Einer = 4 Then Portb = Seg_array(4)
    If Einer = 5 Then Portb = Seg_array(5)
    If Einer = 6 Then Portb = Seg_array(6)
    If Einer = 7 Then Portb = Seg_array(7)
    If Einer = 8 Then Portb = Seg_array(8)
    If Einer = 9 Then Portb = Seg_array(9)
    If Einer = 0 Then Portb = Seg_array(10)
    End If
    Waitms 1000
    
    Loop
    
    End
    Probleme machen wir aber diese 4 Zeilen, die Bascom als Fehlerhaft ausweist und ich nicht weiß warum:
    Code:
    Zeit / 1757 = Test                                          '357
    
    Test / 100 = Hunderter                                      '357/100=3,57=3
    (test / 10) -(hunderter * 10) = Zehner                      '357/10=35,7=35- 3*10)=5
    Test -(hunderter * 100) -(zehner * 10) = Einer

  9. #9
    Erfahrener Benutzer Roboter Genie
    Registriert seit
    16.02.2006
    Beiträge
    1.113
    Zitat Zitat von mollyman
    Zeit / 1757 = Test '357

    Test / 100 = Hunderter '357/100=3,57=3
    (test / 10) -(hunderter * 10) = Zehner '357/10=35,7=35- 3*10)=5
    Test -(hunderter * 100) -(zehner * 10) = Einer
    Eine Zuweisung geht in Bascom immer anders herum:
    Ergebnis=operand1 operator operand2
    Es ist keine Schachtelung erlaubt. Also wäre das die richtige Berechnung:
    Hunderter = Test / 100 '357/100=3
    Zehner = Hunderter * 100 '3*100=300
    Zehner = Test - Zehner '357-300=57
    Einer = Zehner Mod 10 'Rest(57/10)=7
    Zehner = Zehner / 10 '57/10=5

    Zitat Zitat von mollyman
    If Hunderter = 1 Then Portd = Seg_array(1)
    If Hunderter = 2 Then Portd = Seg_array(2)
    If Hunderter = 3 Then Portd = Seg_array(3)
    If Hunderter = 4 Then Portd = Seg_array(4)
    If Hunderter = 5 Then Portd = Seg_array(5)
    If Hunderter = 6 Then Portd = Seg_array(6)
    If Hunderter = 7 Then Portd = Seg_array(7)
    If Hunderter = 8 Then Portd = Seg_array(8)
    If Hunderter = 9 Then Portd = Seg_array(9)
    If Hunderter = 0 Then Portd = Seg_array(10)
    Die brauchst du alle nicht mehr, sondern so:
    If Hunderter = 0 Then
    Portd = Seg_array(10)
    Else
    Portd = Seg_array(Hunderter)
    Endif

    Für die Zehner und Einer entsprechend.

    Gruß

    Rolf

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •  

Solar Speicher und Akkus Tests