PDA

View Full Version : DS1994 i-Button Real Time Clock



crhomberg
- 29th September 2008, 13:20
I have started a project using this clock and successfully programmed the time and date using the 1-wire protocol. There don't seem to be any extra application notes from Dallas/Maxim on this chip and the manual is very skimpy. All I need is to set it up as an alarm clock. It has 3 alarms inside, each with it's register but I cannot see hoe the registers are set out or how to program them & then read them to see if the alarm flags have been triggered.
I saw a post a while back with someone programming the device but he also only got to where I am now.

Any ideas?

Regards

Chris

Melanie
- 29th September 2008, 18:44
Chris... is this for your PLC project?

If it is, you're thinking way too complex...

Example, you need the PIC to stop your PLC roughly 90 days after installation... the installation runs 24/7, so have the PIC simply keep time (with a Pause 1000) and increment EEPROM every hour. Once a day (on the 24th hour) increment EEPROM days counter. At 90 Days stop the process... you don't need great accuracy... if the PIC loses or gains a day in the process it won't matter. If the unit is switched off, too bad you could lose 59 minutes that weren't stored in EEPROM - but who cares? All you want to do is kill the equipment at some future point give or take a day or two... you could accomplish all this with a PIC16F628 running on internal Oscillator!

PS - DS1994 is obsolete!

crhomberg
- 29th September 2008, 22:59
Melanie,

I need to keep the system running for at least 6 months +- a day or so.
The PLC is far from me (as in another country) so it is not easy or cheap to reset it or change the setting. My original idea was to have a DS1994 with it's alarm set at 6 months and another without an alarm. When the customer pays I ship a new DS1994 without alarm to them. As long as the clock ticks all is happy, if it gets removed for more than maybe an hour it will shut down too.
Maybe that is too complicated.....
Would two ibutton eeproms with different codes do the same thing if the PIC was the clock and I would have to ensure that that PIC clock works for years, it cannot fail after the customer has paid.

Regards

Chris

crhomberg
- 30th September 2008, 01:50
Melanie,

After thinking about it after my last post I thought maybe a good solution is a small PIC, a iButton eeprom with a code with a date and another that just keeps the output on with a small realtime clock inside which I can set before sending the switchboard off. (maybe a DS1302) I will still have the ibutton exchange system but without having to set the DS1994 alarm which I cannot get around. (Is the DS1302 relatively accurate over a year? +- 1 day)

Regards

Chris

Melanie
- 30th September 2008, 07:33
I'm not on the forum every day Chris, yesterday was an exception.

Firstly, with the DS1994, I've never actually played with one. That code I wrote with Ralph was 100% on paper with detail just from the Datasheet. I would assume, that you write to the Real-Time Alarm Register exactly the same way as you would for the Clock Register. Try it, set the time, advance five minutes in software and Set the RTC Alarm Register. Then just wait and continuously poll the Alarm Flag and see what happens five minutes hence.

Secondly, with regard to the DS1302... I've only used the DS1307. The accuracy is about +/- 20 minutes in a year (with a junk crystal). Batteries (CR2032 type) I've never had run out, some units have been in service for over five years.

Thirdly, I don't think you need a clock at all. A PIC will do everything 100%. What you have is a simple application (I know because I've done something very similar with a time delay of about 14 months!!!!).

crhomberg
- 30th September 2008, 14:06
Thanks Melanie for your time,

I can see your point of not needing a rtc. You mentioned using PAUSE 1000 for my seconds count, don't you think this will be "very" inaccurate if the pic is also saving to eeprom, talking to the PLC etc. Will it not be better to use the clock in the PIC to generate interrupts with ON INTERRUPT to keep the counting more precise. I need it to try not to loose a day in 6 months to a year.

Regards

Chris

Melanie
- 30th September 2008, 14:38
> talking to the PLC etc...

Not seeing the big picture what else the PIC has to do it's difficult to comment.

If it's just ensuring a Power-Up sequence to the PLC, keep rough time and maintaining a HPWM value then there's no sweat. Of course you need to ensure the equipment is on 24/7 (or otherwise provide a Battery). As soon as you put a clock-chip on a PCB, the punter starts to wonder Why? What is it for? A PIC on it's own however you can make any number of excuses why it's there.

Why is it so important to keep accurate time? If the guy pays his bill it's OK. If he doesn't, then to have it die exactly at 9pm on Wednesday 27th May 2009 (taking into account Daylight Savings time as well) is pretty irrelevant. So +/-up to 24 hours is neither here or there.

This is what gets me about the ol' Muslim Prayer times... like God is going to get the hump if you miss it by a couple of minutes!

crhomberg
- 30th September 2008, 15:02
Melanie,

I don't think I need Muslim prayers.
I agree, I don't think I really need such high accuracy (about a day in 6 months is OK)
Do you think I can get that using the PAUSE or the TIMER?

Regards
Chris

Melanie
- 30th September 2008, 16:05
Well, the way I did it was quite simple.

First, I wrote the program for what the PIC had to do. For the timekeeping part it kept a tally of SECONDS in a variable, and every hour it would increment a BYTE in EEPROM. Every 24 HOURS it would reset the EEPROM HOURS counter and increment an EEPROM DAYS counter (which actually was two bytes - a WORD). Now, back in 2003/4, the EEPROM endurance was 100,000 writes... so I calculated that was about eleven years worth of hours, way more than I needed.

Now my calibration was simple... my program loop was calculated to execute every 250mS. I simply set an I/O to toggle a LED at each HOURS write, and I simply compared it against my wrist-watch. First time, I was out by about 50 Seconds... so by adjusting my PAUSE value I eventually got it +/-5 seconds in an hour which was fine. I could have added a PAUSEUS and trimmed it even further, but I couldn't be bothered.

The reasoning was a couple of minutes a day was only 12 hours a year... my program started to blink a 'Service Due' LED, and if the Customer didn't respond, it would shut the equipment down two weeks after that (for Safety reasons of course!). The original device used a 16F84 and a 4MHz Resonator and was as crude as you could get - but it worked a treat!

To RESET (for the next time period), you had to hold one of the I/O's low for 20 seconds, then the LED would turn ON for 1 second only, at which point you had to release the I/O. If you didn't wait long enough, it wouldn't reset, and if you waited too long it wouldn't reset either... simple, but effective if you don't know what to do and prevents tampering.

Now in your case I would have a RESET Button that could be used only ONCE. If the machine shuts-down and they call you, tell them to press the RESET Button which would give them 14 days grace. During that time they have to straighten-out their account with you which will entitle them to a free replacement PCB.

crhomberg
- 30th September 2008, 22:34
I like your style,

Keep it simple and functional. I think I am going to do it exactly as you say except I think to control the device I will include a iButton eeprom with a code on it which will come with the installation and another with another code telling the pic to just keep output on.
Have you any code on reading and writing to iButton EEPROM? else I will just plough through the datasheet and work it out the long way.

Thanks & best regards

Chris

praveedca
- 10th November 2010, 06:48
Hi to all I thought maybe a good solution is a small PIC, a iButton eeprom with a code with a date and another that just keeps the output on with a small realtime clock inside which I can set before sending the switchboard off. (maybe a DS1302) I will still have the ibutton exchange system but without having to set the DS1994 .

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~