DS1307 - RTC Time Keeper

A forum where Flowcode v6 user created components can be shared, discussed and reviewed.

Moderator: Benj

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 787 times
Been thanked: 226 times
Contact:

Re: DS1307 - RTC Time Keeper

Postby acestu » Wed Nov 27, 2013 6:24 pm

Hi guys,

What am I doing wrong here :? , I have just received 2 x new RTC modules, so I wired one up and programmed the chip, but when I power on

The time says 45:85 and the date is 45/25/165

I have it wired up like so:

VCC TO +5 VOLTS
GND TO -5VOLTS
SCK TO PIN 18 OF CHIP
I/O TO PIN 23 OF THE CHIP

RST NOT CONNECTED


Is this correct ?

cheers
Acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

User avatar
Jordy101091
Posts: 519
Joined: Sat Jan 08, 2011 4:02 pm
Location: The Netherlands
Has thanked: 27 times
Been thanked: 190 times
Contact:

Re: DS1307 - RTC Time Keeper

Postby Jordy101091 » Wed Nov 27, 2013 7:23 pm

acestu wrote:Hi guys,

What am I doing wrong here :? , I have just received 2 x new RTC modules, so I wired one up and programmed the chip, but when I power on

The time says 45:85 and the date is 45/25/165

I have it wired up like so:

VCC TO +5 VOLTS
GND TO -5VOLTS
SCK TO PIN 18 OF CHIP
I/O TO PIN 23 OF THE CHIP

RST NOT CONNECTED


Is this correct ?

cheers
Acestu


I hope you did not applied a negative voltage to the GND pin of you module, I think you mean GND TO 0V.
I don't know the module youre working with but the RST and I think that is the RESET, you cannot let this hanging in the breeze. You need to make sure its a known state.

Secondly, the battery backup are u using a backup battery, with out the voltage at the battery input pin being HIGH to 3.3V or connected to Ground the DS1307 will not operate.

I hope this helps you if not let me know.

Regards Jordy
These users thanked the author Jordy101091 for the post:
acestu (Wed Nov 27, 2013 8:05 pm)
Rating: 5.88%
 
the will to learn, should not be stopped by any price

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 787 times
Been thanked: 226 times
Contact:

Re: DS1307 - RTC Time Keeper

Postby acestu » Wed Nov 27, 2013 7:48 pm

Hi Jordy,

Well the RTC units that I have just received are DS1302 and It looks like these are not i2c, I have also changed 2 pull up resisters on the chip i2c pins as they were not 4.7k, I connected an rtc module that I have been using a couple of months ago, now when I power up everything on the lcd is as it should be, however when I power off the board then back on the time starts from the beginning, the rtc module is a sparkfun one with only 5 pins and the only one not connected is a SQW pin, should this be connected to anything ?


cheers
Acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

User avatar
JohnCrow
Valued Contributor
Valued Contributor
Posts: 1367
Joined: Wed Sep 19, 2007 1:21 pm
Location: Lincolnshire
Has thanked: 381 times
Been thanked: 713 times
Contact:

Re: DS1307 - RTC Time Keeper

Postby JohnCrow » Wed Nov 27, 2013 7:52 pm

Hi Stuart

Sorry but you have confused me slightly by saying module.

Do you mean a DS1307 (8 pin chip) or a RTC clock module that is compatible with this.

http://www.matrixmultimedia.com/mmforums/viewtopic.php?f=29&t=8607&hilit=+rtc

My old project shows how I have it wired up.
Using a 16F877A

SCL = PORT C3
SDA = PORT C4

If I remember correctly, I got that error when I first started playing with the chip, Id not connected the I2C lines to 5V with the pull-up resistors.
These users thanked the author JohnCrow for the post:
acestu (Wed Nov 27, 2013 8:05 pm)
Rating: 5.88%
 
1 in 10 people understand binary, the other one doesn't !

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 787 times
Been thanked: 226 times
Contact:

Re: DS1307 - RTC Time Keeper

Postby acestu » Wed Nov 27, 2013 8:04 pm

Hi John,

I only have modules with everything already on there for a hopefully functioning RTC unit, the one I have on the board at the moment I have used in another project, but now I can't get it to keep time when I power off the main supply...

RTC1.JPG
RTC1.JPG (214.77 KiB) Viewed 7067 times

RTC2.JPG
RTC2.JPG (241.04 KiB) Viewed 7067 times


cheers
Acestu

P.S. Yes Jordy the GND on the RTC module is connected to 0v
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

User avatar
Jordy101091
Posts: 519
Joined: Sat Jan 08, 2011 4:02 pm
Location: The Netherlands
Has thanked: 27 times
Been thanked: 190 times
Contact:

Re: DS1307 - RTC Time Keeper

Postby Jordy101091 » Wed Nov 27, 2013 8:46 pm

Hi acestu,

do you still have trouble get the module from sparkfun to work properly?
the will to learn, should not be stopped by any price

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 787 times
Been thanked: 226 times
Contact:

Re: DS1307 - RTC Time Keeper

Postby acestu » Wed Nov 27, 2013 8:52 pm

Hi Jordy,

Everything works fine with the sparkfun module apart from keeping time, surely the battery shouldn't be flat they are supposed to last for about 9 years...

cheers
Acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

User avatar
Jordy101091
Posts: 519
Joined: Sat Jan 08, 2011 4:02 pm
Location: The Netherlands
Has thanked: 27 times
Been thanked: 190 times
Contact:

Re: DS1307 - RTC Time Keeper

Postby Jordy101091 » Wed Nov 27, 2013 8:55 pm

I know why this is happening when you power down you PIC. and the DS1307 is still running on battery power.
When you reconnect the power to the PIC the DS1307 is re-initialized and the date and time are reprogramed with the initial value you first programed.

I don't know if this is fault of the component (My side) or this has to be worked around in you own code.

Let me know what you think,

Regards Jordy
the will to learn, should not be stopped by any price

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 787 times
Been thanked: 226 times
Contact:

Re: DS1307 - RTC Time Keeper

Postby acestu » Wed Nov 27, 2013 9:01 pm

Hi Jordy,

I think John has built the circuit, if he has and the time keeps updating after a power recycle then it cannot be your code, I will PM John and ask him ....

cheers
Acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

User avatar
Jordy101091
Posts: 519
Joined: Sat Jan 08, 2011 4:02 pm
Location: The Netherlands
Has thanked: 27 times
Been thanked: 190 times
Contact:

Re: DS1307 - RTC Time Keeper

Postby Jordy101091 » Wed Nov 27, 2013 9:06 pm

I have updated the component to version V1.6

it now includes a property that return the Day of week as a string type.

the return format can be chosen as follow:

Number: returns a string representing the number that corresponds to the day of week so for 1 = sunday 2 = Monday and so on.
First three Chars: Sun, Mon, Tue and so on
Whole Word: Sunday, Monday, Tuesday and so on.

You can download the component ad the start post.
These users thanked the author Jordy101091 for the post (total 2):
acestu (Wed Nov 27, 2013 9:12 pm) • JohnCrow (Wed Nov 27, 2013 9:40 pm)
Rating: 11.76%
 
the will to learn, should not be stopped by any price

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 787 times
Been thanked: 226 times
Contact:

Re: DS1307 - RTC Time Keeper

Postby acestu » Wed Nov 27, 2013 9:12 pm

Hi Jordy,

Thanks for the new version, that's brilliant, also once I get the timer to keep time I can help you with the help documentation and or video if you require.....

cheers
Acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 787 times
Been thanked: 226 times
Contact:

Re: DS1307 - RTC Time Keeper

Postby acestu » Wed Nov 27, 2013 9:18 pm

Hi Jordy,

Of course you are right, I need to use the eeprom in my code so that the time and date set procedure is only run once.....DOH ! :oops:

Sorry, I am only a novice


thanks
Acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

User avatar
JohnCrow
Valued Contributor
Valued Contributor
Posts: 1367
Joined: Wed Sep 19, 2007 1:21 pm
Location: Lincolnshire
Has thanked: 381 times
Been thanked: 713 times
Contact:

Re: DS1307 - RTC Time Keeper

Postby JohnCrow » Wed Nov 27, 2013 9:46 pm

Hi

Just realised the same thing.
Once I re-power the PIC it runs the whole code and resets everything:)
Just commented the icons that set time and date out, with the DS1307 programmed and all works fine.

Thanks Jordy, this component is getting better all the time.
These users thanked the author JohnCrow for the post:
acestu (Wed Nov 27, 2013 9:59 pm)
Rating: 5.88%
 
1 in 10 people understand binary, the other one doesn't !

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 787 times
Been thanked: 226 times
Contact:

Re: DS1307 - RTC Time Keeper

Postby acestu » Wed Nov 27, 2013 9:59 pm

Hi,

I have just added the new DS1307 component and when I tried to program my chip I got this error:

compile-error.png
compile-error.png (10.34 KiB) Viewed 7057 times


EDIT: John did you install the new component before you reprogrammed your chip ?

cheers
Acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

User avatar
JohnCrow
Valued Contributor
Valued Contributor
Posts: 1367
Joined: Wed Sep 19, 2007 1:21 pm
Location: Lincolnshire
Has thanked: 381 times
Been thanked: 713 times
Contact:

Re: DS1307 - RTC Time Keeper

Postby JohnCrow » Wed Nov 27, 2013 10:03 pm

Hi Stuart
I got that first time

Check you are using a string in DayOfTheWeek

DS1307-TimeSwitch2-PIC.fcfx
(13.57 KiB) Downloaded 181 times


DS1307-TimeSwitch2-PIC-no_program.fcfx
(13.67 KiB) Downloaded 175 times


Ive tried V1.5 and V1.6

Attached are in V1.6

no program just reads the RTC
These users thanked the author JohnCrow for the post (total 2):
acestu (Wed Nov 27, 2013 10:17 pm) • medelec35 (Wed Nov 27, 2013 11:36 pm)
Rating: 11.76%
 
1 in 10 people understand binary, the other one doesn't !

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 787 times
Been thanked: 226 times
Contact:

Re: DS1307 - RTC Time Keeper

Postby acestu » Wed Nov 27, 2013 10:17 pm

Hi John,

I would do but I can't open Flowcode now, I am going to reboot and try again, report back in a little while....

cheers
Acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 787 times
Been thanked: 226 times
Contact:

Re: DS1307 - RTC Time Keeper

Postby acestu » Wed Nov 27, 2013 10:59 pm

Hi Guys,

Ok everything is working now, component is excellent now Jordy, I am enclosing my chart for those who want to have a go at this project, also if anyone wants the wiring diagram just ask in this post and I will upload one..... :D


Cheers
Acestu


Timeswitch_V1.fcfx
(14.94 KiB) Downloaded 166 times
These users thanked the author acestu for the post:
medelec35 (Wed Nov 27, 2013 11:35 pm)
Rating: 5.88%
 
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 787 times
Been thanked: 226 times
Contact:

Re: DS1307 - RTC Time Keeper

Postby acestu » Wed Nov 27, 2013 11:47 pm

Hi Jordy,

Is it possible to display the seconds with this component ?

cheers
Acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

dazz
Posts: 1314
Joined: Sun Jan 15, 2012 3:15 pm
Has thanked: 514 times
Been thanked: 466 times
Contact:

Re: DS1307 - RTC Time Keeper

Postby dazz » Thu Nov 28, 2013 12:06 am

Hi Mutley
when you do a read theres an option to show seconds you need to enter 1 as a parameter

Regards
Dazz
These users thanked the author dazz for the post:
acestu (Thu Nov 28, 2013 12:20 am)
Rating: 5.88%
 
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 787 times
Been thanked: 226 times
Contact:

Re: DS1307 - RTC Time Keeper

Postby acestu » Thu Nov 28, 2013 12:27 am

Hi Dazz,

how are you doin, (Mutley LOL)

I am just testing the timers, if you want a switch to come on every day would you set Sunday to Sunday or Sunday to Monday ? ,

I have set all ten timers with roughly 5 min intervals and tried both methods above but the timers don't come on, I will investigate further tomorrow...

cheers
Acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

dazz
Posts: 1314
Joined: Sun Jan 15, 2012 3:15 pm
Has thanked: 514 times
Been thanked: 466 times
Contact:

Re: DS1307 - RTC Time Keeper

Postby dazz » Thu Nov 28, 2013 12:50 am

Hi Stu
I thought youd like mutley :lol: , i havent got V6 on my netbook as i suspect if i started connecting boards and programming in bed wendy would kill me :lol:
as far as i can see if you wanted a timer from say 7am to 9pm i think you set it as on time 7am monday and the off time as sunday 9pm, try it like that but with a time of two or 3 minutes to test
Regards
Dazz
These users thanked the author dazz for the post:
acestu (Thu Nov 28, 2013 12:29 pm)
Rating: 5.88%
 
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 787 times
Been thanked: 226 times
Contact:

Re: DS1307 - RTC Time Keeper

Postby acestu » Thu Nov 28, 2013 12:29 pm

Hi Dazz,

Yes I will have a look when I get home, and don't you be upsetting your missus or she will cut your pocket money :lol:

cheers
Acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

User avatar
JohnCrow
Valued Contributor
Valued Contributor
Posts: 1367
Joined: Wed Sep 19, 2007 1:21 pm
Location: Lincolnshire
Has thanked: 381 times
Been thanked: 713 times
Contact:

Re: DS1307 - RTC Time Keeper

Postby JohnCrow » Thu Nov 28, 2013 1:41 pm

I've connected the RTC to my Elektor ECIO-PLC board.

The sample program has been setup to switch the 4 relays on and off in succession.
These are working as expected

I have had to use software I2C as the lines are used on board to drive the CAN controller.
As can be seen these are on the expansion connector at the top of the board.
RE1 = Data
RE2 = Clock

However when I save and reload the flowchart the I2C connections have gone back to the default settings
C4 = Data
C3 = Clock

DS1307-TimeSwitch3-ecio- works.fcfx
(12.52 KiB) Downloaded 163 times


PLC-RTC.jpg
PLC-RTC.jpg (53.82 KiB) Viewed 7003 times
1 in 10 people understand binary, the other one doesn't !

User avatar
Jordy101091
Posts: 519
Joined: Sat Jan 08, 2011 4:02 pm
Location: The Netherlands
Has thanked: 27 times
Been thanked: 190 times
Contact:

Re: DS1307 - RTC Time Keeper

Postby Jordy101091 » Thu Nov 28, 2013 1:49 pm

Hi john,

I need to look into the problem of the pin configuration not saving properly.
So I will investigate this when I get home, I cannot promise that I can update the component later today because I'm also busy with the T6963C component.

Regards Jordy
the will to learn, should not be stopped by any price

User avatar
JohnCrow
Valued Contributor
Valued Contributor
Posts: 1367
Joined: Wed Sep 19, 2007 1:21 pm
Location: Lincolnshire
Has thanked: 381 times
Been thanked: 713 times
Contact:

Re: DS1307 - RTC Time Keeper

Postby JohnCrow » Thu Nov 28, 2013 2:01 pm

Hi Jordy
Not keeping the pins is not too serious, everything else seems to work great.

I have had the issue Stu had with it showing on this board

The time says 45:85 and the date is 45/25/165


The problem is only there when the USB cable is connected.
I'm suspecting it is loading the 5V rail somehow and effecting the pull ups on the I2C bus. Maybe Benj can throw some light on that.
Same which ever way the ECIO power jumper is set.
1 in 10 people understand binary, the other one doesn't !