توضيحات برنامه رو شب مي دم . ( الان بايد برم مدرسه )
بعد خود برنامه اصلي رو گذاشتم . فايل V&I.BAS برنامه فوق تحت بسكام مي باشد . ( من هيچ وقت فقط فايل هكز رو نمي ذارم و حتما برنامه رو هم مي ذارم )
کد:
$regfile = "M8DEF.dat" : $crystal = 2000000
Config Lcdpin = Pin , Db4 = Pinb.3 , Db5 = Pinb.2 , Db6 = Pinb.1 , Db7 = Pinb.0 , E = Pinb.4 , Rs = Pinb.5
Config Lcd = 16 * 2 : Cursor Off : Cls
Config Portd = &B11111000
Config Adc = Single , Prescaler = Auto , Reference = Internal
Deflcdchar 0 , 24 , 24 , 32 , 7 , 4 , 4 , 4 , 7 '.C
'-------------------------------------------------------------------------------
Dim Cc As Byte , Mm As Byte , Ss As Byte , B As Byte , F As Byte , T As Word , Tt As Byte
Dim Ecc As Eram Byte At 5 , Emm As Eram Byte At 10 , Ft As Byte , W As Word , S As Single
Dim A As Single , I As String * 8 , V As String * 8 , Fv As Byte
'-------------------------------------------------------------------------------
Cc = Ecc : Mm = Emm : Tt = 150
If Cc > 23 Then Cc = 10
If Mm > 59 Then Mm = 00
Gosub Showcc : Gosub Showmm : Gosub Showss
'-------------------------------------------------------------------------------
Config Timer2 = Timer , Prescale = 32 , Async = On
Enable Interrupts : Enable Timer2
On Timer2 Sectic
Start Timer2
'-------------------------------------------------------------------------------
'-------------------------------------------------------------------------------
Star:
F = 0 : Ft = 0
Do
Debounce Pind.0 , 1 , Ant
Loop
'-------------------------------------------------------------------------------
Ant:
For T = 0 To 1200
If Pind.0 = 0 Then Goto Star
Waitms 1
Next
Goto Cc
'------------------------------------------------------------------------------- DESIGN BY A.N.T
'-------------------------------------------------------------------------------
Sectic:
Incr B
Select Case B
Case 1:
Start Adc : W = Getadc(1) : Stop Adc
If W > 800 Then : Fv = 1 : Set Portd.6 : Reset Portd.7
Else : S = W / 400 : S = S + 0.003 : V = Fusing(s , "#.###")
End If
Gosub Offlcd
Case 2:
Ss = Ss + 1 : Toggle Portd.3
If Ss > 59 Then : Ss = 0 : Mm = Mm + 1 : Emm = Mm
End If
If Mm > 59 Then : Mm = 0 : Cc = Cc + 1 : Emm = Mm : Ecc = Cc
End If
If Cc > 23 Then : Cc = 0 : Ecc = Cc
End If
Gosub Onlcd
If Fv = 1 Then :
Start Adc : W = Getadc(1) : Stop Adc
If W > 800 Then : Fv = 1 : Reset Portd.6 : Set Portd.7
Else : S = W / 40 : S = S + 0.03 : Fv = 0 : V = Fusing(s , "##.##")
End If
End If
Case 3:
Gosub Offlcd
Start Adc : W = Getadc(0) : Stop Adc : W = W / 2 : A = W / 2
If Fv = 1 Then :
Start Adc : W = Getadc(1) : Stop Adc
S = W / 4 : Fv = 0 : V = Fusing(s , "###.#")
End If
Case 4:
Start Adc : W = Getadc(2) : Stop Adc : S = W / 200 : I = Fusing(s , "#.###")
B = 0 : Gosub Onlcd : Toggle Portd.3 : Reset Portd.6 : Reset Portd.7 : Fv = 0
End Select
Locate 2 , 22
Return
'------------------------------------------------------------------------------- DESIGN BY A.N.T
'-------------------------------------------------------------------------------
Cc:
F = 2 : Ft = 0
Do
Debounce Pind.0 , 1 , Mm
Debounce Pind.1 , 1 , Cc1
Debounce Pind.2 , 1 , Cc2
Loop
'-------------------------------------------------------------------------------
Cc1:
Incr Cc : If Cc > 23 Then Cc = 0
Gosub Showcc
For T = 0 To Tt
If Pind.1 = 0 Then Goto Cc
Waitms 4
Next
Ft = 1
Do
Gosub Showcc
For T = 0 To Tt
If Pind.1 = 0 Then Goto Cc
Waitms 1
Next
Incr Cc : If Cc > 23 Then Cc = 0
Gosub Showcc
Loop
'-------------------------------------------------------------------------------
Cc2:
Decr Cc : If Cc > 23 Then Cc = 23
Gosub Showcc
For T = 0 To Tt
If Pind.2 = 0 Then Goto Cc
Waitms 4
Next
Ft = 1
Do
Gosub Showcc
For T = 0 To Tt
If Pind.2 = 0 Then Goto Cc
Waitms 1
Next
Decr Cc : If Cc > 23 Then Cc = 23
Gosub Showcc
Loop
'------------------------------------------------------------------------------- DESIGN BY A.N.T
'-------------------------------------------------------------------------------
Mm:
F = 3 : Ecc = Cc : Ft = 0 : Gosub Showcc
Do
Debounce Pind.0 , 1 , Ss
Debounce Pind.1 , 1 , Mm1
Debounce Pind.2 , 1 , Mm2
Loop
'-------------------------------------------------------------------------------
Mm1:
Incr Mm : If Mm > 59 Then Mm = 0
Gosub Showmm
For T = 0 To Tt
If Pind.1 = 0 Then Goto Mm
Waitms 4
Next
Ft = 1
Do
Gosub Showmm
For T = 0 To Tt
If Pind.1 = 0 Then Goto Mm
Waitms 1
Next
Incr Mm : If Mm > 59 Then Mm = 0
Gosub Showmm
Loop
'-------------------------------------------------------------------------------
Mm2:
Decr Mm : If Mm > 59 Then Mm = 59
Gosub Showmm
For T = 0 To Tt
If Pind.2 = 0 Then Goto Mm
Waitms 4
Next
Ft = 1
Do
Gosub Showmm
For T = 0 To Tt
If Pind.2 = 0 Then Goto Mm
Waitms 1
Next
Decr Mm : If Mm > 59 Then Mm = 59
Gosub Showmm
Loop
'-------------------------------------------------------------------------------
Ss:
Ft = 0 : F = 4 : Emm = Mm : Gosub Showmm : Gosub Showss
Do
Debounce Pind.0 , 1 , Star
Debounce Pind.1 , 1 , Ss1
Debounce Pind.2 , 1 , Ss2
Loop
'-------------------------------------------------------------------------------
Ss1:
Timer2 = 0 : B = 0
If Ss > 29 Then : Mm = Mm + 1
End If
If Mm = 60 Then : Mm = 0 : Incr Cc
End If
If Cc = 24 Then Cc = 0
Ss = 0 : Goto Ss
'-------------------------------------------------------------------------------
Ss2:
Timer2 = 0 : Ss = 0 : B = 0 : Goto Ss
'-------------------------------------------------------------------------------
'-------------------------------------------------------------------------------
Onlcd:
Gosub Showcc : Gosub Showmm : Gosub Showss : Gosub Showa : Gosub Showi
Return
'-------------------------------------------------------------------------------
Offlcd:
If Ft = 1 Then Return
If F = 0 Then : Return
Else :
If F = 2 Then : Home : Lcd " "
Elseif F = 3 Then : Locate 1 , 4 : Lcd " "
Else :
If F = 4 Then : Locate 1 , 7 : Lcd " "
End If
End If
End If
Return
'------------------------------------------------------------------------------- DESIGN BY A.N.T
'-------------------------------------------------------------------------------
Showa:
Locate 1 , 12
If A < 10 Then : Lcd " " ; A ; Chr(0) ; " "
Else : Lcd A ; Chr(0) ; " "
End If
Return
'-------------------------------------------------------------------------------
Showcc:
Home
If Cc < 10 Then : Lcd " " ; Cc
Else : Lcd Cc
End If
Lcd ":"
Return
'-------------------------------------------------------------------------------
Showmm:
Locate 1 , 4
If Mm < 10 Then : Lcd "0" ; Mm
Else : Lcd Mm
End If
Lcd ":"
Return
'-------------------------------------------------------------------------------
Showss:
Locate 1 , 7
If Ss < 10 Then : Lcd "0" ; Ss
Else : Lcd Ss
End If
Lcd " "
Return
'------------------------------------------------------------------------------- DESIGN BY A.N.T
Showi:
Home L : Lcd V ; "v "
Locate 2 , 10 : Lcd I ; " A "
Return