Time display on 7-seg 4 digits


Closed Thread
Results 1 to 13 of 13

Hybrid View

  1. #1
    Join Date
    May 2005
    Posts
    70

    Default Time display on 7-seg 4 digits

    Here is sample code of time display on 7 seg
    we try on pic16f877a ,DS1307


    Code:
    Define LOADER_USED 1
    define OSC 4
    include"modedefs.bas"
    Digits VAR PORTD
    SEGMENTS VAR PORTC
    SO var portc.6 ' tx
    DPIN var PORTd.5 'I2C DATA PIN ds1307,with 4K7 pull up
    CPIN var PORTd.6 'I2C CLOCK PIN with pulled up resister 4K7

    B1 var byte
    B2 var byte
    B3 var byte
    I VAR BYTE
    N VAR BYTE
    VALUE VAR WORD

    BB var byte
    B_H var byte
    B_L var byte
    B_W VAR WORD
    SEC VAR BYTE
    M VAR BYTE
    HR VAR BYTE
    TIMES VAR WORD

    TRISB = $00
    Portb = $00
    TRISc = $00 ' Set segment pins to output
    'portc = $00
    TRISd = $00 ' Set digit pins to output
    'portd = $ff

    ' Setting time & date to 21:58:00
    I2CWRITE DPIN,CPIN,$D0,$00,[$00,$26,$11] ' Write to DS1307

    pause 10

    loop:
    i2cread dpin,cpin,$d0,$00,[b1,b2,b3]
    pause 10

    BB=B1
    gosub conv
    SEC = ((B_H*10)+B_L)
    'serout SO,t9600,["sec ",#SEC,10]
    BB=B2
    gosub conv
    M=(B_H*10)+ B_L
    'serout SO,t9600,["Min ",#M,10]
    BB=B3
    gosub conv
    hR=(B_H*10)+ B_L
    'serout SO,t9600,["Hour ",#HR,":",#M,":",#SEC,10]
    VALUE = ((HR*100) + M)
    'serout SO,t9600,["TIMES ",#TIMES,10]
    gosub display_time
    pause 1
    goto loop
    conv:
    B_L=BB&%00001111
    B_H=BB&%11110000
    B_H=B_H>>4

    return

    display_TIME:
    dot var byte

    For i = 0 To 4 ' Loop through 4 digits

    n = Value Dig i ' Get digit to display

    ' Gosub display1 ' Display the value
    Digits = $ff

    Lookup n, [$3F, $06, $5B, $4F, $66, $6D, $7D, $07, $7F, $6F,_
    $77, $7C, $39, $5E, $79, $71, $0FF], Segments

    if dot < 100 then ' Flishing dot precess
    If i = 2 then segments = segments + 128 'Digit 2 show dot
    Digits = ~Dcd i
    dot = dot+1
    else
    dot = dot+1
    If dot < 254 then
    Digits = ~Dcd i
    else
    dot = 0
    digits = ~dcd i
    endif
    endif

    PAUSE 1 'INCREASE BRITE OF LED

    NEXT i

    RETURN

    End

  2. #2
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    What is the question chai98a?

    -----------------
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  3. #3
    Join Date
    May 2005
    Posts
    70


    Did you find this post helpful? Yes | No

    Default

    About code is work no problem we post for share idea for other peple.
    "Code Example " is forums for place with sample code with working right...

  4. #4
    Join Date
    Sep 2003
    Location
    INDIA
    Posts
    161


    Did you find this post helpful? Yes | No

    Default

    Hello chai98a

    Thank you for your code. I am also trying the same stuff with some 10 voice alarms at this end. I have 3 buttons to spare to enter the alarm.

    I am looking for some Idea to SET the RTC clock time with just three buttons and 4 digit display.

    Any help.

  5. #5
    Join Date
    May 2005
    Posts
    70


    Did you find this post helpful? Yes | No

    Default

    Let you show circuit daigram..and some detail of 3 bottom function.
    I never try about this

  6. #6
    Join Date
    Sep 2003
    Location
    INDIA
    Posts
    161


    Did you find this post helpful? Yes | No

    Default The Schematic

    Hello Chai98a,

    Ok, here's the schematic. I have just 3 buttons to set the RTC time.

    That is not the problem but the problem is the way to set the RTC with a 4 digit - 7 Segment display.

    The display type is 74HC595 connected to each of the digit.

    regards
    Attached Images Attached Images

  7. #7
    abeltcb's Avatar
    abeltcb Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by chai98a View Post
    Here is sample code of time display on 7 seg
    we try on pic16f877a ,DS1307


    Code:
    Define LOADER_USED 1
    define OSC 4
    include"modedefs.bas"
    Digits VAR PORTD
    SEGMENTS VAR PORTC
    SO var portc.6 ' tx
    DPIN var PORTd.5 'I2C DATA PIN ds1307,with 4K7 pull up
    CPIN var PORTd.6 'I2C CLOCK PIN with pulled up resister 4K7
    .....................................

    End
    Hi,
    I would like to try your code, do you have the circuit?
    thanks

  8. #8
    Join Date
    May 2005
    Posts
    70


    Did you find this post helpful? Yes | No

    Default

    here is circuit ...
    I cannot attached some picture file..
    Attached Images Attached Images  

Similar Threads

  1. Hdsp 21xx display
    By Original in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 7th June 2012, 20:07
  2. lumex 4 line display
    By glkosec in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 12th August 2009, 17:55
  3. Alarm Time
    By Santana in forum Code Examples
    Replies: 1
    Last Post: - 8th December 2006, 13:58
  4. SMART Serial 4 Digit LCD Display (SMARD4)
    By paul borgmeier in forum Adverts
    Replies: 0
    Last Post: - 5th January 2005, 05:50
  5. WRITE not working
    By servo260 in forum mel PIC BASIC Pro
    Replies: 31
    Last Post: - 29th December 2004, 02:02

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts