Date and time manipulation in STEP7

Pandiani

Lifetime Supporting Member
Join Date
Apr 2005
Location
Tz
Posts
718
Hello guys,
I need your help about using date and time types in Step 7.
I need to make a simple PLC program that needs to take current date and time
and extract time of week (1 = Sunday...), Current date and current time.
If current time is between 7:00 nad 15:00 (3 pm) program sets some output to 1, otherwise
it remains 0. If day of the week is Monday (2) program sets other binary output
to 1 and similar.
I've read documentation and found out that DATE_AND_TIME format is what I need, so
I decided to use it with IEC functions DT_DAY (to extract current day of week),
DT_DATE ( to extract current date) and DT_TOD (to extract current time). However
I don't know how to find out all these things. )Is there any way to access PLC's date and time if exists just like date and time in BIOS in PC). Is there any library function that reads current DATE and TIME,
and store it into some variable example VAR1. My idea is to create my own function in which all these IEC
functions would be caled.
How to solve this if it's possible at all?
Thanks very much
 
Last edited:
Pandiani said:
Is there any library function that reads current DATE and TIME,and store it into some variable example VAR1.
Hi Pandiani
You can use function SFC1 "READ_CLK" for reading a PLC clock. It is very simple to use.
And opposite, if you want rewrite PLC clock from the HMI -> use function SFC0 "SET_CLK".

-Pete-
🍻
 
OK, that helps me a lot.
Now, I wonder how PLC date and time is updated? Maybe every time when PG is connected PLC reads time and date and update itself...
Do you know anything more about this?
 
Pandiani said:
Now, I wonder how PLC date and time is updated? Maybe every time when PG is connected PLC reads time and date and update itself..
Hi again!
There must be a many different ways to do it but here is a two what I normally use.
1) Set PLC's clock syncronization mode "As Slave" and some external PC/HMI is the clock master. In this case PLC clock follows automatically the time of clock master.
2) External system writes day and time into DBxx and then you copy that time to the plc using by SFC0. Then you can define the triggering moment by your self. (e.g. Scheduled task in PC or HMI / Once per hour / compare the PLC and Ext-time together, if over 10s difference -> update time. etc...)

Pete
🍻
 

Similar Topics

From the Red Lion website, after some customer enquiries in the last week or so... Rev. March 25, 2024 [18:30] Just thought it might help a...
Replies
9
Views
247
How do you install update on Red Lion Crimson ver 3.1. Do I just need to run the exe file on the host server?
Replies
1
Views
92
Has anyone found a way to convert/replace/update the firmware on old Parker TS80xx series HMIs (i.e. TS8010, TS8006, etc) to accept Crimson...
Replies
0
Views
85
Hello, I have an automation direct d2 262 plc and C-more HMI EA9T6CL-R. I need to prepare a program, scheduled to be performed on a future date. I...
Replies
1
Views
112
Hi All, we've recently upgraded from FTView SE v10 to v12. Since the upgrade we've been having a problem where the HMI is slow to update tags in...
Replies
0
Views
85
Back
Top Bottom