'----------------------------------------------------------------------------------------- 'Titel : Betriebsstundenzähler 'Name : Betriebsstundenzähler.bas 'Autor : Arno Schweißinger 'Datum : 13.01.2008 'Version : 0.02 '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 '----------------------------------------------------------------------------------------- $regfile = "m8def.dat" $crystal = 1000000 Powerpin Alias Pinb.0 Ledpin Alias Portb.1 Resetpin Alias Pinb.2 Config Resetpin = Input ' Reset clock Config Pinb.1 = Output ' Blink LED Config Powerpin = Input ' Power down 'configure LCD-Display Config Lcd = 24 * 2 Config Lcdpin = Pin , Db4 = Portc.0 , Db5 = Portc.1 , Db6 = Portc.2 , Db7 = Portc.3 , E = Portc.5 , Rs = Portc.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 Checkpower Declare Sub Ledblinklicht Declare Sub Outlcd Declare Sub Datenloeschen Const _version = "0.02" Const Starttime = "00:00:00" Const Startdate = "01.01.00" Dim E_time As Eram String * 8 Dim E_date As Eram String * 8 Dim Temp As Byte Dim Old_sec As Byte Dim Sec_poc As Integer '------------------------- ' Hauptprogramm '------------------------- 'Begin Call Init_prog Call Datenkonsistent Cls Do Call Checkpower Call Datenloeschen If _sec <> Old_sec Then Call Ledblinklicht Call Outlcd Old_sec = _sec End If Loop End ' ende Hauptprogramm Sub Init_prog Initlcd Cls Cursor Off Lcd "Arno Schweissinger" Locate 2 , 1 Lcd "BeStuZae Vers " ; _version Waitms 500 Time$ = E_time Date$ = E_date ' Push reset button on Pinb.2 End Sub Sub Checkpower If Powerpin = 0 Then E_time = Time$ E_date = Date$ Locate 2 , 1 Lcd "power off" Idle End If End Sub Sub Outlcd Locate 1 , 1 Lcd Sysday() ; "-Tage" Locate 1 , 13 Lcd Time$ End Sub Sub Ledblinklicht ' kurzer Impuls Reset Ledpin Waitms 5 Set 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 Outlcd Locate 2 , 1 Lcd "Daten inkonsistent" Do Toggle Ledpin Waitms 100 Call Datenloeschen Loop End Sub