Hi.
I found bug with component DS3231 v1.68 from here => http://www.matrixtsl.com/mmforums/viewt ... 58&t=14566
I set in properties date format DDMMYYYY. When I set year to correct 2017, DS3231 return 2065. When date format is DDMMYY it's no problem. Interesting is that day of the week is not true on 2065 and correct in 2017.
I attach simple project.
DS3231 not display correct year and day of week
Moderator: Benj
-
- Posts: 71
- Joined: Mon Dec 01, 2014 1:38 pm
- Location: Bulgaria
- Has thanked: 17 times
- Been thanked: 12 times
DS3231 not display correct year and day of week
- Attachments
-
- DS3231.fcfx
- (50.07 KiB) Downloaded 456 times
Last edited by maharadga on Sun Jan 29, 2017 12:05 pm, edited 1 time in total.
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: DS3231 not display correct year
Hello,
The year can only be stored as a two digit number 00 to 99 on the DS3231 device, maybe this is the cause of the issue?
So at the moment you would store the number as 17 and then when printing out the year you could add the century.
"20" + ToString(Year)
The year can only be stored as a two digit number 00 to 99 on the DS3231 device, maybe this is the cause of the issue?
So at the moment you would store the number as 17 and then when printing out the year you could add the century.
"20" + ToString(Year)
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 71
- Joined: Mon Dec 01, 2014 1:38 pm
- Location: Bulgaria
- Has thanked: 17 times
- Been thanked: 12 times
Re: DS3231 not display correct year
Aha, this explain all. Thanks, Benj for your time to explain me.
But why day of week not correspond truth day? I try different date and month for example:
1.1.2000 must be Sat => shows Sun
3.2.2004 must be Tue => shows Sat
1.1.2012 must be Sun => shows Wed
6.8.2010 must be Fri => shows Tue
26.1.2017 must be Thu => shows Mon
30.5.2020 must be sat => shows Sun
I don't see any sequence. Is there no way I write correct day of week and DS3231 begin work correctly after that?
But why day of week not correspond truth day? I try different date and month for example:
1.1.2000 must be Sat => shows Sun
3.2.2004 must be Tue => shows Sat
1.1.2012 must be Sun => shows Wed
6.8.2010 must be Fri => shows Tue
26.1.2017 must be Thu => shows Mon
30.5.2020 must be sat => shows Sun
I don't see any sequence. Is there no way I write correct day of week and DS3231 begin work correctly after that?
Last edited by maharadga on Fri Jan 27, 2017 1:08 pm, edited 1 time in total.
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
Re: DS3231 not display correct year
Hi,
A Day (of the week) counter will just increment each day.
So if you set it to 1 on a Monday, it will read as 2 the following day, then 1 again next Monday.
It will not work out the day of the week for any given date.
A Day (of the week) counter will just increment each day.
So if you set it to 1 on a Monday, it will read as 2 the following day, then 1 again next Monday.
It will not work out the day of the week for any given date.
-
- Posts: 71
- Joined: Mon Dec 01, 2014 1:38 pm
- Location: Bulgaria
- Has thanked: 17 times
- Been thanked: 12 times
Re: DS3231 not display correct year
I understand, thank you.
But how set day of week? I didn't see write option, only read?
I tune day as calculated depending on what value displayed and add or subtract the required days. But I think that the various chips will return a different value. Or at a different date will back a different day of the week and my method will not be accurate.
But how set day of week? I didn't see write option, only read?
I tune day as calculated depending on what value displayed and add or subtract the required days. But I think that the various chips will return a different value. Or at a different date will back a different day of the week and my method will not be accurate.
-
- Posts: 71
- Joined: Mon Dec 01, 2014 1:38 pm
- Location: Bulgaria
- Has thanked: 17 times
- Been thanked: 12 times
Re: DS3231 not display correct year
I try write day of week, but Flowcode return mistake wenn compile. I added C code:
FCD_005f1_I2C_Master1__Start();
FCD_005f1_I2C_Master1__TransmitByte(0xD0);
FCD_005f1_I2C_Master1__TransmitByte(3);
FCD_005f1_I2C_Master1__TransmitByte(day_of_Week);
FCD_005f1_I2C_Master1__Stop();
after my macro adjust_Date with the intention to record the set value. I use variable day_of_Week to set correct day.
The mistake is in red color. What should I do?
When try write some value for example 5 instead day_of_Week no mistake. I sure the answer is simple, but I don't know it.
I'm not expert in C.
FCD_005f1_I2C_Master1__Start();
FCD_005f1_I2C_Master1__TransmitByte(0xD0);
FCD_005f1_I2C_Master1__TransmitByte(3);
FCD_005f1_I2C_Master1__TransmitByte(day_of_Week);
FCD_005f1_I2C_Master1__Stop();
after my macro adjust_Date with the intention to record the set value. I use variable day_of_Week to set correct day.
The mistake is in red color. What should I do?
When try write some value for example 5 instead day_of_Week no mistake. I sure the answer is simple, but I don't know it.
I'm not expert in C.
Last edited by maharadga on Sat Jan 28, 2017 5:51 pm, edited 1 time in total.
-
- Valued Contributor
- Posts: 2045
- Joined: Wed Aug 27, 2008 10:31 pm
- Location: Netherlands
- Has thanked: 553 times
- Been thanked: 1081 times
Re: DS3231 not display correct year
If your Flowcode variable is called day_of_Week the C variable is called FCV_DAY_OF_WEEK or FCL_DAY_OF_WEEK. The easiest way to get the variable name right is to drag the variable from the right pane with the variables in the C code editor.maharadga wrote: FCD_005f1_I2C_Master1__TransmitByte(day_of_Week);
“Integrity is doing the right thing, even when no one is watching.”
― C.S. Lewis
― C.S. Lewis
-
- Posts: 71
- Joined: Mon Dec 01, 2014 1:38 pm
- Location: Bulgaria
- Has thanked: 17 times
- Been thanked: 12 times
Re: DS3231 not display correct year
Hello kersing, I try that, what you say but can't make success. Finally I made switch with this variable and solve problem.
As an amateur, but an amateur resourceful
I attach my sample, which work very correct, with leap year compensation / tryed this/, writable correct Day of Week and tree buttons for adjust time and day.
In next stage I add alarms. Last two days was very difficult understand I2C protocol, but I success. Hope this sample helps beginners like me understand DS3231 better.
Have a nice day.
As an amateur, but an amateur resourceful
I attach my sample, which work very correct, with leap year compensation / tryed this/, writable correct Day of Week and tree buttons for adjust time and day.
In next stage I add alarms. Last two days was very difficult understand I2C protocol, but I success. Hope this sample helps beginners like me understand DS3231 better.
Have a nice day.
- Attachments
-
- DS3231.fcfx
- (50.85 KiB) Downloaded 557 times