Herkeze kolay gelsin.
Kod bu haliyle çalışıyor,lakin sensoründen okuduğum chksum la okunan değerlerin toplamı eşit olması gerekirken eşit olmuyor.Elimde odanın nemini ve ısısını ölçen çin malı bi cihaz var benim sensörden okuduğum değerlerle bu cihazdan okunan değerler hemen hemen aynı.Örneğin ben nemi 42.3 okurken diğer alette 43 gösteriyor.Derecelerde hemen hemen aynı.Şimdi chksum boşvermelimiyim boşvermemelimiyim.
İlgilenen arkadaşlara şimdiden teşekkürler.
'****************************************************************
'* Name : UNTITLED.BAS *
'* Author : Yuppi *
'* Notice : Copyright (c) 2013 KE LTD.Şti *
'* : All Rights Reserved *
'* Date : 08.12.2013 *
'* Version : 1.0 *
'* Notes : *
'* : *
'****************************************************************
Device = 18F4520
Config_Start
OSC = HS ;HS oscillator
FCMEN = OFF ;Fail-Safe Clock Monitor disabled
IESO = OFF ;Oscillator Switchover mode disabled
PWRT = OFF ;PWRT disabled
BOREN = SBORDIS ;Brown-out Reset enabled in hardware only (SBOREN is disabled)
BORV = 3 ;Minimum setting
WDT = On ;WDT enabled
WDTPS = 32768 ;1:32768
CCP2MX = PORTC ;CCP2 input/output is multiplexed with RC1
PBADEN = OFF ;PORTB<4:0> pins are configured as digital I/O on Reset
LPT1OSC = OFF ;Timer1 configured for higher power operation
MCLRE = OFF ;RE3 input pin enabled; MCLR disabled
STVREN = On ;Stack full/underflow will cause Reset
LVP = On ;Single-Supply ICSP enabled
XINST = OFF ;Instruction set extension and Indexed Addressing mode disabled (Legacy mode)
Debug = OFF ;Background debugger disabled, RB6 and RB7 configured as general purpose I/O pins
Cp0 = OFF ;Block 0 (000800-001FFFh) not code-protected
CP1 = OFF ;Block 1 (002000-003FFFh) not code-protected
CP2 = OFF ;Block 2 (004000-005FFFh) not code-protected
CP3 = OFF ;Block 3 (006000-007FFFh) not code-protected
CPB = OFF ;Boot block (000000-0007FFh) not code-protected
CPD = OFF ;Data EEPROM not code-protected
WRT0 = OFF ;Block 0 (000800-001FFFh) not write-protected
WRT1 = OFF ;Block 1 (002000-003FFFh) not write-protected
WRT2 = OFF ;Block 2 (004000-005FFFh) not write-protected
WRT3 = OFF ;Block 3 (006000-007FFFh) not write-protected
WRTC = OFF ;Configuration registers (300000-3000FFh) not write-protected
WRTB = OFF ;Boot block (000000-0007FFh) not write-protected
WRTD = OFF ;Data EEPROM not write-protected
EBTR0 = OFF ;Block 0 (000800-001FFFh) not protected from table reads executed in other blocks
EBTR1 = OFF ;Block 1 (002000-003FFFh) not protected from table reads executed in other blocks
EBTR2 = OFF ;Block 2 (004000-005FFFh) not protected from table reads executed in other blocks
EBTR3 = OFF ;Block 3 (006000-007FFFh) not protected from table reads executed in other blocks
EBTRB = OFF ;Boot block (000000-0007FFh) not protected from table reads executed in other blocks
Config_End
;**** End of Fuse Configurator Settings ****
;-------------------------------------------------------------------------------
Declare Xtal= 20
ADCON0=$01
ADCON1=%00001110
Declare LCD_DTPort = PORTD 'GLCD DATA PORTLARI PORTD'YE BAĞLI
Declare LCD_ENPin = PORTC.3 'GLCD ENABLE PİNİ PORTC.1 BAĞLI
Declare LCD_RWPin = PORTC.7 'GLCD RW PİNİ PORTC.4 BAĞLI
Declare LCD_RSPin = PORTC.6 'GLCD RS PİNİ PORTC.5 BAĞLI
Declare LCD_CS2Pin = PORTC.4 'GLCD CS1 PİNİ PORTC.2 BAĞLI
Declare LCD_CS1Pin = PORTC.5 'GLCD CS2 PİNİ PORTC.3 BAĞLI
Declare LCD_Type = GRAPHIC 'GLCD TİPİ GRAFİK KS0108 128*64B WİNSTAR
Declare Internal_Font = On
Declare Font_Addr = 0
'Declare FLOAT_DISPLAY_TYPE = LARGE
' Declare GLCD_CS_Invert On
Declare GLCD_STROBE_DELAY 10
' Declare GLCD_EXTERNAL_PRINT = PPRINT
Symbol DHT11 = PORTC.2
Dim nem As Float
Dim nem1 As Word
Dim temp As Float
Dim temp1 As Word
Dim kontrol As Byte
Dim ham[5] As Byte
Dim ChkSum As Word
Dim Index As Byte
Dim SenData As Dword
Dim Toplam As Word
Dim gec As Byte
Cls
DelayMS 1000
main:
While
DelayMS 5000
SenData=0:ChkSum=0
Output DHT11
DHT11 = 0
DelayMS 18
DHT11 = 1
DelayUS 20
DHT11=0
Input DHT11
kontrol =PulsIn DHT11,1
If kontrol < 40 Then
Cls
Print At 0,1,"Sensor yok :",Dec kontrol
EndIf
For Index = 31 To 0 Step -1
kontrol = PulsIn DHT11,1 'Sensorden gelen puls okuma RH+DT
If kontrol > 20 Then SetBit SenData,Index
Next Index
For Index = 7 To 0 Step -1
kontrol = PulsIn DHT11,1 'Sensorden gelen puls okuma ChkSum
If kontrol > 20 Then SetBit ChkSum,Index
Next Index
Toplam = (SenData.Byte3)+(SenData.Byte2)+(SenData.Byte1)+(SenData.Byte0)
For gec =1 To 8
nem1=SenData.Byte3 << gec
Next
nem1 =nem1+(SenData.Byte2)
nem =nem1/10
gec=0
For gec=1 To 8
temp1 =SenData.Byte1 << gec
Next
temp1=temp1+(SenData.Byte0)
temp=temp1/10
'if chksum<>toplam then start
Print At 0,1,"Check Sum = ",Dec ChkSum
Print At 1,1,"H:",Dec1 nem," %"
Print At 1,10,"T:",Dec1 temp,"C"
Print At 2,1,"Toplam:",Dec Toplam
Print At 3,1,"HAM:",Hex8 SenData
Print At 4,1,"HAM T:",Hex SenData.Byte1,"",Hex SenData.Byte0
Print At 5,1,"HAM N:",Hex SenData.Byte3,"",Hex SenData.Byte2
Print At 6,1,"nem1:",Hex4 nem1
Print At 7,1,"Temp1:",Hex4 temp1
Wend
End
Include "font.inc"
Ben de şu anda nem sensörü ile uğraşıyorum. Dediğiniz gibi parity koduyla karşılaştırma tutmuyor ama gösterdiği değerler gerçek değerlere çok yakın.