Shop OBEX P1 Docs P2 Docs Learn Events
SX Clock — Parallax Forums

SX Clock

ACE227ACE227 Posts: 15
edited 2009-04-23 23:33 in General Discussion
I am a student in an electronics program and just beginning some work with the SX-28 Chip.· I have found quite a bit of literature on the Clock keeping capabilities of the SX Chip.· My interest is in building a Real-Time Clock with the SX-28 Chip.·

My desire is to use Digital Logic 7 segment drivers for each digit: 10's of hours through minutes.· However, I would like to build a seconds segment that is made up of LED's set up in 2 rows which will show the seconds and 10's of seconds in a Binary fashion.·

I NEED some help on how to program the SX chip to create a Binary output to each of the 7 segment display drivers.· (Values 1,2,4,8) These are the inputs to the 7 segment display drivers.·
This is the data which i have NOT been able to find!

Can anyone help?

·

Comments

  • Shawn LoweShawn Lowe Posts: 635
    edited 2009-02-20 15:54
    Look in the help file for the IDE. There is a timer example that should do exactly what you want!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Shawn Lowe


    When all else fails.....procrastinate!
  • T&E EngineerT&E Engineer Posts: 1,396
    edited 2009-02-20 16:01
    You will not be able to accurately use the SX28 or any other micro-controller alone as a real time clock. You can however, interface a real time clock chip such as the DS1302 or DS1307 with the SX28.

    You probably will want to use some LED driver chip(s) for the display such as the MAX7219 or something similar.

    Here are some of my projects with clocks that may give you ideas.

    Uses obsolete SX52 but may be possible use an SX48 (also in Nuts and Volts - Jan 2009): http://forums.parallax.com/showthread.php?p=649643

    6432 display (also may be in Nuts and Volts - April 2009): http://forums.parallax.com/showthread.php?p=739950

    Basic Stamp 2 project: http://forums.parallax.com/showthread.php?p=553075

    Basic Stamp 2 project: http://forums.parallax.com/showthread.php?p=734329

    SX28 and an LCD: http://forums.parallax.com/showthread.php?p=643780

    Just do a search on the forums for "clock" or "DS1302", etc.
  • JonnyMacJonnyMac Posts: 9,213
    edited 2009-02-20 17:56
    I beg to differ, but with an accurate clock source one can easily use the SX as an RTC with a little code -- no DS1302 (et al) is required unless one needs to maintain time when power is removed (this assumes that is battery back-up of the RTC chip). As Shawn points out I wrote a demo RTC program for the help file that even outputs the time to 7-segment displays which is exactly what Ace needs.
  • T&E EngineerT&E Engineer Posts: 1,396
    edited 2009-02-20 18:00
    I stand corrected. Thanks for the information. I thought I remember reading that a RTC was required due to accuracy issues or something. However, you are the expert. Thats certainly great news!
  • pjvpjv Posts: 1,903
    edited 2009-02-20 18:09
    Hi ACE 227;

    You might be misdirected by some of the above posts...... with a little inginuity, you can very well create a complete real time clock with a multiplexed display from a single SX 28 chip.

    No external driver chips of any sort are required.... just the SX, 4 Seven segment Digits, 8 leds for the 10 Seconds and Seconds, and 8 resistors. Depending on the brightness you desire, an additional 12 resistors may be required.

    You would also want to include two momentary push buttons for setting the time. I use a dimming technique to indicate which digit is being adjusted for time, and the two buttons to Raise/Lower the time value for that digit. Pressing both buttons momentarily advances the adjustment to the next digit. When adjusting the time, the speed of the Raise/Lower interval even changes.

    For stability, the oscillator source should be a standard crystal, probably in the 4 Mhz range.

    I have created hundreds of multiplexed displays as well as discrete multiplexed LED drivers with just this approach, and the results have been excellent.

    Cheers,

    Peter (pjv)
  • Guenther DaubachGuenther Daubach Posts: 1,321
    edited 2009-02-24 00:09
    ACE 227,

    if you have my book, you can find code for "pure" SX real-time clocks in the applications sample section. If not, please let me know, and I'll send you links to the sample code.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Greetings from Germany,

    G
  • ACE227ACE227 Posts: 15
    edited 2009-02-24 13:21
    Dear Guenther,

    I have your book on order but it is going to be about another week before it comes in. If you could please send me the link to the sample code I would be able to start working on it sooner than that. Thank you.

    ACE 227
  • ZootZoot Posts: 2,227
    edited 2009-02-24 13:46
    JonnyMac said...
    no DS1302 (et al) is required unless one needs to maintain time when power is removed (this assumes that is battery back-up of the RTC chip).

    Or because you need the day of week, day of month, month, and year as well.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST

    1uffakind.com/robots/povBitMapBuilder.php
    1uffakind.com/robots/resistorLadder.php
  • Guenther DaubachGuenther Daubach Posts: 1,321
    edited 2009-02-25 14:09
    ACE 227,

    This is the link: www.parallax.com/Portals/0/Downloads/src/prod/sx/ProgSXEdPre.zip.

    In the ZIP file, you will find the clock sample code in APP016.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Greetings from Germany,

    G
  • ACE227ACE227 Posts: 15
    edited 2009-04-23 13:44
    I had to switch up to the SX 48 for the purpose of having binary seconds but I am having trouble with the code. I do not know how to change the code from P Basic to SX/B for the SX 48 chip. I also need to have the code to say that it uses a 50 mHz external oscillator. Here is a sample of my code. It isn't finished yet to work for the clock part but I don't know how to make sure it will work for the SX 48 chip.

    Also The SX\B language does not recognize () and when they are taken out an error is given. It say that there is an invalid number of perameters in the line. Could you please help me to get around this bit code. Here is one piece of the code that I need to change:
    theDig = theDig + 1 // 4

    Thank you,
    Ace 227
  • ZootZoot Posts: 2,227
    edited 2009-04-23 13:47
    You can't have more than one expression in an SX/B line. You have to break it up into separate statements.

    dig = dig + 1
    dig = dig // 4

    Re: frequency -- time to hit the SX/B help file where everything is spelled out (directives) for setting brownout, frequency, external clock/resonator settings, etc.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST

    1uffakind.com/robots/povBitMapBuilder.php
    1uffakind.com/robots/resistorLadder.php
  • JonnyMacJonnyMac Posts: 9,213
    edited 2009-04-23 23:33
    In SX/B the // (modulus) operator generates a fair bit of code -- I suggest this:

    INC dig
    IF dig = 4 THEN
      dig = 0
    ENDIF
    


    It does the same thing while generating less [noparse][[/noparse]Assembly] code.

    Here's another trick that works with powers of two:

    INC dig
    dig = dig & %0000_0011
    


    I use this one a lot -- again, when the divisor that you would have used with // is a power of 2 (2, 4, 8, 16, 32, 64, 128)
Sign In or Register to comment.