DS3231 - RTC Time Keeper

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

Moderator: Benj

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:

DS3231 - RTC Time Keeper

Post by Jordy101091 »

DS3231 - Component
Current Version = 1.68
Best Working Version = 1.68



Info:

I have made a DS3231 component which lets you easy use the DS3231 device and configure it. No need to have difficult calculations.
With this component you can just put in your time and date data in decimal values the component takes care of the rest. A nice thing is that you can choose what the behaviour is of the SQW output.
Via a simple pull down menu you can select what the output frequency is.
Also this device with two configurable Alarm settings, with this component it now a peace of cake to configure those as well.
This component uses just 19 component macros:

- Initialise
- DayOfWeek
- ReadDate
- ReadTime
- WriteDate
- WriteTime
- SetAlarm1
- SetAlarm2
- AlarmRate1
- AlarmRate2
- ReadTemperature
- AutoTimeAdjust
- CheckStatus
- ClearAlarms
- ReadDateINT
- ReadTimeINT
- WriteTimeHour
- WriteTimeMinutes
- WriteTimeSeconds

(A help file will be attached for those that doesn't understand the function of every macro)

Component Use:
The component can be used by copying the ".fcpx" file into the component directory of Flowcode v6.
Then component can be found under the tap inputs as DS3231 - RTC.

Future Updates

Future update will include:

...

Suggestion are accepted


Download:

DS3231.fcpx
Component version 1.67
(9.76 KiB) Downloaded 776 times
DS3231.fcpx
Component Version 1.68
(11.71 KiB) Downloaded 1091 times
Log:

v1.6 - Changed the way Checkstatus works, now the Checkstatus macro checks the alarm bits and returns the value to the user. Checkstatus does not clear these bits.
------- Added a new macro ClearAlarm, this macro clears the alarm given in the "Alarm" parameter. This is necessary so that a new event can happen.
v1.65 - Now the alarm functions as well as the alarm clearing routine are working correctly thank to the help of hyperion007
v1.66 - Attempted to fix the issues with the alarm functions.
-------- Made some little changes to the component code to make a little bit better and slightly faster
-------- The RTC now switches to vbat when power is removed and the alarm flags have been cleared.
v1.67 - Added 12 Hour Mode, the user can now select if he want 24 Hr notation or 12 Hour (AM/PM)
v1.68 - Added two new macro which enabled the user to manipulate the alarm rates for both the alarms.

Changing Alarm Rate with Macro's "AlarmRate1 - 2"

AlarmRate1 - MatchCondition Valid inputs between 0 to 5

0 - Alarm once per second
1 - Alarm when seconds match
2 - Alarm when minutes and seconds match
3 - Alarm when hours, minutes and seconds match
4 - Alarm when date, hours, minutes and seconds match
5 - Alarm when day, hours, minutes and seconds match

AlarmRate2 - MatchCondition Valid inputs between 0 to 4

0 - Alarm once per minute (00 seconds of every minute)
1 - Alarm when minutes match
2 - Alarm when hours and minutes match
3 - Alarm when date, hours and minutes match
4 - Alarm when day, hours and minutes match
the will to learn, should not be stopped by any price

hyperion007
Posts: 528
Joined: Sat Dec 01, 2012 1:23 pm
Location: Sweden
Has thanked: 49 times
Been thanked: 101 times
Contact:

Re: DS3231 - RTC Time Keeper (98% Done)

Post by hyperion007 »

I designed a breakout board for the DS3231 on Friday night last week and got that ordered. I also ordered some other components from Mouser this week. I'll test the component as soon as I have all components. Jordy is receiving a complete board as thanks for his efforts. I'll be using the DS3231 RTC as my go-to RTC so a component for it is very nice.

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: DS3231 - RTC Time Keeper (98% Done)

Post by JohnCrow »

Hi Jordy

I've just made up my DS3231 Break Out Board.
After reading the data sheet, I realised the basic functions are the same as the DS1307, so I've just tried it with your (DS1307) component, and it works fine.
DS3231.jpg
DS3231.jpg (81.52 KiB) Viewed 37570 times
1 in 10 people understand binary, the other one doesn't !

hyperion007
Posts: 528
Joined: Sat Dec 01, 2012 1:23 pm
Location: Sweden
Has thanked: 49 times
Been thanked: 101 times
Contact:

Re: DS3231 - RTC Time Keeper (98% Done)

Post by hyperion007 »

I have not received the PCBs yet, nor all components. But here's a preview:
RTC_Preview.jpg
(94.73 KiB) Downloaded 8219 times
CR2032 battery holder on the other side of the board.

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: DS3231 - RTC Time Keeper (98% Done)

Post by Jordy101091 »

Nice looking forward to receive one.
Is it in a fancy color, blue or yellow.

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

hyperion007
Posts: 528
Joined: Sat Dec 01, 2012 1:23 pm
Location: Sweden
Has thanked: 49 times
Been thanked: 101 times
Contact:

Re: DS3231 - RTC Time Keeper (98% Done)

Post by hyperion007 »

It will be purple with ENIG finish. btw, any progress on the vinculum regarding the time and date values for file creation and file modification? ;)

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: DS3231 - RTC Time Keeper (98% Done)

Post by Jordy101091 »

Yes I have added the option to adjust the file creation date.
If I find sometime I will update the component.
the will to learn, should not be stopped by any price

hyperion007
Posts: 528
Joined: Sat Dec 01, 2012 1:23 pm
Location: Sweden
Has thanked: 49 times
Been thanked: 101 times
Contact:

Re: DS3231 - RTC Time Keeper (98% Done)

Post by hyperion007 »

Great! Thanks.

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: DS3231 - RTC Time Keeper (98% Done)

Post by Jordy101091 »

Hyperion7,

I just did A quick test, to see if it was possible to interface to a 120GB SSD Harddrive.
And what do you know, I just works just like a normal USB flash-drive so if anybody needs mass stores for there data logging application you can use a SSD hard drive.
I will post detailed information about that, when I get the time.

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

hyperion007
Posts: 528
Joined: Sat Dec 01, 2012 1:23 pm
Location: Sweden
Has thanked: 49 times
Been thanked: 101 times
Contact:

Re: DS3231 - RTC Time Keeper (Waiting For Test Results)

Post by hyperion007 »

I'm lagging behind but I did receive the circuit boards today. Not the best surface finish unfortunately but hey, it's only cosmetics :)
20140407_202049.jpg
(830.79 KiB) Downloaded 8166 times

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: DS3231 - RTC Time Keeper (Waiting For Test Results)

Post by Jordy101091 »

Looks Good I like it.

Great Job

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

hyperion007
Posts: 528
Joined: Sat Dec 01, 2012 1:23 pm
Location: Sweden
Has thanked: 49 times
Been thanked: 101 times
Contact:

Re: DS3231 - RTC Time Keeper (Waiting For Test Results)

Post by hyperion007 »

I finished one of the three boards today and will test it with the custom component before finishing the other two boards.
1.jpg
(330.47 KiB) Downloaded 8137 times
2.jpg
(157.3 KiB) Downloaded 8137 times

hyperion007
Posts: 528
Joined: Sat Dec 01, 2012 1:23 pm
Location: Sweden
Has thanked: 49 times
Been thanked: 101 times
Contact:

Re: DS3231 - RTC Time Keeper (Waiting For Test Results)

Post by hyperion007 »

I've been testing Jordy's custom component since I got home today and some issues have been discovered and sent to Jordy. These are all regarding the functions of the INT/SQW pin. I'm sure we'll get that sorted in a jiffy.
3.jpg
(285.14 KiB) Downloaded 8115 times

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: DS3231 - RTC Time Keeper

Post by Jordy101091 »

I have updated the component status from testing to released.
The component is now fully functioning.
Thanks to Hyperion007 for his breakout board which made the last bit of testing very easy, thanks to you.

I hope the rest of you enjoy this component.

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

User avatar
Crenwick
Posts: 127
Joined: Sun Aug 07, 2011 1:40 pm
Location: Belgium
Has thanked: 7 times
Been thanked: 21 times
Contact:

Re: DS3231 - RTC Time Keeper

Post by Crenwick »

Hi Jordy,

Many thanks for your work !

I have a question about 12/24h setting. In the DS1307 component we have the HoursFormat variable in WriteTime but I'm unable to to find this item in the DS3231 component.

Is there another trick to change this setting :wink:

Regards,
Last edited by Crenwick on Sun Apr 27, 2014 8:14 am, edited 1 time in total.
Bernard

Flowcode 6 / EB006-V9

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: DS3231 - RTC Time Keeper

Post by Jordy101091 »

I have not yet made this available, in the next release of the component I will make this available.
I not sure when I have some time because I'm starting with a new job.

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: DS3231 - RTC Time Keeper

Post by JohnCrow »

Hi Jordy
Thanks, works great.

FYI I've just tried it with a DS3232 as well on basic Time, Date and Temp functions, works on this device too.

The DS3232 is similar functionally but is not pin for pin compatible (The DS3232 has 20 pins as opposed to 14 for the DS3231)
Will have to study the data sheet closer to see what the differences are.
1 in 10 people understand binary, the other one doesn't !

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: DS3231 - RTC Time Keeper

Post by JohnCrow »

Hi Jordy

I've just been working with your DS3231 component.
Is the alarm option finished as I can add the settings for activating the alarm but the return box stays "greyed out" and Im not able to add a return variable.
Thanks
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: DS3231 - RTC Time Keeper

Post by Jordy101091 »

Hi John,

What do you mean by that, I also cannot see your problem.
As for as I know the macro for setting the alarm time does not have a return value.
Maybe you can be a a little more specific about your problem.

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: DS3231 - RTC Time Keeper

Post by JohnCrow »

Hi Jordy
As for as I know the macro for setting the alarm time does not have a return value.
That's why its greyed out then :)

I can see how to set the time & date for the alarm in the macro settings.
But what I'm not able to see is when the alarm is activated, how do I detect it.
I want to send for example Port A0 High

Thanks
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: DS3231 - RTC Time Keeper

Post by Jordy101091 »

JohnCrow wrote:Hi Jordy
As for as I know the macro for setting the alarm time does not have a return value.
That's why its greyed out then :)

I can see how to set the time & date for the alarm in the macro settings.
But what I'm not able to see is when the alarm is activated, how do I detect it.
I want to send for example Port A0 High

Thanks
If that is what you mean, its is possible to do this with the checkstatus macro, if you take a look at the tooltip you can figure out what to fill in.
But im afraid that there is a nasty bug in it, so I have to make some time to crack it, I didn't have much time this weekend birthdays and mothers day as well.
So I hope I can make some time later this week.

I hope you don't mind.

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

User avatar
Crenwick
Posts: 127
Joined: Sun Aug 07, 2011 1:40 pm
Location: Belgium
Has thanked: 7 times
Been thanked: 21 times
Contact:

Re: DS3231 - RTC Time Keeper

Post by Crenwick »

Or you can also connect the INT/SQW to an external interupt and trigger a macro to check alarm :wink:
Bernard

Flowcode 6 / EB006-V9

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: DS3231 - RTC Time Keeper

Post by Jordy101091 »

Crenwick wrote:Or you can also connect the INT/SQW to an external interupt and trigger a macro to check alarm :wink:
If the alarm is critical or you use it to get the microcontroller out of sleep.
But if it's not that big of a deal then the option of john would also work.

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

hyperion007
Posts: 528
Joined: Sat Dec 01, 2012 1:23 pm
Location: Sweden
Has thanked: 49 times
Been thanked: 101 times
Contact:

Re: DS3231 - RTC Time Keeper

Post by hyperion007 »

If I was correct this weekend there is a bug with clearing the Alarm Interrupt Flag and instead of writing a 0 it writes the retval which is 1 if the alarm has "gone off".

But it is an interesting idea that John had. Maybe the CheckStatus macro could have a function to read back the Alarm Time registers as well as a true/false to indicate if the alarm is active or not.
Without having to write a new time into the Alarm Time registers.

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: DS3231 - RTC Time Keeper

Post by JohnCrow »

This is my version of the board.
DS3231_Board.jpg
DS3231_Board.jpg (76.61 KiB) Viewed 37204 times
TouchScreen Clock-No Alarm V1.fcfx
(34.52 KiB) Downloaded 593 times
The 3 blue terminals are SCL SDA Alarm
Small green terminals are 5V & Gnd

The main flowchart is working, just started to add the alarm macro now.
Alarm will connect to A0 (For example) and turn on the buzzer

Jordy, I've not noticed if anyone else has posted about it, but the component symbol on the desktop is labelled DS3132.All other labels seem ok.
1 in 10 people understand binary, the other one doesn't !

Post Reply