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

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
36
Good Morning , Not sure how many use Markem-Imaje SmartDate X60 Printers , but I'm having trouble finding a good manual for...
Replies
3
Views
346
Hi, I have an iFIX 5.5 project (Windows 7) that needs to be updated to version 6.5 (Windows 10). iFIX communicates with the "Siemens Industrial...
Replies
1
Views
145
Hi I have a number of the older PanelView Plus 600 HMI's (2711P-T6C20D, Ser D) that I want to update to the latest firmware. I believe that the...
Replies
10
Views
390
Hello all, I am trying to set PLC clock using DATE function. When DATE function is enabled, I can see A351 to A354 change to the register...
Replies
3
Views
361
Back
Top Bottom