RSS

Programmable Timers for Fridges,Coolers,AC,etc

20 Jun

‘——————————————————————————-
‘Designer                 : Abhishek kumar
‘name                     : prog_timer.bas
‘copyright                : (c) 1995-2005, MCS Electronics
‘purpose                  : Programmable Timer for Refrigerators,AC,Coolers,etc
‘micro                    : ATMEGA16
‘suited for demo          : yes
‘commercial addon needed  : no
‘use in simulator         : possible
‘eeprom memory usage      : yes
‘——————————————————————————-
‘*******************************************************************************
$regfile = “m16def.dat”
$crystal = 8000000
‘$sim
‘************************Port Configure*****************************************
Config Pind.7 = Input                                       ‘SET TIME / OK
Config Pind.6 = Input                                       ‘Up (+)
Config Pind.5 = Input                                       ‘Down (-)
Config Pinc.0 = Output                                      ‘Relay / Load
‘********************* LCD Configuration ***************************************
Config Lcd = 16 * 2
Config Lcdbus = 4
Config Lcdmode = Port
Config Lcdpin = Pin , Db4 = Portb.0 , Db5 = Portb.1 , Db6 = Portb.2 , Db7 = Portb.3 , E = Portc.5 , Rs = Portc.4
‘******************EEPROM INITIALISING *****************************************
$eepromhex
$eeprom
Defaulttime:
Data 60%
$data
‘*******************************************************************************
Dim S As Integer
S = 0
Dim Timest As Integer
Dim Count As Byte
Count = 0
‘**************************Timer Config and initialisations*********************
Config Timer1 = Timer , Prescale = 1
Start Timer1
Enable Interrupts
Enable Ovf1

On Ovf1 Abhishek
‘************************Welcome Note*******************************************
Startupd:
S = 0
Count = 0
Readeeprom Timest , Defaulttime

Cls
Lcd “Programmable”
Lowerline
Lcd ”     Timer !!!”
Wait 1
‘———————————–
Cls
Lcd “Default Time for”
Lowerline
Lcd “startup==>” ; Timest
Wait 1
‘***************************Main Loop*******************************************
Do
Set Portd.7
Set Portd.6
Set Portd.5

If S = Timest Then
          Set Portc.0
          Stop Timer1
End If

If Pind.7 = 0 Then

            Do
            Waitms 100

            Set Portd.6
            Set Portd.7
            Set Portd.5

            Cls
            Lcd “Set New Time for”
            Lowerline
            Lcd “startup=>” ; Timest

            If Pind.6 = 0 Then                              ‘time increment for setting
               Timest = Timest + 1
            End If

            If Pind.5 = 0 Then                              ‘time decrement for setting
               Timest = Timest – 1
            End If

            If Timest < 1 Or Timest > 1000 Then
             Timest = 1
            End If
            If Pind.7 = 0 Then
              Reset Portc.0
              Writeeeprom Timest , Defaulttime              ‘write eeprom new time value
              Goto Startupd
              Exit Do
            End If
            Loop

End If

Loop
End
‘****************************Timer ISR******************************************
Abhishek:
Count = Count + 1
If Count = 122 Then

            S = S + 1

End If
Return
‘*******************************************************************************

Advertisements
 
Leave a comment

Posted by on June 20, 2010 in AVR

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: