Device 16F877A
Xtal 4
'*********LCD Tanımlamaları***********
LCD_DTPin = PORTD.4
LCD_RSPin = PORTD.0
LCD_ENPin = PORTD.1
LCD_Interface = 4 ' 4-bit Interface
LCD_Lines = 2
LCD_Type = 0
LCD_CommandUs = 2000
LCD_DataUs = 50
All_Digital TRUE
Symbol RBIF = INTCON.0 ' RB Port Interrupt Flag
Symbol INTF = INTCON.1 ' RB0 External Interrupt Flag
Symbol T0IF = INTCON.2 ' TMR0 Overflow Interrupt Flag
Symbol RBIE = INTCON.3 ' RB Port Change Interrupt Enable
Symbol INTE = INTCON.4 ' RB0 External Interrupt Enable
Symbol T0IE = INTCON.5 ' TMR0 Overflow Interrupt Enable
Symbol PEIE = INTCON.6 ' Peripheral Interrupt Enable
Symbol GIE = INTCON.7 ' Global Interrupt Enable
INTE = 1
GIE = 1
Input PORTB
Output PORTC
PORTD=0:TRISD=%00000000
PORTE=0:TRISE=%00000000
'Include "MODEDEFS.BAS"
On Interrupt GoTo KESME
ADCON1=7
OPTION_REG.7=1
'-----------------------------B A Ş L A N G I Ç ---------------------------
Clear
GoSub RE_SET
GoSub T_START
;--------------------TANIMLAMALAR--------------------;
Dim HAM As Word
Dim RHlin As Float
Dim RHlin2 As Float
Dim c1 As Float
Dim c2 As Float
Dim c3 As Float
Dim RHtrue As Float
Dim T As Float
Dim t1 As Float
Dim t2 As Float
Dim d1 As Float
Dim d2 As Float
Dim KONTROL As Byte
Dim H0 As HAM.LowByte
Dim H1 As HAM.HighByte
Dim HATA As Bit
Dim W As Word
Dim DURUM As Byte
Dim isi_deger As Float
Dim nem_deger As Byte
Symbol CLK=PORTE.0
Symbol DTA=PORTE.1
Symbol arti=PORTB.1
Symbol eksi=PORTB.2
All_Digital true
;--------------------DEGERLER------------------;
c1 = -2.0468 ;data sheetlerde farklılık gösterebiliyor
c2 = 0.0367 ;data sheetlerde farklılık gösterebiliyor
c3 = -0.0000015955 ;data sheetlerde farklılık gösterebiliyor
t1 = 0.01
t2 = 0.00008
d1 = -40.1 ;data sheetlerde farklılık gösterebiliyor
d2 = 0.01
BASLA:
If DURUM = 0 Then GoTo OLCUM
If DURUM = 1 Then GoTo MENU
If DURUM = 2 Then GoTo ISI_AYAR
If DURUM = 3 Then GoTo NEM_AYAR
OLCUM:
KONTROL=%00000011
HAM=0 'SICAKLIK ÖLÇME'
GoSub OLCUM_AL
GoSub ISI_HESAP
GoSub EKRAN1
If isi_deger > T Then High PORTC.2
DelayMS 250
KONTROL=%00000101
HAM=0 'RUTUBET ÖLÇME'
GoSub OLCUM_AL
GoSub RUTUBET_HESAP:GoSub EKRAN2
If nem_deger > RHtrue Then High PORTC.1
DelayMS 300
KONTROL=%00011110
GoTo BASLA
'=======================EKRANA YAZDIRMA==================='
EKRAN1:
Print At 1,1, " ISI : ",Dec2 T," C ":Return
EKRAN2:
Print At 2,1, " NEM : ",Dec2 RHtrue," % "
Return
T_START:
Output DTA:Output CLK
High DTA
Low CLK
DelayMS 1
High CLK
Low DTA
DelayMS 1
Low CLK
DelayMS 1
High CLK
DelayMS 1
High DTA
Low CLK
Return
'-----------------------------R E S E T -----------------------------------------------------------
RE_SET:
Output DTA
Output CLK'
High DTA
For W=0 To 9
High CLK
DelayMS 1
Low CLK
Next W
Return
OLCUM_AL:
GoSub T_START
SHOut DTA,CLK,1,[KONTROL]
Input DTA
PulsOut CLK,10
HATA=0
For W=0 To 65500
If DTA=0 Then CIK
Next W
HATA = 1
CIK:
If HATA=1 Then
GoSub SENSORYOK
EndIf
SHIn DTA,CLK,0,[H1]
Output DTA
Low DTA
PulsOut CLK,10
Input DTA
SHIn DTA,CLK,0,[H0]
PulsOut CLK,10
Return
RUTUBET_HESAP:
RHlin = c1 + c2 * HAM
RHlin2 = c3 * HAM * HAM
RHlin = RHlin + RHlin2
RHtrue = ( t1 + t2 * HAM)
RHtrue = RHtrue * ( T - 25)
RHtrue = RHtrue + RHlin
Return
ISI_HESAP:
T = d1 + d2 * HAM
Return
MENU:
Print At 2,1," MENU "
DelayMS 100
GoTo BASLA
ISI_AYAR:
If arti = 1 Then isi_deger = isi_deger + 0.1
If eksi = 1 Then isi_deger = isi_deger - 0.1
Print At 1,1," ISI AYAR "
Print At 2,1," ",Dec1 isi_deger," C "
DelayMS 100
GoTo BASLA
NEM_AYAR:
If arti = 1 Then Inc nem_deger
If eksi = 1 Then Dec nem_deger
Print At 1,1," NEM AYAR "
Print At 2,1," ",Dec nem_deger," % "
DelayMS 100
GoTo BASLA
'----------------------------------------------------------------------------------
SENSORYOK:
Print At 1,1," SENSOR YOK "
Print At 2,1," LUTFEN TAKINIZ "
DelayMS 1500
Return
Disable
KESME:
Inc DURUM
If DURUM = 4 Then DURUM = 0
INTF = 0
Resume
Enable
End