+ Reply to Thread
Results 1 to 8 of 8

Thread: Binary Clock

  1. #1

    Default Binary Clock

    I'm trying to build a binary clock. Hour Minutes and Seconds I have a DS1307 connected to the Propeller. There are 4 LEDs connected to pins 0-3 for the hours. 8,4,2,1 Then 6 LEDs connected to pins 4-9 for the minutes. 32,16,8,4,2,1 There are 6 LEDs connected to pins 10-15 for seconds. 32,16,8,4,2,1 How do I convert the decimal DS1307 to binary output to the LEDs?

  2. #2

    Default Re: Binary Clock

    The standard technique for converting from one base to another is to keep dividing the number by the new base, outputting the remainders in reverse order. Try doing it with pencil and paper.
    Leon Heller

  3. #3

    Default Re: Binary Clock

    The output is BCD which is really easy to convert -- here's a method you could use:

    pub frombcd(bcdval)
      return ((bcdval >> 4) * 10) + (bcdval & $F)
    Jon McPhalen
    Burbank, CA

  4. #4

    Default Re: Binary Clock

    So the RTC (real time clock) sends BCD (binary-coded decimal) to make it easy to display the digits on normal 2digit pairs 7seg.
    You want to scramble it back to raw binary.

    If the minutes is at 49, in BCD you would get %0100_1001

    ' in this example bcd = 49 = %0100_1001
    mov temp, bcd        ' bcd= two 4 bit nybbles 
    and bcd, #%1111      ' just keep the lower nybble = 9
    and temp, #%11110000 ' just keep the higer nybble = 64
    shr temp, #1         ' divide by 2 = 32
    add bcd, temp        ' add it to new bcd. 32+9 = 41
    shr temp, #2         ' divide it by 4  = 8
    add bcd, temp        ' add it to bcd, the bcd is now 49 
     ...                 ' continue your regular code here.
    bcd long %01001001
    temp res 1
    Last edited by tonyp12; 10-08-2010 at 11:24 PM.

  5. #5

    Default Re: Binary Clock

    If you are doing a binary readout clock why not go all the way and use only 10 leds (11 if you want a 24 hour clock).

  6. #6

    Default Re: Binary Clock

    This is How my display looks for clarity. The O are LEDs
    O O O O O O O O O O O O O O O O
    32 16 8 4 2 1 32 16 8 4 2 1 8 4 2 1
    Hours Minutes Seconds

    Im not doing the BCD

    8 O O O
    4 O O O O O
    2 O O O O O
    1 O O O O O O
    H M S

    Attached is my code it only has seconds works great but the code is very long.
    Attached Files Attached Files

  7. #7

    Default Re: Binary Clock

    if sec == 0
    outa[10..15] := %000000

    I hope you did see a pattern and that all your code so far can be replaced
    with a single line of
    outa[10..15] := sec

    and that the rtcEngine already have NumBCD<>BCDNum converter built-in
    Last edited by tonyp12; 10-08-2010 at 04:23 PM.

  8. #8

    Default Re: Binary Clock

    Thanks a lot Tonyp12 that worked great.

+ Reply to Thread

Similar Threads

  1. Binary Digital Clock
    By Chris Savage in forum Projects
    Replies: 17
    Last Post: 03-16-2010, 12:07 AM
  2. System clock as 7 day to 24Hour real time clock?
    By T Chap in forum Propeller 1 Multicore Microcontroller
    Replies: 5
    Last Post: 02-10-2009, 05:15 AM
  3. Binary clock
    By Jeff Dege in forum Projects
    Replies: 12
    Last Post: 03-09-2006, 07:41 AM
  4. Ds1302 binary clock
    By Stephen Swanson (Parallax) in forum Projects
    Replies: 0
    Last Post: 04-28-2005, 05:20 AM
  5. Binary Clock with DS1302
    By Stephen Swanson (Parallax) in forum BASIC Stamp
    Replies: 6
    Last Post: 11-05-2004, 12:12 AM


Posting Permissions

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