Shop OBEX P1 Docs P2 Docs Learn Events
DS1302 Real Time Clock - BASIC Stamp 2 interface — Parallax Forums

DS1302 Real Time Clock - BASIC Stamp 2 interface

Rich36Rich36 Posts: 3
edited 2008-03-14 04:53 in BASIC Stamp
I am trying to get the DS1302 Real Time Clock chip to work with my Basic Stamp 2 Board of Education. I am sure that the hardware is wired correctly and I am sure the 2 programs I've tried are correct. (One program I downloaded from this Parallax forum.)

One of the things I questioned is the installation of the 32.768kHz Crystal. I have it plugged in the BOE next to pins 2 and 3 of the DS1302. Would this create enough capacitance to load the crystal down and not operate correctly? Is anyone experienced with the DS1302 interface? Any suggestions?

Thanks,
Rich

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-03-11 04:29
    I believe the DS1302 is very sensitive to crystal loading. It also might be just a poor connection in that the usual crystal leads are quite small and may not make proper contact in the breadboard area. You could try soldering them to header pins or scrap component leads and insert that into the breadboard.
  • QuattroRS4QuattroRS4 Posts: 916
    edited 2008-03-11 11:19
    Rich - Mike hit the nail on the head - the crystal is 'Uber' sensitive and it is quite difficult to successfully breadboard a trial application without taking steps like mike mentioned.

    Regards,
    John Twomey

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    'Necessity is the mother of invention'
  • RDL2004RDL2004 Posts: 2,554
    edited 2008-03-11 14:15
    Make sure your crystal is the correct capacitance, 6 pf is what's specified and the ones that are most commonly available are 12pf and 20pf. The 6 pf is not as easy to find and tends to be more expensive.

    You can try trimming the leads on the crystal and then plug it into the same holes as the chip's leads, or bend the leads upward and solder the crystals leads directly to the chips pins.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Rick
  • Tracy AllenTracy Allen Posts: 6,666
    edited 2008-03-11 16:29
    The while breadboard has a huge capacitance and can prevent the crystal from oscillating. Here is a photo of how I recommend soldering the crystal to the DS1302.
    attachment.php?attachmentid=52476
    Note that pins 2 and 3 of the chip have been cut off short. They are dedicated to the crystal and not plugged into anything else. The crystal is held on top with a little dab of glue.

    This is from a recent thread in Stamps in class:
    http://forums.parallax.com/showthread.php?p=712670
    and
    http://forums.parallax.com/showthread.php?p=712702

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • Rich36Rich36 Posts: 3
    edited 2008-03-12 04:16
    Thanks to all for your responses. I ended up soldering the crystal directly to pins 2 and 3, and cutting the pins short. The DS1302 and crystal were provided by Parallax so the crystal was the one recommended. Unfortunately I still cannot get the clock to function.

    My next step is to order another chip and crystal from another source.

    Thanks again,

    Rich
  • sam_sam_samsam_sam_sam Posts: 2,286
    edited 2008-03-12 11:35
    Rich36
    Please check If you hooked·it up this way .........>>>>>>>>>>>>>

    The way i hooked it up

    Then you will have to change two pin # around like this and it will work

    When you hooked up the DS1302 Chip to the Basic Stamp I/O Pins let say 0,1,2 did the three pin 6,7,8··Of the time chip

    BS pin # 0·to TC pin # 6···················································· ··Data IO········ ·· PIN·· ···1·······' DS1302.6 ..> These are changed from the demo
    BS pin # 1·to TC pin #·7····· TC = DS1302 Time Chip Pins #······Clock············ ·PIN·····0·······' DS1302.7· ..> These are changed from the demo
    BS pin #·2 to TC pin # 8····· BS = Basic Stamp Pins #··············CS1302········· ·PIN·····2·······' DS1302.5




    This the way the Demo is set up and if you hook up the right way it will work

    ·Pin Assignment
    ·0·· DS1302 DataIO············· DataIO········· PIN·····0············· ' DS1302.6
    ·1·· DS1302 Clock··············· Clock·········· ·PIN·····1··············' DS1302.7
    ·2·· DS1302 Chip Select······· CS1302·········PIN·····2··············' DS1302.5


    This is the mistake i made when i first started using the DS1302 and still hook it this way because it is easy hook up·pin to pin and do not have to cross pins and have wire to do it I just have to remember change the pins #

    I hope this helps



    ·

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ··Thanks for any·idea.gif·that you may have and all of your time finding them

    ·
    ·
    ·
    ·
    Sam

    Post Edited (sam_sam_sam) : 3/12/2008 11:48:09 AM GMT
  • manxstampmanxstamp Posts: 57
    edited 2008-03-12 13:07
    Before spending more on replacement parts, have you considered using a simple plug-in board for the DS1302. The crystal is then more stable and the optional back-up battery facility can be used.

    I purchased a kit for a simple RTC·board from a US company (Bay Point Engineering) on eBay. Soldering a pin header to the underside gave a board which can easily be plugged in to the BOE and is easy to wire up. It works perfectly with the DS1302 programs found on the Parallax website and these can be modified to display time and date in different formats, to add a serial LCD etc.

    I have found it very accurate in maintaining the time using the battery back-up. A photo of the set up is attached.

    John



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔



    Manxstamp,
    Isle of Man, British Isles
    420 x 600 - 110K
  • HIBITDACHIBITDAC Posts: 40
    edited 2008-03-12 14:13
    What exactly isn't working? I had to mess with mine for quite a while before I realized what the problem was. Post your code, a pic of the circuit and what all problems you are having.
  • Tracy AllenTracy Allen Posts: 6,666
    edited 2008-03-12 20:28
    Attached is yet another test program for the DS1302. This is minimalist, but it allows you to set the clock from the keyboard, and it also illustrates how to synch display of time to the rollover of the seconds, and how to calculate elapsed time.


    Like sam_sam_sam says, it is important to match the program pin numbers to the DS1302 pin numbers.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • Rich36Rich36 Posts: 3
    edited 2008-03-14 03:21
    A picture of the BOE and a copy of the program I am using is attached. The DS1302 will only display zeros for the date and time. If I try to add any values to the DS1302 ram, the return value is zero.
    800 x 600 - 238K
  • sam_sam_samsam_sam_sam Posts: 2,286
    edited 2008-03-14 04:53
    DO NOT RELOAD THE BASIC STAMP unless you made an mistake inputting date and time

    YOU MUST ENTER ALL FIELDS

    Here are·each step that is need to SET·the TIME and DATE

    "Press 1 to Set Date/Time."·· Just PRESS 1

    "2 to Display Date/Time.

    "3 to Set/Read DS1302 RAM."

    "RESET Stamp to return to menu."



    When you input the date and time this is what it would look in the window at the top of the debug window you see what you type

    This is what it would look like if you input what i have here



    1080313610110

    2



    "Enter 2 digit year, i.e. 05 = 2005:" ' Set Year······································08···················

    "Enter 2 digit month, i.e. 03 = March:" ' Set Month····························· · 03

    "Enter 2 digit date, i.e. 02 = 2nd:", ' Set Date···································· ·13

    "Enter day of the week as a number 1-7",

    "1=SUN, 2=MON, 3=TUE, 4=WED, 5=THU, 6=FRI, 7=SAT", ' Set Day······· ·6

    "Enter 1 for 12 Hour Mode or 0 for 24 Hour Mode:",

    "Enter 2 digit hour, 00-23:", CR ' Set Hours (24 Hour Mode)··················· --

    "Enter 2 digit hour, 01-12:", CR ' Set Hours (12 Hour Mode)···················· 10

    "Enter 0 for AM, 1 for PM:", CR ' Set AM/PM Flag··································· 1

    "Enter 2 digit minutes, 00-59:", CR ' Set Minutes·································· 10

    Press ENTER·to SET TIME AND DATE



    "Press 1 to Set Date/Time."··

    "2 to Display Date/Time.·· Just PRESS 2

    "3 to Set/Read DS1302 RAM."

    "RESET Stamp to return to menu."

    After you·PRESSed ·2 and your time and date should be there

    I·tryed the same Demo·I hope that i have each step that is need·

    I hope this help you to get it to work

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ··Thanks for any·idea.gif·that you may have and all of your time finding them

    ·
    ·
    ·
    ·
    Sam

    Post Edited (sam_sam_sam) : 3/14/2008 5:20:29 AM GMT
Sign In or Register to comment.