glcd ile bir proje

Başlatan AKP, 27 Haziran 2009, 23:50:40

AKP

valla arkadaşlar bu projeyi bu kadar yapabildim kapasitem yetmedi. benden bu kadar :o

geliştirmek isteyenler buyursun :? Valla yapanlar paylaşırsa bizede faydalı olur...



Include "PROTON18_G4.INT"
		
		ALL_DIGITAL = True
		Cls
		
;************
        
        Dim RTCCMD		As Byte
		Dim TEMP0		As Byte
		Dim TEMP1 		As Byte
		Dim TIMEDATA[6]	As Byte
		Dim OLDSECONDS 	As Byte
		Dim SECONDS 	As timedata#0
		Dim MINUTES 	As timedata#1
		Dim HOURS		As timedata#2
		Dim DATE		As timedata#3
		Dim MONTH		As timedata#4
		Dim YEAR		As timedata#5

		Symbol SECREG	= %00000
		Symbol MINREG	= %00001
		Symbol HRSREG	= %00010
		Symbol DATEREG	= %00011
		Symbol MONREG	= %00100
		Symbol YRREG	= %00110
		Symbol CTRLREG = %00111
		Symbol BRSTREG = %11111
        
        Symbol CLK 		= PORTA.0
		Symbol DTA		= PORTA.2
		Symbol RST		= PORTA.1
		

PRST 	EData $00,$00,$12,$20,$03,$02		

;************      
        
        Dim command As     Byte            ' Storage for command
		Dim i       As     Byte            ' Storage for loop counter
		Dim temp    As     Word            ' Storage for temperature
		
		Symbol DQ      =     PORTB.0         ' Alias DS1820 data pin
		Symbol DQ_DIR  =     TRISB.0         ' Alias DS1820 data direction pin

         

' Clear Write Protect bit in control register of DS1302
		TEMP0 = $10
		RTCCMD = CTRLREG
		GoSub DS1302_WRITE

' Pre-set the time registers using a data table stored in eeprom memory
		For TEMP1 = 0 To 5
			TEMP0 = ERead PRST + TEMP1
			RTCCMD = TEMP1
			GoSub DS1302_WRITE
		Next

		TEMP0 = $80
		RTCCMD = CTRLREG
		GoSub DS1302_READ

'Only Displays on the LCD if the seconds have changed
		While 1 = 1
			GoSub DS1302_READ 
            	If OLDSECONDS <> SECONDS Then
				Print At 1,2, "SAAT  : ", HEX2 HOURS,":",HEX2 MINUTES,":",HEX2 SECONDS
				Print At 3,2, "TARIH : ", HEX2 DATE,"/",HEX2 MONTH,"/",HEX2 YEAR
			EndIf
		
         mainloop:
        
        GoSub init1820          ' Init the DS1820

        command = $cc           ' Issue Skip ROM command
        GoSub write1820

        command = $44           ' Start temperature conversion
        GoSub write1820

        DelayMS 2000              ' Wait 2 seconds for conversion to complete

        GoSub init1820          ' Do another init

        command = $cc           ' Issue Skip ROM command
        GoSub write1820

        command = $be           ' Read the temperature
        GoSub write1820
        GoSub read1820

        ' Display the decimal temperature
        Print At 5,2, "DERECE : ",Dec (temp >> 1), ".", Dec (temp.0 * 5), " C"        
        
        
        
        Wend
      


              
       ; GoTo mainloop           ' Do it forever
        
        
' Initialize DS1820 and check for presence
init1820:
        Low DQ                  ' Set the data pin low to init
        DelayUS 500             ' Wait > 480us
        DQ_DIR = 1              ' Release data pin (set to input for high)

        DelayUS 100             ' Wait > 60us
        If DQ = 1 Then
                Print At 4,6, "DS1820 yok!"
                DelayMS 500
                GoTo mainloop   ' Try again
        EndIf
        DelayUS 400             ' Wait for end of presence pulse
        Return
          

' Write "command" byte to the DS1820
write1820:
        For i = 1 To 8          ' 8 bits to a byte
                If command.0 = 0 Then
                        GoSub write0    ' Write a 0 bit
                Else
                        GoSub write1    ' Write a 1 bit
                EndIf
                command = command >> 1  ' Shift to next bit
        Next i
        Return

' Write a 0 bit to the DS1820
write0:
        Low DQ
        DelayUS 60              ' Low for > 60us for 0
        DQ_DIR = 1              ' Release data pin (set to input for high)
        Return

' Write a 1 bit to the DS1820
write1:
        Low DQ                  ' Low for < 15us for 1
@       nop                     ' Delay 1us at 4MHz
        DQ_DIR = 1              ' Release data pin (set to input for high)
        DelayUS 60              ' Use up rest of time slot
        Return


' Read temperature from the DS1820
read1820:
        For i = 1 To 16         ' 16 bits to a word
                temp = temp >> 1        ' Shift down bits
                GoSub readbit   ' Get the bit to the top of temp
        Next i
        Return

' Read a bit from the DS1820
readbit:
        temp.15 = 1             ' Preset read bit to 1
        Low DQ                  ' Start the time slot
@       nop                     ' Delay 1us at 4MHz
        DQ_DIR = 1              ' Release data pin (set to input for high)
        If DQ = 0 Then
                temp.15 = 0     ' Set bit to 0
        EndIf
        DelayUS 60              ' Wait out rest of time slot
        Return

'-----------------------------------------------------------------------------------
' Write to DS1302 RTC
DS1302_WRITE:		
		High RST
		SHOut DTA, CLK, lsbfirst, [%0\1,RTCCMD\5,%10\2,TEMP0\8]
		Low RST
		Return
'-----------------------------------------------------------------------------------
' Read from the DS1302
DS1302_READ:
		High RST
		SHOut DTA, CLK, lsbfirst, [%111111\6,%10\2]
		OLDSECONDS = SECONDS
		SHIn DTA, CLK, lsbpre, [SECONDS,MINUTES,HOURS,DATE,MONTH,YEAR,YEAR]
		Low RST
		Return


        End
        
          
       	Include "FONT.INC"

mustafa_cmbz

çok güzel bir çalışma olmuş çok...ellerine sağlık...yazılımının bazı bölümlerini metal dedektöründe kullanacağım...çok teşekkürler...

iyi çalışmalar...

Murat Mert

Arkadaşım güzel bir şey yapmışsın eline sağlık. Devamını bekleriz. kolay gelsin.  :D
mert07

AKP

bu dandirik bişey oldu 3dk da yaptım kopyala yapıştır yöntemi ile doğru çalışırmı bilmem bende protonda yapılmış böyle birşey arıyorum. Yada sadece derecede olabilir.