The Godfather talking
Share your stuff or I will make you regret it.
Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
November 29, 2024, 01:27:38 13:27


Login with username, password and session length


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

Posts: 44

Thank You
-Given: 13
-Receive: 4


« on: February 25, 2014, 05:19:58 17: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: 173

Thank You
-Given: 122
-Receive: 254


« Reply #1 on: February 25, 2014, 05:45:29 17: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
Senior Member
****
Offline Offline

Posts: 432

Thank You
-Given: 284
-Receive: 1654



WWW
« Reply #2 on: February 25, 2014, 06:50:41 18: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
Senior Member
****
Offline Offline

Posts: 282

Thank You
-Given: 1005
-Receive: 101


« Reply #3 on: February 25, 2014, 08:23:48 20: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
**
Offline Offline

Posts: 89

Thank You
-Given: 101
-Receive: 26


« Reply #4 on: February 25, 2014, 08:49:51 20: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, 08:59:53 20:59 by gan_canny » Logged
cadence
Junior Member
**
Offline Offline

Posts: 93

Thank You
-Given: 103
-Receive: 430



« Reply #5 on: February 27, 2014, 03:24:44 03: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
Senior Member
****
Offline Offline

Posts: 432

Thank You
-Given: 284
-Receive: 1654



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

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

Posts: 4667

Thank You
-Given: 834
-Receive: 4323


There is no evidence that I muted SoNsIvRi


« Reply #7 on: March 06, 2014, 01:20:39 13:20 »

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

Note: I stoped Muteing bad members OK I now put thier account in sleep mode
jobitjoseph1
Junior Member
**
Offline Offline

Posts: 44

Thank You
-Given: 18
-Receive: 178


« 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
*
Offline Offline

Posts: 11

Thank You
-Given: 0
-Receive: 4


« Reply #9 on: May 10, 2014, 10:38:31 22: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: 130

Thank You
-Given: 121
-Receive: 565



« Reply #10 on: May 23, 2014, 09:24:15 21: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