21669756_Zeitschaltuhr_einfach_DOKU_v21_e.pdf

Embed Size (px)

Citation preview

  • 7/27/2019 21669756_Zeitschaltuhr_einfach_DOKU_v21_e.pdf

    1/36

    Applications & ToolsAnswers for industry.

    Cover

    Time Switch Based on anS7-300/400 CPU with optionalRadio Clock Connection

    SIMATIC S7-300/400

    Application Description March 2011

  • 7/27/2019 21669756_Zeitschaltuhr_einfach_DOKU_v21_e.pdf

    2/36

    2Time Switches

    V2.1, ID Number: 21669756

    CopyrightS

    ie

    mensAG2

    011Allrightsreserved

    Industry Automation and Drive Technologies Service & Support Portal

    This document is taken from the Service Portal of Siemens AG, IndustryAutomation and Drive Technologies. The following link takes you directly to thedownload 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 thefollowing address:

    [email protected]

    http://support.automation.siemens.com/WW/view/en/21669756mailto:[email protected]:[email protected]://support.automation.siemens.com/WW/view/en/21669756
  • 7/27/2019 21669756_Zeitschaltuhr_einfach_DOKU_v21_e.pdf

    3/36

    Time SwitchesV2.1, ID Number: 21669756 3

    CopyrightS

    ie

    mensAG2

    011Allrightsreserved

    s

    SIMATIC

    Time Switches

    SIMATIC S7-300/400

    Automation Problem 1

    Automation Solution 2

    Functional Mechanismsof this Application 3

    Installation 4

    Description of theTime Switching Functions

    5

    Operation of the

    Application 6

    Further Notes, Tips andTricks, etc. 7

    References 8

    History 9

  • 7/27/2019 21669756_Zeitschaltuhr_einfach_DOKU_v21_e.pdf

    4/36

    Warranty and Liability

    4Time Switches

    V2.1, ID Number: 21669756

    CopyrightS

    ie

    mensAG2

    011Allrightsreserved

    Warranty and LiabilityNote The application examples are not binding and do not claim to be complete

    regarding the circuits shown, equipping and any eventuality. The applicationexamples do not represent customer-specific solutions. They are only intended

    to provide support for typical applications. You are responsible for ensuring thatthe described products are correctly used. These application examples do notrelieve you of the responsibility of safely and professionally using, installing,operating and servicing equipment. When using these application examples, yourecognize that Siemens cannot be made liable for any damage/claims beyondthe liability clause described. We reserve the right to make changes to theseapplication examples at any time without prior notice. If there are any deviationsbetween the recommendations provided in these application examples and otherSiemens publications e.g. Catalogs then the contents of the other documentshave 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 ofthe examples, information, programs, engineering and performance data etc.described in this application example shall be excluded. Such an exclusion shallnot apply in the case of mandatory liability, e.g. under the German Product LiabilityAct (Produkthaftungsgesetz), in case of intent, gross negligence, or injury of life,body or health, guarantee for the quality of a product, fraudulent concealment of adeficiency or breach of a condition which goes to the root of the contract(wesentliche Vertragspflichten). However, claims arising from a breach of acondition which goes to the root of the contract shall be limited to the foreseeabledamage which is intrinsic to the contract, unless caused by intent or grossnegligence or based on mandatory liability for injury of life, body or health. Theabove 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 ofthem without first having prior authorization from Siemens Industry Sector inwriting.

  • 7/27/2019 21669756_Zeitschaltuhr_einfach_DOKU_v21_e.pdf

    5/36

    Table of Contents

    Time SwitchesV2.1, ID Number: 21669756 5

    CopyrightS

    ie

    mensAG2

    011Allrightsreserved

    Table of ContentsWarranty and Liability ................................................................................................. 4

    1 Automation Problem ......................................................................................... 7

    1.1 Overview .............................................................................................. 71.2 Requirements ....................................................................................... 7

    2 Automation Solution ......................................................................................... 9

    2.1 Overview of the overall solution ........................................................... 92.2 Description of the core functionality ..................................................... 92.3 Hardware and software components used......................................... 10

    3 Functional Mechanisms of this Application ................................................. 11

    3.1 Absolute time switching functions ...................................................... 113.1.1 Day time switch .................................................................................. 113.1.2 Week time switch ............................................................................... 123.1.3 Month time switch............................................................................... 12

    3.1.4 Year time switch................................................................................. 123.2 Relative time switching function......................................................... 133.2.1 Relative time switch............................................................................ 133.3 Additional functions ............................................................................ 133.3.1 Summer-/wintertime changeover ....................................................... 133.3.2 Identification of holidays/special days................................................ 13

    4 Installation........................................................................................................ 14

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

    5 Description of the Time Switching Functions .............................................. 16

    5.1 Absolute time switching functions ...................................................... 175.1.1 Day time switch .................................................................................. 195.1.2 Week time switch ............................................................................... 205.1.3 Month time switch............................................................................... 215.1.4 Year time switch................................................................................. 225.2 Relative time switch............................................................................ 235.3 Additional functions ............................................................................ 255.3.1 Program-controlled summer-/wintertime changeover........................ 255.3.2 Radio-controlled summer-/wintertime changeover ............................ 265.3.3 Identification of holidays..................................................................... 27

    6 Operation of the Application .......................................................................... 28

    6.1 Absolute time switching functions ...................................................... 286.2 Relative time switching function......................................................... 296.3 Input of special days........................................................................... 30

    7 Further Notes, Tips and Tricks, etc. .............................................................. 31

    7.1 How can I include several switch-on/switch-off times in one block?.. 317.2 What do I have to do if I need more holidays or special days? ......... 317.3 How can I integrate a SICLOCK radio clock into the project? ........... 327.3.1 Introduction......................................................................................... 327.3.2 Functionality ....................................................................................... 327.3.3 Performance data............................................................................... 327.3.4 Hardware components....................................................................... 337.3.5 Hardware connection ......................................................................... 337.3.6 Software interface and block parameterization.................................. 35

    8 References ....................................................................................................... 36

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

  • 7/27/2019 21669756_Zeitschaltuhr_einfach_DOKU_v21_e.pdf

    6/36

    Table of Contents

    6Time Switches

    V2.1, ID Number: 21669756

    CopyrightS

    ie

    mensAG2

    011Allrightsreserved

    8.2 Internet links ....................................................................................... 36

    9 History............................................................................................................... 36

  • 7/27/2019 21669756_Zeitschaltuhr_einfach_DOKU_v21_e.pdf

    7/36

    1 Automation Problem

    Time SwitchesV2.1, ID Number: 21669756 7

    CopyrightS

    ie

    mensAG2

    011Allrightsreserved

    1 Automation Problem

    1.1 Overview

    Many fields of automation require accurate timing of processes. Even in domesticelectrical installation practice, individual systems must operate, for example,depending on the time of day or the day of the week. One possibility to solve thisproblem is to use electrical or mechanical time switches. The figure below showsexamples 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 keptsimple so that this clock can be easily used by ordinary persons.

    Accurate time switching of processes is also necessary in a large number ofindustrial applications in the field of automation.

    1.2 Requirements

    To be able to create the time characteristic of such or similar processes, theS7 CPU requires a block that, depending on the absolute time, sets an output orensures 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 possibleto parameterize a specific time interval that will elapse depending on a start event(relative time).

  • 7/27/2019 21669756_Zeitschaltuhr_einfach_DOKU_v21_e.pdf

    8/36

    1 Automation Problem

    8Time Switches

    V2.1, ID Number: 21669756

    CopyrightS

    ie

    mensAG2

    011Allrightsreserved

    Requirements for the automation problem

    In the S7 CPU, the automation problem requirements for the application are asfollows:

    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.

  • 7/27/2019 21669756_Zeitschaltuhr_einfach_DOKU_v21_e.pdf

    9/36

    2 Automation Solution

    Time SwitchesV2.1, ID Number: 21669756 9

    CopyrightS

    ie

    mensAG2

    011Allrightsreserved

    2 Automation Solution

    2.1 Overview of the overall solution

    Figure 2-1: Overall solution

    2.2 Description of the core functionality

    The application includes function blocks for absolute and relative time switchingfunctions (clocks). Each clock has only one setting option (corresponds to onecam), 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 optimumutilization 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 bya function block. As an option, this changeover can also be controlled using a radioclock. In this case, a digital input module (here: SM321) must be used since twodigital inputs are necessary to receive the data sent from the radio clock module.

    DCF77

  • 7/27/2019 21669756_Zeitschaltuhr_einfach_DOKU_v21_e.pdf

    10/36

    2 Automation Solution

    10Time Switches

    V2.1, ID Number: 21669756

    CopyrightS

    ie

    mensAG2

    011Allrightsreserved

    2.3 Hardware and software components used

    The application was created with the following components:

    Hardware components

    Table 2-1: Hardware used

    Component Qty. MLFB/order number Note

    PS307 2A 1 6ES7 307-1BA00-0AA0 Or similarpower supply

    CPU 315-2 DP 1 6ES7-315-2AG10-0AB0 Or other CPU

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

    Table 2-2: Optional hardware

    Component Qty. MLFB/order number Note

    SM 321 1 6ES7 321-7BH00-0AB0 Or other digitalinput module

    SIPLUS DCF77radio receiver

    1 6AG1057-1AA03-0AA0 Or SICLOCK

    Software components

    Table 2-3: Standard software

    Component Qty. MLFB/order number Note

    STEP7 V5.4+SP5 1 6ES7810-4CC08-0YA5

    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 Note

    21669756_Zeitschaltuhr_einfach_CODE_V2.1.zip This zip file contains the STEP 7project.

    21669756_Zeitschaltuhr_einfach_DOKU_V2.1.pdf This document.

  • 7/27/2019 21669756_Zeitschaltuhr_einfach_DOKU_v21_e.pdf

    11/36

    3 Functional Mechanisms of this Application

    Time SwitchesV2.1, ID Number: 21669756 11

    CopyrightS

    ie

    mensAG2

    011Allrightsreserved

    3 Functional Mechanisms of this ApplicationThe functions included in this application can be divided into the following groups.

    Figure 3-1: Function chart

    3.1 Absolute time switching functions

    3.1.1 Day time switch

    This block can cover a time interval within 24 hours, for example 8:00 a.m. to 12:00a.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.

  • 7/27/2019 21669756_Zeitschaltuhr_einfach_DOKU_v21_e.pdf

    12/36

    3 Functional Mechanisms of this Application

    12Time Switches

    V2.1, ID Number: 21669756

    CopyrightS

    ie

    mensAG2

    011Allrightsreserved

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

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

    Figure 3-3: Week time switch

    Tue, 8:00 p.m.

    Sun 12:00 Sat 11:59:59 p.m.

    Fri, 6:00 a.m.

    3.1.3 Month time switch

    This block can cover a time interval within 31 days, for example each month from12:00 a.m. on the 3

    rdto 9:00 p.m. on the 7

    th.

    Figure 3-4: Month time switch

    1st

    0:00 a.m.

    31st

    11:59:59 p.m.

    3r, 12:00 a.m. 7

    t, 9:00 p.m.

    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.

    31st Dec.

    11:59:59 p.m.

    13t

    April, 8:00 28t

    Sept, 12:00

  • 7/27/2019 21669756_Zeitschaltuhr_einfach_DOKU_v21_e.pdf

    13/36

    3 Functional Mechanisms of this Application

    Time SwitchesV2.1, ID Number: 21669756 13

    CopyrightS

    ie

    mensAG2

    011Allrightsreserved

    3.2 Relative time switching function3.2.1 Relative time switch

    The clock is activated by a start signal and remains active until the parameterizedtime interval has elapsed.

    Figure 3-6: Relative time switch

    Start signal

    Parameterized time

    (e.g.: 3 hours)

    3.3 Additional functions

    3.3.1 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 tosummertime or from summertime to wintertime.

    For the summer-/wintertime changeover, two options are available:

    1. Radio-controlled changeoverThe system time is adjusted after the radio clock connected to the system hasprovided 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/yearformat. The block checks whether a day in this data block matches the current dateand 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 achievethat, for example, the day time switch is not switched on on holidays.

  • 7/27/2019 21669756_Zeitschaltuhr_einfach_DOKU_v21_e.pdf

    14/36

    4 Installation

    14Time Switches

    V2.1, ID Number: 21669756

    CopyrightS

    ie

    mensAG2

    011Allrightsreserved

    4 Installation

    4.1 Hardware installation

    For the hardware components, please refer to chapter2.3Hardware and softwarecomponents used.

    Figure 4-1: Hardware of the application

    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 tothe power supply / SM 321 as follows:

    Table 4-1: Hardware installation: Radio clock

    PS SM 321 SIPLUS DCF77

    E 0.0 Sec

    E 0.1 DCF Data

    L+ 24Vdc

    M Ground

    You can also connect the radio clock to digital inputs that differ from the onesdescribed here. In this case, you only have to adjust the interconnection of theSekTakt 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

  • 7/27/2019 21669756_Zeitschaltuhr_einfach_DOKU_v21_e.pdf

    15/36

    4 Installation

    Time SwitchesV2.1, ID Number: 21669756 15

    CopyrightS

    ie

    mensAG2

    011Allrightsreserved

    Note When selecting the place of installation of the SIPLUS DCF77 radio clockmodule, it should be ensured that the radio clock signal is not shielded bybuilding faades made of metal or similar material. The actual module must beshielded 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 supplyvoltage to the SIPLUS DCF77 radio clock module. If there is radio reception, theouter red LED must flash every second. If this is not the case or if the LEDsputters after a longer period of operation, a more suitable place of installationshould be selected. Depending on the reception conditions, setting the clocknormally lasts approximately 3-4 minutes; however, it may take longer atunfavorable places of installation.

  • 7/27/2019 21669756_Zeitschaltuhr_einfach_DOKU_v21_e.pdf

    16/36

    5 Description of the Time Switching Functions

    16Time Switches

    V2.1, ID Number: 21669756

    CopyrightS

    ie

    mensAG2

    011Allrightsreserved

    5 Description of the Time SwitchingFunctions

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

    Figure 5-1: Program structure

    OB1

    call summer_winterFB103 FB103

    prfe, ob Sommer-/Winterzeit-umschaltungstattgefunden hat

    DB103

    InstanzDB zu FB103

    callday FB120 FB120

    prfe, ob aktuelle Zeit impara-

    metriertenZeitraum liegt

    DB120

    InstanzDB zu FB120

    call weekFB121 FB121

    prfe, ob aktuelle Zeit impara-metriertenZeitraum liegt

    DB121

    InstanzDB zu FB121

    call monthFB122 FB122

    prfe, ob aktuelle Zeit impara-metriertenZeitraum liegt

    DB122

    InstanzDB zu FB122

    call yearFB123 FB123

    prfe, ob aktuelle Zeit impara-

    metriertenZeitraum liegt

    DB123

    InstanzDB zu FB123

    call relativ FB124 FB124

    prfe, ob aktuelle Zeit impara-

    metriertenZeitraum liegt

    DB124

    InstanzDB zu FB124

    callcheck_holidaysFC100 FC100

    prfe, ob aktuelles Datum ein

    Feiertag oder Sondertag ist

    DB100

    DB mit Feier-und Sondertagen Additionalfunctions

    Absolute

    tim

    eswitchingfunctions

    Relative

    timeswitchingfunction

    (Kapitel 4.3.3.1)

    (Kapitel 4.3.3.2)

    (Kapitel 4.3.1.1)

    (Kapitel 4.3.1.2)

    (Kapitel 4.3.1.3)

    (Kapitel 4.3.1.4)

    (Kapitel 4.3.2)

    OB1

    call summer_winterFB103 FB103

    check whether summer/wintertime changeover occurred

    DB103

    InstancDBto FB103

    calltimer_day FB120 FB120

    check whether current time is

    within parameterized range

    DB120

    Instance DBto FB120

    call timer_week FB121 FB121

    check whether current time iswithin parameterized range

    DB121

    InstancDB to FB121

    call timer_month FB122 FB122

    check whether current time iswithin parameterized range

    DB122

    InstancDB to FB122

    call timer_year FB123 FB123

    check whether current time is

    within parameterized range

    DB123

    InstancDB to FB123

    call timer_relativ FB124 FB124

    check whether current time is

    within parameterized range

    DB124

    InstancDB to FB124

    callspecial_daysFC100 FC100

    check whether current date is

    holiday or special day

    DB100

    DB with holiday/special days

  • 7/27/2019 21669756_Zeitschaltuhr_einfach_DOKU_v21_e.pdf

    17/36

    5 Description of the Time Switching Functions

    Time SwitchesV2.1, ID Number: 21669756 17

    CopyrightS

    ie

    mensAG2

    011Allrightsreserved

    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 beactive, including absolute start and end time. The parameter is specific foreach time switch.

    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

  • 7/27/2019 21669756_Zeitschaltuhr_einfach_DOKU_v21_e.pdf

    18/36

    5 Description of the Time Switching Functions

    18Time Switches

    V2.1, ID Number: 21669756

    CopyrightS

    ie

    mensAG2

    011Allrightsreserved

    Note The EN input parameter and the ENO output parameter are parameters thatare included by default in the S7 blocks. For more information, please refer to theSTEP 7 documentation and the respective online help.

    The EnableClock, Time_To_Check and Reset input signals and the Q outputbehave towards one another as shown in the following pulse timing diagram:

    ime range

    t is a programmed time range (time switch active)

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

  • 7/27/2019 21669756_Zeitschaltuhr_einfach_DOKU_v21_e.pdf

    19/36

    5 Description of the Time Switching Functions

    Time SwitchesV2.1, ID Number: 21669756 19

    CopyrightS

    ie

    mensAG2

    011Allrightsreserved

    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 inthe figure below. Data block DB120 is used as an instance data block:

    Figure 5-2: timer_day

    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 astructure of the times (UDT6) type

    End hour, end minute, end second, combined as endtime and with a structure

    of the times (UDT6) type

  • 7/27/2019 21669756_Zeitschaltuhr_einfach_DOKU_v21_e.pdf

    20/36

    5 Description of the Time Switching Functions

    20Time Switches

    V2.1, ID Number: 21669756

    CopyrightS

    ie

    mensAG2

    011Allrightsreserved

    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 ofthe block. If this is the case, the output will be set to 1. Otherwise, the output is0.

    The block for the timer_week FB121 week time switch is parameterized as shownin the figure below. Data block DB121 is used as an instance data block:

    Figure 5-3: timer_week

    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 astructure 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 structureof the times_udt (UDT6) type

    If the startday parameter has a value between 1 and 7, only a value between 1and 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.

  • 7/27/2019 21669756_Zeitschaltuhr_einfach_DOKU_v21_e.pdf

    21/36

    5 Description of the Time Switching Functions

    Time SwitchesV2.1, ID Number: 21669756 21

    CopyrightS

    ie

    mensAG2

    011Allrightsreserved

    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 inputparameters 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 asshown in the figure below. Data block DB122 is used as an instance data block:

    Figure 5-4: timer_month

    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 astructure 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 structureof the times_udt (UDT6) type

    Note When parameterizing start day and end day, it must be considered that not everymonth has 31 days. If a function is to be executed on or until or starting from thelast day of the month, 32 must be entered instead of 28, 30 or 31. The blockchecks which month is the current month and automatically sets the end day tothe last day of this month.

  • 7/27/2019 21669756_Zeitschaltuhr_einfach_DOKU_v21_e.pdf

    22/36

    5 Description of the Time Switching Functions

    22Time Switches

    V2.1, ID Number: 21669756

    CopyrightS

    ie

    mensAG2

    011Allrightsreserved

    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 theblock. 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 shownin the figure below. Data block DB123 is used as an instance data block:

    Figure 5-5: timer_year

    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 astructure of the times_udt (UDT6) type

    End month

    End day

    End hour, end minute, end second, combined as endtime and with a structureof the times_udt (UDT6) type

  • 7/27/2019 21669756_Zeitschaltuhr_einfach_DOKU_v21_e.pdf

    23/36

    5 Description of the Time Switching Functions

    Time SwitchesV2.1, ID Number: 21669756 23

    CopyrightS

    ie

    mensAG2

    011Allrightsreserved

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

    In addition, you can parameterize whether the parameterized time restarts witheach positive edge or whether the system responds only to the first edge change.

    Figure 5-6: timer_relative

    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

    CheckEdge of the BOOL type

    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 isevaluated. When the time has elapsed, the clock can be restarted byanother edge change at the StartTime input-

    Time_To_Go

    The Time_To_Go parameter is a structure of the relative_udt (UDT5) type. Itincludes:

    Number of days

    Number of hours

    Number of minutes

    Number of seconds

    Reset of the BOOL type

    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.

  • 7/27/2019 21669756_Zeitschaltuhr_einfach_DOKU_v21_e.pdf

    24/36

    5 Description of the Time Switching Functions

    24Time Switches

    V2.1, ID Number: 21669756

    CopyrightS

    ie

    mensAG2

    011Allrightsreserved

    Control parameters for the relative time switch are EnableClock, CheckEdge,Reset and StartTime. The control parameters and the output behave towards oneanother as shown in the following pulse timing diagrams.

    CheckEdge = 0:

    CheckEdge = 1:

    The block for the timer_relative FB124 relative time switch is parameterized asshown in the figure below. Data block DB124 is used as an instance data block:

    EnableClock

    CheckEdge

    StartTime

    Reset

    Time Aktive

    Output

    EnableClock

    CheckEdge

    StartTime

    Reset

    Time Aktive

    Output

  • 7/27/2019 21669756_Zeitschaltuhr_einfach_DOKU_v21_e.pdf

    25/36

    5 Description of the Time Switching Functions

    Time SwitchesV2.1, ID Number: 21669756 25

    CopyrightS

    ie

    mensAG2

    011Allrightsreserved

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

    5.3.1 Program-controlled summer-/wintertime changeover

    The block for the summer-/wintertime changeover adds exactly 1 hour to thecurrent system time in the S7 CPU when wintertime is changed over tosummertime and subtracts exactly 1 hour from the current system time in theS7 CPU when summertime is changed over to wintertime. The changeover fromwintertime to summertime always takes place on the last Saturday in March. Thechangeover from summertime to wintertime takes place on the last Saturday in

    October.Figure 5-7: summer_winter

    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, executionof 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.

  • 7/27/2019 21669756_Zeitschaltuhr_einfach_DOKU_v21_e.pdf

    26/36

    5 Description of the Time Switching Functions

    26Time Switches

    V2.1, ID Number: 21669756

    CopyrightS

    ie

    mensAG2

    011Allrightsreserved

    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 thispurpose, which evaluates the radio clock signals.

    Block FB77 is included in the application example; however, it is not parameterizedin the example. At this point, it is only shown as an alternative.

    Figure 5-8: DCF77_FB

    The block has the following input parameters:

    SekTakt of the BOOL type One-second interval input of the DCF77 module

    Data of the BOOL type Bit pattern input, data of the DCF77module

    SekCPU of the BOOL type 1 Hz clock bit memory of the CPU clock

    DCF77 of the Timer type Timing element for the detection of the minutemark

    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 takesplace in one hour

    Min_Puls of the BOOL typeA 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 alonger period of time

  • 7/27/2019 21669756_Zeitschaltuhr_einfach_DOKU_v21_e.pdf

    27/36

    5 Description of the Time Switching Functions

    Time SwitchesV2.1, ID Number: 21669756 27

    CopyrightS

    ie

    mensAG2

    011Allrightsreserved

    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 datein 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 specialdays.

    The block has the following output parameter:

    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

  • 7/27/2019 21669756_Zeitschaltuhr_einfach_DOKU_v21_e.pdf

    28/36

    6 Operation of the Application

    28Time Switches

    V2.1, ID Number: 21669756

    CopyrightS

    ie

    mensAG2

    011Allrightsreserved

    6 Operation of the ApplicationThis application provides variable tables as an operating option for the time andspecial functions.

    Note The individual input and output parameters of the functions have already beendescribed in chapter5Description of the Time Switching Functions.

    6.1 Absolute time switching functions

    As an operator control and monitoring option, a VAT variable table is assigned toeach 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

    The figure below shows the VAT_timer_month variable table of FB122timer_month as an example of the operation of the absolute time switches.

    Figure 6-1: VAT_timer_month

    The table starts with the input parameters of the time functions. This is where thefunction 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 statusand a possibly occurring error code are displayed here.

    Inputparameters

    Outputparameters

    Start time of thetime switch: Fifthday, 11:21:00 h

    End time of the

    time switch

  • 7/27/2019 21669756_Zeitschaltuhr_einfach_DOKU_v21_e.pdf

    29/36

    6 Operation of the Application

    Time SwitchesV2.1, ID Number: 21669756 29

    CopyrightS

    ie

    mensAG2

    011Allrightsreserved

    Note Operation of the absolute time functions differs only in the number of parametersfor 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 andmonitoring option for the relative time switching function.

    Figure 6-2: VAT_timer_relative

    Outputparameters

    Inputparameters

    Runtime of thetime function:One day,2 hours,

    10 minutes,30 seconds

  • 7/27/2019 21669756_Zeitschaltuhr_einfach_DOKU_v21_e.pdf

    30/36

    6 Operation of the Application

    30Time Switches

    V2.1, ID Number: 21669756

    CopyrightS

    ie

    mensAG2

    011Allrightsreserved

    6.3 Input of special days

    The check for special days is performed using FC100 special_days. The specialdays 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

    Special day 1(06.01.2010)

    Special day 2(25.12.2010)

    Outputparameter

  • 7/27/2019 21669756_Zeitschaltuhr_einfach_DOKU_v21_e.pdf

    31/36

    7 Further Notes, Tips and Tricks, etc.

    Time SwitchesV2.1, ID Number: 21669756 31

    CopyrightS

    ie

    mensAG2

    011Allrightsreserved

    7 Further Notes, Tips and Tricks, etc.

    7.1 How can I include several switch-on/switch-off times inone block?

    Step Action Note / action

    1 In the block container of the SIMATICManager, create a new FB and open it.

    2 Create as many input parameters of theassociated UDT as switch-on/switch-off timesneeded (e.g., 3).

    Note:When calling, interconnect the inputparameters of the new FB with the data areasthat have the structure of the required UDT.

    3 In the statement section of the new FB, call theFB for the respective time function (dependingon which UDT you have used) as often as youhave configured an associated inputparameter.

    4 Save the newly created FB.

    5 Now call this FB in your user program, e.g.OB1.

    7 Save

    8 Menu: PLC -> Download Or Download icon

    7.2 What do I have to do if I need more holidays or specialdays?

    Step Action Note / action

    1 Open the DB in which the holidays andspecial days are stored (in the example:DB100).

    2 Increase the number of array elements to

    the desired number (30 is entered bydefault).

    3 Save the DB.

    4 Open the FC that checks the holidays (inthe example: FC100).

  • 7/27/2019 21669756_Zeitschaltuhr_einfach_DOKU_v21_e.pdf

    32/36

    7 Further Notes, Tips and Tricks, etc.

    32Time Switches

    V2.1, ID Number: 21669756

    CopyrightS

    ie

    mensAG2

    011Allrightsreserved

    Step Action Note / action

    5 Increase the loop counter. The loopcounter must be as large as the number

    of array elements (by default, the loopcounter is 30).

    Note:The code sequence is in network 2 of theblock.

    7 Save the FC.

    8 Download the block via the PLC ->

    Download menu in the SIMATIC

    Manager.

    Or Download icon

    7.3 How can I integrate a SICLOCK radio clock into theproject?

    7.3.1 Introduction

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

    7.3.2 Functionality

    Basically, the SICLOCK radio clock has the same functionality as SIPLUS. It isused to receive the DCF77 time signal transmitter whose signal is demodulatedand provided as a pulse for the S7. The supplied software synchronizes the S7CPU 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 77.5 kHz

    Bandwidth 400 Hz

    Dimensions (W x H x D) 185 x 80 x 65 mm

    Sensitivity 0.3 V

    Connection cable 20 m, fixed

    Plug type SUBD 9-pole

    Power supply Via RS232 interface

    Operating temperature -10C to +50C

    Degree of protection IP65

  • 7/27/2019 21669756_Zeitschaltuhr_einfach_DOKU_v21_e.pdf

    33/36

    7 Further Notes, Tips and Tricks, etc.

    Time SwitchesV2.1, ID Number: 21669756 33

    CopyrightS

    ie

    mensAG2

    011Allrightsreserved

    7.3.4 Hardware components

    The following hardware components are necessary to connect it to the S7-300:

    Component Order no. Description/pictureSICLOCK DCFRS 2XV9450-1AR06 DCF77 receiver

    9-pole DSUB plug with 5 mconnection cable

    2XV9450-1AR35 For connection to SIMATIC

    Optocoupler 3TX7-005-3PB54 Optional

    The diagrammatic representation below shows the complete hardwareconfiguration of an S7-300 with a SICLOCK radio clock:

    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 asfollows:

    PS SM 321 SICLOCK

    E 0.3 Yellow (receive signal)

    M Gray (cable shield)

    L+ Green (supply voltage)

    M Brown (signal and supply ground)

  • 7/27/2019 21669756_Zeitschaltuhr_einfach_DOKU_v21_e.pdf

    34/36

    7 Further Notes, Tips and Tricks, etc.

    34Time Switches

    V2.1, ID Number: 21669756

    CopyrightS

    ie

    mensAG2

    011Allrightsreserved

    To amplify the SICLOCK encoder signal, it may be necessary to use anoptocoupler. In this case, the following scheme is used for the wiring:

    SIMATIC S7PS SM

    Optocoupler SICLOCK

    +1324Vdc

    Green (supply voltage)

    A2

    0V

    Brown (signal and supply ground)

    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 beensured that the radio clock signal is not shielded by building faades made ofmetal or similar material. The actual module must be shielded from interferencefrequencies and should not be attached directly on a metal surface.

  • 7/27/2019 21669756_Zeitschaltuhr_einfach_DOKU_v21_e.pdf

    35/36

    7 Further Notes, Tips and Tricks, etc.

    Time SwitchesV2.1, ID Number: 21669756 35

    CopyrightS

    ie

    mensAG2

    011Allrightsreserved

    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

  • 7/27/2019 21669756_Zeitschaltuhr_einfach_DOKU_v21_e.pdf

    36/36

    8 References

    CopyrightS

    ie

    mensAG2

    011Allrightsreserved

    8 References

    8.1 References

    This list is by no means complete and only presents a selection of relatedreferences.

    Table 8-1

    Topic Title

    /1/ STEP7 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 appropriateinformation.

    Table 8-2

    Topic Title

    \1\ Reference to thedocument

    http://support.automation.siemens.com/WW/view/en/21669756

    \2\ Siemens I IA/DTCustomer Support

    http://support.automation.siemens.com

    \3\

    9 History

    Table 9-1

    Version Date Modification

    V2.0 07/2002 First edition

    V2.0.1 08/2006 Error correction in week time switch, FB121

    V2.1 03/2011 To simplify the example, the OP connection was removed

    http://support.automation.siemens.com/WW/view/en/21669756http://support.automation.siemens.com/http://support.automation.siemens.com/http://support.automation.siemens.com/WW/view/en/21669756