Compare Date and Time

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 6.

Moderator: Benj

Post Reply
User avatar
tiny
Posts: 200
Joined: Wed Jul 08, 2009 8:29 am
Has thanked: 51 times
Been thanked: 93 times
Contact:

Compare Date and Time

Post by tiny »

Hello,

is there a function to compare date and time?
For example:
Date 5/1/14 to 9/15/14
Turn on in this period from 10:00 to 16:00 clock
It would be nice if someone had a solution for me!

Thanks
Tiny

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: Compare Date and Time

Post by acestu »

Hi Tiny,

Check out this RTC user component by Jordy it may help you :

http://www.matrixtsl.com/mmforums/viewt ... 58&t=12882


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
tiny
Posts: 200
Joined: Wed Jul 08, 2009 8:29 am
Has thanked: 51 times
Been thanked: 93 times
Contact:

Re: Compare Date and Time

Post by tiny »

Hello acestu,
I have already viewed this macro, great features. However, I need I2C master for RTC, LCD and keypad. So I can't use this macro. I've 4 relay in my circuit and switch for several months at a certain time on and off. The switching times are in the EEPROM and are compared using a timer every few seconds with RTC. For that I need the date and time comparison.
Tiny

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

Re: Compare Date and Time

Post by hyperion007 »

Can't you use software I2C for any of the components?
Also, you could use the DS3231 RTC alarm function to first set the alarm to the first date, lets say Jan 1st 2015. Then use the INT pin of the RTC to trigger an INT on the MCU. When that happens, you clear the alarm INT Flag bit and then set the alarm again, but now for the second date, say June 1st 2015. In addition to this you set a variable (or EEPROM value maybe) to indicate that when the next INT comes (June 1st 2015) it will then turn off something or whatever you want it to do.


Hope you understand what I mean :)

User avatar
tiny
Posts: 200
Joined: Wed Jul 08, 2009 8:29 am
Has thanked: 51 times
Been thanked: 93 times
Contact:

Re: Compare Date and Time

Post by tiny »

The idea is good, but I have no problem with I2C and 2x RS232 to control for GSM and WiFi, and the microcontroller has the functions for that. I have 4 timers that turn on and off in a date window at certain times. Add to that the options "every day, odd or even days, Monday to Friday, and Saturday and Sunday". As a bonus nor the matrix of the assignment of Timer in different relay outputs. With these specifications, it is difficult for me to integrate the DS1307 macro, since the programming effort is simply too large.
Here, the control of multi-timer from the PC via WiFi:
FourChannelTimer.jpg
I just need a couple of how to compare date and time advice.

Tiny

User avatar
tiny
Posts: 200
Joined: Wed Jul 08, 2009 8:29 am
Has thanked: 51 times
Been thanked: 93 times
Contact:

Re: Compare Date and Time

Post by tiny »

Hi,

I have created a Flowchart, around between two date values daily turn one and off an output. It must test exactly but the first tests were successful.

Tiny
Flowcode12.fcfx
(13.51 KiB) Downloaded 243 times

Rudi
Posts: 666
Joined: Mon Feb 10, 2014 4:59 am
Has thanked: 493 times
Been thanked: 187 times

Re: Compare Date and Time

Post by Rudi »

Hi Tiny,
do you need a "Virtual RTC function" for the Microcontroller or do you need a Base compare Date and Time with Data from/over Wifi? ( RS232 UART ? )
Best wishes.
Rudi
;-)


Edit:
Hi Tiny,
i have see your Flowchart.
Ok i think i have understand.
Tiny, only a hint, perhabs this helps..

If you calculate the Time example and convert to ULong ( sec )

have a look to this ...
http://www2.informatik.uni-halle.de/lehre/c/c_time.html
https://asciich.ch/wordpress/systemzeit ... esen-in-c/
http://www.a-m-i.de/tips/datetime/datetime.php

you can make a Setup Constante by your self
normaly..
Start 1.1.1970 00:00:00
yours:
Start 1.1.2014 00:00:00 ( or other )
and then calculate the sec after this.
Now you know your start constante and then you can given the On / Off by simple make one Calculate ( If Then ) .
StartTime
OffTime
--
Example you can make short Value ( only the difference to your Base ( Start Constante )
and you can calculate with this.

Example Timer:
Switch Off after 3 hour.. = 3 h * 3600(s/h) = 10800 = OnDuration[0]
so you can make a simple
calculate your OnTime for the On[0]
then
a) add your time Code for "how long did On[0] be on = TimeConstante + OnDuration[0]
or
b) make a simple TimeValue for duration for be On[0] = 10800

then you can make ..

a)
if JustInTime >= On[0] // You calculate the wishes Time example Time Constante + 10800 and gives the On[0] the TimeCode
then off..

b)
if JustInTime >= On[0] + OnDuration[0]
then switch off

or
..

In Setup your Timer You can work example with a Function Time(now) to calculate the TimeCode and Duration..

Best wishes
Rudi
;-)

User avatar
tiny
Posts: 200
Joined: Wed Jul 08, 2009 8:29 am
Has thanked: 51 times
Been thanked: 93 times
Contact:

Re: Compare Date and Time

Post by tiny »

Hi Rudi,

I just need a function to compare stored date and time values ​​with the current date and time. Date / time is stored in the EEPROM, RTC is present and functioning.
I have the function Compare Date / Time again revised and corrected some mistakes, but maybe you know a simpler function.
Flowcode12_V2.fcfx
(15.26 KiB) Downloaded 249 times
Tiny

User avatar
tiny
Posts: 200
Joined: Wed Jul 08, 2009 8:29 am
Has thanked: 51 times
Been thanked: 93 times
Contact:

Re: Compare Date and Time

Post by tiny »

Hi Rudi,

Thank you for your advice. I'll try it that way, does not look so complicated like my solution.

Tiny

Rudi
Posts: 666
Joined: Mon Feb 10, 2014 4:59 am
Has thanked: 493 times
Been thanked: 187 times

Re: Compare Date and Time

Post by Rudi »

tiny wrote:Hi Rudi,

I just need a function to compare stored date and time values ​​with the current date and time. Date / time is stored in the EEPROM, RTC is present and functioning.
I have the function Compare Date / Time again revised and corrected some mistakes, but maybe you know a simpler function.
Flowcode12_V2.fcfx
Tiny

Hi Tiny,
not perfect but other thinking.
i attached you a example for compare as "string Data"
the RTC comes in a String from your "RTC Function"
i simulated this in panel properties for you .. fill out simple the year(yyyy) month ( mm ) and day (dd ) for your "just now Testing"
i make only 2 timer progs ( timer1 timer2 ) for on and off
this data comes from the EEPROM same as String.
you can save example 2 0 1 4 as 0x32 0x30 0x31 0x34 ( char )
i make for this byte variable y1 y2 y3 y4 and so on.. for compare each ;-)
the String Data for test i make simple as timer1_on timer1_off like
YourTimer1_On = "20140901"
YourTimer1_Off = "20140903"
and so on ( pic attached )
the compare makro compares bytewiese
YourTimer1_On[0] // Year '2'
YourTimer1_On[1] // Year '0'
YourTimer1_On[2] // Year '1'
YourTimer1_On[3] // Year '4'
and so on

In Simulation Mode you can make pause ánd change the RTC Parameter for testing the Timer Progams..simple make pause, change example day 01 -> 03 Enter.. ( the RTC String update automatic ) and go on with simulation again with next step you need not to start from behin, the RTC Variable will up2date too ;-)

you can make with this your own TimeCompare Icon like you need and want -
only a simple Parameter is later need quickly to implement.

if you not know - you can post again and i try to help you.
hope this helps..
and Tiny ;-)
.. your Homework will be the HH MM SS ;-)

Best wishes and nice Weekend!
Rudi
;-)

Post Reply