Академический Документы
Профессиональный Документы
Культура Документы
Page 1 of 5
show the entry list
STEP 7 -- Creating S7 programs -- Editing date, time and counters
Which STEP 7 standard blocks are available for time stamping and time-of-day synchronization?
How is the runtime of a terminal device (e.g. pump) calculated?
What is the modified Julian date and how can you calculate it with STEP 7?
Tips and tricks for reading and comparing date, time and counters
How do you convert an available seconds value into days, hours, minutes and seconds?
Information about the topic of "Editing date and time"
How can you measure the time?
How do you program a timer that retains the time value at STOP and counts on starting at the stored value?
How can you set the time of an S7-300 CPU via Industrial Ethernet and via MPI?
How do you load the IEC standard functions FC3, FC6, FC7 and FC8 from the STEP 7 IEC library?
How can you use IEC functions to read and input the date and time of the CPU?
How can you synchronize CPU clocks with each other?
How can you count forwards and backwards in a bandwidth between -2147483648 and +2147483647?
How can you read out the date and time with SFC1 (READ_CLK) and input them with SFC0 (SET_CLK)?
How can you create a timer for the "S7" without using an "S7 Timer"?
Instructions:
In automation technology measuring time is a frequent application in controllers. There are various
options for measuring time with SIMATIC. This entry includes a STEP 7 program with six example for
measuring time.
Examples 1, 2, 3 and 4 are programmed directly in OB1 and examples 5 and 6 are called as S7-SCL
programs (FB1 and FB2) in OB1. With the VAT_1 variables table you can control and monitor time
measurement for all six examples. The markers M0.0 "START" and M0.1 "RESET" are used to start
and reset the six sample programs.
Fig. 01
http://support.automation.siemens.com/WW/llisapi.dll?func=ll&objid=26116927&nodeid0=10805384... 2/19/2011
Siemens Industry IA/DT/BT Service&Support - Automation Service, Automation Support, Simatic Se... Page 2 of 5
If the preset time for T1 ("S5T#20s" with parameter TW) has expired, the marker M10.0 (output
Q of timer T1) receives the True signal.
Fig. 02
2 Example 2: Time measurement with the IEC timer SFB4 "TON"
The SFB4 delays a rising edge by the time PT. The time PT is started with a rising flank at the
input IN.
Fig. 03
In the VAT_1 variables table you can monitor the expired time (ET) until the setpoint value
(parameter PT) is reached.
Fig. 04
3 Example 3: Time measurement with the system functions SFC2 "SET_RTM", SFC3
"CTRL_RTM" and SFC4 "READ_RTM"
The system functions SFC2 "SET_RTM", SFC3 "CTRL_RTM" and SFC4 "READ_RTM" make it
possible to measure the time with a 16-bit runtime meter of the CPU.
SFC2 is used to set the runtime meter of the CPU to a preset value.
SFC3 is used to start and stop the runtime meter.
SFC4 is used to read the current runtime elapsed and the status ("stopped" or
"counting") of the runtime meter.
The marker word MW106 is parameterized with the output CV of SFC4 and provides the
number of operating hours as in Fig. 05.
Fig. 05
4 Example 4: Time measurement with the system function SFC101 "RTM"
With SFC101 "RTM" you can measure the time with a 32-bit runtime meter. The program for
example 4 includes 5 networks (networks 6 to 10) in OB1 for controlling and evaluating
SFC101.
http://support.automation.siemens.com/WW/llisapi.dll?func=ll&objid=26116927&nodeid0=10805384... 2/19/2011
Siemens Industry IA/DT/BT Service&Support - Automation Service, Automation Support, Simatic Se... Page 3 of 5
Fig. 06
The starting, stopping and setting of a new value is done as described above with markers M0.0
and M0.1. The current value of the runtime meter is read via the parameter "CV" (MD110).
Fig. 07
5 Example 5: Time measurement with the system function SFC64 "TIME_TCK"
The function block FB1 contains an S7-SCL program for acquiring the system time of the CPU
with SFC64 and for evaluating the time measurement. FB1 is called and parameterized in
network 11 of OB1.
Fig. 08
The starting, stopping and resetting is done as described above with markers M0.0 and M0.1.
Fig. 09 shows the evaluation of the three variables in DB1:
Fig. 09
6 Example 6: Time measurement with the system function SFC1 "READ_CLK"
The function block FB2 contains an S7-SCL program for acquiring the time of the CPU with
SFC1 and for evaluating the time measurement. FB2 is called and parameterized in network 12
of OB1.
http://support.automation.siemens.com/WW/llisapi.dll?func=ll&objid=26116927&nodeid0=10805384... 2/19/2011
Siemens Industry IA/DT/BT Service&Support - Automation Service, Automation Support, Simatic Se... Page 4 of 5
Fig. 10
The starting, stopping and resetting is done as described above with markers M0.0 and M0.1.
Fig. 11 shows the evaluation of the three variables in DB2:
Fig. 11
Note:
More information on the timers, system function blocks and system functions is available in the STEP
7 Online Help by marking the block and pressing the "F1" key.
The attached download "Time_rec" contains a STEP 7 project with the blocks described above. Copy
the "Time_rec.zip" file into a separate directory and then start the file with a double-click. The STEP 7
project is now unpacked automatically with all the associated subdirectories. You can use the
SIMATIC Manager to open and process the extracted project.
Time_rec.zip ( 391 KB )
Keywords:
S7-SCL (Structured Control Language)
Entry
Entry ID:26116927 Date:
ID: Date:2007-08-03
Date:
http://support.automation.siemens.com/WW/llisapi.dll?func=ll&objid=26116927&nodeid0=10805384... 2/19/2011
Siemens Industry IA/DT/BT Service&Support - Automation Service, Automation Support, Simatic Se... Page 5 of 5
This entry is available in the following languages:
german french italian spanish chinese
I regard this article.... as helpful as not helpful
http://support.automation.siemens.com/WW/llisapi.dll?func=ll&objid=26116927&nodeid0=10805384... 2/19/2011