The Godfather talking
You can run, but you can't hide.
Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 05, 2016, 01:24:32 01:24


Login with username, password and session length


Pages: [1]
Print
Author Topic: Help with Real Time Clock DS1307  (Read 2613 times)
0 Members and 1 Guest are viewing this topic.
lou
Junior Member
**
Offline Offline

Posts: 39

Thank You
-Given: 14
-Receive: 3


« on: February 25, 2014, 06:19:58 18:19 »

I'm working on a modified version of the Temperature Logger http://www.sonsivri.to/forum/index.php?topic=55425.0.  The circuit uses a DS1307 Real Time Clock, and I'm having a real hard time understanding how to program the time into the DS1307 chip.  Everything that I can find on the net uses Arduino AVR programmer to set the clock.  I have barely got around to program a PIC, little lone start on a new type of programmer. Can anyone help me on a simple method of setting the time on this Real Time Clock ??  The clock module that I will be using is from eBay  http://www.ebay.com/itm/New-RTC-I2C-DS1307-AT24C32-Real-Time-Clock-Module-For-Arduino-AVR-PIC-51-ARM-/390647079687?pt=LH_DefaultDomain_0&hash=item5af4616307.

Thanks, Lou
Logged
xpress_embedo
Active Member
***
Offline Offline

Posts: 153

Thank You
-Given: 103
-Receive: 188


WWW
« Reply #1 on: February 25, 2014, 06:45:29 18:45 »

Ds1307 works on i2c protocol.
So first of all you should learn about i2c protocol, mikroc has inbuilt function for this.

Then initially you have to set the time by any means and then after that place a 3.3v battery on rtc battery backup pin, and it will retain and increment the value.

Posted on: February 25, 2014, 06:38:19 18:38 - Automerged

In the temperature logger project, i had posted there is full code for DS1307, but the problem for you is that how you will set initial time and date.
My advice for this is that, use serial port and send a packet which contains time and date information, and on controller end decode this packet and extract time and date information then write it to rtcc.
Logged
Catcatcat
Active Member
***
 Warned
Offline Offline

Posts: 117

Thank You
-Given: 88
-Receive: 258



WWW
« Reply #2 on: February 25, 2014, 07:50:41 19:50 »

All chip clock work almost identically, there are small differences. For example, the program to work, look, maybe something useful. http://catcatcat.d-lan.dp.ua/skachat/primeryi-postroeniya-koda-programm-dlya-pic-kontrollerov/chasyi-realnogo-vremeni-m41t56/
Logged
Unhappy
V.I.P
Active Member
*****
Offline Offline

Posts: 200

Thank You
-Given: 369
-Receive: 52


« Reply #3 on: February 25, 2014, 09:23:48 21:23 »

All chip clock work almost identically, there are small differences. For example, the program to work, look, maybe something useful. http://catcatcat.d-lan.dp.ua/skachat/primeryi-postroeniya-koda-programm-dlya-pic-kontrollerov/chasyi-realnogo-vremeni-m41t56/
Dear catcatcat
That page is in cyrillics any with english language please
Logged
gan_canny
Junior Member
**
 Warned
Offline Offline

Posts: 85

Thank You
-Given: 98
-Receive: 25


« Reply #4 on: February 25, 2014, 09:49:51 21:49 »

Well something to be aware of is the notation used for the Ds1307. The notation represents time and date as BCD ( Binary code decimal). A notational issue is the hours..12 hour and 24 hour are encoded differently and the days of the week notation (1..7).

With BCD the nibble ( 4 bits) notate a number 0..9 so the most significant nibble is ten times the value of the least significant nibble.

Now odds are that your microcomputer is binary with word lengths  8 16 24 32 etc.
You will need to convert the notation from BCD when reading the DS1307 and the reverse when writing.
This is a number base conversion but since time and date are whole numbers no notational inaccuracies will occur.
So take the most significant BCD digit shift it left 3 times to get a multiply by 8(decimal) and add the digit back in after shifting left one time ( 8+2=10) then add in the least significant BCD digit to get a binary notation of the BCD notation.

As mentioned above data move into and out of the ds1307 via an electrical convention I2C....This is a serial protocol with a data line and a clock line....Since I2C is a shared interface any connected device has to be able to drive the line down to ground..this means devices don't drive the line high ..instead pull up resistors are used.
I2C needs pull up resistors about 2k to 4k. Next the ds1307 has a battery backup so the power supplied must equal or exceed the battery voltage when accessing the device.
« Last Edit: February 25, 2014, 09:59:53 21:59 by gan_canny » Logged
cadence
V.I.P
Junior Member
*****
Offline Offline

Posts: 92

Thank You
-Given: 103
-Receive: 428



« Reply #5 on: February 27, 2014, 04:24:44 04:24 »

Take a look at the examples file Mikroelektronika provides for free for use with their range of compilers at the following link:

http://www.mikroe.com/downloads/get/258/rtc2_examples.zip

It's for their RTC breakout board based on the DS1307 (http://www.mikroe.com/add-on-boards/rtc/rtc2/), but the examples provided are in Basic, Pascal and C for a range of different micros - including the PIC.  They're are also small enough to compile in the demo versions of their compilers too.

The Mikroe page also includes a link to the Maxim site where there's a link to App Note 3921:  Using a DS1307 with a PIC Microcontroller.

Hope this helps.
Logged
Catcatcat
Active Member
***
 Warned
Offline Offline

Posts: 117

Thank You
-Given: 88
-Receive: 258



WWW
« Reply #6 on: February 27, 2014, 07:58:43 07:58 »

Dear catcatcat
That page is in cyrillics any with english language please
Right switch from Google Translator Technology
Logged
pickit2
Moderator
Hero Member
*****
Offline Offline

Posts: 3816

Thank You
-Given: 567
-Receive: 2049


There is no evidence that I muted SoNsIvRi


« Reply #7 on: March 06, 2014, 02:20:39 14:20 »

here his the full circuit for the Tiny RTC pcb that is on ebay and other sites.
Logged

Note: If you have no posts other than, I want or reporting a dead link Then you can't complain If I remove your post So Stop Leeching
jobitjoseph1
Newbie
*
Offline Offline

Posts: 24

Thank You
-Given: 9
-Receive: 17


« Reply #8 on: March 15, 2014, 03:47:20 15:47 »

You have to load the time value to the chips registers through i2c protocol
Logged
user77
Newbie
*
 Muted
Offline Offline

Posts: 11

Thank You
-Given: 0
-Receive: 4


« Reply #9 on: May 10, 2014, 11:38:31 23:38 »

to start oscillator remember that you must set to 0 the CH bit (the most important bit of second byte) to do this you can mask second byte with 7F (AND between second value and 7F).
Logged
Crackn
Active Member
***
Offline Offline

Posts: 106

Thank You
-Given: 71
-Receive: 408



« Reply #10 on: May 23, 2014, 10:24:15 22:24 »

Hello,

 the easy way to set the time/date to rtc module is using an arduino board and a DS1307 example sketch named Set Time. just open the arduino ide and load the example. you will need an arduino and an usb cable to play with.

cya
Logged
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC