Shop OBEX P1 Docs P2 Docs Learn Events
Real Time Clock on Professional Development Board? — Parallax Forums

Real Time Clock on Professional Development Board?

jcpolejcpole Posts: 92
edited 2005-08-31 21:48 in BASIC Stamp
Hi all...

I'm new to the Stamp, and to its interfaces, and I was wondering if anyone had some sample code to set the time & date, as well as to read the time & date from the embedded real time clock on the Professional Development Board? The Stamp itself is a BS2px. I'm also very curious as to the best way to actually connect to the clock hardware - all of the code I have seen so far reflects a 3-wire connection to the clock on the board that the PDB replaced. Unless I'm reading the datasheet wrong, I should only need 2 wires for the clock on the PDB. Is this incorrect?

Finally, is there an easy way to output the time from the clock to the 7-segment LEDs on the PDB? How about to a 2x16 LCD?

I'm researching security applications, so having access to the correct time & date is crucial.

Thanks in advance.

Jamie

--
Jamie C. Pole
Principal Consultant
J.C. Pole & Associates, Inc.
http://www.jcpa.com/

Post Edited (jcpole) : 8/31/2005 3:21:12 AM GMT

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-08-31 03:49
    Hello,

    ·· Jon Williams recently uploaded some code for the BS2 and BS2p for the DS1307.· I have attached it since I cannot seem to find the thread.· I hope this helps.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • jcpolejcpole Posts: 92
    edited 2005-08-31 05:31
    Thanks very much for the code...

    When I run either program, pressing either button to set the hours & minutes results in both values incrementing by 1. The wiring is pretty straightforward, so I'm kinda stumped about why both buttons increment both values.

    Any ideas about that?

    Jamie

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    --
    Jamie C. Pole
    Principal Consultant
    J.C. Pole & Associates, Inc.
    http://www.jcpa.com/
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-08-31 13:06
    The DS1307 is an I2C device -- this is reflected in the PDB documentation.· I2C devices use just two wires (SDA and SCL).

    Luckily, I just happened to have a BS2px plugged into my PDB today so I've updated the demo program that was posted earlier to work with I2CIN and I2COUT (available only on BS2p-family modules).· The program runs as expected.· Note that the seconds get reset when either the minutes or hours are updated; this is easy to "fix" by removing the line that sets secs to zero.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax

    Post Edited (Jon Williams (Parallax)) : 8/31/2005 1:05:56 PM GMT
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-08-31 14:19
    jcpole said...(trimmed)
    When I run either program, pressing either button to set the hours & minutes results in both values incrementing by 1. The wiring is pretty straightforward, so I'm kinda stumped about why both buttons increment both values.
    Any ideas about that?
    Jamie,

    ·· Can you confirm this by moving one of the button connections to another button?· Let me know if it still does this.· If it doesn't, then move it back to the original button and see if it happens again.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • jcpolejcpole Posts: 92
    edited 2005-08-31 15:16
    The new program that Jon provided works just fine. I'm going to look at the logic to see what is different as far as the buttons.

    Now that the clock is set properly, is there a fairly simple mechanism to display the time on the 7-segment LED block, or the LCD?

    I'm starting to think that I'm going to need a BS2p40 just to get enough i/o pins... smile.gif

    Thanks for all of your help.

    Jamie

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    --
    Jamie C. Pole
    Principal Consultant
    J.C. Pole & Associates, Inc.
    http://www.jcpa.com/
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-08-31 15:31
    Jamie,

    ·· There are a few chips which can drive the 7-Segment Display from only 3 I/O pins.· The two more common ones are the MC14489, and the more expensive MAX7219.· As for I/O pins, don't fret...The BASIC Stamp I/O can be expanded very easily using simple shift registers.

    ·· For example, you can add 24 outputs to the BASIC Stamp for about $4.00 using 3 74HC595 ICs, and only 3 I/O pins.· If you need inputs, you can use the 74HC165.· Often the Clock and data lines can be common, so you can have 24 inputs and 24 outputs using only about 4 I/O lines.· See the StampWorks Manual, a free download in PDF format from our website for examples of this.

    http://www.parallax.com/detail.asp?product_id=27220

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-08-31 15:56
    I'd go with Chris's recommendation on the MC14489 -- cheap, and pretty easy to use.· Since the RTC returns everything in BCD all you have to do is copy proper NIBs from the time registers to the nib outputs for the MC14489.· I've attached a piece of demo code for the MC14489 so you can see how to program it.· Of course, you'll have to modify the code for your own use.· Be sure to download and review the MC14489 specs.· The code will make more sense if you do.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • jcpolejcpole Posts: 92
    edited 2005-08-31 17:04
    Thanks...

    I ordered the chips that Chris recommended, and I'll drop back in if I have any other questions.

    You guys have been great - I sincerely appreciate the help and information.

    Jamie

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    --
    Jamie C. Pole
    Principal Consultant
    J.C. Pole & Associates, Inc.
    http://www.jcpa.com/
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-08-31 17:59
    Jon,

    ·· Don't be so modest...I was using the MAX7219 until Jon told me about the MC14489.· Here is a screenshot of Jon's code running on a Prototype·we are working on using our PDB for development.· Note that the temperature is displayed with a degrees symbol and the F.· The leading digit, when zero is automatically blanked.

    Jamie,

    ·· Good luck with your project!


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com


    Post Edited (Chris Savage (Parallax)) : 8/31/2005 9:46:47 PM GMT
    682 x 591 - 81K
  • Brian RileyBrian Riley Posts: 626
    edited 2005-08-31 20:23
    Jon Williams (Parallax) said...


    ... with I2CIN and I2COUT (available only on BS2p-family modules).

    Strictly speaking that is not quite right. While the above statement applies only to the Basic Stamp family, I2C is also available to the SX28/48/52 via SX/B ???? So since the PDB services the Sx28, it is available for that, though it really isn't a stamp in that form. Oh well I guess I'm arguing semantics. But its probably not a bad idea to be reminded from time to time that as primitive as the SX/B compiler is compared to full blown PBASIC, it does have some powerful constructs.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    cheers ... brian riley, n1bq, underhill center, vermont
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-08-31 21:48
    Let's try to stay on topic within the forum, please -- this one is for BASIC Stamps and, in fact, SX/B does not have I2COUT and I2CIN commands (it has other instructions that are single-byte oriented, unlike I2COUT and I2CIN which handle start and stop conditions, and can be multi-byte).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
Sign In or Register to comment.