Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

dijital clock project (PIC16F628)

Status
Not open for further replies.

ilker_32

Member level 3
Member level 3
Joined
Jun 22, 2009
Messages
56
Helped
10
Reputation
20
Reaction score
10
Trophy points
1,288
Location
Turkey
Activity points
1,464
pic16f628 ile derece saat

with Sofie Elenctronics,

ºematik : Proteus 7.5 service pack 3
programlama dili : Pic Basic Pro

simulation:

**broken link removed**

**broken link removed**

sourcecode:

Code:
PORTA=0:portb=0
TRISB=0   
TRISA=%11100000  
'-----------------------------------------------------------------
@ DEVICE pic16F628                      'iºlemci 16F628                                
@ DEVICE pic16F628, WDT_ON              'Watch Dog timer açık
@ DEVICE pic16F628, PWRT_ON             'Power on timer açık
@ DEVICE pic16F628, PROTECT_OFF         'Kod Protek kapalı
@ DEVICE pic16F628, MCLR_off            'MCLR pini kullanılMIYOR.
@ DEVICE pic16F628, INTRC_OSC_NOCLKOUT  'Dahili osilatör kullanılacak 
'-----------------------------------------------------------------
DEFINE OSC 4
'-------------------------------------------------------------------------
ON INTERRUPT GoTo KESME   'kesme oluºursa KESME adlı etikete git.
OPTION_REG=%10000101   'Pull up dirençleri İPTAL- Bölme oranı 1/64.
INTCON=%10100000  'Kesmeler aktif ve TMR0 kesmesi aktif
TMR0=0
CMCON=7  
'----------------------------------------------------------------------------
Comm_Pin    VAR	PortA.4     ' One-wire Data-Pin "DQ" PortB.0 da
Busy        VAR BIT         ' Busy Status-Bit
POZ         VAR BIT
Z           VAR BIT
W           VAR BIT
U           VAR BIT
T           VAR BIT
GOR         VAR BYTE
HAM         VAR	WORD        ' Sensör HAM okuma değeri
ISI         VAR WORD        ' Hesaplanmıº ISI değeri
Float       VAR WORD        ' Holds remainder for + temp C display
X           VAR WORD  
Y           VAR BYTE  
SAYI        VAR BYTE   
SIGN_BITI   VAR HAM.Bit11   '   +/- sıcaklık ݺaret biti,  1 = olursa eksi sıcaklık
NEGAT_ISI   CON 1           ' Negatif_Cold = 1
Deg         CON 223         ' ° iºareti
SIGN        VAR BYTE        '  ISI değeri için  +/-  iºaret
TEMP        VAR BYTE         ' Div32 bit hesap için geçici değiºken
SAYAC       VAR BYTE
SN          VAR BYTE
DAK         VAR BYTE
SAAT        VAR BYTE
GUN         VAR BYTE
AY          VAR BYTE
YIL         VAR BYTE
MEM         var byte ' 
EKRAN_ZAM   var byte ' 
SUM         VAR BYTE
EKRAN_ISI   VAR BYTE
ONLAR       VAR BYTE
BIRLER      VAR BYTE
ESN         VAR BYTE
'---------------------------------------------
SYMBOL  DTA=PortB.0
SYMBOL  CLK=PORTB.1
symbol  ST=PORTB.2
SYMBOL  RTC_DTA=PORTA.0
SYMBOL  RTC_CLK=PORTA.1
SYMBOL  RTC_RST=PORTA.2
symbol  SEC   =PORTA.5  
SYMBOL  ASAGI =PORTA.6 
SYMBOL  YUKARI=PORTA.7 
'-----------------------------------------------------------------------------
CLEAR  'tüm değiºkenler sıfırlandı
EKRAN_ZAM=10  'ZAMANIN EKRANDA KALMA SÜRESİ
EKRAN_ISI=5   'SICAKLIĞIN EKRANDA KALMA SÜRESİ BUNLARI DEĞݪTİREBİLİRSİNİZ.
SUM=EKRAN_ZAM+EKRAN_ISI
IF sec=0 then ZAM_AYAR
ILK:
gosub ekran0
gosub sensoryaz
gosub sensoroku
low RTC_RST
low RTC_CLK 
GOSUB GECIKME
'-----------------------------------------------------------------------------
HIGH PORTA.3 
gosub ZAMAN_OKU:esn=SN
BASLA: 
        IF Y=SUM THEN Y=0
        IF Y>(EKRAN_ZAM-1) AND Y<SUM THEN
         if y=(EKRAN_ZAM+1) then GOSUB SENSOROKU
         GOSUB EKRAN1
        ENDIF 
        IF Y<EKRAN_ZAM THEN GOSUB EKRAN0
       
ATLA:  if SEC=0 THEN AYAR  'MODE TUªUNA BASILMIª İSE AYAR'A GİT
       
       GOTO BASLA
'-----------------------alt programlar-------------------------------------------       
TEKRAR:
       SHIFTOUT DTA,CLK,1,[SAYI] 
       RETURN
BAK_0:
       GOSUB AL
       IF Z=1 AND W=1 THEN SAYI=0  
       RETURN
BAK_1:
       GOSUB AL
       IF Z=1 AND U=1 THEN SAYI=0             
       RETURN
BAK_2:
       GOSUB AL
       IF Z=1 AND T=1 THEN SAYI=0             
       RETURN
     

EKRAN0: if sayac=28 then LOW porta.3          
'        X= SN DIG 0 :GOSUB al:GOSUB TEKRAR 
'        X= sn DIG 1 :GOSUB al:GOSUB TEKRAR
        
        X= DAK DIG 0:GOSUB BAK_1:GOSUB TEKRAR
        X= DAK DIG 1 :GOSUB BAK_1:GOSUB TEKRAR
        u=0
        X= SAAT DIG 0 :GOSUB BAK_0:GOSUB TEKRAR
        X= SAAT DIG 1:GOSUB BAK_0:GOSUB TEKRAR
        w=0
       HIGH st:PAUSEUS 2:LOW st
       RETURN
       
AL:    LOOKUP X,[63,6,91,79,102,109,125,7,127,111,99,57],SAYI :RETURN
     

EKRAN1:LOW PORTA.3
       X=11:GOSUB AL:GOSUB TEKRAR
       X=10:GOSUB AL:GOSUB TEKRAR
       
       x=(ISI DIG 0):GOSUB AL:GOSUB TEKRAR
       x=(ISI DIG 1):GOSUB AL:GOSUB TEKRAR
'       IF SIGN_BITI = NEGAT_ISI THEN 
'         SAYI=64 
'         else
'         SAYI=0
'         endif
'       GOSUB TEKRAR
'       SAYI=0
'       GOSUB TEKRAR 
       HIGH st:PAUSEUS 2:LOW st
       RETURN
       
EKRAN2:IF POZ=0 THEN HIGH porta.3
       X= YIL DIG 0:GOSUB BAK_2:GOSUB TEKRAR
       X= YIL DIG 1:GOSUB BAK_2:GOSUB TEKRAR
       T=0
       X= AY DIG 0:GOSUB BAK_1:GOSUB TEKRAR       
       X= AY DIG 1:GOSUB BAK_1:GOSUB TEKRAR 
       U=0      
       X= GUN DIG 0:GOSUB BAK_0:GOSUB TEKRAR
       X= GUN DIG 1:GOSUB BAK_0:GOSUB TEKRAR
       w=0 
       HIGH st:PAUSEUS 2:LOW st    
       RETURN  
       
EKRAN_3: 

        X= SN DIG 0:GOSUB BAK_1:GOSUB TEKRAR
        X= SN DIG 1 :GOSUB BAK_1:GOSUB TEKRAR
        u=0
        SAYI=0:GOSUB TEKRAR
        SAYI=SUM:GOSUB TEKRAR
        w=0
       HIGH st:PAUSEUS 2:LOW st
       RETURN            
'-----------------------------------------------------  
ZAM_AYAR:
        LOW PORTA.3:SN=0:POZ=1:SUM=6 
        SN=EKRAN_ZAM:GOSUB EKRAN_3
        WHILE SEC=0:WEND
        
ZAM_BIR:
        W=1
        IF SEC=0 THEN ZAM_IKI
        IF YUKARI=0 THEN
          IF Z=0 THEN sn=SN+1
          IF SN=31 THEN SN=0       
        ENDIF             
        IF ASAGI=0 THEN
           IF Z=0 THEN SN=SN-1
           IF SN=255 THEN SN=30
        ENDIF
        Z=1-Z
        GOSUB EKRAN_3       
        GOSUB GECIKME
        GOTO ZAM_BIR
        
ZAM_IKI: 
        EKRAN_ZAM=SN:SUM=91
        SN=EKRAN_ISI:GOSUB EKRAN_3
        WHILE SEC=0:WEND
        
ZAM_UC:
        W=1
        IF SEC=0 THEN ZAM_DORT
        IF YUKARI=0 THEN
          IF Z=0 THEN sn=SN+1
          IF SN=31 THEN SN=0       
        ENDIF             
        IF ASAGI=0 THEN
           IF Z=0 THEN SN=SN-1
           IF SN=255 THEN SN=30
        ENDIF
        Z=1-Z
        GOSUB EKRAN_3       
        GOSUB GECIKME
        GOTO ZAM_UC        
        
ZAM_DORT:
         EKRAN_ISI=SN
         SUM=EKRAN_ZAM+EKRAN_ISI
         Z=0:W=0:POZ=0
         GOTO ILK        
AYAR:  
       LOW PORTA.3:SN=0:POZ=1':GOSUB FLASH
       gosub ekran0
       WHILE SEC=0:WEND
HOUR:  W=1
       LOW PORTA.3
       IF SEC=0 THEN MINBIR
       IF YUKARI=0 THEN
          IF Z=0 THEN SAAT=SAAT+1
          IF SAAT=24 THEN SAAT=0       
        ENDIF   
        IF ASAGI=0 THEN
           IF Z=0 THEN SAAT=SAAT-1
           IF SAAT=255 THEN SAAT=23
        ENDIF
        Z=1-Z
        GOSUB EKRAN0   
        GOSUB GECIKME
        GOTO HOUR
        
MINBIR: W=0:Z=0
        GOSUB EKRAN0
'        GOSUB FLASH
        WHILE SEC=0
        WEND
        
MINUTE: U=1        
       LOW PORTA.3
       IF SEC=0 THEN ara
        IF YUKARI=0 THEN
           IF Z=0 THEN  DAK=DAK+1
           IF DAK=60 THEN DAK=0
        ENDIF
        IF ASAGI=0 THEN
           IF Z=0 THEN  DAK=DAK-1
           IF DAK=255 THEN DAK=59              
        ENDIF
        Z=Z-1
        GOSUB EKRAN0
        GOSUB GECIKME
        GOTO MINUTE
        
SECBIR: WHILE SEC=0
        WEND
        U=0
GECIKME:
        FOR X=0 TO 3500
        PAUSEUS 5
        NEXT
        RETURN
DELAY:
        FOR X=0 TO 1900
        PAUSEUS 10
        NEXT
        RETURN      

ARA:    W=0:u=0:T=0:Z=0
        GOSUB FLASH
        Gosub EKRAN0
        HIGH PORTA.3
        WHILE SEC=0  
        wend
        MEM=SN:GOSUB TERSCEVIR:SN=SAYI
        MEM=DAK:GOSUB TERSCEVIR:DAK=SAYI
        MEM=SAAT:GOSUB TERSCEVIR:SAAT=SAYI
        MEM=GUN:GOSUB TERSCEVIR:GUN=SAYI
        MEM=AY:GOSUB TERSCEVIR:AY=SAYI
        MEM=YIL:GOSUB TERSCEVIR:YIL=SAYI 
        GOSUB ZAMAN_YAZ
        GOSUB ZAMAN_OKU
        y=0:POZ=0
        goto BASLA
        
FLASH:
      TOGGLE PORTA.3:GOSUB DELAY:TOGGLE PORTA.3:GOSUB DELAY
      TOGGLE PORTA.3:GOSUB DELAY:TOGGLE PORTA.3:GOSUB DELAY
      return 
'-------------------------------------------------------------------------------      
            
              
'----------------ISI SENSÖR OKUMA BÖLÜMÜ --------------------------------
SENSOROKU: 
'-----------------DİKKAT İSİS'de BU SATIR AKTİF EDİLECEK----------------------
'           ham=$ff5e:Gosub hesapla:return 'NORMAL ÇALIªMADA BU SATIR SİLİNECEK
'------------------------------------------------------------------------------
           OWOUT   Comm_Pin, 1, [$CC, $44]' ISI değerini oku
Bekle:
'           OWIN    Comm_Pin, 4, [Busy]    ' Busy değerini oku
'           IF      Busy = 0 THEN Bekle  ' hala meºgulmü? , evet ise goto Bekle..!
           OWOUT   Comm_Pin, 1, [$CC, $BE]' scratchpad memory oku
           OWIN    Comm_Pin, 2, [HAM.Lowbyte, HAM.Highbyte]' İki byte oku ve okumayı bitir.
           GOSUB   Hesapla
           RETURN
           
SENSORYAZ:
          OWOUT   COMM_Pin, 1, [$CC, $4E, $00,$00,$31]
          return           
             
Hesapla:                 ' Ham değerden Santigrat derece hesabı
    Sign  = "+"
    IF SIGN_BITI = NEGAT_ISI THEN
       Sign   = "-"  
       temp=($ffff-ham+1)*625
       ISI  = DIV32 10 
       GOTO GEC   
    endif
    TEMP = 625 * (HAM+1)        ' 
    ISI = DIV32 10          ' Div32 hassas derece hesabı için 32 bit bölme yapıyoruz.
GEC:
    FLOAT = (ISI //1000)/100
    ISI=ISI/1000
    RETURN              

ZAMAN_OKU: 
         high RTC_RST:OUTPUT rtc_dta
         shiftout RTC_DTA, RTC_CLK, 0, [$BF]:INPUT RTC_DTA
         SHIFTIN RTC_DTA, RTC_CLK, 1, [SN, DAK, SAAT,GUN , AY, MEM, YIL, MEM]  'OKU
         MEM=SN:GOSUB CEVIR:SN=SAYI
         MEM=DAK:GOSUB CEVIR:DAK=SAYI
         MEM=SAAT:GOSUB CEVIR:SAAT=SAYI
         MEM=GUN:GOSUB CEVIR:GUN=SAYI
         MEM=AY:GOSUB CEVIR:AY=SAYI
         MEM=YIL:GOSUB CEVIR:YIL=SAYI
         low RTC_RST 
         return

ZAMAN_YAZ:
      
         high  RTC_RST:OUTPUT RTC_DTA 
         SHIFTOUT RTC_DTA, RTC_CLK, 0, [$8E, 0]    'WRT Protek açıldı
         low RTC_RST:PAUSEUS 10 
         high RTC_RST          
         SHIFTOUT  RTC_DTA, RTC_CLK, 0, [$BE, SN, DAK, SAAT,GUN , AY, 0, YIL, 128]  'YAZ
         low RTC_RST
         PAUSEUS 10
         return
               
CEVIR:
         ONLAR=MEM & %01110000
         ONLAR=ONLAR>>4
         BIRLER=MEM & %00001111
         SAYI=ONLAR*10+BIRLER
         RETURN  

TERSCEVIR:                
         ONLAR=MEM DIG 1
         ONLAR=ONLAR<<4
         BIRLER=MEM DIG 0
         SAYI=ONLAR+BIRLER
         RETURN
         
DISABLE
KESME:IF POZ=1 then CIK 
        SAYAC=SAYAC+1  'kesme sayacı  1 sn= 61(sayac) x 256 (Tmr0) x 64 (bölme)
        IF SAYAC=58 then  '61 adet kesme olunca 1 sn. süre geçiyor.(999424 us)
         SAYAC=0        'sayaç sıfırlanıyor
          Y=Y+1
          GOSUB ZAMAN_OKU
         if Y<EKRAN_ZAM then HIGH porta.3
       ENDIF
CIK:     INTCON.2=0  'TMR0 Kesme bayrağı sıfırlanıyor
         RESUME
         ENABLE
                  
         
END
 

digital clock with pic16f628 schematic isis

Clock PCB, it was made and was functional
 

pıc16f628

Clock Design, was made too early may be usefull for u
 

@mfarooq1 thanks,

sorry, i don't know english. I'm looking at from the dictionary to the words

there is the problem in .dsn file. And, can you do export of the .dsn file again.

anyway,

i'm giving you the pictures. And pcb.

**broken link removed**
**broken link removed**
 
or, can use that...

**broken link removed**

and don't forget that...

use with PIC,

Code:
ham=$ff5e:Gosub hesapla:return 'NORMAL ÇALIªMADA BU SATIR SİLİNECEK

use with ISIS,

Code:
'ham=$ff5e:Gosub hesapla:return 'NORMAL ÇALIªMADA BU SATIR SİLİNECEK
 

This is excellent but can you please give the Schematic as I could not get from your uploads. I have made a Digital clock on Atmel with ds 1307, but I am facing some problems, specially in 7 segment gaint display. I can not control the current and dont know how to glow gaint 7 segment display with brightness. I made it but the display is dim and LEDs (when off) are not completely off they glow a little bit in off mode. Can you please give the schematic of your gaint display with large scale LEDs???

secondly I dont know why my DS 1307 is not accurate? it works fast although I m not using any trimmer with it? can you please help me in this matter????
 

Sorry, i really want to help you but my english is not enough.:cry:

and i don't useing the schematic...

But, you can understand the logic. And,

i drew a schematic for you...:D

**broken link removed**

or TPIC6b595 you can use.

74hc595+uln2803=tpic6b595:idea:

I'm here to learn English... And a good friends...

are you knowing Turkish or German... ?
 

thanks for your reply but I can not download your file??? its giving error. Plz help me.
 
  • Like
Reactions: ie05

    ie05

    Points: 2
    Helpful Answer Positive Rating
not important. What is the error?

the links are strong...

or

Is there your e-mail. And, i can send to you the files. :D

Are i able to set correct the sentences. :cry:
 

ilker_32

Thank you very much for sharing.
 
Sir_rouge84 said:
help any idea on real time clock....

sorry, i can not understand you.

do you give some knowledge? And what do you want to do?
 

please the code source in ccs
thanks for yor help
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top