Shop OBEX P1 Docs P2 Docs Learn Events
Real Time Clock chip. A DS12887 — Parallax Forums

Real Time Clock chip. A DS12887

Clock LoopClock Loop Posts: 2,069
edited 2005-06-25 23:13 in BASIC Stamp
Just got my first board of education, BS2 stamp! I love it already and have done alot fairly eaisly.

I have this real time clock chip that I don't understand. I have downloaded the PDF datasheet on it and looked it over many times now.

The chip has its own internal battery backup, and crystal.

The chip has the ability to output a square wave at user selectable intervals, via its own SQW pin.

I don't understand how to go about telling commands to this chip.
I understand the basics of binary, serial and parallel outputs, but don't understand how this chip is addressed.

The chip has two modes, motorola bus timing, or intel bus timing. What do I use? Whats the difference?

I guess I must program register A to set my frequency of the square wave.

My chip has input pins (or address/data bus) AD0 - AD7

I must set Register A like this to get 64 hz from the square wave output.

AD0 = 0
AD1 = 1
AD2 = 0
AD3 = 1

Now. To tell my chip that this is the address I want, I must make the AS (address strobe input) GO high then low (for the falling edge)
this then that tells my chip I wish to set my Register A to the data on inputs ??? How does my chip know I want to set register A and not B?

Does this then mean my output of SQW should read a 64hz Square wave?

If someone could write the code or tell me the steps I must take to set this chip to a 64hz square wave, I will be able to read the code and realize what is going on. I just don't understand the layout of what must come first, second, third, etc.

Is there a tutorial on basic addressing? Mabee one that would include some of the pins I have here. CS(chip select) AS (address Strobe) R/W (read write input) DS (data strobe) ...

Comments

  • Clock LoopClock Loop Posts: 2,069
    edited 2005-06-25 06:27
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2005-06-25 08:21
    BPM -

    The chip you have chosen to use is intended for use in a bus type system (Intel or Motorola) and really isn't the best choice for use with the Stamp or any micro-controller which uses pin port I/O, as many do. Personally, unless you're planning to use it for such a system, I'd toss it back in the drawer for future use.

    Two RTC chips made by Maxim-Dallas which are often used successfully·with the Stamp are the DS1302, and the DS1307. Attached you will find the datasheets and some sample programs for using them. One of the chips (the DS1307 I think) is very similar to the DS12887 in function but it uses a much more micro-controller friendly 2-wire serial interface.

    Regards,

    Bruce Bates

    Note: Twice I tried to upload the 384KB zipped file of datasheets and samples, and twice it failed with some very unhelpful message. If you'd like that zip file, you can contact me at the email address below, and I'll be happy to send it to you via email.

    bvbates @ usamailbox.com
  • Clock LoopClock Loop Posts: 2,069
    edited 2005-06-25 09:03
    Hmm, I was hoping you wouldn't say try another chip. I just wanted to avoid the purchase of yet more stuff. I am one of those use what you have people. I understand that it might be eaiser to purchase a new chip, but basically I am either going to use this chip, a 555 timer (which is unreliable in temp changes), or a crystal oscillator (but I only have ones that are 1mhz or above) I have no idea how to make a 1mhz oscillator divide into a 60hz output. (without insane combinations of divider/counters) And do I understand correctly that using a crystal above 32khz isn't possible with the BS2?
    I would use the 1mhz crystal, and then just use operands to get 60hz, but like I said, can a BS2 count that fast / high?
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-06-25 12:41
    You can certainly use that chip but understand that you're going to use up a lot of pins.· Be sure to connect the AD0..AD7 pins to an even byte group (P0..P7, or P8..P15) to make configuring the pins as inputs or outputs and moving data back and forth easy.· I would also suggest connecting the clock buss pins to the Stamp via 470 resistors to prevent a possible buss conflict that crops up due to a programming error.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • edited 2005-06-25 13:55
    BPM,

    You could get the DS-1307 which I have had success using by simply asking Maxim for free samples. You can register on their web site to obtain them. They have been very good to me in the past with freebies. It may take them up two a week or more to ship them to you via USPS. But, hey, for free who is going to complain tongue.gif .

    Regards,
    Michael G. Jessat

    P.S.- Make sure you read the DS-1307 application notes and crystal selection guide, it will show you the choices you have.

    Post Edited (Dobermann (Black Dog Systems, LLC)) : 6/25/2005 1:58:48 PM GMT
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-06-25 14:03
    And if you do decide to go with the DS1307 the attached program will get you started.· It included generic I2C subroutines as well as specific code for reading from and writing to the DS1307.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Clock LoopClock Loop Posts: 2,069
    edited 2005-06-25 17:08
    Hmm, thanks everyone, I just ordered a few free sample chips. However when choosing the DS1307, they didn't allow me to choose a DIP package, I specified thats is what I would like in the memo, but if its not DIP, then how does one go about using it...


    I would like to just try the DS12887 that I have, I do understand that its not worth it, using up too many pins, but learning how to interface this chip was also something I was interested in. Like for a project I was just going to try to operate this chip. I had not CURRENTLY planned to do anything else with my BS2, other than operate the real time clock. Thats why I wanted to know the proper process of setting addresses, inputing data, etc...
  • edited 2005-06-25 18:21
    BPM,

    Every time I ordered, I specified the DIP. However, a few times I forgot to do so, the order always must default to the DIP package. Since that was what I had received regardless, it probably will be the same in your case also. BTW- Did you order
    the proper crystal while you were there? I recommend Maxim part number DS32KHZ with the DIP packaging. Its a little larger than using a crystal, but it also supports a battery back up. This way once the clock is set, it will maintain time and day functions even while the rest of the circuit is powered off. You can use a button cell battery to provide the necessary power to the clock circuit. If you need any more help let me know. I'll be more than happy to share with you!


    Regards,
    Michael G. Jessat

    P.S. - I have looked at the data for the DS12887A, its going to be a challenge to get it running. I'm not saying that its impossible, but it will require loads of I/O on the stamp. It might well end up being quite a bit of work. I'm following the pack. When I see something thats been done or I have done before, using an easier method, I go with it. I have found that sometimes you just end up re-inventing the wheel or, in my case, making life miserable by getting frustrated.

    Post Edited (Dobermann (Black Dog Systems, LLC)) : 6/25/2005 6:30:27 PM GMT
  • Clock LoopClock Loop Posts: 2,069
    edited 2005-06-25 18:39
    I suppose simplicity is the reason I purchased the stamp in the first place, instead of trying to use, understand, and operate one of these Z80 cpus I have here. I guess sticking with simplicity is wise. Now I must be patient and do something ELSE with my stamp untill my samples get here.. [noparse]:)[/noparse]

    And yes I did order the DS32KHZ dip. Not knowing at the time that I needed it, I just wanted an oscillator that offered low oscillation. I have a bajillion osc chips that osc over 1mhz, kinda useless for me wanting to generate a 60hz square (from a battery, without a 555)
  • edited 2005-06-25 18:57
    BPM,

    Have a look at all the Nuts and Volt's articles, they could provide you with countless hours of stamping. Also have a look at "What's a Microcontroller", along with the many educational guides that www.parallax.com provides for free download. They are wonderful learning tools!!

    Respectfully,
    Michael G. Jessat
  • Clock LoopClock Loop Posts: 2,069
    edited 2005-06-25 19:21
    Yea, ive pretty much downloaded them all and have multiple pdfs open at once. They have all been very usefull. However, I haven't really noticed any that go into multiple bus addressing and the like. I suppose thats cause newer I2C techs have taken over?

    Thanks.
  • edited 2005-06-25 19:28
    BPM,

    I would suppose you are right. I2C is really the way to go, especially with microcontrollers yeah.gif

    Regards,
    Michael G. Jessat
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-06-25 21:04
    Wow,

    ·· This thread brought back some memories.· The DS1287 (I think later succeeded by the DS12887) was the first clock·chip I ever interfaced to a CPU (Z80).· The used to be the BBRTC chip in many computer motherboards back in the 80386 days.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Clock LoopClock Loop Posts: 2,069
    edited 2005-06-25 21:19
    Thats where I got the chip from, heh. I have a ton of elec Smile that I TRY to reuse.. (collected for this very use)
  • Clock LoopClock Loop Posts: 2,069
    edited 2005-06-25 21:57
    I have another question on this topic.

    Concerning the internal clock of the BS2. HOW much a deviation does the internal clock get from temp variations.

    Is it a big deal when you only need to measure something every second? Is the difference between a room temp of 75F versus 90F, noticeable ?

    If not, then I don't even need an external clock. I can just use the clock with the COUNT.
  • edited 2005-06-25 22:24
    BPM,

    Very well could effect its operation. Seems that two flavours of the BS-II are in production. The standard Basic Stamp II and the Basic Stamp II Industrial Module. It supports higher temperature extremes than the standard BS-II. I would be careful as a general rule of thumb not to let my stamps get too hot. Or operate in an environment outside their extreme's.

    Regards,
    Michael G. Jessat
  • Clock LoopClock Loop Posts: 2,069
    edited 2005-06-25 22:35
    So your basically saying that If I stay within the (32º - 158º F) range of the BS2, the internal clock shouldn't change enough to affect timing drastically, If my timing is only to the 100ms resolution?
  • edited 2005-06-25 23:13
    BPM,

    Stay within the range and you'll be OK. But, remember, heat has an effect on every component in a circuit. That is why IC manufactors certify them for operation within certain temperature ranges. They (the IC manufactors) will err on the side of safety in most cases, so a few degrees lower or higher than their 'specified' ranges are tolerable. But several degrees over/under that and it can effect operation adversely. I have built temperature transmitters, that are launched on balloons, a simple form of Radiosonde. The 555 timers that I was testing showed just how relavant an issue this is. Some of the 555's were rated 0 to +70 degrees celsius, while others were 'industrial rated' to -65 to +85 degrees celsius. The 'commercial' version of the 555 would become very unstable shortly after the 0 degree celsius temperature was reached. Within two degrees under the lowest rated temperature, they failed completely. The 'industrial' version 555's operated without as much as a hiccup, since their full range was never exceeded. Like I said, I am always on the careful side of things. Stamps are low price, but not cheap.

    Regards,
    Michael G. Jessat

    Post Edited (Dobermann (Black Dog Systems, LLC)) : 6/26/2005 1:38:49 AM GMT
Sign In or Register to comment.