'----------------------------------------------------------------------------------------- 'Titel : Betriebsstundenzähler 'Name : Betriebsstundenzähler.bas 'Autor : Arno Schweißinger 'Datum : 13.01.2008 'Version : 0.03 'Compiler : Bascom 1.11.8.7 'MicroController : AtMega8 1MHz interner Takt 'Hardware : Display HD 44780-kompatibel, 20x2 Zeichen ' ' Quarz 32768Hz an TOSC1/2 - Pin 9/10 'Stromversorgung: : 4V bis 6V , 5mA 'Besonderes : 'Letzte Änderung : 10.01.08 LED Betriebsanzeige binkt 5ms ' 09.01.08 EEPROM Daten werden auf plausibilität geprüft ' 18.01.08 LCD Animation '----------------------------------------------------------------------------------------- $regfile = "m8def.dat" $crystal = 1000000 Powerpin Alias Pinc.0 Ledpin Alias Portc.1 Resetpin Alias Pinc.2 Config Resetpin = Input ' Reset clock Config Pinc.1 = Output ' Blink LED Config Powerpin = Input ' Power down 'configure LCD-Display Config Lcd = 24 * 2 Config Lcdpin = Pin , Db4 = Portb.0 , Db5 = Portb.1 , Db6 = Portb.2 , Db7 = Portb.3 , E = Portb.5 , Rs = Portb.4 'configure clock Config Date = Dmy , Separator = . ' ANSI-Format Config Clock = Soft 'this is how simple it is Enable Interrupts Declare Sub Init_prog Declare Sub Datenkonsistent Declare Sub Error Declare Sub Savetime Declare Sub Ledblinklicht Declare Sub Lcdouttime Declare Sub Datenloeschen Declare Sub Animation Const _version = "0.04" Const Starttime = "00:00:00" Const Startdate = "01.01.00" Const Sec_zeichen = "->" Dim E_time As Eram String * 8 Dim E_date As Eram String * 8 'Dim Temp As Byte Dim B_poscusor As Byte Dim Old_sec As Byte '------------------------- ' Hauptprogramm '------------------------- 'Begin Call Init_prog Call Datenkonsistent Cls Do Waitms 200 Call Datenloeschen If _sec <> Old_sec Then Call Lcdouttime Toggle Ledpin Call Savetime Call Animation Old_sec = _sec End If Loop End ' ende Hauptprogramm Sub Init_prog Initlcd Cls Cursor Off Lcd "Arno Schweissinger" Locate 2 , 1 Lcd "Version: " ; _version Waitms 500 Time$ = E_time Date$ = E_date ' Push reset button on Pinb.2 End Sub Sub Savetime If _sec = 0 Then E_time = Time$ E_date = Date$ Locate 2 , 1 Lcd "Time saved" Waitms 200 End If End Sub Sub Lcdouttime Locate 1 , 1 Lcd Sysday() ; "-Tage" Locate 1 , 13 Lcd Time$ End Sub Sub Ledblinklicht Toggle Ledpin End Sub Sub Datenloeschen If Resetpin = 1 Then Cls Time$ = Starttime Date$ = Startdate E_time = Starttime E_date = Startdate Lcd "Daten sind geloescht" Waitms 500 $asm jmp 0000 ' cpu reset $end Asm End If End Sub Sub Datenkonsistent If _hour > 23 Then Call Error If _min > 59 Then Call Error If _sec > 59 Then Call Error If _day > 31 Then Call Error If _month > 12 Then Call Error End Sub Sub Error Cls Call Lcdouttime Locate 2 , 1 Lcd "Daten inkonsistent" Do Toggle Ledpin Waitms 100 Call Datenloeschen Loop End Sub Sub Animation B_poscusor = _sec Mod 20 If B_poscusor = 0 Then Locate 2 , 1 Lcd " " ' 21 x Space End If Locate 2 , B_poscusor Lcd Sec_zeichen End Sub