PDA

View Full Version : pcf8583, seriall eeprom and f876



pasicr
- 27th August 2007, 19:40
Hi for all,
I need help abouth this, I need some king data logger,
to work this,
when one door is opened I need to register when (date + time), put this in eeprom, with possibility for reed eeprom with PC ,
rs232 for example,
regards
ps In pbp or ass

Jerson
- 28th August 2007, 05:00
You planning to do this yourself? How much code have you got? Where are you stuck?

pasicr
- 29th August 2007, 01:23
Hi Jerson,
I need help abouth using RTC pcf8583, if you have some example, please share with me,
regards

Jerson
- 29th August 2007, 03:41
I have this. Hope it helps you




' RTC registers
ControlReg con 0
SecondsReg con 2
DayYear con 5
Month con 6
TimerReg con 7
AlarmReg con 8

Time var byte[3]

'================================================= ===============================
' I2C RTC PCF8583 CODE using I2C_read and I2C_write routines of compiler
'================================================= ===============================
' RTC registers are defined
' 0 - Command / Status register
' .0 timer flag
' .1 alarm flag
' .2 alarm enable 1 - enabled
' .3 mask flag
' .54 function 00 clock 32.768KHz/01 clock 50Hz/10 evt counter/11 test
' .6 hold last count flag
' .7 stop counting, reset divider
' 1 - 1/10 s | 1/100s
' 2 - 10s | 1s seconds
' 3 - 10m | 1m minutes
' 4 - 10h | 1h hours
' .3..0 unit hours BCD
' .54 10s hours 0..2 binary
' .6 1 PM
' .7 1 12 hour format
' 5 - 10d | 1day Day & Year
' .3..0 unit days BCD
' .54 ten days 0..3 binary
' .76 year 0..3 binary (read 0 if mask)
' 6 - 10mo | 1month month
' .3..0 unit months BCD
' .4 ten months
' .7..5 weekdays 0..6 binary (read 0 if masked)
'
' 0x10 to 0xff RAM

' If RTC is not running, start it
TimerOff:
I2CWRITE SDA, SCL, $A2, ControlReg, [0]
return

' Read the time in BCD format
RTC_GetTime:
I2Cread SDA, SCL, $A2, SecondsReg+0, [Time[2],Time[1],Time[0]]
return

' Set time in BCD format
RTC_SetTime:
I2Cwrite SDA, SCL, $A2, SecondsReg+0, [Time[2],Time[1],Time[0]]
goto TimerOff

' ************************************************** *********************
' End of 8583 code
' ************************************************** *********************

pasicr
- 29th August 2007, 19:07
Thank you,
do you have some explanation about summer and winter time calculating and 8583,
regards

Jerson
- 30th August 2007, 03:49
No, we don't have that concept in India, so I haven't done it.

pasicr
- 31st August 2007, 03:01
Thanks Jerson,
best regards

BobK
- 1st September 2007, 02:56
Hi pasicr,

Here is how I handled the time change. First goto www.nist.time.gov and get the dates of the time changes. I built a table for Spring and Fall dates. My program checks the date each morning at 0001. If the date is the date of one of the time changes, then I start looking for 0200. I have a flag called DST. If DST = 0 then my program is looking for the Spring time change. When the program detects 0200 and DST = 0 then I set the hour register to 0300 and write the new hour to the RTC then set DST to = 1. If the date was for the Fall change, the program will set the hour register to 0100 and the DST flag to 0. I then have to watch that at 0200 again I don't reset the clock again by checking that at 0200, if DST = 1 do time change else exit time check routine until next Spring.

I believe there are several ways to handle the time changes. Maxim (the maker of many types of rtc chips, posted a flowchart on how to handle the change. You can also create additional registers that look for how many Sundays there are and when the right one comes along it changes the time.

I use my own routines and store the DST flag in EEPROM and use the DS1337 RTC with backup battery for my projects. I have the DST situation handled thru 2015. I should not be bothered by this until then. I have about 80 clocks out there for one customer and I certainly don't want to have to go and re-program clocks twice a year.

My original effort to get this program setup took an entire weekend of testing. I have made 4 different programs using the same RTC and program type and I think it's working fine.

The DS1337 has two alarms. If not using both for a project then it's possible to use the other to let you know when the time change comes around. Once it has been cleared your program could load a new alarm time for the next change and so on.

This kind of stuff is exciting to work on. I have sold two projects so far that totally rely on RTC's for executing programs on a time schedule.

One word of caution though. Carefully read the data sheet for your RTC. Specifically the capacitance load of the crystal. The DS1337 needs a 6pf crystal. My first project didn't and the clock never kept good time. I then replaced that cyrstal with a 6pf one and it has been right on since!

Hope this helps!

BobK