Vous êtes sur la page 1sur 36

Cover

Time Switch Based on an S7-300/400 CPU with optional Radio Clock Connection
SIMATIC S7-300/400 Application Description March 2011

Applications & Tools


Answers for industry.

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

Copyright Siemens AG 2011 All rights reserved

Time Switches V2.1, ID Number: 21669756

Automation Problem

1 2 3 4 5 6 7 8 9

Automation Solution Functional Mechanisms of this Application

SIMATIC Time Switches


SIMATIC S7-300/400

Installation Description of the Time Switching Functions Operation of the Application Further Notes, Tips and Tricks, etc.

Copyright Siemens AG 2011 All rights reserved

References

History

Time Switches V2.1, ID Number: 21669756

Warranty and Liability

Warranty and Liability


Note The application examples are not binding and do not claim to be complete regarding the circuits shown, equipping and any eventuality. The application examples do not represent customer-specific solutions. They are only intended to provide support for typical applications. You are responsible for ensuring that the described products are correctly used. These application examples do not relieve you of the responsibility of safely and professionally using, installing, operating and servicing equipment. When using these application examples, you recognize that Siemens cannot be made liable for any damage/claims beyond the liability clause described. We reserve the right to make changes to these application examples at any time without prior notice. If there are any deviations between the recommendations provided in these application examples and other Siemens publications e.g. Catalogs then the contents of the other documents have priority.

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.

Copyright Siemens AG 2011 All rights reserved

Time Switches V2.1, ID Number: 21669756

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

Copyright Siemens AG 2011 All rights reserved

Installation........................................................................................................ 14 4.1 Hardware installation.......................................................................... 14

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

References ....................................................................................................... 36 8.1 References ......................................................................................... 36

Time Switches V2.1, ID Number: 21669756

Table of Contents 8.2 9 Internet links ....................................................................................... 36

History............................................................................................................... 36

Copyright Siemens AG 2011 All rights reserved

Time Switches V2.1, ID Number: 21669756

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

Copyright Siemens AG 2011 All rights reserved

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).

Time Switches V2.1, ID Number: 21669756

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.

Copyright Siemens AG 2011 All rights reserved

Time Switches V2.1, ID Number: 21669756

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

Description of the core functionality


The application includes function blocks for absolute and relative time switching functions (clocks). Each clock has only one setting option (corresponds to one cam), i.e. one switch-on time and one switch-off time can be entered on a block. This property has several advantages: The design of the function blocks is very fine-grained. This allows optimum utilization of the memory requirement in the S7 CPU. The blocks can be used flexibly. The blocks can be easily parameterized.

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.

Time Switches V2.1, ID Number: 21669756

2 Automation Solution

2.3

Hardware and software components used


The application was created with the following components:

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

Optional hardware components (only necessary when using a radio clock):


Table 2-2: Optional hardware Component SM 321 SIPLUS DCF77 radio receiver Qty. 1 1 MLFB/order number 6ES7 321-7BH00-0AB0 6AG1057-1AA03-0AA0 Note Or other digital input module Or SICLOCK

Copyright Siemens AG 2011 All rights reserved

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

Time Switches V2.1, ID Number: 21669756

3 Functional Mechanisms of this Application

Functional Mechanisms of this Application


The functions included in this application can be divided into the following groups.
Figure 3-1: Function chart

Copyright Siemens AG 2011 All rights reserved

3.1
3.1.1

Absolute time switching functions


Day time switch
This block can cover a time interval within 24 hours, for example 8:00 a.m. to 12:00 a.m. These switching times are repeated on a daily basis.
Figure 3-2: Day time switch

12:00 a.m

11:59:59 p.m

8:00 a.m.

12:00 a.m.

Time Switches V2.1, ID Number: 21669756

11

3 Functional Mechanisms of this Application

3.1.2

Week time switch


This block can cover a time interval within 7 days, for example each Tuesday from 8:00 p.m. to Friday 6:00 a.m. These switching times are repeated on a weekly basis.

Note

It is also possible to repeat one switching time on a daily basis from Monday to Friday.

Figure 3-3: Week time switch

Sun 12:00

Sat 11:59:59 p.m.

Tue, 8:00 p.m.

Fri, 6:00 a.m.

Copyright Siemens AG 2011 All rights reserved

3.1.3

Month time switch


This block can cover a time interval within 31 days, for example each month from 12:00 a.m. on the 3rd to 9:00 p.m. on the 7th.
Figure 3-4: Month time switch

1st 0:00 a.m.

31st 11:59:59 p.m.

3 , 12:00 a.m.

rd

7 , 9:00 p.m.

th

3.1.4

Year time switch


This block can cover a time interval within 365 days, for example from April 13, 8:00 a.m. to September 28, 12:00 noon.
Figure 3-5: Year time switch

1st Jan. 0:00 a.m. 13th April, 8:00 28th Sept, 12:00

31st Dec. 11:59:59 p.m.

12

Time Switches V2.1, ID Number: 21669756

3 Functional Mechanisms of this Application

3.2
3.2.1

Relative time switching function


Relative time switch
The clock is activated by a start signal and remains active until the parameterized time interval has elapsed.
Figure 3-6: Relative time switch

Parameterized time (e.g.: 3 hours) Start signal


Copyright Siemens AG 2011 All rights reserved

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

Identification of holidays/special days


In a data block, the data for holidays and special days is stored in day/month/year format. The block checks whether a day in this data block matches the current date and then sets an output to 1. Otherwise, the output is 0. When wiring this output to an EnableClock input of a time switch, you can achieve that, for example, the day time switch is not switched on on holidays.

Time Switches V2.1, ID Number: 21669756

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

Copyright Siemens AG 2011 All rights reserved

Note

The installation guidelines for SIMATIC modules must always be observed.

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

SM 321 E 0.0 E 0.1

SIPLUS DCF77 Sec DCF Data 24Vdc Ground

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

Time Switches V2.1, ID Number: 21669756

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.

Copyright Siemens AG 2011 All rights reserved

Time Switches V2.1, ID Number: 21669756

15

5 Description of the Time Switching Functions

Description of the Time Switching Functions


The figure below shows the program structure and the used blocks.

Figure 5-1: Program structure


OB1

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

InstanzDB to InstancDB zu FB103

DB100 DB withFeierholiday/special days DB mit und Sondertagen

call timer_day day FB120FB120


Copyright Siemens AG 2011 All rights reserved

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

DB120 Instance InstanzDB DBto zu FB120 FB120

call timer_week week FB121 FB121

DB121 InstanzDB to InstancDB zu FB121 FB121

call timer_month month FB122 FB122

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

DB122 InstanzDB to InstancDB zu FB122 FB122

call timer_year year FB123 FB123

DB123 InstanzDB to InstancDB zu FB123 FB123

call timer_relativ relativ FB124FB124

FB124 (Kapitel 4.3.2) check ob prfe, whether aktuelle current Zeit time imparais within metriertenZeitraum parameterizedliegt range

DB124 InstanzDB to InstancDB zu FB124 FB124

16

Time Switches V2.1, ID Number: 21669756

Relative time switching function

Absolute time switching functions

Additional functions

call summer _ winter FB103

FB103 (Kapitel 4.3.3.1)

DB103

5 Description of the Time Switching Functions

5.1

Absolute time switching functions


The absolute time switching functions include day time switch week time switch month time switch year time switch.

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.

Copyright Siemens AG 2011 All rights reserved

Note

The Time_To_Check parameter of the week time switch is an in/out parameter.

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

Time Switches V2.1, ID Number: 21669756

17

5 Description of the Time Switching Functions

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

t is a programmed time range (time switch active)


Copyright Siemens AG 2011 All rights reserved

The pulse timing diagram applies to all absolute function blocks, which are described in detail in the following sections.

18

Time Switches V2.1, ID Number: 21669756

5 Description of the Time Switching Functions

5.1.1

Day time switch


FB timer_day checks whether the current system time in the S7 CPU is within the parameterized time interval on the input parameters of the block. If this is the case, the output will be set to 1. Otherwise, the output is 0. The block for the timer_day FB120 day time switch is parameterized as shown in the figure below. Data block DB120 is used as an instance data block:
Figure 5-2: timer_day

Copyright Siemens AG 2011 All rights reserved

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

Time Switches V2.1, ID Number: 21669756

19

5 Description of the Time Switching Functions

5.1.2

Week time switch


FB timer_week checks whether the current system time and the current weekday in the S7 CPU are within the parameterized time interval on the input parameters of the block. If this is the case, the output will be set to 1. Otherwise, the output is 0. The block for the timer_week FB121 week time switch is parameterized as shown in the figure below. Data block DB121 is used as an instance data block:
Figure 5-3: timer_week

Copyright Siemens AG 2011 All rights reserved

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

Time Switches V2.1, ID Number: 21669756

5 Description of the Time Switching Functions

5.1.3

Month time switch


FB timer_month checks whether the current system time and the current day of the month in the S7 CPU are within the parameterized time interval on the input parameters of the block. If this is the case, the output will be set to 1. Otherwise, the output is 0. The block for the timer_month FB122 month time switch is parameterized as shown in the figure below. Data block DB122 is used as an instance data block:
Figure 5-4: timer_month

Copyright Siemens AG 2011 All rights reserved

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.

Time Switches V2.1, ID Number: 21669756

21

5 Description of the Time Switching Functions

5.1.4

Year time switch


FB timer_year checks whether the current system time and the current date in the S7 CPU are within the parameterized time interval on the input parameters of the block. If this is the case, the output will be set to 1. Otherwise, the output is 0. The block for the timer_year FB123 year time switch is parameterized as shown in the figure below. Data block DB123 is used as an instance data block:
Figure 5-5: timer_year

Copyright Siemens AG 2011 All rights reserved

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

Time Switches V2.1, ID Number: 21669756

5 Description of the Time Switching Functions

5.2

Relative time switch


FB timer_relative sets the output to 1 if a positive edge is detected at the EnableClock input. The output remains set to 1 until the parameterized time has elapsed. In addition, you can parameterize whether the parameterized time restarts with each positive edge or whether the system responds only to the first edge change.
Figure 5-6: timer_relative

Copyright Siemens AG 2011 All rights reserved

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-

CheckEdge of the BOOL type

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

Reset of the BOOL type

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.

Time Switches V2.1, ID Number: 21669756

23

5 Description of the Time Switching Functions

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:

EnableClock CheckEdge StartTime Reset Time Aktive Output

Copyright Siemens AG 2011 All rights reserved

CheckEdge = 1:

EnableClock CheckEdge StartTime Reset Time Aktive Output

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

Time Switches V2.1, ID Number: 21669756

5 Description of the Time Switching Functions

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

Program-controlled summer-/wintertime changeover


The block for the summer-/wintertime changeover adds exactly 1 hour to the current system time in the S7 CPU when wintertime is changed over to summertime and subtracts exactly 1 hour from the current system time in the S7 CPU when summertime is changed over to wintertime. The changeover from wintertime to summertime always takes place on the last Saturday in March. The changeover from summertime to wintertime takes place on the last Saturday in October.
Figure 5-7: summer_winter

Copyright Siemens AG 2011 All rights reserved

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.

Time Switches V2.1, ID Number: 21669756

25

5 Description of the Time Switching Functions

5.3.2

Radio-controlled summer-/wintertime changeover


Instead of the block described in chapter 7.4.1, a radio clock can optionally be used for the summer-/wintertime changeover. FB77 DCF77_FB is used for this purpose, which evaluates the radio clock signals. Block FB77 is included in the application example; however, it is not parameterized in the example. At this point, it is only shown as an alternative.
Figure 5-8: DCF77_FB

Copyright Siemens AG 2011 All rights reserved

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

Time Switches V2.1, ID Number: 21669756

5 Description of the Time Switching Functions

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

Time Switches V2.1, ID Number: 21669756

27

6 Operation of the Application

Operation of the Application


This application provides variable tables as an operating option for the time and special functions.

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

Absolute time switching functions


As an operator control and monitoring option, a VAT variable table is assigned to each absolute time switching function. These tables are VAT_timer_day for the day time switch VAT_timer_week for the week time switch VAT_timer_month for the month time switch VAT_timer_year for the year time switch

Copyright Siemens AG 2011 All rights reserved

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

End time of the time switch

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

Time Switches V2.1, ID Number: 21669756

6 Operation of the Application

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

Relative time switching function


The VAT_timer_relative variable table is available as an operator control and monitoring option for the relative time switching function.
Figure 6-2: VAT_timer_relative

Copyright Siemens AG 2011 All rights reserved

Input parameters

Runtime of the time function: One day, 2 hours, 10 minutes, 30 seconds Output parameters

Time Switches V2.1, ID Number: 21669756

29

6 Operation of the Application

6.3

Input of special days


The check for special days is performed using FC100 special_days. The special days data is stored in DB100 IDB_special_days and can be entered using the VAT_special_days variable table.
Figure 6-3: VAT_special_days

Output parameter

Special day 1 (06.01.2010)

Copyright Siemens AG 2011 All rights reserved

Special day 2 (25.12.2010)

30

Time Switches V2.1, ID Number: 21669756

7 Further Notes, Tips and Tricks, etc.

7
7.1

Further Notes, Tips and Tricks, etc.


How can I include several switch-on/switch-off times in one block?
Step 1 2 Action In the block container of the SIMATIC Manager, create a new FB and open it. Create as many input parameters of the associated UDT as switch-on/switch-off times needed (e.g., 3). Note: When calling, interconnect the input parameters of the new FB with the data areas that have the structure of the required UDT. In the statement section of the new FB, call the FB for the respective time function (depending on which UDT you have used) as often as you have configured an associated input parameter. Save the newly created FB. Now call this FB in your user program, e.g. OB1. Save Menu: PLC -> Download Or Download icon Note / action

3
Copyright Siemens AG 2011 All rights reserved

4 5 7 8

7.2

What do I have to do if I need more holidays or special days?


Step 1 Action Open the DB in which the holidays and special days are stored (in the example: DB100). Increase the number of array elements to the desired number (30 is entered by default). Note / action

3 4

Save the DB. Open the FC that checks the holidays (in the example: FC100).

Time Switches V2.1, ID Number: 21669756

31

7 Further Notes, Tips and Tricks, etc.

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

How can I integrate a SICLOCK radio clock into the project?


Introduction
The scope of this application included the explanation of the optional use of a SIPLUS radio clock. As an alternative, the SICLOCK radio clock can be used. The purpose of this chapter is to provide a concise description of the properties of the SICLOCK radio clock.

Copyright Siemens AG 2011 All rights reserved

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

77.5 kHz 400 Hz


(W x H x D) 185 x 80 x 65 mm 0.3 V

20 m, fixed SUBD 9-pole Via RS232 interface -10C to +50C IP65

32

Time Switches V2.1, ID Number: 21669756

7 Further Notes, Tips and Tricks, etc.

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

9-pole DSUB plug with 5 m 2XV9450-1AR35 connection cable Optocoupler 3TX7-005-3PB54

For connection to SIMATIC Optional

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

Figure 7-1: Hardware configuration with SICLOCK

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

Time Switches V2.1, ID Number: 21669756

33

7 Further Notes, Tips and Tricks, etc.

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

+13 Green (supply voltage)

Ground

A2 0V Brown (signal and supply ground) Gray (cable shield) E 0.3 14 A1 Yellow (receive signal)

Copyright Siemens AG 2011 All rights reserved

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

Time Switches V2.1, ID Number: 21669756

7 Further Notes, Tips and Tricks, etc.

7.3.6

Software interface and block parameterization


The scope of delivery of the hardware includes a disk with all S7 blocks that are necessary for the SICLOCK DCF77 Reception Service. These blocks are: FB100, DB100, SFC0, SFC39, SFC40, FC34. The blocks must be inserted into the block folder of your S7 project. Function block FB100 has to be called in the following blocks: OB 1 OB 100 (startup OB) OB 35 (10 ms cyclic interrupt)

Parameterization is performed as shown in the following table:

OB1

OB100

OB35

Copyright Siemens AG 2011 All rights reserved

Time Switches V2.1, ID Number: 21669756

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.

Copyright Siemens AG 2011 All rights reserved

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

Time Switches V2.1, ID Number: 21669756

Vous aimerez peut-être aussi