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: 783 times
Been thanked: 223 times
Contact:

Re: DS1307 - RTC Time Keeper

Post by acestu »

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: 25 times
Been thanked: 188 times
Contact:

Re: DS1307 - RTC Time Keeper

Post by Jordy101091 »

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
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: 783 times
Been thanked: 223 times
Contact:

Re: DS1307 - RTC Time Keeper

Post by acestu »

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: 364 times
Been thanked: 716 times
Contact:

Re: DS1307 - RTC Time Keeper

Post by JohnCrow »

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/mmforum ... 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.
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: 783 times
Been thanked: 223 times
Contact:

Re: DS1307 - RTC Time Keeper

Post by acestu »

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 62052 times
RTC2.JPG
RTC2.JPG (241.04 KiB) Viewed 62052 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: 25 times
Been thanked: 188 times
Contact:

Re: DS1307 - RTC Time Keeper

Post by Jordy101091 »

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: 783 times
Been thanked: 223 times
Contact:

Re: DS1307 - RTC Time Keeper

Post by acestu »

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: 25 times
Been thanked: 188 times
Contact:

Re: DS1307 - RTC Time Keeper

Post by Jordy101091 »

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: 783 times
Been thanked: 223 times
Contact:

Re: DS1307 - RTC Time Keeper

Post by acestu »

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: 25 times
Been thanked: 188 times
Contact:

Re: DS1307 - RTC Time Keeper

Post by Jordy101091 »

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.
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: 783 times
Been thanked: 223 times
Contact:

Re: DS1307 - RTC Time Keeper

Post by acestu »

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: 783 times
Been thanked: 223 times
Contact:

Re: DS1307 - RTC Time Keeper

Post by acestu »

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: 364 times
Been thanked: 716 times
Contact:

Re: DS1307 - RTC Time Keeper

Post by JohnCrow »

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.
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: 783 times
Been thanked: 223 times
Contact:

Re: DS1307 - RTC Time Keeper

Post by acestu »

Hi,

I have just added the new DS1307 component and when I tried to program my chip I got this error:
compile-error.png
(10.34 KiB) Downloaded 8981 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: 364 times
Been thanked: 716 times
Contact:

Re: DS1307 - RTC Time Keeper

Post by JohnCrow »

Hi Stuart
I got that first time

Check you are using a string in DayOfTheWeek
DS1307-TimeSwitch2-PIC.fcfx
(13.57 KiB) Downloaded 2158 times
DS1307-TimeSwitch2-PIC-no_program.fcfx
(13.67 KiB) Downloaded 2161 times


Ive tried V1.5 and V1.6

Attached are in V1.6

no program just reads the RTC
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: 783 times
Been thanked: 223 times
Contact:

Re: DS1307 - RTC Time Keeper

Post by acestu »

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: 783 times
Been thanked: 223 times
Contact:

Re: DS1307 - RTC Time Keeper

Post by acestu »

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 2167 times
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: 783 times
Been thanked: 223 times
Contact:

Re: DS1307 - RTC Time Keeper

Post by acestu »

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: 474 times
Been thanked: 458 times
Contact:

Re: DS1307 - RTC Time Keeper

Post by dazz »

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

Regards
Dazz
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: 783 times
Been thanked: 223 times
Contact:

Re: DS1307 - RTC Time Keeper

Post by acestu »

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: 474 times
Been thanked: 458 times
Contact:

Re: DS1307 - RTC Time Keeper

Post by dazz »

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
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: 783 times
Been thanked: 223 times
Contact:

Re: DS1307 - RTC Time Keeper

Post by acestu »

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: 364 times
Been thanked: 716 times
Contact:

Re: DS1307 - RTC Time Keeper

Post by JohnCrow »

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 2063 times
PLC-RTC.jpg
PLC-RTC.jpg (53.82 KiB) Viewed 61988 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: 25 times
Been thanked: 188 times
Contact:

Re: DS1307 - RTC Time Keeper

Post by Jordy101091 »

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: 364 times
Been thanked: 716 times
Contact:

Re: DS1307 - RTC Time Keeper

Post by JohnCrow »

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 !

Post Reply