'-----------------------------------------------------------------------------------------
'-----------------------------------------------------------------------------------------
'Titel : Betriebsstundenzähler
'Name : Betriebsstundenzähler.bas
'Autor : Arno Schweißinger
'Datum : 08.01.2008
'MicroController : AtMega8 1MHz intern
'Hardware : Display HD 44780-kompatibel,
' Quarz 32768Hz an TOSC1/2 - Pin 9/10
'Stromversorgung: : 5V für Logik,
'Besonderes :
'
'
'
'-----------------------------------------------------------------------------------------
$regfile = "m8def.dat"
$crystal = 1000000
Config Pinb.2 = Input ' Reset clock
Config Pinb.1 = Output ' Blink LED
Config Pinb.0 = 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 Checkpower
Declare Sub Ledblinklicht
Declare Sub Init_prog
Declare Sub Outlcd
Declare Sub Datenloeschen
Const _version = "0.01"
Const Starttime = "00:00:00"
Const Startdate = "01.01.00"
Const Zeilenende = 24
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
Powerpin Alias Pinb.0
ledpin Alias Pinb.1
Resetpin Alias Pinb.2
'-------------------------
' Hauptprogramm
'-------------------------
'Begin
Call Init_prog
Cls
Do
Call Checkpower
If Resetpin = 1 Then 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 "Version: " ; _version
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
Toggle Ledpin
End Sub
Sub Datenloeschen
Cls
Time$ = Starttime
Date$ = Startdate
Lcd "Daten sind geloescht"
Waitms 500
Cls
End Sub
|