Académique Documents
Professionnel Documents
Culture Documents
Time Switch Based on an S7-300/400 CPU with optional Radio Clock Connection
SIMATIC S7-300/400 Application Description March 2011
Industry Automation and Drive Technologies Service & Support Portal This document is taken from the Service Portal of Siemens AG, Industry Automation and Drive Technologies. The following link takes you directly to the download page of this document. http://support.automation.siemens.com/WW/view/en/21669756
If you have any questions concerning this document please e-mail us to the following address: online-support.automation@siemens.com
Automation Problem
1 2 3 4 5 6 7 8 9
Installation Description of the Time Switching Functions Operation of the Application Further Notes, Tips and Tricks, etc.
References
History
We do not accept any liability for the information contained in this document. Any claims against us based on whatever legal reason resulting from the use of the examples, information, programs, engineering and performance data etc. described in this application example shall be excluded. Such an exclusion shall not apply in the case of mandatory liability, e.g. under the German Product Liability Act (Produkthaftungsgesetz), in case of intent, gross negligence, or injury of life, body or health, guarantee for the quality of a product, fraudulent concealment of a deficiency or breach of a condition which goes to the root of the contract (wesentliche Vertragspflichten). However, claims arising from a breach of a condition which goes to the root of the contract shall be limited to the foreseeable damage which is intrinsic to the contract, unless caused by intent or gross negligence or based on mandatory liability for injury of life, body or health. The above provisions do not imply a change in the burden of proof to your detriment. It is not permissible to transfer or copy these application examples or excerpts of them without first having prior authorization from Siemens Industry Sector in writing.
Table of Contents
Table of Contents
Warranty and Liability ................................................................................................. 4 1 Automation Problem ......................................................................................... 7 1.1 1.2 2 Overview .............................................................................................. 7 Requirements ....................................................................................... 7
Automation Solution ......................................................................................... 9 2.1 2.2 2.3 Overview of the overall solution ........................................................... 9 Description of the core functionality ..................................................... 9 Hardware and software components used......................................... 10
Functional Mechanisms of this Application ................................................. 11 3.1 3.1.1 3.1.2 3.1.3 3.1.4 3.2 3.2.1 3.3 3.3.1 3.3.2 Absolute time switching functions ...................................................... 11 Day time switch .................................................................................. 11 Week time switch ............................................................................... 12 Month time switch............................................................................... 12 Year time switch ................................................................................. 12 Relative time switching function ......................................................... 13 Relative time switch............................................................................ 13 Additional functions ............................................................................ 13 Summer-/wintertime changeover ....................................................... 13 Identification of holidays/special days ................................................ 13
Description of the Time Switching Functions .............................................. 16 5.1 5.1.1 5.1.2 5.1.3 5.1.4 5.2 5.3 5.3.1 5.3.2 5.3.3 Absolute time switching functions ...................................................... 17 Day time switch .................................................................................. 19 Week time switch ............................................................................... 20 Month time switch............................................................................... 21 Year time switch ................................................................................. 22 Relative time switch............................................................................ 23 Additional functions ............................................................................ 25 Program-controlled summer-/wintertime changeover ........................ 25 Radio-controlled summer-/wintertime changeover ............................ 26 Identification of holidays ..................................................................... 27
Operation of the Application .......................................................................... 28 6.1 6.2 6.3 Absolute time switching functions ...................................................... 28 Relative time switching function ......................................................... 29 Input of special days........................................................................... 30
Further Notes, Tips and Tricks, etc. .............................................................. 31 7.1 7.2 7.3 7.3.1 7.3.2 7.3.3 7.3.4 7.3.5 7.3.6 How can I include several switch-on/switch-off times in one block?.. 31 What do I have to do if I need more holidays or special days? ......... 31 How can I integrate a SICLOCK radio clock into the project? ........... 32 Introduction......................................................................................... 32 Functionality ....................................................................................... 32 Performance data............................................................................... 32 Hardware components ....................................................................... 33 Hardware connection ......................................................................... 33 Software interface and block parameterization.................................. 35
History............................................................................................................... 36
1 Automation Problem
1
1.1
Automation Problem
Overview
Many fields of automation require accurate timing of processes. Even in domestic electrical installation practice, individual systems must operate, for example, depending on the time of day or the day of the week. One possibility to solve this problem is to use electrical or mechanical time switches. The figure below shows examples of electrical time switches:
Figure 1-1: Examples of time switches
All of the examples are hardware clocks that can be used to solve the time switching problem in domestic electrical installation practice. Operation is kept simple so that this clock can be easily used by ordinary persons. Accurate time switching of processes is also necessary in a large number of industrial applications in the field of automation.
1.2
Requirements
To be able to create the time characteristic of such or similar processes, the S7 CPU requires a block that, depending on the absolute time, sets an output or ensures that a parameterized time interval elapses when a specific event occurs. The absolute start and end times for these processes must be configurable on a relevant block and then be available in the S7 CPU. In addition, it is to be possible to parameterize a specific time interval that will elapse depending on a start event (relative time).
1 Automation Problem
Requirements for the automation problem In the S7 CPU, the automation problem requirements for the application are as follows: The following blocks exist: Day, week, month, year time switch Relative time switch Summer-/wintertime changeover Identification of holidays Radio clock connection
Start and end time can be parameterized for each time switch (day, week, month, year time switch and relative time switch). The time switches must be easily resettable.
2 Automation Solution
2
2.1
Automation Solution
Overview of the overall solution
Figure 2-1: Overall solution
DCF77
2.2
Copyright Siemens AG 2011 All rights reserved
Furthermore, the application includes additional functions such as summer-/ wintertime changeover and identification of holidays. By default, the additional Summer-/wintertime changeover function is executed by a function block. As an option, this changeover can also be controlled using a radio clock. In this case, a digital input module (here: SM321) must be used since two digital inputs are necessary to receive the data sent from the radio clock module.
2 Automation Solution
2.3
Hardware components
Table 2-1: Hardware used Component PS307 2A CPU 315-2 DP Qty. 1 1 MLFB/order number 6ES7 307-1BA00-0AA0 6ES7-315-2AG10-0AB0 Note Or similar power supply Or other CPU
Software components
Table 2-3: Standard software Component STEP7 V5.4+SP5 Qty. 1 MLFB/order number 6ES7810-4CC08-0YA5 Note
Sample files and projects The following list contains all files and projects that are used in this example.
Table 2-4: Files of the application Component 21669756_Zeitschaltuhr_einfach_CODE_V2.1.zip 21669756_Zeitschaltuhr_einfach_DOKU_V2.1.pdf Note This zip file contains the STEP 7 project. This document.
10
3.1
3.1.1
12:00 a.m
11:59:59 p.m
8:00 a.m.
12:00 a.m.
11
3.1.2
Note
It is also possible to repeat one switching time on a daily basis from Monday to Friday.
Sun 12:00
3.1.3
3 , 12:00 a.m.
rd
7 , 9:00 p.m.
th
3.1.4
1st Jan. 0:00 a.m. 13th April, 8:00 28th Sept, 12:00
12
3.2
3.2.1
3.3
3.3.1
Additional functions
Summer-/wintertime changeover
The absolute system time in the S7 CPU is changed by plus or minus 1 hour, depending on whether the changeover is performed from wintertime to summertime or from summertime to wintertime. For the summer-/wintertime changeover, two options are available: 1. Radio-controlled changeover The system time is adjusted after the radio clock connected to the system has provided the changeover signal. 2. Program-controlled changeover: A supplied function block adjusts the system time at the officially defined times.
3.3.2
13
4 Installation
4
4.1
Installation
Hardware installation
For the hardware components, please refer to chapter 2.3 Hardware and software components used.
Figure 4-1: Hardware of the application
Note
Hardware installation: Radio clock Using a 4-wire shielded cable, the SIPLUS DCF77 radio clock module is wired to the power supply / SM 321 as follows:
Table 4-1: Hardware installation: Radio clock
PS
L+ M
You can also connect the radio clock to digital inputs that differ from the ones described here. In this case, you only have to adjust the interconnection of the SekTakt and Data parameters in OB1 when calling FB77 DCF77_FB. Functions of the LEDS on the SIPLUS DCF77 radio clock module: Green LED: 24Vdc: Power supply is connected Center red LED: DCF data: Data transfer to the automation system Outer red LED: sec: Second settings from atomic clock
14
4 Installation
Note
When selecting the place of installation of the SIPLUS DCF77 radio clock module, it should be ensured that the radio clock signal is not shielded by building faades made of metal or similar material. The actual module must be shielded from interference frequencies and should not be attached directly on a metal surface.
At the place of installation, radio reception can be tested by applying the supply voltage to the SIPLUS DCF77 radio clock module. If there is radio reception, the outer red LED must flash every second. If this is not the case or if the LED sputters after a longer period of operation, a more suitable place of installation should be selected. Depending on the reception conditions, setting the clock normally lasts approximately 3-4 minutes; however, it may take longer at unfavorable places of installation.
15
check whether prfe, ob Sommer-/Winterzeitsummer/winter umschaltungstattgefunden time changeover occurred hat call special_days check_holidays FC100 FC100 FC100 (Kapitel 4.3.3.2) check whether prfe, ob aktuelles current Datum date ein is Feiertagor holiday oder special Sondertag day ist
FB120 (Kapitel 4.3.1.1) prfe, ob check whether aktuelle current Zeit imparatime is within metrierten parameterized Zeitraum range liegt FB121 (Kapitel 4.3.1.2) prfe, ob check whether aktuelle current Zeit time imparais within metriertenZeitraum parameterized range liegt
FB122 (Kapitel 4.3.1.3) prfe, ob check whether aktuelle current Zeit time imparais within metriertenZeitraum parameterized range liegt FB123 (Kapitel 4.3.1.4) check ob prfe, whether aktuelle current Zeit time imparais within metriertenZeitraum parameterizedliegt range
FB124 (Kapitel 4.3.2) check ob prfe, whether aktuelle current Zeit time imparais within metriertenZeitraum parameterizedliegt range
16
Additional functions
DB103
5.1
Each of the blocks has the following inputs: EnableClock of the BOOL type Value = 1: Clock is enabled Value = 0: Clock is not enabled
Time_To_Check of the UDT type The parameter contains the time interval during which the clock is to be active, including absolute start and end time. The parameter is specific for each time switch.
Note
Reset of the BOOL type Value = 1: Clock is reset Value = 0: Clock is in normal mode
Each of the blocks has the following outputs: Q = clock active of the BOOL type The parameter indicates whether the clock is active. Value = 1: Clock is active Value = 0: Clock is not active
Error of the INT type Value = 0: No error has occurred Value <> 0: An error has occurred
Possible errors: Return values of called SFCs in the block (e.g., SFC1 Read_Clk) 8000h in the event of a limit violation on the input parameters 8001h if start time equals end time
17
Note
The EN input parameter and the ENO output parameter are parameters that are included by default in the S7 blocks. For more information, please refer to the STEP 7 documentation and the respective online help.
The EnableClock, Time_To_Check and Reset input signals and the Q output behave towards one another as shown in the following pulse timing diagram:
Time range
The pulse timing diagram applies to all absolute function blocks, which are described in detail in the following sections.
18
5.1.1
The Time_To_Check parameter is a structure of the UDT_timer_day (UDT1) type. It includes: Start hour, start minute, start second, combined as starttime and with a structure of the times (UDT6) type End hour, end minute, end second, combined as endtime and with a structure of the times (UDT6) type
19
5.1.2
The Time_To_Check parameter is a structure of the UDT_timer_week (UDT2) type. It includes: Start day 1 to 7: Sunday to Saturday 8: Monday to Friday 9: Saturday to Sunday Start hour, start minute, start second, combined as starttime and with a structure of the times_udt (UDT6) type End day 1 to 7: Sunday to Saturday 8: Monday to Friday 9: Saturday to Sunday End hour, end minute, end second, combined as endtime and with a structure of the times_udt (UDT6) type
If the startday parameter has a value between 1 and 7, only a value between 1 and 7 may be entered on the end day. If the startday parameter equals 8 or 9, only 8 or 9 may be entered on the end day.
20
5.1.3
The Time_To_Check parameter is a structure of the UDT_timer_month (UDT3) type. It includes: Start day 1 to 31: Corresponds to the day of the month 32: Last day of the month Start hour, start minute, start second, combined as starttime and with a structure of the times_udt (UDT6) type End day 1 to 31: Corresponds to the day of the month 32: Last day of the month End hour, end minute, end second, combined as endtime and with a structure of the times_udt (UDT6) type
Note
When parameterizing start day and end day, it must be considered that not every month has 31 days. If a function is to be executed on or until or starting from the last day of the month, 32 must be entered instead of 28, 30 or 31. The block checks which month is the current month and automatically sets the end day to the last day of this month.
21
5.1.4
The Time_To_Check parameter is a structure of the UDT_timer_year (UDT4) type. It includes: Start month Start day Start hour, start minute, start second, combined as starttime and with a structure of the times_udt (UDT6) type End month End day End hour, end minute, end second, combined as endtime and with a structure of the times_udt (UDT6) type
22
5.2
The block for relative time switching has the following input parameters: EnableClock of the BOOL type Value = 1: Clock is enabled Value = 0: Clock is not enabled Value = 1: Each positive edge on the StartTime parameter is evaluated -> the time is restarted each time Value = 0: The first positive edge on the StartTime parameter is evaluated. When the time has elapsed, the clock can be restarted by another edge change at the StartTime input-
Time_To_Go The Time_To_Go parameter is a structure of the relative_udt (UDT5) type. It includes: Number of days Number of hours Number of minutes Number of seconds Value = 1: Clock is reset Value = 0: Clock is in normal mode
The block for relative time switching has the following in/out parameters: StartTime of the BOOL type In the event of a positive-going edge on this parameter, the clock is activated and remains active until the time on the time_to_go parameter has elapsed.
23
Control parameters for the relative time switch are EnableClock, CheckEdge, Reset and StartTime. The control parameters and the output behave towards one another as shown in the following pulse timing diagrams. CheckEdge = 0:
CheckEdge = 1:
The block for the timer_relative FB124 relative time switch is parameterized as shown in the figure below. Data block DB124 is used as an instance data block:
24
5.3
Additional functions
Aside from the blocks for absolute time switching and relative time switching, blocks for the summer/-wintertime changeover and identification of holidays are supplied.
5.3.1
The block has the following input parameters: activ of the BOOL type If the parameter = 1, the block will be executed. If the parameter = 0, execution of the block will be prevented. The block has the following output parameters: summertime of the BOOL type Value = 1: It is summertime Value = 0: It is wintertime
Error of the INT type Not equal to 0 if an error has occurred during processing.
25
5.3.2
The block has the following input parameters: SekTakt of the BOOL type Data of the BOOL type module SekCPU of the BOOL type DCF77 of the Timer type mark One-second interval input of the DCF77 module Bit pattern input, data of the DCF77 1 Hz clock bit memory of the CPU clock Timing element for the detection of the minute
The block has the following output parameters: Time zone of the BOOL type Value = 1: It is summertime (CEST) Value = 0: It is wintertime (CET)
Umsch_Zeitzone of the BOOL type Value = 1: Changeover from summertime to wintertime or vice versa takes place in one hour
Min_Puls of the BOOL type A negative edge starts a minute and/or the clock is set Error of the BOOL type Value = 1: No valid message frame has been received for three minutes or a longer period of time
26
5.3.3
Identification of holidays
The block checks a DB with 30 memory locations for holidays or special days and sets an output to 1 if the current day of the S7 CPU system time matches a date in this DB.
Figure 5-9: special_days
The block has the following input parameters: DB_Nr of the INT type Contains the number of the data block that stores the holidays and special days. The block has the following output parameter:
Copyright Siemens AG 2011 All rights reserved
special_day of the BOOL type Value = 1: Current day is a holiday or special day Value = 0: Current day is not a holiday or special day
27
Note
The individual input and output parameters of the functions have already been described in chapter 5 Description of the Time Switching Functions.
6.1
The figure below shows the VAT_timer_month variable table of FB122 timer_month as an example of the operation of the absolute time switches.
Figure 6-1: VAT_timer_month
Input parameters Start time of the time switch: Fifth day, 11:21:00 h
Output parameters
The table starts with the input parameters of the time functions. This is where the function can be activated or reset. Then the start and end time of the time switch are entered. The output parameters form the end of the variable table. The time switch status and a possibly occurring error code are displayed here.
28
Note
Operation of the absolute time functions differs only in the number of parameters for the start and end time of the time switch.
6.2
Input parameters
Runtime of the time function: One day, 2 hours, 10 minutes, 30 seconds Output parameters
29
6.3
Output parameter
30
7
7.1
3
Copyright Siemens AG 2011 All rights reserved
4 5 7 8
7.2
3 4
Save the DB. Open the FC that checks the holidays (in the example: FC100).
31
Step 5
Action Increase the loop counter. The loop counter must be as large as the number of array elements (by default, the loop counter is 30). Note: The code sequence is in network 2 of the block. Save the FC. Download the block via the PLC -> Download menu in the SIMATIC Manager.
Note / action
7 8
Or Download icon
7.3
7.3.1
7.3.2
Functionality
Basically, the SICLOCK radio clock has the same functionality as SIPLUS. It is used to receive the DCF77 time signal transmitter whose signal is demodulated and provided as a pulse for the S7. The supplied software synchronizes the S7 CPU system time with the received official time.
7.3.3
Performance data
The following table lists the key data for the SICLOCK DCF77 radio receiver:
Radio frequency Bandwidth Dimensions Sensitivity Connection cable Plug type Power supply Operating temperature Degree of protection
32
7.3.4
Hardware components
The following hardware components are necessary to connect it to the S7-300: Component SICLOCK DCFRS Order no. 2XV9450-1AR06 Description/picture DCF77 receiver
The diagrammatic representation below shows the complete hardware configuration of an S7-300 with a SICLOCK radio clock:
Copyright Siemens AG 2011 All rights reserved
7.3.5
Hardware connection
The SICLOCK radio clock module is wired to the power supply and the SM 321 as follows:
PS
SM 321 E 0.3
SICLOCK Yellow (receive signal) Gray (cable shield) Green (supply voltage) Brown (signal and supply ground)
M L+ M
33
To amplify the SICLOCK encoder signal, it may be necessary to use an optocoupler. In this case, the following scheme is used for the wiring:
SIMATIC S7 PS 24Vdc SM
Optocoupler
SICLOCK
Ground
A2 0V Brown (signal and supply ground) Gray (cable shield) E 0.3 14 A1 Yellow (receive signal)
Note
When selecting the place of installation of the radio clock module, it should be ensured that the radio clock signal is not shielded by building faades made of metal or similar material. The actual module must be shielded from interference frequencies and should not be attached directly on a metal surface.
34
7.3.6
OB1
OB100
OB35
35
8 References
8
8.1
References
References
This list is by no means complete and only presents a selection of related references.
Table 8-1 Topic /1/ STEP7 Title Automating with STEP7 in STL and SCL Hans Berger Publicis Corporate Publishing ISBN 3-89578-113-4
/2/
8.2
Internet links
This list is by no means complete and only presents a selection of appropriate information.
Table 8-2 Topic \1\ \2\ \3\ Reference to the document Siemens I IA/DT Customer Support Title
http://support.automation.siemens.com/WW/view/en/21669756 http://support.automation.siemens.com
History
Table 9-1 Version V2.0 V2.0.1 V2.1 Date 07/2002 08/2006 03/2011 First edition Error correction in week time switch, FB121 To simplify the example, the OP connection was removed Modification
36