Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 14:36 24 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Internal RTC

     Page 3 of 4    
Author Message
heppy36

Regular Member

Joined: 29/07/2011
Location: Australia
Posts: 54
Posted: 10:50am 10 Aug 2011
Copy link to clipboard 
Print this post



When say disconnect battery,will removing the jumper do,or should I un solder it?
it seems to write ok but when I read,also if i just write then turn off it forgets
Heppy
 
seco61
Senior Member

Joined: 15/06/2011
Location: Australia
Posts: 205
Posted: 12:15pm 10 Aug 2011
Copy link to clipboard 
Print this post

  heppy36 said  
When say disconnect battery,will removing the jumper do,or should I un solder it?
it seems to write ok but when I read, also if i just write then turn off it forgets


Hi.

I do not have one of these eBay RTC devices, so I am not certain if the battery is permanently in circuit or not.

When you disconnect power and remove the jumper is there any voltage on pin 8 of the PCF8563 IC (measure from ground to pin 8)?

Either way, looking at the datasheet the control registers can be set to default values by writing them. Replacing the following line in the code will also update the control registers:


725 I2CSEND i2caddr, 0, 10, 0, 0, 0, seconds, minutes, hours, day, rtcwday, month, year



regards

Gerard (vk3cg/vk3grs)

Regards

Gerard (vk3cg/vk3grs)
 
jman

Guru

Joined: 12/06/2011
Location: New Zealand
Posts: 711
Posted: 07:55pm 10 Aug 2011
Copy link to clipboard 
Print this post

Hi
Removing the jumper dissconnects the battery
For normal use move the jumper to the batt position

Thanks for code update Gerard i set my 8563 registers previous to using wr8563
:)

I can confirm this line fixs the register setup problem
725 I2CSEND i2caddr, 0, 10, 0, 0, 0, seconds, minutes, hours, day, rtcwday, month, year


Regards

John
 
heppy36

Regular Member

Joined: 29/07/2011
Location: Australia
Posts: 54
Posted: 09:20pm 10 Aug 2011
Copy link to clipboard 
Print this post

Thanks Gerard,but its still the sames as the Pic I sent,I think my ebay unit was probley a friday one,I will order another as other people seem to be working fine.
I was going to get 2 (should off)
Thanks again for all your help,realy is a appreciated
Martin
Heppy
 
seco61
Senior Member

Joined: 15/06/2011
Location: Australia
Posts: 205
Posted: 10:06pm 10 Aug 2011
Copy link to clipboard 
Print this post

Hi.

While it may be a dodgy unit, if you would like to send the unit to me I will put the logic analyser on it and check what is being sent and received from the unit. I will send it back with the results of the test.

If this is of interest send me a private message (PM).

I have also ordered a couple of units to test with.

regards

Gerard (vk3cg/vk3grs)

Regards

Gerard (vk3cg/vk3grs)
 
jman

Guru

Joined: 12/06/2011
Location: New Zealand
Posts: 711
Posted: 08:27am 11 Aug 2011
Copy link to clipboard 
Print this post

Hi

I have tried the below code (with Gerard's fix) on a never before used chip and it works
To set the time and date

600 ' Get time from time$ and date$
610 tempdec = VAL(LEFT$(TIME$, 2))
615 GOSUB 1100
617 hours = hex
620 tempdec = VAL(MID$(TIME$, 4, 2))
625 GOSUB 1100
627 minutes = hex
630 tempdec = VAL(RIGHT$(TIME$, 2))
635 GOSUB 1100
637 seconds = hex
640 tempdec = VAL(LEFT$(DATE$, 2))
645 GOSUB 1100
647 day = hex
650 tempdec = VAL(MID$(DATE$, 4, 2))
655 GOSUB 1100
657 month = hex
660 tempdec = (VAL(RIGHT$(DATE$, 4)) - 2000)
665 GOSUB 1100
667 year = hex
670 ' rtcctrl = &h10
680 rtcwday= &h1
690 ' Write Time to RTC
700 i2caddr = &h51 ' PCF8563 I2C address
710 I2CEN 100,100 ' Enable I2C
725 I2CSEND i2caddr, 0, 10, 0, 0, 0, seconds, minutes, hours, day, rtcwday, month, year
730 I2CDIS
770 ? "0=ok 1=nack 2=timeout"; MM.I2C
780 END

1100 ' Convert to Hex
1110 hex = FIX(tempdec / 10) * 16
1120 hex = hex OR ((tempdec / 10) - (FIX(tempdec / 10))) * 10
1140 RETURN


To read the time and date

100 ' I2C RTC based On PCF8563 Secs,Mins,Hours,Day,Date,Month,Year
200 DIM RTCbuff(255)
220 i2caddr = &h51 ' PCF8563 I2C address
250 I2CEN 100,100 ' Enable I2C
260 I2CRCV i2caddr, 0, 7, RTCbuff(0), 1, 2
265 I2CDIS
270 BCDTEMP = RTCBuff(0) AND &H7F ' Mask unwanted bits
280 GOSUB 1000
290 sec$ = STR$(decimal)
295 BCDTEMP = RTCBuff(1) AND &H7F ' Mask unwanted bits
300 GOSUB 1000
305 min$ = STR$(decimal)
310 BCDTEMP = RTCBuff(2) AND &H3f ' Mask unwanted bits
315 GOSUB 1000
320 hours$ = STR$(decimal)
325 BCDTEMP = RTCBuff(3) AND &H3f ' Mask unwanted bits
330 GOSUB 1000
340 day$ = STR$(decimal)
350 BCDTEMP = RTCBuff(5) AND &h1F ' Mask unwanted bits
360 GOSUB 1000
370 month$ = STR$(decimal)
380 bcdtemp = rtcbuff(6)
390 GOSUB 1000
400 year$ = STR$(decimal + 2000 )
440 t$ = hours$+":"+min$+":"+sec$
442 D$ = day$+"/"+month$+"/"+year$
445 TIME$ = T$
446 DATE$ = D$
450 ? "Time has been set to ";T$
460 ?"Date has been set to ";D$
500 END

1000 ' Convert to Decimal
1010 Decimal = FIX(BCDTemp / 16) * 10
1020 Decimal = Decimal + (BCDTEMP AND &hF)
1030 RETURN


Hope this helps

JmanEdited by jman 2011-08-12
 
heppy36

Regular Member

Joined: 29/07/2011
Location: Australia
Posts: 54
Posted: 08:38am 11 Aug 2011
Copy link to clipboard 
Print this post

Thanks I gave it try ,but still no luck.
Gerard if you message me your details I will send it to you,see if you can see if it me or it!!
Thanks again Martin
Heppy
 
seco61
Senior Member

Joined: 15/06/2011
Location: Australia
Posts: 205
Posted: 10:43am 15 Aug 2011
Copy link to clipboard 
Print this post

Hi Martin.

I received your RTC module today and have connected it to one of my maximite's, as well as to the logic analyser.

It is working beautifully! It is keeping time and all the I2C data communications are correct. I am running it off the internal battery.

I also connected a scope and frequency meter to the external clock out pin (along with a 30K pullup resistor) and it is showing a nice square wave at 32.76892kHz (which is a little fast - it will gain time at around 1 second every 10 hours).

I will send it back to you tomorrow.

Regards

Gerard (vk3cg/vk3grs)
 
pcaffalldavis

Senior Member

Joined: 17/10/2011
Location: United States
Posts: 187
Posted: 03:50am 17 Oct 2011
Copy link to clipboard 
Print this post

Hello everyone. Newbie here from Alaska. I read this thread and the other RTC one and was hoping for a summary as I seem to have gotten confused.

The PFC8653 is still available on ebay, though it looks a bit different. Link here:


http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=250846999 759&category=4661&_trksid=p5197.c0.m619

What I want to know or find is a complete set of installation instructions to put it on a SD1 DonTronics Maximite. I could use a list of basic coding to set it's date and time. One person on this thread seems to have had lots of troubles getting it going. Have others had it work straight away? And if there is a need to modify the PCB by cutting two connection points did everyone need to do this?

Is it true, that once it is working that any time the Maximite is turned on or powered up the date$ and time$ will reflect the current time or is there some additional program lines that need to be added to whatever autorun.bas program the Maximite is set to run by default?

Just a bit of overview please if that is possible.

Sorry to be a newbie, but that is what I am. I've been writing Basic code for decades, but this type of project is new to me.

Thank you all.

Pete in Hyder Alaska
We're all here 'cause we're not all there.
 
jman

Guru

Joined: 12/06/2011
Location: New Zealand
Posts: 711
Posted: 04:03am 17 Oct 2011
Copy link to clipboard 
Print this post

Hi Pete

This should do the trick
http://www.ebay.com/itm/PCF8563-RTC-Board-PCF8563-I2C-interf ace-3-3V-battery-/250846999759?pt=LH_DefaultDomain_0&hash=it em3a67a574cf

This device use's the I2C interface you can moount it inside
the case if you use the program header pins to mount the board you will need to
make the PCB modifactions.

The program I use is posted in this thread.
Load it via autorun and your Maximite will allways start with the correct date and time

Regards

John
 
pcaffalldavis

Senior Member

Joined: 17/10/2011
Location: United States
Posts: 187
Posted: 04:38am 17 Oct 2011
Copy link to clipboard 
Print this post

Thanks John.

I just ordered up three of the PCF8563's for my three Dontronic SD1 Maximites.

I'm still not sure where exactly to connect the wires, but that is because I don't know the difference between the I2C and the 26 pin connector. I'm guessing what you are saying is that the I2C connection points are somewhere in the middle of the PCB, not on the 26 pin connector. Like I said, I'm new to this. Maybe the I2C appears different on the Dontronic's boards? If so, I wonder if that means I must cut the connections in different places too? Just wondering. I will get your basic programs next. I saw two in one of the postings. Is that the post you are referring to?

Thanks again,

Pete in Hyder

We're all here 'cause we're not all there.
 
jman

Guru

Joined: 12/06/2011
Location: New Zealand
Posts: 711
Posted: 04:41am 17 Oct 2011
Copy link to clipboard 
Print this post

Hi Pete

This device is connected just like any other I2C device

Pin 12 maps to MCU pin 43 (SDA1) and pin 6 on the I/O connector (revised schematic) or pin 21 (original schematic).
Pin 13 maps to MCU pin 44 (SCL1) and pin 8 on the I/O connector (revised schematic) or pin 19 (original schematic).

The PCF8563 has built in pullup resistors to the VCC line so no need for those
You can get +5V from I/O connector pin 23 (revised schematic) or pin 3 (original schematic). A ground will also have to be run to the I2C device (I/O connector pins 1,2,25,26).

This device will also run from 3.3V in that case pin 24 (revised schematic) or pin 4 (original schematic)

So the short answer is yes the I2C signals are avaiable on the 26 pin connector

John
 
pcaffalldavis

Senior Member

Joined: 17/10/2011
Location: United States
Posts: 187
Posted: 06:07am 17 Oct 2011
Copy link to clipboard 
Print this post

Okay John. Thank you. I think I understand.

So if I choose to permanently wire it in inside to MCU pins 43 & 44 is that the reason folks cut the PCB after these connections? To prevent any other connections to these same two I/O connectors since they have been permanently used for the clock?

Pete
We're all here 'cause we're not all there.
 
Keith W.
Senior Member

Joined: 09/10/2011
Location: Australia
Posts: 118
Posted: 12:37pm 17 Oct 2011
Copy link to clipboard 
Print this post

Hi
Are RTC’s in the news again?
I have built a small printed circuit using the Lazer Toner method for a M41T11 Real Time Chip purchased from Rockby Electronics, On-Special at 5 for $5. Crystals at 76c each, stock number 26005.
The chips pin out and registers and I2C address are almost exactly as the DS1307 but this chip enables more precise calibration via the control register. I have not tried this yet. A suggested method requires running the clock for a month and then determining the correction required.
My time-read program is built upon the work of others but I have added day of the week display, see below. Note that the string containing day names must have 9 characters for each day as Wednesday has 9 characters. I think no changes are required to run this program with a DS1307 RTC.

I have added to the SETTIME program to ask for the day (1 to 7) and then set the day byte in the message to the RTC. The control byte for M41T11 is different to the DS1307. Set rtcctrl to &H40 to enable the frequency test output pin. If used output pin requires an external pull-up and 150 Hz output only.

10 ' Read I2C RTC (M41T11) for Secs,Mins,Hours,Day,Date,Month,Year,Control
20 '
30 DIM RTCBuff(64) ' Allows for RTC's 56 byte ram also, but ram not used here
40 DIM Regs$(8) 'Save strings created from RTC's 8 registers here
50 '
60 i2caddr = &h68 ' M41T11 I2C address = &B1101000X shifted 1 bit right
70 I2CEN 100,100 ' Enable I2C @ 100 KHz and 100 Ms timeout
80 I2CRCV I2CADDR, 0, 8, RTCBuff(0), 1, 0 ' Read 8 bytes from RTC chip
90 I2CDIS ' Disable I2C
100 '
110 FOR i = 0 TO 7 ' Convert 8 Hex bytes to 8 strings in Regs$ array
120 Decimal = FIX(RTCBuff(i) / 16) * 10 ' Most sig nibble
130 Regs$(i) = STR$(Decimal + (RTCBuff(i) AND &H0F)) ' + least sig nibble
140 NEXT i
150 '
160 Regs$(6) = STR$(VAL(Regs$(6)) + 2000 ) 'Add 2000 to RTC Year
170 '
180 TIME$ = Regs$(2) + ":" + Regs$(1) + ":" + Regs$(0) ' Set the Maximite Time
190 DATE$ = Regs$(4) + "/" + Regs$(5) + "/" + Regs$(6) ' and Date
200 '
210 PRINT : PRINT " ....Maximite Clock set from RTC...." : PRINT
220 PRINT "Maximite Time has been set to " ; TIME$ : PRINT ' From Maximite
230 '
240 Days$ = "Sunday Monday Tuesday WednesdayThursday Friday Saturday "
250 dayoffset = ((RTCBuff(3) - 1) * 9) + 1 ' Multiply day of week * 9 + 1
260 Today$ = MID$(Days$,dayoffset,9) ' take required 9 characters from Days$
270 '
280 PRINT " Today is " + Today$ + ".. Date " ; DATE$
290 END

Keith W.
 
roleyrev
Newbie

Joined: 13/10/2011
Location: New Zealand
Posts: 8
Posted: 07:18pm 17 Oct 2011
Copy link to clipboard 
Print this post

  jman said   Hi Sparkey

In the SM1 circuit diagram the RTC is show.
So just get the bits and add them.

John





I like this idea, Is there a kit of parts for this? or will I have to do a mouser special

Cheers

Roleyrev
 
Greg Fordyce
Senior Member

Joined: 16/09/2011
Location: United Kingdom
Posts: 153
Posted: 08:27pm 17 Oct 2011
Copy link to clipboard 
Print this post

My understanding is that the SM1 rtc circuit isn't supported by the current firmware. I would wait for 2.7 and see if this changes.
 
jman

Guru

Joined: 12/06/2011
Location: New Zealand
Posts: 711
Posted: 07:05am 01 Nov 2011
Copy link to clipboard 
Print this post

8563 files in a zip as requested

John
2011-11-01_170454_8563.zip
 
VK6MRG

Guru

Joined: 08/06/2011
Location: Australia
Posts: 347
Posted: 08:24am 01 Nov 2011
Copy link to clipboard 
Print this post

I've got my setup described in this thread. <<HERE>>

Hope it helps to spell it out a bit better.
Its easier to ask forgiveness than to seek permission!

............VK6MRG.............VK3MGR............
 
centrex

Guru

Joined: 13/11/2011
Location: Australia
Posts: 320
Posted: 08:09pm 13 Nov 2011
Copy link to clipboard 
Print this post

Can someone tell me how you determine the i2caddr from the rtc data sheets.
ie i2cadr = &H68

thanks centrex
Cliff
 
crackerjack

Senior Member

Joined: 11/07/2011
Location: Australia
Posts: 164
Posted: 10:35pm 13 Nov 2011
Copy link to clipboard 
Print this post

Look for the Data Read/ Write Slave address. See figures 4,5,6 in the Maxim datasheet. The address is given in binary: 1101000 which is &h68. This is for a DS1307. But the idea is to look for the Slave Address in the datasheets.
 
     Page 3 of 4    
Print this page
© JAQ Software 2024