۰۳-شهریور-۱۳۹۰, ۱۳:۴۹:۵۴
باسلام
من در مورد برنامه زیر مشکل داشتم
در پروتئوس مدام پرش می کند بطوری که اصلا صفحه نمایش خوانده نمی شود
لطفا کمکم کنید
باتشکر
من در مورد برنامه زیر مشکل داشتم
در پروتئوس مدام پرش می کند بطوری که اصلا صفحه نمایش خوانده نمی شود
لطفا کمکم کنید
باتشکر
کد:
$regfile = "M16def.dat"
$crystal = 1000000
Config Portd = Output
Config Pinb.2 = Input
Config Pinb.3 = Input
Config Pinb.4 = Input
Config Pinb.5 = Input
Config Lcdpin = Pin , Db4 = Portc.2 , Db5 = Portc.3 , Db6 = Portc.4 , Db7 = Portc.5 , E = Portc.1 , Rs = Portc.0
Config Lcd = 20 * 4
Config Adc = Single , Prescaler = Auto , Reference = Internal
Config Portd = Output
Config Portb = Input
Config Debounce = 50
Start Adc
Seting Alias Pinb.2 : Up Alias Pinb.3 : Down Alias Pinb.4 : Menu Alias Pinb.5
Dim T0 As Word , T1 As Word , Temp As Word
Dim A As Byte , B As Word , C As Byte , D As Byte , E As Byte , F As Single
Dim O As Byte , Of As Byte , M As Byte , S As Byte , , Cx As Byte
Dim X As Word , Y As Word , Z As Word , Ch As Single , Tc As Single , Tr As Single
Dim W As Word , U As Single , J As Single , L As Single , H As Single , Q As Single,
Dim V As Single , R As Single , Pv As Single , Pc As Single , N As Single
Declare Sub Tempsens
Declare Sub Key
Declare Sub Llcd
Cursor Off
Do
Call Key
Call Tempsens
Call Llcd
Loop
End
'===============================================================================
Sub Key
If M <> 0 Then
If Seting = 0 Then
Incr S
Waitms 200
If S > 3 Then S = 0
End If
If S = 1 Then
Locate 2 , 4
Cursor Off Noblink
Waitms 10
Cursor On Blink
Waitms 10
Cursor Off Noblink
Waitms 10
Cursor On Blink
Waitms 10
Cursor Off Noblink
End If
If S = 2 Then
Locate 3 , 3
Cursor Off Noblink
Waitms 10
Cursor On Blink
Waitms 10
Cursor Off Noblink
Waitms 10
Cursor On Blink
Waitms 10
Cursor Off Noblink
End If
If S = 3 Then
Locate 4 , 4
Cursor Off Noblink
Waitms 10
Cursor On Blink
Waitms 10
Cursor Off Noblink
Waitms 10
Cursor On Blink
Waitms 10
Cursor Off Noblink
End If
End If
If Menu = 0 Then
Incr M
Cls
Waitms 1000
If M > 1 Then M = 0
Cls
O = C
Of = D
Cx = E
S = 0
End If
If Up = 0 Then
If S = 1 Then
Incr O
Waitms 50
If M = 1 Then C = O
End If
If S = 2 Then
Incr Of
Waitms 50
If M = 1 Then D = Of
End If
If S = 3 Then
Incr Cx
Waitms 50
If M = 1 Then E = Cx
End If
End If
If Down = 0 Then
If S = 1 Then
Decr O
Waitms 150
If M = 1 Then C = O
End If
If S = 2 Then
Decr Of
Waitms 150
If M = 1 Then D = Of
End If
If S = 3 Then
Decr Cx
Waitms 150
If M = 1 Then E = Cx
End If
End If
End Sub
'===============================================================================
Sub Tempsens
X = Getadc(0)
Y = Getadc(1)
Temp = X - Y
Temp = Temp / 4
Ch = Temp * 1.8
Ch = Ch + 502
Tc = T1 + 470
Tr = Ch / Tc
Z = Getadc(2)
Z = Z / 3
U = Tr ^ 6
U = 0.16934 * U
F = Log(tr)
F = 1.28862 * F
J = 1 / Tr
J = 6.09648 * J
H = 5.92714 - J
H = H - F
H = H + Y
L = Tr ^ 6
L = 0.4357 * L
Q = Log(tr)
Q = 13.4721 * Q
V = 1 / Tr
V = 15.6875 * V
N = 15.2518 - V
N = N - Q
N = N + L
R = W * N
R = R + H
R = Exp(r)
Pv = Pc * R
Pv = A
Waitms 1000
End Sub
'===============================================================================
Sub Llcd
If M = 0 Then
Locate 2 , 1
Lcd "Temp=" ; Temp ; Chr(0) ; "c"
Locate 3 , 1
Lcd "pv=" ; A ; "psia"
Locate 4 , 1
Lcd "p=" ; Z ; "psia"
End If
If M = 1 Then
Locate 2 , 1
Lcd "pc=" ; C ; " " ; "psia"
Locate 3 , 1
Lcd "w=" ; D ; " "
Locate 4 , 1
Lcd "T1=" ; E ; " "
End If
End Sub