Shop OBEX P1 Docs P2 Docs Learn Events
DS1302 clock does not run — Parallax Forums

DS1302 clock does not run

Jonny555Jonny555 Posts: 46
edited 2004-09-15 01:47 in BASIC Stamp
Looking over the crystal considerations appnote for the DS1302 they mention that the reason why a clock doesn't run might be "the CH (clock halt) or EOSC (enable oscillator) bit has not been set or cleared".

Looking at the code from "StampWorks Experiment #30: Using Real Time Clock",
I·do not see any mention of setting the CH bit. The crystal in use is a citizen which is listed.

Could someone offer advice as to why my clock isn't running?

Anyone have some code which demonstrates this?

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2004-09-05 21:20
    The code in the StampWorks manual should work fine.· I've used it myself, and built my current routines from it.· I have code that prints the Day, Date & Time to an LCD Display, I could post that if you want.· But it would have to be tomorrow, since I am not at the shop today.· Never on a Sunday!


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage

    Knight Designs
    324 West Main Street
    P.O. Box 97
    Montour Falls, NY 14865
    (607) 535-6777

    Business Page:·· http://www.knightdesigns.com
    Personal Page:··· http://www.lightlink.com/dream/chris
    Designs Page:··· http://www.lightlink.com/dream/designs
    ·
  • Jonny555Jonny555 Posts: 46
    edited 2004-09-05 22:52
    I would like that very much thanks.
    The code runs as-is without buttons attached and results in descending day/time displaying to debug.

    I ripped the circuit apart and re-wired it to no avail. I'm simply trying to set the time without buttons and display it to the debug screen. The clock sits at "Sunday 12:00:00 AM". I'm going to have another look at the code,
    I must have missed something.

    Post Edited (Jonny555) : 9/5/2004 10:58:45 PM GMT
  • Jonny555Jonny555 Posts: 46
    edited 2004-09-06 19:21
    I found out what was the matter when I checked out another rtc project using the same chip.

    http://www.parallax.com/dl/docs/prod/appkit/ds1302rtc.pdf show the pin connections like this:
    BS2······· DS1302
    Pin0<--->Pin7(SCLK)
    Pin1<--->Pin6(IO)
    Pin2<--->Pin5(RST)

    But the stampworks(http://www.parallax.com/dl/docs/books/sw/exp/sw30.pdf) has it setup like this:


    Pin0<--->Pin6(IO)
    Pin1<--->Pin7(SCLK)
    Pin2<--->Pin5(RST)

    by switching the pins my clock began advancing on its own...
    All this headache over inverted wires lol


    Jon

    Post Edited (Jonny555) : 9/6/2004 7:28:12 PM GMT
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-09-06 19:28
    That will happen from time-to-time -- I chose different connections for StampWorks because they made sense to my "larger" scheme. The lesson is to make sure you run code that goes along with the connections you're using.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2004-09-06 22:56
    Glad you got it figured out...Do you still need the LCD Display code, or are you set now?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage

    Knight Designs
    324 West Main Street
    P.O. Box 97
    Montour Falls, NY 14865
    (607) 535-6777

    Business Page:·· http://www.knightdesigns.com
    Personal Page:··· http://www.lightlink.com/dream/chris
    Designs Page:··· http://www.lightlink.com/dream/designs
    ·
  • Jonny555Jonny555 Posts: 46
    edited 2004-09-06 23:17
    Ya I'm set [noparse]:)[/noparse] Thanks though.
  • KlubbssonKlubbsson Posts: 2
    edited 2004-09-07 10:48
    ·Chris Savage, I have a small project that I will display the clock in an LCD display. If you want to post the display code to me I will be grateful.
    ·
    Regards
    Klubbsson· (from Sweden)
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2004-09-07 16:57
    Okay, I was going to cut a piece of code down and make it so that it reads the DS1302 and displays the temp on an LCD Display, which is what's going on in the code I am providing, however, I've noticed that many people are using different types of LCD Displays and/or interfaces, making it non-universal.

    The attached code is the free code from my Digital Thermostat Prototype.· The attached code runs on a stock BS2, and reads data from a Battery-Backed DS1302 (This code doesn't preset the time) and a DS1620, and displays them on a 20 X 4 LCD Display.· Of course, there are other routines, but everything is well-documented.· If you have any questions, either post them here, or to designs@knightdesigns.com and I will address them.



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage

    Knight Designs
    324 West Main Street
    P.O. Box 97
    Montour Falls, NY 14865
    (607) 535-6777

    Business Page:·· http://www.knightdesigns.com
    Personal Page:··· http://www.lightlink.com/dream/chris
    Designs Page:··· http://www.lightlink.com/dream/designs
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2004-09-07 23:00
    An important part of the code I posted above that I forgot to mention, is that the LCD routines are all SEROUT to a PIC-an-LCD http://pic-an-lcd.com/

    That's the main way I connect LCDs to the BS2s...When I have a surplus of pins, I use 4-bit parallel, but the code above uses all SEROUT @ 9600bps.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage

    Knight Designs
    324 West Main Street
    P.O. Box 97
    Montour Falls, NY 14865
    (607) 535-6777

    Business Page:·· http://www.knightdesigns.com
    Personal Page:··· http://www.lightlink.com/dream/chris
    Designs Page:··· http://www.lightlink.com/dream/designs
    ·
  • KlubbssonKlubbsson Posts: 2
    edited 2004-09-08 10:48
    Thanks Chris!· But I still wonder how you know that I wanted to measure and display the temperature also.confused.gif· I’m working on a small project there I will control my saltwater fish tank with a Basic Stamp. I will switch on and off different lamps at different times and the circulation pumps will run in some kind of random pattern.
    But it is a long way to get there for me. I bought the Parralax summer special 3 weeks ago and for the fist time started to learn programming.· So I’m very grateful for all help I can get.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2004-09-08 15:23
    Well then the code you have should help, sicne it does the same thing for air, with humans!· LOL· Seriously, it's the same concept...You check the water temp VS the desired temp, and either turn the tank heater on/off as I am turning the furnace on/off...

    You may, however, need to replace the DS1620 with an ADC0803 and an LM34 or similar so that you can get accurate water temperature.

    To be honest I was only offering the code in respect to displaying the time from the DS1302 on an LCD Display, I didn't remember what your original application was.

    Good Luck...I will help if I can.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage

    Knight Designs
    324 West Main Street
    P.O. Box 97
    Montour Falls, NY 14865
    (607) 535-6777

    Business Page:·· http://www.knightdesigns.com
    Personal Page:··· http://www.lightlink.com/dream/chris
    Designs Page:··· http://www.lightlink.com/dream/designs
    ·
  • OrionOrion Posts: 236
    edited 2004-09-15 01:47
    I currently use 2 DS1620 glued directly to the back of the tank currently and average them.· So far this works really well.· Temps read into the stamp line right up with in tank thermometer.

    Post Edited (Orion) : 9/15/2004 1:52:48 AM GMT
Sign In or Register to comment.