System clock in S7 and starting equipment from it

kemppioy

Member
Join Date
Oct 2005
Location
Dallas
Posts
72
Hello,

I need to make a routine to start some equipment at a certain time of the day but that time can change from a setpoint on our MMI. I don't really want to use the time of day interrupt unless that is something that is really necessary. What is the best way for using the clock and comparing if the time is at the setpoint for when I want the equipment to come on? Is there a certain format for the tags that I need to use or can I use a premade tag from somewhere?

Thanks for your help!

Regards,

PK
 
Function to PLC: read clock
COPY DATE_AND_TIME DATA TYPE FROM CPU TO DB

Temp FC Vars
CPU_DT Date_And_Time
retval Int

CALL SFC 1
RET_VAL:=#retval
CDT :=#CPU_DT
LAR1 P##CPU_DT
L B [AR1,P#0.0]
T DB70.DBB 20 //Year
L B [AR1,P#1.0]
T DB70.DBB 21 //Month
L B [AR1,P#2.0]
T DB70.DBB 22 //Day
L B [AR1,P#3.0]
T DB70.DBB 23 //hours
L B [AR1,P#4.0]
T DB70.DBB 24 //minutes
L B [AR1,P#5.0]
T DB70.DBB 25 //seconds
L W#16#FFF0
L W [AR1,P#6.0]
AW
T DB70.DBW 26 //milliseconds
L B#16#F
L B [AR1,P#7.0]
AW
T DB70.DBB 28 //day of the week

DB70 declared as all bytes except miiliseconds as word.

All vars are now usable in compare functions and logics etc.
To set the clock, use SFC0

Good luck
 
This S7 function is very similar to s7xp.com's offering except that it returns the time components as integers rather than in BCD format allowing you to use the standard integer compare functions to set up your start times..

S7 System Clock As Integers
 

Similar Topics

HEllo! Where do it setup the clock? Couldn´t find anything useful in General-->Time of day besides daylight saving time. And when i have set the...
Replies
9
Views
1,235
Hello everyone one. I'm using M340 with simulation mode (actually I still don't have the cpu to test the software). I've made a simple counter...
Replies
4
Views
488
I took an online course but don't remember covering this. How do I access the system clock in a compare instruction? I want to turn on an output...
Replies
1
Views
505
I am using a Studio 5000 with an Allen Bradley CompactLogix 1769-L24ER-QB1B controller. Im wondering how I can use the system clock to be able to...
Replies
10
Views
2,411
hello everyone, I'm trying to set the system clock on my plc for daylight savings time so the operator does not need to adjust himself twice a...
Replies
1
Views
2,410
Back
Top Bottom