RSS

Intelligent pedometer v1.00

20 Jun

‘——————————————————————————–
‘Designer                 : Abhishek kumar
‘name                     : iped.bas
‘copyright                : (c) 1995-2005, MCS Electronics
‘purpose                  : Intelligent Pedometer
‘micro                    : ATMEGA16
‘suited for demo          : yes
‘commercial addon needed  : no
‘use in simulator         : possible
‘eeprom memory usage      : yes
‘——————————————————————————–
‘******************************************************************
$regfile = “m16def.dat”
$crystal = 8000000
‘$sim
‘********************* 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
‘********************* Port configuration *************************
Config Pind.7 = Input
Config Pind.6 = Input
Config Pind.5 = Input
Config Pind.4 = Input
Config Pind.0 = Input

Config Pinc.0 = Output
‘******************EEPROM INITIALISING ****************************
$eepromhex
$eeprom
Steplengthdefault:
Data 57%
$data
‘******************* Declaring Sub-Routines ***********************
Declare Sub Setlength
‘******************* Variable Declaration *************************
Dim Steplength As Byte
Dim A As Single
Dim Tim As Single
Dim Cnt As Integer , Dis As Single , Vel As Single , Cal As Single
Cnt = 0
Cal = 0
Vel = 0
Dis = 0
Tim = 0
‘******************* Welcome Screen *******************************
Cls
Lcd “Digi Pedometer”
Lowerline
Lcd “===>I-Sense<==”
Wait 1
Cls
‘****************Read EEPROM Step Value ***************************
Readeeprom Steplength , Steplengthdefault
A = Steplength / 100
‘**************** Interrupts Start and Configure ******************
Config Int0 = Low Level
Enable Interrupts
Enable Int0
On Int0 Ped
‘******************************************************************
Do

Reset Portc.0
Set Portd.6
Set Portd.5
Set Portd.4
Set Portd.7
Set Portd.0

Gosub Everlcd
‘@@@@@@@@ To set step length@@@@@@@@@@
If Pind.0 = 0 Then
   Call Setlength
End If
‘@@@@@@@@@@  to view distance @@@@@@@@
If Pind.6 = 0 Then
Cls
Lcd “Distance:”
Lowerline
Lcd Dis ; ” m”
Wait 1
End If
‘@@@@@@@@@ to view calorie burned @@@@
If Pind.4 = 0 Then
Cls
Lcd “Calorie Burn:”
Lowerline
Lcd Cal
Wait 1
End If
Loop
End
‘******************************************************************
‘############### Inturrupt routine(INT0) #########################
Ped:
Start Timer1
Cnt = Cnt + 1
Dis = Dis + A
Cal = Cal + 0.0485

Gosub Everlcd
Set Portc.0

Waitms 150
Return
‘################# Sel Length Sub ################################
Sub Setlength

Set Portd.7
Set Portd.0
Readeeprom Steplength , Steplengthdefault
Cls
Lcd “Def Step Length:”
Lowerline
Lcd Steplength ; “cm”
Wait 1

Do
     Set Portd.0
     Set Portd.7
     If Pind.7 = 0 Then
          Steplength = Steplength + 1
          Cls
          Lcd “Chanege Value:”
          Lowerline
          Lcd Steplength ; “cm”
          Waitms 70
     End If
     If Pind.0 = 0 Then
     Writeeeprom Steplength , Steplengthdefault
     Waitms 500
     Exit Do
     End If
Loop

End Sub
‘############### Routine Everlcd #################################
Everlcd:

Cls
Lcd “Steps:”
Lowerline
Lcd Cnt
Waitms 34
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: