Wincc Configuration Manual Volume 2

download Wincc Configuration Manual Volume 2

of 456

description

Wincc Configuration Manual Volume 2

Transcript of Wincc Configuration Manual Volume 2

  • WinCC

    Configuration Manual

    Manual

    Volume 2

    C79000-G8276-C140-01

    Edition February 1999

  • WinCC, SIMATIC, SINEC, STEP are Siemens registered trademarks.

    All other product and system names in this manual are (registered) trademarks of their respective owners andmust be treated accordingly.

    (The reproduction, transmission or use of this document or itscontents is not permitted without express written authority.Offenders will be liable for damages. All rights, including rightscreated by patent grant or registration of a utility model ordesign, are reserved.)

    (We have checked the contents of this manual for agreementwith the hardware and software described. Since deviationscannot be precluded entirely, we cannot guarantee fullagreement. However, the data in this manual are reviewedregularly and any necessary corrections included in subsequenteditions. Suggestions for improvement are welcomed.)

    Siemens AG 1994 - 1999 All rights reserved Technical data subject to change

    C79000-G8276-C140-01Printed in the Federal Republic of Germany Siemens Aktiengesellschaft

  • WinCC Configuration Manual iC79000-G8276-C140-01

    Table of Contents1 Configuration - Examples ......................................................... 1-1

    2 Tags (Project: varia_00.mcp).................................................... 2-12.1 Creating, grouping and moving tags............................................. 2-22.2 Incrementing, decrementing and jogging...................................... 2-72.2.1 Jogging - changing a set value (example 01)................................ 2-82.2.2 Jogging - changing a set value using Global Script (example 02) . 2-102.2.3 Jogging - buttons (example 05).................................................... 2-132.2.4 Jogging - changeover switch (example 06)................................... 2-172.2.5 Incrementing and decrementing (example 01).............................. 2-192.2.6 Incrementing and decrementing using Global Script (example 02) 2-222.2.7 The other examples related to this topic ....................................... 2-272.3 Changing tag value using Windows Objects................................. 2-282.3.1 Inputting by means of a slider with direct connection

    (example 01)................................................................................ 2-292.3.2 Inputting by means of slider and tag connection (example 03)...... 2-322.3.3 Inputting by means of an Option Group (example 02)................... 2-342.3.4 Inputting by means of check box (example 04)............................. 2-362.4 Bit editing in words....................................................................... 2-392.4.1 Directly setting a bit with the aid of a check box and direct

    connection (example 06).............................................................. 2-402.4.2 Selecting a bit and changing its state (example 01) ...................... 2-432.4.3 The other examples related to this topic ....................................... 2-462.5 Indirect addressing of tags ........................................................... 2-472.5.1 Indirect addressing by means of a direct connection

    (example 01)................................................................................ 2-482.5.2 Multiplex display using indirect addressing and a C action

    (example 02)................................................................................ 2-502.5.3 Indirect addressing by means of C action (example 03)................ 2-522.5.4 The other examples related to this topic ....................................... 2-542.6 Simulation of tags ........................................................................ 2-552.6.1 Simulating a triangular oscillation by means of a C action

    (example 01)................................................................................ 2-562.6.2 Simulation by means of an external program (example 02) .......... 2-592.7 Importing / exporting tags............................................................. 2-612.8 Using structure tags ..................................................................... 2-632.8.1 Valve control by means of a structure tag (example 01) ............... 2-642.9 Serial connection to S5 ................................................................ 2-672.9.1 The other examples related to this topic ....................................... 2-68

    3 Picture configuration (Project: pictu_00.mcp)........................ 3-13.1 Screen layout and changing pictures............................................ 3-33.1.1 Laying out the screen................................................................... 3-43.2 Picture change............................................................................. 3-63.2.1 Opening a picture by means of a direct connection and

    displaying the picture name (example 01) .................................... 3-7

  • 7DEOHRI&RQWHQWV

    ii WinCC Configuration ManualC79000-G8276-C140-01

    3.2.2 Opening a picture by means of the Dynamic Wizard(example 02) ............................................................................... 3-12

    3.2.3 Opening a picture by means of internal function (example 02)...... 3-143.2.4 Single picture change by means of the Dynamic Wizard

    (example 03) ............................................................................... 3-153.2.5 Single picture change by means of a direct connection

    (example 04) ............................................................................... 3-173.2.6 Opening a picture by means of the object name and an internal

    function (example 05) .................................................................. 3-193.2.7 Opening a picture by means of the object name and a tag

    connection, with display of the picture name (example 06) ........... 3-213.3 Shutdown WinCC / access protection .......................................... 3-253.3.1 Shutting down (exiting) runtime and the system (example 01) ...... 3-263.3.2 Access protection, login by means of a standard box

    (example 02) ............................................................................... 3-283.3.3 Operator-Control Enable, login in a separate dialog box

    (example 03) ............................................................................... 3-313.4 Showing a picture window............................................................ 3-333.4.1 Showing and hiding from outside a picture window (example 01) . 3-343.4.2 Showing from outside and hiding from inside a picture window

    (example 02) .............................................................................. 3-363.4.3 Time-controlled hiding of a picture window (example 03).............. 3-373.4.4 Showing a picture window while holding down the right mouse

    button (example 04)..................................................................... 3-393.4.5 Configuring info (instruction) boxes with the wizard (example 05). 3-403.4.6 Showing a dialog box for entering text (example 06) .................... 3-443.5 Zoom........................................................................................... 3-463.5.1 Changing picture geometry between two sizes (example 01) ....... 3-473.5.2 Changing the picture geometry steplessly (smooth zoom)

    (example 02) ............................................................................... 3-503.5.3 Configuring adjustable picture geometry by means of the

    properties dialog (example 03)..................................................... 3-523.6 Operator panels........................................................................... 3-533.6.1 Binary switching operation (two-step control) (example 01) .......... 3-543.6.2 Binary S/R switching operation (two-step control) (example 02) ... 3-563.6.3 Binary switching operation with acknowledgement (example 03).. 3-583.6.4 Automatic input check (example 04) ............................................ 3-603.6.5 Enhanced automatic input check (example 05) ............................ 3-623.6.6 Multiple operation (example 06) ................................................... 3-663.7 Dynamics .................................................................................... 3-703.7.1 Color change (example 01).......................................................... 3-713.7.2 Text exchange (example 02)........................................................ 3-733.7.3 Animation of movement (example 03).......................................... 3-743.7.4 Showing and hiding objects by means of bit evaluation

    (example 04) ............................................................................... 3-753.7.5 Animation of movement by means of a C action (example 05) ..... 3-773.7.6 Create animation of movement by means of a wizard

    (example 06) ............................................................................... 3-793.7.7 Color change by means of a C action (example 06) ..................... 3-813.7.8 Animation of movement by means of a status display

    (example 07) ............................................................................... 3-82

  • 7DEOHRI&RQWHQWV

    WinCC Configuration Manual iiiC79000-G8276-C140-01

    3.8 Language switch.......................................................................... 3-843.8.1 Change runtime language (example 01)....................................... 3-853.8.2 Dialog box for changing the runtime and Control Center language

    (example 02)................................................................................ 3-863.9 Working without a mouse............................................................. 3-873.9.1 Operation with the TAB key or hot key (example 01) .................... 3-883.9.2 Cursor keyboard (example 02)..................................................... 3-963.9.3 Value input, control actions (example 03)..................................... 3-1013.10 Showing and hiding information ................................................... 3-1043.10.1 Showing and hiding objects (example 01) .................................... 3-1053.10.2 Displaying the date and time (example 02)................................... 3-1073.11 Configuring messages ................................................................. 3-109

    4 Additional Functions in WinCC (Project: example_01.mcp).. 4-14.1 Tag Logging................................................................................. 4-24.1.1 Cyclic-Continuous Archiving (ex_3_chapter_01.PDL) ................... 4-34.1.2 Cyclic-Selective Archiving (ex_3_chapter_01a.PDL) .................... 4-184.1.3 Archiving if Value is Exceeded (ex_3_chapter_01b.PDL) ............. 4-244.1.4 User defined table layout (ex_3_chapter_01c.PDL)...................... 4-334.1.5 Archiving of binary tags (ex_3_chapter_01d.PDL) ........................ 4-424.1.6 Archiving at Set Times (ex_3_chapter_01e.PDL) ......................... 4-464.1.7 Exporting an Archive (ex_3_chapter_01f.PDL) ............................. 4-504.2 Alarm Logging.............................................................................. 4-554.2.1 Bit Message Procedure (ex_3_chapter_02.PDL) .......................... 4-564.2.2 Bit Message Procedure (Continued)............................................. 4-694.2.3 Analog Alarms (ex_3_chapter_02a.PDL)...................................... 4-784.2.4 Analog Alarms (continued) ........................................................... 4-844.2.5 Message Window (ex_3_chapter_02b.PDL)................................. 4-954.2.6 Message Archiving (ex_3_chapter_02c.PDL) ............................... 4-984.2.7 WinCC Alarm Control (ex_3_chapter_02d.PDL)........................... 4-1054.2.8 Group Messages (ex_8_generator_00.PDL) ................................ 4-1094.3 Report Designer........................................................................... 4-1174.3.1 Picture Documentation (ex_3_chapter_03.PDL)........................... 4-1184.3.2 Reporting the Project Function (ex_3_chapter_03.PDL) ............... 4-1244.3.3 Reporting of the Control Center (ex_3_chapter_03.PDL).............. 4-1274.3.4 Reporting of Tag Logging CS (ex_3_chapter_03.PDL) ................. 4-1304.3.5 Print Out the Trend Window in Runtime (ex_3_chapter_01a.PDL) 4-1324.3.6 Printing Out the Table in Runtime (ex_3_chapter_01c.PDL)......... 4-1394.3.7 Message Sequence Report (ex_3_chapter_02b.PDL) .................. 4-1434.3.8 Message Sequence Report on a Line Printer ............................... 4-1464.3.9 Message Archive Report (ex_3_chapter_02c.PDL) ...................... 4-1484.4 OLE Communication to EXCEL.................................................... 4-1504.4.1 Reading and Writing Tag Values (ex_3_chapter_04.PDL) ............ 4-1514.5 Additional Configurations in the Examples.................................... 4-1554.5.1 Picture Register ........................................................................... 4-1564.5.2 Table of Contents ........................................................................ 4-1604.5.3 Dialog Boxes for Setting Colors (ex_3_chapter_01c).................... 4-1634.5.4 Bar Graph Display (ex_3_chapter_01e) ....................................... 4-166

    5 User Archive .............................................................................. 5-1

  • 7DEOHRI&RQWHQWV

    iv WinCC Configuration ManualC79000-G8276-C140-01

    5.1 User Archive................................................................................ 5-25.1.1 Creating a User Archive (ex_3_chapter_01.PDL)......................... 5-35.1.2 Data Entry (ex_3_chapter_01.PDL) ............................................. 5-125.1.3 Configuring a Table View (ex_3_chapter_01.PDL) ....................... 5-165.1.4 Configuring a Form View (ex_3_chapter_011.PDL)...................... 5-245.1.5 Working with Control Tags (ex_3_chapter_012.PDL) ................... 5-295.1.6 Connecting via WinCC Tags (ex_3_chapter_01a.pdl) .................. 5-355.1.7 Connection via WinCC Raw Data Tags to the S5

    (ex_3_chapter_01b.pdl) ............................................................... 5-505.1.8 Connection via WinCC Raw Data Tags to the S7

    (ex_3_chapter_01c.pdl) ............................................................... 5-715.1.9 Status Monitoring of External Tags (ex_3_chapter_01c.pdl)......... 5-1005.1.10 Structure of raw data message frames......................................... 5-105

  • 7DEOHRI&RQWHQWV

    WinCC Configuration Manual vC79000-G8276-C140-01

    3UHIDFH

    3XUSRVHRIWKHPDQXDO

    The purpose of this manual is to show you the options open to you when configuring withWinCC and it does this by means of the following sections:

    description of example project YDULDB description of example project SLFWXB description of example project H[DPSOHB

    The Contents or Index will point you quickly and easily to the information you require.This information is of course also available as an on-line document in HTML format andwith enhanced search functions.

    You will find general information on effective and efficient configuration with WinCC inthe :LQ&&&RQILJXUDWLRQ0DQXDO3DUW.

    5HTXLUHPHQWVIRUXVLQJWKLVPDQXDO

    Knowledge of WinCC *HWWLQJ6WDUWHG) or practical configuration experience usingWinCC.

    $GGLWLRQDO6XSSRUW

    For technical questions, please contact your local Siemens representative at the responsiblebranch office.

    Their addresses can be found at the "Siemens Worlwide Appendix" of the "S7-300Programmable Controller System, Hardware and Installtion Manual", in catalogs, and atCompuServe ("go autforum").

    You can also direct your questions to our Hotline, which can be reached at:+49 (911) 895-7000 (Fax 7001).

    Additional information can be found on the Internet at the address:www.aut.siemens.de/coros/html_00/coros.htm.

  • 7DEOHRI&RQWHQWV

    vi WinCC Configuration ManualC79000-G8276-C140-01

    ,QIRUPDWLRQDERXW6,0$7,&3URGXFWV

    Continuously updated information about SIMATIC products can be obtained: from the Internet at http://www.aut.siemens.de/ via fax back service at 0876593 02 77 95 00

    Additionally, the SIMATIC Customer Support provides you with current information anddownloads helpful for the application of SIMATIC products. They can be reached:

    from the Internet at http://www.aut.siemens.de/support/html_00/index.shtml via the SIMATIC Customer Support Mailbox at +49 (911) 8957100 To access the mailbox, use a modem up to V.34 (28.8 kBaud). Set its parameters as

    follows: 8, N, 1, ANSI, or dial-in via ISDN (x.75, 64 kBit).The SIMATIC Customer Support can be reached by phone at +49 (911) 8957000 and byfax at +49 (911) 8957002. Inquiries can also be made via Internet mail or to the abovemailbox.

  • 6DPSOH3URMHFWV

    WinCC Configuration Manual 1-1C79000-G8276-C140-01

    &RQILJXUDWLRQ([DPSOHVIn this section of the manual, we describe configuration using WinCC on the basis ofsample projects. Taking into account the multitude of potential applications WinCC has tooffer, the projects described below are to be seen only as examples of what can be donewith WinCC.

    1RWH

    The projects have been configured for a resolution of 1024 x 768. If you would prefer tostart the projects with a resolution of 800 x 600, you must select the window attributes )XOO6FUHHQand6OLGHU under&RQWURO&HQWHU&RPSXWHU3URSHUWLHV3URSHUWLHV*UDSKLFV5XQWLPH.

    The partitioning of the screen and the associated presettings and scripts associated with thisare described in more detail in Chapter /D\LQJRXWWKHVFUHHQ nher beschrieben.

    1RWH

    There is frequently more than just a single method of tackling a particular task. If a task canbe implemented by means of a direct link, you should DOZD\V choose this type ofdynamization, since this is the method which offers the best level of performance inruntime.

    The consequence of configuring a direct link for an event is that when this event occursduring runtime, the valueof a source element (source) is taken over for a destinationelement (destination). Sources can take the form of constants, tags or the attributes of theobjects in the picture, while the dynamizable attributes of objects, the dynamizableattributes of the eigenen window and tags can be used as destinations.The advantages of the direct link are to be found in the simplicity of configuration and inthe link's time response during runtime.

  • 6DPSOHSURMHFWV

    1-2 WinCC Configuration ManualC79000-G8276-C140-01

    ,QLWLDOL]DWLRQ

    If required, initialization procedures are performed for the individual pictures. Theseinitialization procedures are configured under (YHQWV 0LVFHOODQHRXV 2SHQ3LFWXUH.

  • 6DPSOH3URMHFWYDULDB

    WinCC Configuration Manual 2-1C79000-G8276-C140-01

    7DJV3URMHFWYDULDBPFSIn this project, we will show you a number of ways of creating, changing and reusingWinCC tags. There are three different types of tag in WinCC. ,QWHUQDOWDJV without processdriver connection, ([WHUQDOWDJV with process driver connection, and in the scripts, &WDJV.In our examples, we will mainly be using LQWHUQDOWDJV and &WDJV.

    The examples used for these topics are configured in the WinCC project entitled YDULDB.

  • 6DPSOH3URMHFWYDULDB

    2-2 WinCC Configuration ManualC79000-G8276-C140-01

    &UHDWLQJJURXSLQJDQGPRYLQJWDJV

    In WinCC, tags can be created in the &RQWURO&HQWHU under the items 7DJ0DQDJHPHQW and'DWD7\SHV.

    7DJPDQDJHPHQW

    When processing large volumes of data and, consequently, a large number of tags, it isadvisable to organize these tags into groups. Only in this way is it possible to keep a trackof things in large-scale projects. The tag groups, however, do nothing toward ensuring theuniqueness of the tags. This is done solely by means of the tag names.6WHS 3URFHGXUHFUHDWLQJWDJVLQWKH7DJ0DQDJHPHQW

    1 To create a tag group for LQWHUQDOWDJV, 8' the item. Then 85 the subitem,QWHUQDOWDJV that appears in order to open the pop-up menu. Select the 1HZ*URXS item.

    2 In the window that appears, enter a suitable name (e.g. button). A new groupsymbol with the name you have just entered now appears in the right window ofthe &RQWURO&HQWHU. If you now 8' the ,QWHUQDOWDJV item, this group symboland name will also appear as a further subitem in the left window. In our sampleproject, grouping has been carried out in accordance with the sequence of thechapters.

    3 To create a tag in a tag group, 8' the group symbol in the right window or 8the corresponding symbol in the left window. Then 85 this symbol to open thepop-up menu and select the 1HZ7DJ item.

  • 6DPSOH3URMHFWYDULDB

    WinCC Configuration Manual 2-3C79000-G8276-C140-01

    6WHS 3URFHGXUHFUHDWLQJWDJVLQWKH7DJ0DQDJHPHQW

    4 On the *HQHUDO,QIRUPDWLRQ tab in the window that appears, enter a tag name.Then select the GDWDW\SH you want from the list box immediately below. An$GGUHVV does not have to be set for internal tags.

    1RWH

    The current status of the tag in the process image can be queried in the &RQWURO&HQWHU bymeans of a tool tip while runtime is active.

    'DWDW\SHV

    A new tag can also be created by means of the 'DWD7\SHV item.You can choose from the following data types:

    6WHS 3URFHGXUHFUHDWLQJWDJVE\PHDQVRIWKH'DWD7\SHVPHQXLWHP

    1 By 8' the 'DWD7\SHV item, a list of the data types available appears.2 By 85 the desired type, open the pop-up menu and select the appropriate item.

    A selection window appears which controls how the tag to be created is to beassigned.

  • 6DPSOH3URMHFWYDULDB

    2-4 WinCC Configuration ManualC79000-G8276-C140-01

    6WHS 3URFHGXUHFUHDWLQJWDJVE\PHDQVRIWKH'DWD7\SHVPHQXLWHP

    3 When you click the 2. button, you are returned to the *HQHUDO,QIRUPDWLRQ tabin the 7DJSURSHUWLHV window under the Tag Management item.

    0RYLQJWDJV

    To move tags from one group to another, proceed as follows:6WHS 3URFHGXUHPRYLQJWDJV

    185 the tag in question to open the pop-up menu and select the &XW item.

    2 Switch to the group to which the tag is to be moved. Open the pop-up menu inthis group and select 3DVWH.The same procedure can also be used for several tags simultaneously.

    1RWH

    If you want to cut or delete tags in the Control Center, runtime must not be active.

    If you require a large number of tags which should all have the same tag name but benumbered consecutively, you only have to create one tag of this type. You can copy this tagusing the pop-up menu and then insert (paste) it as often as you want. The tags will benumbered automatically in ascending order. You should take this possibility into accountwhen defining the name convention for tags.

    ([WHUQDOWDJV

    Before you can create external tags in the Tag Management, you first have to configure aconnection to a programmable controller. You do not, however, have to install thisconnection in the sense of hardware; all you have to do is install the desired communicationdriver and configure the desired connection.6WHS 3URFHGXUH

    185 the Tag Management item to open the pop-up menu and select the $GG1HZ'ULYHU item.

    2 Select the driver you want from the list displayed and click the 2SHQ button. Anew subitem with the name of the driver appears in the left window of the&RQWURO&HQWHU.

    3 If you 8' this new subitem, a further subitem appears. 85 this new subitemto open the pop-up menu and select the 1HZ'ULYHU&RQQHFWLRQ item.

  • 6DPSOH3URMHFWYDULDB

    WinCC Configuration Manual 2-5C79000-G8276-C140-01

    6WHS 3URFHGXUH

    4 On the *HQHUDO,QIRUPDWLRQ tab, give the connection a name.The tab named after the driver is used to make the connection settings. Theconnection is created when you click the 2. button.

    5 Open the pop-up menu by 85 the new subitem created, which represents thenew connection. This menu enables you to create tag groups and tags in the usualway.

    6 When you create an H[WHUQDOWDJ, you must also define the addressing and formatadjustment in addition to the settings for LQWHUQDOWDJV. The addressing refers tothe address of the tag in the programmable controller.

    6WUXFWXUHWDJV

    Structure tags are used to enable a larger number of different tags and tag types which forma logical unit to be combined. These tag and tag types can then be addressed under onename.A structure tag consists of a number of individual tags, which can represent the most variedout data types.6WHS 3URFHGXUH

    1 To create a new structure, 85 the 6WUXFWXUHWDJ item to open the pop-up menuand select the 1HZ6WUXFWXUH7\SH item.

    2 In the window that appears, 85 1HZ6WUXFWXUH and select 5HQDPH in the pop-upmenu that appears. Give the new structure a name.

    3 You can then add a new structure element by clicking the 1HZHOHPHQW button.

  • 6DPSOH3URMHFWYDULDB

    2-6 WinCC Configuration ManualC79000-G8276-C140-01

    6WHS 3URFHGXUH

    4 By 85 the new element created, you can select its data type and enter its name.For each structure element, you must define whether it refers to an internal or anexternal tag. You conclude configuration and create the structure type by clickingthe 2. button.

    1RWH

    Once a structure type has been created, it cannot be reconfigured. The complete structuretype must be redefined.

    A structure tag is created in the same way as all other types of tag, but the data type usedmust be structure type created.The name of the individual elements of the structure tag created is composed of thestructure name assigned when creating the tag and the element name assigned whencreating the structure type. The two are separated in the name by a dot.

  • 6DPSOH3URMHFWYDULDB

    WinCC Configuration Manual 2-7C79000-G8276-C140-01

    ,QFUHPHQWLQJGHFUHPHQWLQJDQGMRJJLQJ

    In runtime, you access the examples that relate to these topics inour YDULDB project by 8 the button depicted above. The examples are configured in thepictures YDULDBBFKDSWHUBSGO and YDULDBBFKDSWHUBDSGO.

    'HILQLWLRQ

    ,QFUHPHQWLQJ refers to the increasing of a tag value by a fixed or variable increment.'HFUHPHQWLQJ refers to the decreasing of a tag value by a fixed or variable increment.-RJJLQJ refers to the execution of an action when a EXWWRQ is clicked (comparable withpressing a pushbutton). In the case of binary signals, this represents, as a rule, the triggeringof a device. With analog values, a set value can be changed by means of jogging.

  • 6DPSOH3URMHFWYDULDB

    2-8 WinCC Configuration ManualC79000-G8276-C140-01

    -RJJLQJFKDQJLQJDVHWYDOXHH[DPSOH

    7DVNGHILQLWLRQ

    Jogging is to be performed using the mouse.A set value is to be changed in fixed steps by clicking a button. This changing of the valueis to be restricted to fixed limits.The changes are to be implemented locally in the picture.

    ,PSOHPHQWDWLRQFRQFHSW

    We implement changing of the set value by means of two buttons, which we create under; changing is event-driven. When the EXWWRQ is 8, the value of an LQWHUQDOWDJ ischanged to the extent of one increment. The increment is specified beforehand and cannotbe altered during runtime. The change in the set value is implemented by means of a &DFWLRQ.

    The change in the set value is displayed by means of a 6PDUW2EMHFWV,2)LHOG. Theoutput value of the,2ILHOG is linked to the LQWHUQDOWDJ.

    ,PSOHPHQWLQJLQWKH:LQ&&SURMHFW

    6WHS 3URFHGXUHFKDQJLQJDVHWYDOXHLQIL[HGVWHSV

    1 Create a tag of type 6LJQHGELWYDOXH in Tag Management. In our example, weuse the tag called 6LBYDULDBEXWB

    2 In a picture, configure an object by selecting 6PDUW2EMHFWV,2)LHOG. In ourexample, we use the object called ,2)LHOG. When configuring the ,2ILHOG inthe FRQILJXUDWLRQGLDORJ, select the tag named 6LBYDULDBEXWB, change theentry in the list box from the default value of 2s to 8SRQFKDQJH and change thefield type entry (7\SH) to 2XWSXW.

    3 In the same picture, configure a button object under :LQGRZV2EMHFWV%XWWRQ.In our example, we use the object called %XWWRQ

    4 To change the set value, create a &DFWLRQ by the object and selecting3URSHUWLHV(YHQWV0RXVH3UHVVOHIW. This &DFWLRQ changes the value ofthe tag each time the button is clicked with the 8. The limit value is specifiedand checked in the &DFWLRQ.

    5 Configure decrementation of the set value in the same way. In our example, weuse the object called %XWWRQ.

  • 6DPSOH3URMHFWYDULDB

    WinCC Configuration Manual 2-9C79000-G8276-C140-01

    C action for Button2#include "apdefap.h"void OnLButtonDown(char* lpszPictureName, char* lpszObjectName,

    char* lpszPropertyName, UINT nFlags, int x, int y){DWORD value;

    value=GetTagDWord("S32i_varia_but_00"); //get tag valueif (value>1300) (value=1400); //check limitelse value=value+100; //inc valueSetTagDWord("S32i_varia_but_00",value); //set new value} Declare the C tag value. Use the LQWHUQDOIXQFWLRQ *HW7DJ':RUG to read out the current value from tag6LBYDULDBEXWB.

    In the LI inquiry, check whether the value of the tag is greater than 1300. If it is, 1400will be specified as the upper limit. If the value of the tag is less than 1300, theinstruction in the HOVH branch is executed and the value is raised in this way by 100.

    The LQWHUQDOIXQFWLRQ 6HW7DJ':RUG then returns the changed value to the6LBYDULDBEXWB tag.

    1RWHVRQJHQHUDOXVH

    The &DFWLRQV linked to the two EXWWRQV can be used after changes have been made to thetag (internal or external), the limits and the increment.

  • 6DPSOH3URMHFWYDULDB

    2-10 WinCC Configuration ManualC79000-G8276-C140-01

    -RJJLQJFKDQJLQJDVHWYDOXHXVLQJ*OREDO6FULSWH[DPSOH

    7DVNGHILQLWLRQ

    Jogging is to be performed using the mouse.A set value is to be changed in fixed steps by clicking a button. This changing of the valueis to be restricted to fixed limits.It is to be implemented with the aid of a SURMHFWIXQFWLRQ.

    ,PSOHPHQWDWLRQFRQFHSW

    We implement changing of the set value by means of two buttons, which we create under; changing is event-driven. When the EXWWRQ is 8, the value of an LQWHUQDOWDJ ischanged to the extent of one increment. The increment is specified beforehand and cannotbe altered during runtime. The change in the set value is implemented by means of a SURMHFWIXQFWLRQ.

    The change in the set value is displayed by means of a 6PDUW2EMHFWV,2)LHOG. Theoutput value of the,2ILHOG is linked to the LQWHUQDOWDJ.

    ,PSOHPHQWLQJLQWKH:LQ&&SURMHFW

    6WHS 3URFHGXUHFUHDWLQJWKHSURMHFWIXQFWLRQ

    1 Open the *OREDO6FULSW editor from the &RQWURO&HQWHU.2 Create a new function by selecting )LOH1HZ3URMHFW)XQFWLRQ.3 Assign this new function the name ,QF'HF9DOXH and save the function by

    selecting )LOH6DYH$V,QF'HF9DOXHIFW.4 Program and compile the function.

    Project function IncDecValuevoid IncDecValue(DWORD *value,DWORD low,DWORD high,DWORD step,DWORD

    a){DWORD v;v=*value; //get current valueswitch (a){ case 0: { if (v(high-step)) (v=high); //high limit else v=v+step; //increment }//case 1 break; }//switch*value=v; //return}

  • 6DPSOH3URMHFWYDULDB

    WinCC Configuration Manual 2-11C79000-G8276-C140-01

    The function header with the name of the project function ,QF'HF9DOXH and the transferparameters. We use the same SURMHFWIXQFWLRQ for incrementing and decrementing.

    The declaration of the tag. When the function is called, it is not the tag to be processed that is transferred as the

    transfer parameter, but only its address. The contents of this address are read into the&WDJ

    Y.

    Using the VZLWFK statement, evaluate the information of the direction tag D. In the relevant FDVH branch, check the limit values and specify the maximum or

    minimum value if the limit is exceeded. If the limit is not violated, change the current value. Transfer the current set value to the address of the tag to be processed.

    Implementing in the WinCC project6WHS 3URFHGXUHFKDQJLQJDVHWYDOXHLQIL[HGVWHSV

    1 Create a tag of type 6LJQHGELWYDOXH in Tag Management. In our example, weuse the tag called 6LBYDULDBEXWB

    2 In a picture, configure an object by selecting 6PDUW2EMHFWV,2)LHOG.In our example, we use the object called I/O Field2. When configuring the,2ILHOG in the FRQILJXUDWLRQGLDORJ, select the tag named 6LBYDULDBEXWB. changethe entry in the list box from the default value of 2s to 8SRQFKDQJH and changethe field type entry (7\SH) to 2XWSXW.

    3 In the same picture, configure a button object under :LQGRZV2EMHFWV%XWWRQ.In our example, we use the object called %XWWRQ

    4 To change the set value, create a &DFWLRQ by the object and selecting3URSHUWLHV(YHQWV0RXVH3UHVVOHIW. This &DFWLRQ calls the SURMHFWIXQFWLRQ ,QF'HF9DOXH and transfers the required parameters to it. The changes thevalue of the tag each time the EXWWRQ is clicked with the 8. The limits arespecified as the transfer parameters when the SURMHFWIXQFWLRQ is called. They arechecked in the SURMHFWIXQFWLRQ.

    5 Configure decrementation of the set value in the same way. In our example, weuse the object called %XWWRQ.

  • 6DPSOH3URMHFWYDULDB

    2-12 WinCC Configuration ManualC79000-G8276-C140-01

    C action for Button7#include "apdefap.h"void OnLButtonDown(char* lpszPictureName, char* lpszObjectName,

    char* lpszPropertyName, UINT nFlags, int x, int y){DWORD value;

    value=GetTagDWord("S32i_varia_but_04");

    //IncDecValue(DWORD *value,DWORD low,DWORD high,DWORD step,DWORD a )IncDecValue(&value,0,1400,100,1);SetTagDWord("S32i_varia_but_04",value);} Use the LQWHUQDOIXQFWLRQ *HW7DJ':RUG to read out the current value of the LQWHUQDOWDJV.

    Call the SURMHFWIXQFWLRQ ,QF'HF9DOXHand transfer the parameters (3RLQWHUWRWDJ,/RZHUOLPLW8SSHUOLPLW,QFUHPHQW'LUHFWLRQ.

    Use the LQWHUQDOIXQFWLRQ 6HW7DJ':RUG to transfer the changed value to the LQWHUQDOWDJ.

    1RWHVRQJHQHUDOXVH

    The SURMHFWIXQFWLRQ can be used immediately without any further changes being required.In the &DFWLRQ used for calling the SURMHFWIXQFWLRQ, adapt the transfer parameters to suityour own requirements.

  • 6DPSOH3URMHFWYDULDB

    WinCC Configuration Manual 2-13C79000-G8276-C140-01

    -RJJLQJEXWWRQVH[DPSOH

    You access the solutions to these subjects in our project called YDULDBby choosing thetwo EXWWRQVwith the 8. They are configured in the picture with the nameSLFWXBBFKDSWHUBDSGO.

    7DVNGHILQLWLRQ

    Jogging is to be performed using the mouse.A unit (motor, valve) is to be activated by clicking a button. When the button is released,activation will be canceled.

    ,PSOHPHQWDWLRQFRQFHSW

    We implement the button along event-driven lines by means of a button, which we createunder :LQGRZV2EMHFWV%XWWRQ.We visualize this implementation by means of a GLUHFWFRQQHFWLRQ and a &DFWLRQ.

    1RWH

    Implementing a button by means of a GLUHFWFRQQHFWLRQ offers the best level of performanceduring runtime.

    ,PSOHPHQWLQJLQWKH:LQ&&SURMHFWGLUHFWFRQQQHFWLRQ

    6WHS 3URFHGXUHKRZDEXWWRQZRUNVGLUHFWFRQQHFWLRQ

    1 Create a tag of type %LQDU\WDJ in Tag Management. In our example, we use thetag called %,1LBYDULDBEXWB

    2 In a picture, we configure :LQGRZV2EMHFWV%XWWRQ. In our example, we usethe object called %XWWRQ

    3 Configure a GLUHFWFRQQHFWLRQ for %XWWRQ under (YHQWV0RXVH3UHVVOHIW.Connect the VRXUFH &RQVWDQW to the WDUJHW 9DULDEOH%,1LBYDULDBEXWB.Accept the settings by clicking the 2. button. Configure another GLUHFWFRQQHFWLRQ under (YHQWV0RXVH5HOHDVHOHIW, but this time for the VRXUFH&RQVWDQW.

  • 6DPSOH3URMHFWYDULDB

    2-14 WinCC Configuration ManualC79000-G8276-C140-01

    6WHS 3URFHGXUHKRZDEXWWRQZRUNVGLUHFWFRQQHFWLRQ

    4 We control our animation by means of the %,1LBYDULDBEXWB tag.

    As an option, we will explain implementation with a &action in the same example.TheGLUHFWFRQQHFWLRQ method described above is the better and quicker way of doing it.

    ,PSOHPHQWLQJLQWKH:LQ&&SURMHFW&DFWLRQ

    6WHS 3URFHGXUHKRZDEXWWRQZRUNV&DFWLRQ

    1 Create a tag of type %LQDU\WDJ in Tag Management. In our example, we use thetag called %,1LBYDULDBEXWB

    2 In a picture, we configure :LQGRZV2EMHFWV%XWWRQ. In our example, we usethe object called %XWWRQ

    3 Under (YHQWV0RXVH3UHVVOHIW, generate a &DFWLRQ which sets the value ofthe %,1LBYDULDBEXWB tag to . Under (YHQWV0RXVH5HOHDVHOHIW, generatea further &DFWLRQ which sets the value of the %,1LBYDULDBEXWB tag to .

    C action for Button1#include "apdefap.h"void OnLButtonDown(char* lpszPictureName, char* lpszObjectName,

    char* lpszPropertyName, UINT nFlags, int x, int y){SetTagWord("BINi_varia_but_12",1); //on} Use the LQWHUQDOIXQFWLRQ 6HW7DJ':RUG to set the tag to .

  • 6DPSOH3URMHFWYDULDB

    WinCC Configuration Manual 2-15C79000-G8276-C140-01

    $QLPDWLRQRIRXUH[DPSOH

    In our example, we use the button to animate the following color wheel.

    The color wheel consists of several 6WDQGDUG2EMHFWV3LH6HJPHQW. The 3URSHUWLHV*HRPHWU\6WDUW$QJOH and 3URSHUWLHV*HRPHWU\(QG$QJOH

    of all the objects are dynamized using the '\QDPLF'LDORJ. To change the value, we need an action which changes the value of the angle of rotation

    with a fixed time base. We effect this changing of the value by means of a &DFWLRQ for3LH6HJPHQW under 3URSHUWLHV&RORUV/LQH&RORU. We set the trigger for theaction to PV. In this case, we do QRW dynamize the /LQH&RORU. The reason a &DFWLRQis linked to this property is that we require a trigger to start changing of the value. Wecould also use a different property of the object instead of the .

    The current angle of rotation is changed in the LQWHUQDOWDJ called 6LBYDUDBEXWB.

  • 6DPSOH3URMHFWYDULDB

    2-16 WinCC Configuration ManualC79000-G8276-C140-01

    C action for animation#include "apdefap.h"long _main(char* lpszPictureName, char* lpszObjectName, char*

    lpszPropertyName){static DWORD i = 0;

    //if button pressedif (GetTagBit("BINi_varia_but_12")) { i=i+10; //increment of rotation if (i==360) (i=0); //high limit SetTagDWord("S32i_varia_but_11",i); }//ifreturn(0x0); //black} Declare the &WDJ L as a VWDWLF':25', since its value must remain constant while the

    picture is open. By clicking the EXWWRQ (button on), rotate the wheel further in steps of 10 degrees, i.e.

    increment the value of the tag by 10. The tag L is initialized once the wheel has been fully rotated through 360. Transfer the new value for the angle of rotation of the LQWHUQDOWDJ. Return the input configured for the background color with UHWXUQ. It isn't supposed to be

    changed.

    1RWHVRQJHQHUDOXVH

    The EXWWRQ with the GLUHFWFRQQHFWLRQ can be used after changes have been made to the tag.

  • 6DPSOH3URMHFWYDULDB

    WinCC Configuration Manual 2-17C79000-G8276-C140-01

    -RJJLQJFKDQJHRYHUVZLWFKH[DPSOH

    You access the example that relates to this topic in our YDULDB project by 8 the twoEXWWRQV depicted above. They are configured in the picture with the nameSLFWXBBFKDSWHUBDSGO.

    7DVNGHILQLWLRQ

    Jogging is to be performed using the mouse.The function of a changeover switch is to be implemented by means of a button.Pressing the button will switch the unit (motor, valve) on and the unit is to remain on whenthe button is released. Pressing the button again will switch the unit off.

    ,PSOHPHQWDWLRQFRQFHSW

    We implement the changeover switch along event-driven lines by means of a button, whichwe create under :LQGRZV2EMHFWV%XWWRQ.

    1RWH

    Implementing a changeover switch by means of a GLUHFWFRQQHFWLRQ offers the bestperformance during runtime, but it requires two buttons.

    ,PSOHPHQWLQJLQWKH:LQ&&SURMHFWGLUHFWFRQQQHFWLRQ

    6WHS 3URFHGXUHKRZDFKDQJHRYHUVZLWFKZRUNVGLUHFWFRQQHFWLRQ

    1 Create a tag of type %LQDU\WDJ in Tag Management. In our example, we use thetag called %,1LBYDULDBEXWB

    2 In a picture, configure two buttons under :LQGRZV2EMHFWV%XWWRQ. In ourexample, we use the object %XWWRQ for switching on and the object %XWWRQ forswitching off.

    3 Configure a GLUHFWFRQQHFWLRQ for %XWWRQ under (YHQWV0RXVH3UHVVOHIW.Connect the VRXUFH &RQVWDQW to the WDUJHW 9DULDEOH%,1LBYDULDBEXWB.Accept the settings by clicking the 2. button. Configure a GLUHFWFRQQHFWLRQlinked to %XWWRQ in the same way, but this time with the VRXUFH &RQVWDQW.

    4 The GLUHFWFRQQHFWLRQ under Events Mouse Mouse Action onlysynchronizes the labeling on %XWWRQ and isnt essential for the changeover switchto be able to function.

  • 6DPSOH3URMHFWYDULDB

    2-18 WinCC Configuration ManualC79000-G8276-C140-01

    ,PSOHPHQWLQJLQWKH:LQ&&SURMHFW&DFWLRQ

    6WHS 3URFHGXUHKRZDFKDQJHRYHUVZLWFKZRUNV&DFWLRQ

    1 Create a tag of type %LQDU\WDJ in Tag Management. In our example, we use thetag called %,1LBYDULDBEXWB

    2 In a picture, configure a :LQGRZV2EMHFWV%XWWRQ. In our example, we use theobject called %XWWRQ.

    3 Under (YHQWV0RXVH3UHVVOHIW, generate a &DFWLRQ which negates thestatus of the %,1LBYDULDBEXWB tag.

    C action for changeover switch#include "apdefap.h"void OnLButtonDown(char* lpszPictureName, char* lpszObjectName,

    char* lpszPropertyName, UINT nFlags, int x, int y){BOOL state;

    //flip tagstate = !GetTagBit("BINi_varia_but_16"),SetTagBit("BINi_varia_but_16",(SHORT)state);} The declaration of the VWDWH tag. The LQWHUQDOIXQFWLRQ *HW7DJ%LW reads out the value of the LQWHUQDOWDJ, inverts it and

    returns it with 6HW7DJ%LW.

    1RWHVRQJHQHUDOXVH

    The button with the &DFWLRQ can be used after changes have been made to the tag.Inversion of the LQWHUQDOWDJ can also be carried out without the &WDJ.SetTagDWord("BINi_varia_but_16",(SHORT)!GetTagBit("BINi_varia_but_16"));

  • 6DPSOH3URMHFWYDULDB

    WinCC Configuration Manual 2-19C79000-G8276-C140-01

    ,QFUHPHQWLQJDQGGHFUHPHQWLQJH[DPSOH

    7DVNGHILQLWLRQ

    The value of a tag is to be changed. This changing of the value is to be restricted to fixedlimits. Changing of the value is to be performed using the mouse.A tag value is to be changed by pressing a button. The value is to be changed only when thebutton is pressed. The value set must be retained when the button is released.

    ,PSOHPHQWDWLRQFRQFHSW

    We create a button along event-driven lines using :LQGRZV2EMHFWV%XWWRQ.When the button is pressed with the 8, the value of an LQWHUQDOWDJ is incremented by theincrement set; when the button is pressed with the 85, the value of thistag isdecremented by the increment set. The value keeps changing as long as the button ispressed. The increment is specified beforehand and cannot be altered during runtime.The change in the value is displayed by means of a 6PDUW2EMHFWV,2)LHOG. The outputvalue of the,2ILHOG is linked to the LQWHUQDOWDJ.

    Changing the valueTo change the value, we need an action which changes the value of an LQWHUQDOWDJ with afixed time base. We effect this changing of the value by means of a &DFWLRQ on the ,2ILHOG under 3URSHUWLHV*HRPHWU\3RVLWLRQ;. We set the trigger for the action toPV. We are QRW dynamizing the position of the ,2ILHOG. The reason a &DFWLRQ is linkedto this property is that we want to implement changing of the value directly on the object.In our sample project, we have also solved this problem by means of a JOREDODFWLRQ.

  • 6DPSOH3URMHFWYDULDB

    2-20 WinCC Configuration ManualC79000-G8276-C140-01

    ,PSOHPHQWLQJLQWKH:LQ&&SURMHFW

    6WHS 3URFHGXUHLQFUHPHQWLQJGHFUHPHQWLQJ

    1 Creating the tag in the Tag Management. In our example, we use the tags called6LBYDULDBEXWBDQG6LBYDULDBEXWB

    2 In a picture, configure an object by selecting 6PDUW2EMHFWV,2)LHOG. In ourexample, we use the object called ,2)LHOG When creating the ,2ILHOG in theFRQILJXUDWLRQGLDORJ, set the tag called 6LBYDULDBEXWB. change the entry inthe list box from the default value of 2s to 8SRQFKDQJH and change the field typeentry (7\SH) to 2XWSXW.

    3 In the same picture, configure a :LQGRZV2EMHFWV%XWWRQ. In our example, weuse the object called %XWWRQ

    4 To modify a setpoint at the click of a mouse, we create several GLUHFWFRQQHFWLRQVat thisEXWWRQ. These GLUHFWFRQQHFWLRQVmodify the value of tag6LBYDULDBEXWBevery time the EXWWRQ is chosen with the 8 or 8R.Set (YHQWV0RXVH3UHVVOHIW to incrementation ON (set tag to ). Set (YHQWV0RXVH5HOHDVHOHIW to incrementation OFF (set tag to ). Set (YHQWV0RXVH3UHVVULJKW to decrementation ON (set tag to ) and (YHQWV0RXVH5HOHDVHULJKW to decrementation OFF (set tag to ).

    5 The value of the 6LBYDULDBEXWB tag is changed by a &DFWLRQ for the object,2)LHOG under 3URSHUWLHV*HRPHWU\3RVLWLRQ;.

    6 We then change the trigger for calling the &DFWLRQ to PV.

  • 6DPSOH3URMHFWYDULDB

    WinCC Configuration Manual 2-21C79000-G8276-C140-01

    C action for the I/O field for changing the value#include "apdefap.h"long _main(char* lpszPictureName, char* lpszObjectName, char*

    lpszPropertyName){DWORD value;SHORT count;

    count = GetTagWord("S08i_varia_but_01"); //inc or decif ((count==1) || (count==2)){ //current value value = GetTagDWord("S32i_varia_but_00");

    if (count==1){ //inc value++; if (value>1400) (value=1400); //high limit SetTagDWord("S32i_varia_but_00",value); }//inc if (count==2){ //dec value--; if (value

  • 6DPSOH3URMHFWYDULDB

    2-22 WinCC Configuration ManualC79000-G8276-C140-01

    ,QFUHPHQWLQJDQGGHFUHPHQWLQJXVLQJ*OREDO6FULSWH[DPSOH

    7DVNGHILQLWLRQ

    The value of a tag is to be changed. This changing of the value is to be restricted to fixedlimits. Changing of the value is to be performed using the mouse.A tag value is to be changed by pressing a button. The value is to be changed only when thebutton is pressed. The value set must be retained when the button is released.

    ,PSOHPHQWDWLRQFRQFHSW

    We create a button along event-driven lines using :LQGRZV2EMHFWV%XWWRQ.It is to be implemented with the aid of a JOREDODFWLRQ.When the button is pressed with the 8, the value of an LQWHUQDOWDJ is incremented by theincrement set; when the button is pressed with the 8R, the value of thistag isdecremented by the increment set. The value keeps changing as long as the button ispressed. The increment is specified beforehand and cannot be altered during runtime.The change in the value is displayed by means of a 6PDUW2EMHFWV,2)LHOG. The outputvalue of the,2ILHOG is linked to the LQWHUQDOWDJ.

  • 6DPSOH3URMHFWYDULDB

    WinCC Configuration Manual 2-23C79000-G8276-C140-01

    Changing the valueTo change the value, we need an action which changes the value of an LQWHUQDOWDJ with afixed time base. We implement the change in the value by means of a JOREDODFWLRQ.The action is activated when the WinCC runtime is started and is then processed with theset cycle. The action is programmed in such a way that the actual program component isonly processed when the button is pressed.One unusual feature of this action is that it uses external &WDJV. External &WDJV arerecognized throughout the entire WinCC runtime, but they must be declared outside thefunction header. Since in WinCC this is only possible in a SURMHFWIXQFWLRQ, a separateSURMHFWIXQFWLRQ is created for declaring these tags. This project function must be executedonce when the project is started and is then no longer required.

    ,PSOHPHQWLQJLQWKH:LQ&&SURMHFW

    Configuration is divided into the following three steps.

    6WHS

    &UHDWLQJWKHSURMHFWIXQFWLRQ

    6WHS 3URFHGXUHFUHDWLQJWKHSURMHFWIXQFWLRQIRULQLWLDOL]DWLRQ

    1 Open the *OREDO6FULSW editor from the &RQWURO&HQWHU.2 Create a new function by selecting )LOH1HZ3URMHFW)XQFWLRQ.3 Assign this new function the name ,QLW$FWLRQ and save the function by selecting)LOH6DYH$V,QLW$FWLRQIFW.

    4 Program and compile the function.

    Project function InitAction//declaration for counter.pasextern char tagname[30] = " ";extern SHORT count = 0;extern DWORD low = 0;extern DWORD high = 0;extern DWORD step = 0;

    void InitAction(){//function is used to generate external tags} The declaration of the external &WDJV. This function must be executed once when the project is started and is then no longer

    required. A good way of executing it is in the Start Picture, and this can be set under(YHQWV0LVFHOODQHRXV2SHQ3LFWXUH.

  • 6DPSOH3URMHFWYDULDB

    2-24 WinCC Configuration ManualC79000-G8276-C140-01

    6WHS

    &UHDWLQJWKHJOREDODFWLRQ

    6WHS 3URFHGXUHFUHDWLQJWKHJOREDODFWLRQ

    1 Open the *OREDO6FULSW editor from the &RQWURO&HQWHU.2 Create a new action by selecting )LOH1HZ$FWLRQ.3 Save the file by selecting )LOH6DYH$VFRXQWHUSDV.4 Program and compile the action.5

    Set the trigger. You do this by clicking the EXWWRQ and selecting the 7ULJJHUtab. Add 7LPHU&\FOLFPV on this tab.

    Global action counter.pas#include "apdefap.h"

    int gscAction( void ){extern char tagname[30];extern SHORT count;extern DWORD low;extern DWORD high;extern DWORD step;

    DWORD value;

    if ((count==1)||(count==2)){//get current valuevalue = GetTagDWord(tagname);if (count==1){ //inc

    value = value+step;if (value>high) (value=high); //high limit}//if

    if (count==2){ //decvalue = value-step;if (value

  • 6DPSOH3URMHFWYDULDB

    WinCC Configuration Manual 2-25C79000-G8276-C140-01

    6WHS

    &RQILJXULQJWKHEXWWRQV

    6WHS 3URFHGXUHLQFUHPHQWLQJDQGGHFUHPHQWLQJXVLQJ*OREDO6FULSW

    1 Creating the tag in the Tag Management. In our example, we use the tag called6LBYDULDBEXWB

    2 In a picture, configure an object by selecting 6PDUW2EMHFWV,2)LHOG. In ourexample, we use the object called ,2)LHOG When creating the ,2ILHOG in theFRQILJXUDWLRQGLDORJ, set the tag called 6LBYDULDBEXWB. change the entry inthe list box from the default value of 2s to 8SRQFKDQJH and change the field typeentry (7\SH) to 2XWSXW.

    3 In the same picture, configure a button object under :LQGRZV2EMHFWV%XWWRQ.In our example, we use the object called %XWWRQ

    4 To modify a setpoint at the click of a mouse, we create several &DFWLRQV at thisEXWWRQThese &DFWLRQV provide the JOREDODFWLRQ, FRXQWHUSDVwith the relevantparameters. This happens each time the button is clicked with the 8 or 8R.Set (YHQWV0RXVH3UHVVOHIW to incrementation ON, (YHQWV0RXVH5HOHDVHOHIW to incrementation OFF, (YHQWV0RXVH3UHVVULJKW todecrementation ON and (YHQWV0RXVH5HOHDVHULJKW to decrementationOFF.

    5 The value of the 6LBYDULDBEXWB tag is changed in the JOREDODFWLRQFRXQWHUSDV.

    C action for Button8for incrementation ON#include "apdefap.h"void OnLButtonDown(char* lpszPictureName, char* lpszObjectName,

    char* lpszPropertyName, UINT nFlags, int x, int y){//inc onextern char tagname[30];extern SHORT count;extern DWORD low;extern DWORD high;extern DWORD step;

    strcpy(tagname,"S32i_varia_but_04");count = 1;low = 0;high =1400;step = 1;}

  • 6DPSOH3URMHFWYDULDB

    2-26 WinCC Configuration ManualC79000-G8276-C140-01

    C action for Button8 for incrementation OFF#include "apdefap.h"void OnLButtonUp(char* lpszPictureName, char* lpszObjectName, char*

    lpszPropertyName, UINT nFlags, int x, int y){//inc offextern SHORT count;count=0;} The declaration of the external &WDJV in the &DFWLRQ. These tags are generated in the

    project function ,QLW$FWLRQ. Provide the tags with the relevant values. This is comparable with transferring

    parameters to a SURMHFWIXQFWLRQ. The content of the FRXQW tag is responsible forprocessing the program in the JOREDODFWLRQ.

    When switching off the incrementation process, there is no need to set all the tags.

    1RWHVRQJHQHUDOXVH

    The following adaptations must be made before this button can be put to general use: In the &DFWLRQV, change the tag and adapt the limit values and the increment. If this button is to be used in another project, the SURMHFWIXQFWLRQ ,QLW$FWLRQ and theJOREDODFWLRQ FRXQWHUSDV must both be transferred over together with the button.

  • 6DPSOH3URMHFWYDULDB

    WinCC Configuration Manual 2-27C79000-G8276-C140-01

    7KHRWKHUH[DPSOHVUHODWHGWRWKLVWRSLF

    H[DPSOH

    The functionality of this example is similar to that of example H[DPSOH. The basicdifference is that the increment can be changed during runtime.Another difference is the dynamic changing of the increment when the increment is beingset. If the increment is > 20, the value is changed in steps of 10; if the increment is < 20, thevalue is changed in steps of 1.

    H[DPSOH

    The functionality of this example results from combining H[DPSOH and H[DPSOH. Thevalue is changed with the help of the JOREDODFWLRQ FRXQWHUSDV.

    H[DPSOH

    The functionality of this example is similar to that of example H[DPSOH. The differencehere is in the mode of animation.

  • 6DPSOH3URMHFWYDULDB

    2-28 WinCC Configuration ManualC79000-G8276-C140-01

    &KDQJLQJWDJYDOXHXVLQJ:LQGRZV2EMHFWV

    In runtime, you access the solutions that relate to these topics inour YDULDB project by 8 the EXWWRQ depicted above. The examples are configured in thepicture named YDULDBBFKDSWHUBSGO.

  • 6DPSOH3URMHFWYDULDB

    WinCC Configuration Manual 2-29C79000-G8276-C140-01

    ,QSXWWLQJE\PHDQVRIDVOLGHUZLWKGLUHFWFRQQHFWLRQH[DPSOH

    7DVNGHILQLWLRQ

    Changing a set value is to be performed by means of a slider.This changing of the value is to be restricted to fixed limits.

    ,PSOHPHQWDWLRQFRQFHSW

    We use a slider object created under :LQGRZV2EMHFWV6OLGHU2EMHFW to implementchanging of the set values. By means of a GLUHFWFRQQHFWLRQ, the value of an LQWHUQDOWDJ ischanged when the position of the slider is changed.The change in the set value is displayed by means of a 6PDUW2EMHFWV,2)LHOG.

    ,PSOHPHQWLQJLQWKH:LQ&&SURMHFW

    6WHS 3URFHGXUHFKDQJLQJVHWYDOXHE\PHDQVRIDVOLGHUGLUHFWFRQQHFWLRQ

    1 Create a tag in Tag Management. In our example, we use the tag called6LBYDULDBZLQB

    2 In a picture, configure an object by selecting 6PDUW2EMHFWV,2)LHOG. In ourexample, we use the object called ,2)LHOG. When configuring the ,2ILHOG inthe FRQILJXUDWLRQGLDORJ, select the tag named 6LBYDULDBZLQB. change theentry in the list box from the default value of 2s to 8SRQFKDQJH and change thefield type entry (7\SH) to 2XWSXW.

  • 6DPSOH3URMHFWYDULDB

    2-30 WinCC Configuration ManualC79000-G8276-C140-01

    6WHS 3URFHGXUHFKDQJLQJVHWYDOXHE\PHDQVRIDVOLGHUGLUHFWFRQQHFWLRQ

    3 In the same picture, configure an object under :LQGRZV2EMHFWV6OLGHU2EMHFW.In our example, we use the object called 6OLGHU2EMHFW. Create aGLUHFWFRQQHFWLRQ under (YHQWV0LVFHOODQHRXV3URFHVV'ULYHU&RQQHFWLRQ.

    4 In the 'LUHFW&RQQHFWLRQ dialog box, connect the VRXUFH WKLVREMHFW3URFHVV'ULYHU&RQQHFWLRQ to the WDUJHW 9DULDEOH6BYDULDBZLQB. Accept thesettings by clicking the 2. button.

  • 6DPSOH3URMHFWYDULDB

    WinCC Configuration Manual 2-31C79000-G8276-C140-01

    6WHS 3URFHGXUHFKDQJLQJVHWYDOXHE\PHDQVRIDVOLGHUGLUHFWFRQQHFWLRQ

    1RWHVRQJHQHUDOXVH

    The following adaptations must be made before this button can be put to general use: Change the tag in the GLUHFWFRQQHFWLRQ. The value range of the 6OLGHU2EMHFW can be changed under 3URSHUWLHV0LVFHOODQHRXV

    0D[LPXP9DOXH and0LQLPXP9DOXH. This can also be done under &RQILJXUDWLRQ'LDORJ

  • 6DPSOH3URMHFWYDULDB

    2-32 WinCC Configuration ManualC79000-G8276-C140-01

    ,QSXWWLQJE\PHDQVRIVOLGHUDQGWDJFRQQHFWLRQH[DPSOH

    7DVNGHILQLWLRQ

    Changing a set value is to be performed by means of a slider.This changing of the value is to be restricted to fixed limits.

    ,PSOHPHQWDWLRQFRQFHSW

    We use a slider object created under :LQGRZV2EMHFWV6OLGHU2EMHFW to implementchanging of the set values. By means of a WDJFRQQHFWLRQ, the value of an LQWHUQDOWDJ ischanged when the position of the slider is changed. The tag is only written to when theslider is released.The change in the set value is displayed by means of a 6PDUW2EMHFWV,2)LHOG.

    ,PSOHPHQWLQJLQWKH:LQ&&SURMHFW

    6WHS 3URFHGXUHFKDQJLQJVHWYDOXHE\PHDQVRIDVOLGHUWDJFRQQHFWLRQ

    1 Create a tag in Tag Management. In our example, we use the tag called6LBYDULDBZLQB

    2 In a picture, configure an object by selecting 6PDUW2EMHFWV,2)LHOG. In ourexample, we use the object called ,2)LHOG. When configuring the,2ILHOG inthe FRQILJXUDWLRQGLDORJ, select the tag named 6LBYDULDBZLQB. Change theentry in the list box from the default value of 2s to 8SRQFKDQJH and change thefield type entry (7\SH) to 2XWSXW.

    3 In the same picture, configure an object under :LQGRZV2EMHFWV6OLGHU2EMHFW.In our example, we use the object called 6OLGHU2EMHFW. When configuring theVOLGHUREMHFW in the FRQILJXUDWLRQGLDORJ, select the tag named6LBYDULDBZLQB. Change the entry in the 8SGDWH list box from the defaultvalue of 2s to 8SRQFKDQJH.

  • 6DPSOH3URMHFWYDULDB

    WinCC Configuration Manual 2-33C79000-G8276-C140-01

    1RWHVRQJHQHUDOXVH

    The following adaptations must be made before this button can be put to general use: Change the tag in theWDJFRQQHFWLRQ. The value range of the 6OLGHU2EMHFW can be changed under 3URSHUWLHV0LVFHOODQHRXV

    0D[LPXP9DOXH and0LQLPXP9DOXH. This can also be done under &RQILJXUDWLRQ'LDORJ.

  • 6DPSOH3URMHFWYDULDB

    2-34 WinCC Configuration ManualC79000-G8276-C140-01

    ,QSXWWLQJE\PHDQVRIDQ2SWLRQ*URXSH[DPSOH

    7DVNGHILQLWLRQ

    Changing of a set value is to be implemented by selecting specified, fixed values from alist.

    ,PSOHPHQWDWLRQFRQFHSW

    We implement this changing of the set value by means of an option group, which we createunder :LQGRZV2EMHFWV2SWLRQ*URXS.When one of the specified set values is selecting using the 8, the value in an LQWHUQDOWDJis changed. The list of set values is specified and cannot be altered during runtime.The change in the set value is displayed by means of a 6PDUW2EMHFWV,2)LHOG. Theoutput value of the,2ILHOG is linked to the LQWHUQDOWDJ. The change in the set value isimplemented by means of a &DFWLRQ.

    ,PSOHPHQWLQJLQWKH:LQ&&SURMHFW

    6WHS 3URFHGXUHFKDQJLQJVHWYDOXHXVLQJDQRSWLRQJURXS

    1 Create a tag in Tag Management. In our example, we use the tag called6LBYDULDBZLQB

    2 In a picture, configure an object by selecting 6PDUW2EMHFWV,2)LHOG. In ourexample, we use the object called ,2)LHOG. When configuring the ,2ILHOG inthe FRQILJXUDWLRQGLDORJ, select the tag named 6LBYDULDBZLQB. Change theentry in the list box from the default value of 2s to 8SRQFKDQJH and change thefield type entry (7\SH) to 2XWSXW.

    3 In the same picture, configure a :LQGRZV2EMHFWV2SWLRQ*URXS. In ourexample, this is 2SWLRQ*URXS. Under 3URSHUWLHV*HRPHWU\1XPEHURI%R[HV, change the default value 3 to .

    4 Select the index value 1 under 3URSHUWLHV)RQW,QGH[. Enter theappropriate text for the selected index under 3URSHUWLHV)RQW7H[W. Inthe same way, configure the values for the remaining index inputs.

    5 Under (YHQWV3URSHUW\7RSLFV2XWSXW,QSXW6HOHFWHG%R[HV, create a &DFWLRQ, which set tag 6LBYDULDBZLQB to a specific value depending on thefield selected.

  • 6DPSOH3URMHFWYDULDB

    WinCC Configuration Manual 2-35C79000-G8276-C140-01

    6WHS 3URFHGXUHFKDQJLQJVHWYDOXHXVLQJDQRSWLRQJURXS

    C action for the option groupvoid OnPropertyChanged(char* lpszPictureName, char* lpszObjectName,

    char* lpszPropertyName, long value){//set tag according to selected boxswitch(value){ case 1 : SetTagDWord("S32i_varia_win_02",0); break; case 2 : SetTagDWord("S32i_varia_win_02",50); break; case 4 : SetTagDWord("S32i_varia_win_02",100); break; case 8 : SetTagDWord("S32i_varia_win_02",150); break; }//switch} Assign values to tag 6LBYDULDBZLQB in accordance with the input state. The input

    state is stored in the predefined tag YDOXH.

    1RWHVRQJHQHUDOXVH

    The following adaptation must be made before the 2SWLRQ*URXS can be put to general use: Adapt the tag in the &DFWLRQ under (YHQWV3URSHUW\7RSLFV2XWSXW,QSXW6HOHFWHG%R[HV.

  • 6DPSOH3URMHFWYDULDB

    2-36 WinCC Configuration ManualC79000-G8276-C140-01

    ,QSXWWLQJE\PHDQVRIFKHFNER[H[DPSOH

    7DVNGHILQLWLRQ

    Various objects are to be configured such that they can be shown and hidden by means of acheck box.

    ,PSOHPHQWDWLRQFRQFHSW

    We implement this by means of a check box, which we create under :LQGRZV2EMHFWV&KHFN%R[, and we use this check box to set individual bits in a tag. A number of objectscreated under 6WDQGDUG2EMHFWV3RO\JRQ are shown or hidden depending on these bits.We display the binary output value of the FKHFNER[ by means of a 6PDUW2EMHFWV ,2)LHOG.

    ,PSOHPHQWLQJLQWKH:LQ&&SURMHFW

    6WHS 3URFHGXUHLQSXWWLQJE\PHDQVRIDFKHFNER[

    1 Create a tag of type 6LJQHGELWYDOXH in Tag Management. In our example, weuse the tag called 6LBYDULDBZLQB

    2 Configure a number of objects under 6WDQGDUG2EMHFWV3RO\JRQ; in ourexample, we use 3RO\JRQ through 3RO\JRQ. These objects are to be shown orhidden depending on the selection state of the FKHFNER[.

    3 In the same picture, configure a :LQGRZV2EMHFWV&KHFN%R[. In our example,&KHFN%R[. Under 3URSHUWLHV*HRPHWU\1XPEHURI%R[HV, change thedefault value 3 to .

    4 Select the index value 1 under 3URSHUWLHV)RQW,QGH[. Enter theappropriate text for the selected index under 3URSHUWLHV)RQW7H[W, this textbeing the name of the object you want to control by selecting this field. In thesame way, configure the values for the remaining index inputs.

    5 Under (YHQWV3URSHUW\7RSLFV2XWSXW,QSXW6HOHFWHG%R[HV create a &DFWLRQ which assigns the binary state of &KHFN%R[ to tag S32i_varia_win_03and controls the "visibility" of the individual SRO\JRQREMHFWV.

  • 6DPSOH3URMHFWYDULDB

    WinCC Configuration Manual 2-37C79000-G8276-C140-01

    6WHS 3URFHGXUHLQSXWWLQJE\PHDQVRIDFKHFNER[

    6 Configure an I/O field under 6PDUW2EMHFWV,2)LHOG; in our example, we use,2)LHOG. Under &RQILJXUDWLRQ'LDORJ, select tag 6LBYDULDBZLQB. Changethe entry in the 8SGDWH list box from the default value of 2s to 8SRQFKDQJH.Under 3URSHUWLHV2XWSXW,QSXW, change the 'DWD)RUPDW to %LQDU\ and changethe Output Format to .

  • 6DPSOH3URMHFWYDULDB

    2-38 WinCC Configuration ManualC79000-G8276-C140-01

    C action for the check box#include "apdefap.h"void OnPropertyChanged(char* lpszPictureName, char* lpszObjectName,

    char* lpszPropertyName, long value){

    SetTagDWord("S32i_varia_win_03",value);//first box selectedif (value&1) SetVisible(lpszPictureName,"Polygon1",1);else SetVisible(lpszPictureName,"Polygon1",0);//second box selectedif (value&2) SetVisible(lpszPictureName,"Polygon2",1);else SetVisible(lpszPictureName,"Polygon2",0);//third box selectedif (value&4) SetVisible(lpszPictureName,"Polygon3",1);else SetVisible(lpszPictureName,"Polygon3",0);//fourth box selectedif (value&8) SetVisible(lpszPictureName,"Polygon4",1);else SetVisible(lpszPictureName,"Polygon4",0);//fifth box selectedif (value&16) SetVisible(lpszPictureName,"Polygon5",1);else SetVisible(lpszPictureName,"Polygon5",0);//sixth box selectedif (value&32) SetVisible(lpszPictureName,"Polygon6",1);else SetVisible(lpszPictureName,"Polygon6",0);//seventh box selectedif (value&64) SetVisible(lpszPictureName,"Polygon7",1);else SetVisible(lpszPictureName,"Polygon7",0);} Set tag 6LBYDULDBZLQB to the new input state of the FKHFNER[. Control the visibility of the objects in accordance with the input state. The input state is

    stored in the predefined tag YDOXH. To read out the respective bit, you have to performbit masking to the relevant bit.

    1RWH

    A simple example is shown in the SLFWXB project in the chapter entitled '\QDPLFV inH[DPSOH. In this case, however, visibility is queried for each individual object by means ofthe '\QDPLF'LDORJ.

    1RWHVRQJHQHUDOXVH

    The following adaptation must be made before the &KHFN%R[ can be put to general use: Adapt the tag and the object names in the &DFWLRQ under (YHQWV3URSHUW\7RSLFV2XWSXW,QSXW6HOHFWHG%R[HV.

  • 6DPSOH3URMHFWYDULDB

    WinCC Configuration Manual 2-39C79000-G8276-C140-01

    %LWHGLWLQJLQZRUGV

    You access the solutions that relate to these topics in ourYDULDB project by 8 the EXWWRQ depicted above. The examples are configured in thepictures YDULDBBFKDSWHUBSGO and YDULDBBFKDSWHUBDSGO.

    'HILQLWLRQ

    The term ELWHGLWLQJ refers to changing the state of bits in a word.

  • 6DPSOH3URMHFWYDULDB

    2-40 WinCC Configuration ManualC79000-G8276-C140-01

    'LUHFWO\VHWWLQJDELWZLWKWKHDLGRIDFKHFNER[DQGGLUHFW

    FRQQHFWLRQH[DPSOH

    7DVNGHILQLWLRQ

    The state of a bit in a word is to be changed when this bit is selected. We want to be able toselect several bits.

    ,PSOHPHQWDWLRQFRQFHSW

    We implement changing of the bit states by means of a check box, which we create under:LQGRZV2EMHFWV&KHFN%R[. When we 8 one of the fields of the &KHFN%R[, the bitassigned to it in the LQWHUQDOWDJ is changed with the aid of a GLUHFWFRQQHFWLRQ.The bit pattern is displayed by means of an I/O field created under 6PDUW2EMHFWV,2)LHOG. The output value of the ,2ILHOG is linked to an LQWHUQDOWDJ.

    ,PSOHPHQWLQJLQWKH:LQ&&SURMHFW

    6WHS

    3URFHGXUHGLUHFWO\VHWWLQJDELWZLWKWKHDLGRIDFKHFNER[DQGGLUHFW

    FRQQHFWLRQ

    1 Create a tag of type 8QVLJQHGELWYDOXH in Tag Management. In our example,we use the tag called 8LBYDULDBVHWB

    2 In a picture, configure an object by selecting 6PDUW2EMHFWV,2)LHOG. In ourexample, we use the object called ,2)LHOG. When configuring the ,2ILHOG inthe FRQILJXUDWLRQGLDORJ, select the tag named 8LBYDULDBVHWB. Change theentry in the list box from the default value of 2s to 8SRQFKDQJH and change thefield type entry (7\SH) to 2XWSXW. Under 3URSHUWLHV2XWSXW,QSXW, change the'DWD)RUPDW to %LQDU\ and change the 2XWSXW)RUPDW to .

    3 In the same picture, configure a :LQGRZV2EMHFWV&KHFN%R[In our example,we use the object called &KHFN%R[. Under 3URSHUWLHV*HRPHWU\1XPEHU

  • 6DPSOH3URMHFWYDULDB

    WinCC Configuration Manual 2-41C79000-G8276-C140-01

    6WHS

    3URFHGXUHGLUHFWO\VHWWLQJDELWZLWKWKHDLGRIDFKHFNER[DQGGLUHFW

    FRQQHFWLRQ

    RI%R[HV, change the default value 3 to .4 Select the index value 1 under 3URSHUWLHV)RQW,QGH[. Enter the

    appropriate text for the selected index under 3URSHUWLHV)RQW7H[WELW.In the same way, configure the values for the remaining index inputs.

    5 Under (YHQWV3URSHUW\7RSLFV6HOHFWHG%R[HV, dynamize this event using aGLUHFWFRQQHFWLRQ.

    6 In the 'LUHFW&RQQHFWLRQ dialog box, connect the VRXUFH 3URSHUW\WKLVREMHFW6HOHFWHG%R[HV to the target 9DULDEOH8LBYDULDBVHWB. Accept thesettings by clicking the 2. button.

  • 6DPSOH3URMHFWYDULDB

    2-42 WinCC Configuration ManualC79000-G8276-C140-01

    6WHS

    3URFHGXUHGLUHFWO\VHWWLQJDELWZLWKWKHDLGRIDFKHFNER[DQGGLUHFW

    FRQQHFWLRQ

    7 Configure two :LQGRZV2EMHFWV%XWWRQ. In our example, we use the objectscalled %XWWRQ and %XWWRQ. These will be used to set and reset all bits.

    8 Create a GLUHFWFRQQHFWLRQ for under (YHQWV0RXVH0RXVH$FWLRQ. Connectthe VRXUFH &RQVWDQW to the WDUJHW 2EMHFWLQ3LFWXUH&KHFN%R[6HOHFWHG%R[HV. Accept the settings by clicking the 2. button. The constantselected corresponds to the binary number 1111111111111111.Create a GLUHFWFRQQHFWLRQ linked to the object %XWWRQ in the same way, but thistime with the VRXUFH &RQVWDQW.

    1RWHVRQJHQHUDOXVH

    The following adaptations must be made before this button can be put to general use: The tags must be adapted in the GLUHFWFRQQHFWLRQV.

  • 6DPSOH3URMHFWYDULDB

    WinCC Configuration Manual 2-43C79000-G8276-C140-01

    6HOHFWLQJDELWDQGFKDQJLQJLWVVWDWHH[DPSOH

    7DVNGHILQLWLRQ

    The state of a bit in a word is to be changed by entering its bit number and clicking aEXWWRQ. Switching from 0 to 1 and vice versa.

    ,PSOHPHQWDWLRQFRQFHSW

    We implement changing of the bit states by means of a button, which we create under:LQGRZV2EMHFWV%XWWRQ.To enter the bit number and display the bit pattern, we use a 6PDUW2EMHFWV,2)LHOG.When we enter the bit number and 8 the EXWWRQ, the selected bit in an LQWHUQDOWDJ ischanged. The change is implemented by means of a &DFWLRQ.

    ,PSOHPHQWLQJLQWKH:LQ&&SURMHFW

    6WHS 3URFHGXUHFKDQJLQJDELWLQDZRUG

    1 Create two tags of type 8QVLJQHGELWYDOXH in Tag Management. In ourexample, we use the tags called 8LBYDULDBVHWB and 8LBYDULDBVHWB

    2 In a picture, configure an object by selecting 6PDUW2EMHFWV,2)LHOG. In ourexample, we use the object called ,2)LHOG. When configuring the ,2ILHOG,connect it to tag 8LBYDULDBVHWB. Change the entry in the 8SGDWH list boxfrom the default value of 2s to 8SRQFKDQJH. The bit number is entered in thisinput field.

  • 6DPSOH3URMHFWYDULDB

    2-44 WinCC Configuration ManualC79000-G8276-C140-01

    6WHS 3URFHGXUHFKDQJLQJDELWLQDZRUG

    3 Configure a second ,2ILHOG for displaying the bit states. In our example, we usethe object called ,2)LHOG. When configuring the ,2ILHOG, connect it to tag8LBYDULDBVHWB. Change the entry in the 8SGDWH list box from the defaultvalue of 2s to 8SRQFKDQJH. Change the field type to 2XWSXW. Under 3URSHUWLHV2XWSXW,QSXW, change the 'DWD)RUPDW to %LQDU\ and change the 2XWSXW)RUPDW to .

    4 In the same picture, configure three buttons under :LQGRZV2EMHFWV%XWWRQ. Inour example, we use the objects called %XWWRQ, %XWWRQ and %XWWRQ.

    5 Create a &DFWLRQ for %XWWRQ under (YHQWV0RXVH3UHVVOHIW. This &DFWLRQis to be used to set the bit selected in the ,2ILHOG in an LQWHUQDOWDJ. In the sameway, create &DFWLRQV under the other EXWWRQV for resetting and toggling the bit.

    C action for set button#include "apdefap.h"void OnLButtonDown(char* lpszPictureName, char* lpszObjectName,

    char* lpszPropertyName, UINT nFlags, int x, int y){WORD word,pos;

    //get word and bit positionpos=GetTagWord("U16i_varia_set_09");word=GetTagWord("U16i_varia_set_08");

    word = (WORD)(word|1

  • 6DPSOH3URMHFWYDULDB

    WinCC Configuration Manual 2-45C79000-G8276-C140-01

    C action for reset button#include "apdefap.h"void OnLButtonDown(char* lpszPictureName, char* lpszObjectName,

    char* lpszPropertyName, UINT nFlags, int x, int y){WORD word,pos;

    //get word and bit positionpos=GetTagWord("U16i_varia_set_09");word=GetTagWord("U16i_varia_set_08");

    word=(WORD)(word&~(1

  • 6DPSOH3URMHFWYDULDB

    2-46 WinCC Configuration ManualC79000-G8276-C140-01

    7KHRWKHUH[DPSOHVUHODWHGWRWKLVWRSLF

    H[DPSOH

    The functionality of this example is similar to that of example H[DPSOH. The basicdifference is in the way the bit to be switched is selected. In this example, the bit isswitched by selecting an object which represents this bit. Each object is able to read outwhich bit it is responsible for from its object name.

    H[DPSOH

    The functionality of this example is similar to that of example H[DPSOH. The differenceis that the bit is immediately toggled on being selected with the 8. Here too, the objectsare assigned to the bits by means of the Object name.

    H[DPSOH

    The functionality of this example is similar to that of example H[DPSOH. The differencehere is that an option group is used. Use of this object type means that only one bit can beset in each data word.

  • 6DPSOH3URMHFWYDULDB

    WinCC Configuration Manual 2-47C79000-G8276-C140-01

    ,QGLUHFWDGGUHVVLQJRIWDJV

    You access the solutions that relate to these topics in ourYDULDB project by 8 the EXWWRQ depicted above. The examples are configured in thepicture named YDULDBBFKDSWHUBSGO.

  • 6DPSOH3URMHFWYDULDB

    2-48 WinCC Configuration ManualC79000-G8276-C140-01

    ,QGLUHFWDGGUHVVLQJE\PHDQVRIDGLUHFWFRQQHFWLRQH[DPSOH

    7DVNGHILQLWLRQ

    Various process values are to be displayed in an ,2ILHOG. The corresponding values are tobe selected by means of EXWWRQV.

    ,PSOHPHQWDWLRQFRQFHSW

    We implement selection of the corresponding process values by means of a button, whichwe create under :LQGRZV2EMHFWV%XWWRQ.We use an I/O field created under 6PDUW2EMHFWV,2)LHOG and indirect addressing inWinCC to display the process values. Three more I/O fields created under 6PDUW2EMHFWV,2ILHOGValso enable you to enter the process value directly.

    ,PSOHPHQWLQJLQWKH:LQ&&SURMHFW

    6WHS 3URFHGXUHLQGLUHFWDGGUHVVLQJE\PHDQVRIDGLUHFWFRQQHFWLRQ

    1 Create three tags of type 6LJQHGELWYDOXH in Tag Management. In ourexample, we use the tags called 6LBYDULDBDGUB6LBYDULDBDGUB and6LBYDULDBDGUB. These contain the process values to be displayed.

    2 Create a tag of type 7H[WWDJELWFKDUDFWHUVHW with a length of 20 characters inTag Management. In our example, we use the tag called 7[BYDULDBDGUB.This will be used as an address tag.

    3 In a picture, configure an object by selecting 6PDUW2EMHFWV,2)LHOG. In ourexample, we use the object called ,2)LHOG. When configuring the ,2ILHOG inthe FRQILJXUDWLRQGLDORJ, select the tag named 7[BYDULDBDGUB. Change theentry in the list box from the default value of 2s to 8SRQFKDQJH and change thefield type entry (7\SH) to 2XWSXW. Under 3URSHUWLHV2XWSXW,QSXW2XWSXW9DOXH, select the box in the ,,QGLUHFW column. Select the box.

    4 Configure an object of type 6WDQGDUG2EMHFWV6WDWLF7H[W. In our example, we

  • 6DPSOH3URMHFWYDULDB

    WinCC Configuration Manual 2-49C79000-G8276-C140-01

    6WHS 3URFHGXUHLQGLUHFWDGGUHVVLQJE\PHDQVRIDGLUHFWFRQQHFWLRQ

    use the object called 6WDWLF7H[W. This object indicates which process value iscurrently being displayed. The text in the object is automatically supplied by theEXWWRQ.

    5 In the same picture, configure three buttons under :LQGRZV2EMHFWV%XWWRQInour example, we use the objects called %XWWRQ, %XWWRQ and %XWWRQ.

    6 Configure a GLUHFWFRQQHFWLRQ for %XWWRQ under (YHQWV0RXVH3UHVVOHIW.Connect the VRXUFH &RQVWDQW6LBYDULDBDGUB to the WDUJHW 9DULDEOH7[BYDULDBDGUB. Accept the settings by clicking the 2. button.

    7 Create a further GLUHFWFRQQHFWLRQ under (YHQWV0RXVH0RXVH$FWLRQ.Connect the VRXUFH 3URSHUW\WKLVREMHFW7H[W to the WDUJHW 2EMHFWLQ3LFWXUH6WDWLF7H[W7H[W. Accept the settings by clicking the 2. button.

    8 Configure %XWWRQ and %XWWRQin the same way as %XWWRQ. In the first GLUHFWFRQQHFWLRQ, the tag name in the VRXUFH must be changed. The second GLUHFWFRQQHFWLRQ can be applied without any change.

    1RWHVRQJHQHUDOXVH

    The following adaptations must be made before this button can be put to general use: The tag names must be adapted.

  • 6DPSOH3URMHFWYDULDB

    2-50 WinCC Configuration ManualC79000-G8276-C140-01

    0XOWLSOH[GLVSOD\XVLQJLQGLUHFWDGGUHVVLQJDQGD&DFWLRQ

    H[DPSOH

    7DVNGHILQLWLRQ

    Three different process values of a container are to be displayed. The same display is,however, also to be set up for several containers. The relevant process values are to bedisplayed by selecting the corresponding container.

    ,PSOHPHQWDWLRQFRQFHSW

    We implement selection of the corresponding container by means of an option group,which we create under :LQGRZV2EMHFWV2SWLRQ*URXS.We use three I/O fields created under 6PDUW2EMHFWV,2)LHOG and indirect addressing inWinCC to display the process values.The containers with the corresponding values are displayed in H[DPSOH.

    ,PSOHPHQWLQJLQWKH:LQ&&SURMHFW

    6WHS 3URFHGXUHPXOWLSOH[GLVSOD\ZLWKLQGLUHFWDGGUHVVLQJ

    1 Create nine tags of type 6LJQHGELWYDOXH in Tag Management. In our example,we use the tags called 6LBYDULDBDGUB through 6LBYDULDBDGUB. Thesetags contain the corresponding process values of the container.

    2 Create three tags of type 7H[WWDJELWFKDUDFWHUVHW in Tag Management. In ourexample, we use the tags called 7[BYDULDBDGUB, 7[BYDULDBDGUB and7[BYDULDBDGUB. They will be used as address tags for the,2ILHOGV.

    3 Configure three I/O fields under 6PDUW2EMHFWV,2)LHOG. In our example, weuse ,2)LHOG, ,2)LHOG and ,2)LHOG.

    4 For object ,2)LHOG, change the )LHOG7\SH to 2XWSXW under 3URSHUWLHV2XWSXW,QSXW. Under the property 2XWSXW9DOXH, configure a WDJFRQQHFWLRQ to tag7[BYDULDBDGUB and select the box in the ,,QGLUHFW column. Select thebox.

    5 In the same way, configure the other ,2ILHOGV, but connect each field to adifferent address tag.

    6 Configure an option group under :LQGRZV2EMHFWV2SWLRQ*URXS. In ourexample, we use the object called 2SWLRQ*URXS.

    7 Select the index 1 under 3URSHUWLHV)RQW,QGH[. Enter the appropriate textfor the selected index under 3URSHUWLHV)RQW7H[W&RQWDLQHU. In thesame way, configure the texts for the remaining index values.

    8 Create a &DFWLRQ under (YHQWV3URSHUW\7RSLFV2XWSXW,QSXW6HOHFWHG%R[HV. This action describes the address tag depending on the field selected.

  • 6DPSOH3URMHFWYDULDB

    WinCC Configuration Manual 2-51C79000-G8276-C140-01

    C action for the option group#include "apdefap.h"void OnPropertyChanged(char* lpszPictureName, char* lpszObjectName,

    char* lpszPropertyName, long value){char address1[20],address2[20],address3[20];

    switch(value) {case 2: {

    strcpy(address1,"S32i_varia_adr_03");strcpy(address2,"S32i_varia_adr_06");strcpy(address3,"S32i_varia_adr_09");}//case 2break;

    case 4: {strcpy(address1,"S32i_varia_adr_04");strcpy(address2,"S32i_varia_adr_07");strcpy(address3,"S32i_varia_adr_10");}//case 4break;

    default: {strcpy(address1,"S32i_varia_adr_05");strcpy(address2,"S32i_varia_adr_08");strcpy(address3,"S32i_varia_adr_11");}//defaultbreak;

    }//switch

    SetTagChar("T16x_varia_adr_01",address1);SetTagChar("T16x_varia_adr_02",address2);SetTagChar("T16x_varia_adr_03",address3);} Declaration of three &WDJV as an array of characters. Copy the tag names into the tags declared beforehand, in accordance with the input

    state. The input state is stored in the predefined tag YDOXH. Assign the corresponding tag names to the address tags.

    1RWHVRQJHQHUDOXVH

    The following adaptations must be made before this button can be put to general use: The tag names must be adapted.

  • 6DPSOH3URMHFWYDULDB

    2-52 WinCC Configuration ManualC79000-G8276-C140-01

    ,QGLUHFWDGGUHVVLQJE\PHDQVRI&DFWLRQH[DPSOH

    7DVNGHILQLWLRQ

    Various process values are to be displayed in an ,2ILHOG. The corresponding values are tobe selected by means of an 2SWLRQ*URXS.

    ,PSOHPHQWDWLRQFRQFHSW

    We implement selection of the corresponding process value by means of an option group,which we create under :LQGRZV2EMHFWV2SWLRQ*URXS. We use an I/O field createdunder 6PDUW2EMHFWV,2)LHOG and indirect addressing in WinCC to display the processvalue.

    ,PSOHPHQWLQJLQWKH:LQ&&SURMHFW

    6WHS 3URFHGXUHLQGLUHFWDGGUHVVLQJE\PHDQVRID&DFWLRQ

    1 Create three tags of type 6LJQHGELWYDOXH in Tag Management. In ourexample, we use the tags called 6LBYDULDBDGUB6LBYDULDBDGUB and6LBYDULDBDGUB. These contain the process values to be displayed.

    2 Create a tag of type 7H[WWDJELWFKDUDFWHUVHW with a length of 20 characters inTag Management. In our example, we use the tag called 7[BYDULDBDGUB.This will be used as an address tag.

    3 In a picture, configure an object by selecting 6PDUW2EMHFWV,2)LHOG. In ourexample, we use the object called ,2)LHOG. When configuring the ,2ILHOG inthe FRQILJXUDWLRQGLDORJ, select the tag named7[BYDULDBDGUB. Change theentry in the list box from the default value of 2s to 8SRQFKDQJH and change thefield type entry (7\SH) to 2XWSXW. Under 3URSHUWLHV2XWSXW,QSXW2XWSXW9DOXH, select the box in the ,,QGLUHFW column. Select the box.

    4 In the same picture, configure a :LQGRZV2EMHFWV2SWLRQ*URXS. In ourexample, we use the object called 2SWLRQ*URXS.

    5 Select the index 1 under 3URSHUWLHV)RQW,QGH[. Enter the appropriate textfor the selected index under 3URSHUWLHV)RQW7H[W)LOO/HYHO. In the sameway, configure the texts for the remaining index values.

    6 Create a &DFWLRQ under (YHQWV3URSHUW\7RSLFV2XWSXW,QSXW6HOHFWHG%R[HV. This action describes the address tag depending on the field selected.

  • 6DPSOH3URMHFWYDULDB

    WinCC Configuration Manual 2-53C79000-G8276-C140-01

    C action for the option group#include "apdefap.h"void OnPropertyChanged(char* lpszPictureName, char* lpszObjectName,

    char* lpszPropertyName, long value){char address[40];

    //set tag according to input valueswitch(value) { case 2: strcpy(address,"S32i_varia_adr_01"); break; case 4: strcpy(address,"S32i_varia_adr_02"); break; default: strcpy(address,"S32i_varia_adr_00"); }//switchSetTagChar("T16x_varia_adr_00",address);} Assign a tag name to address tag 7[BYDULDBDGUB in accordance with the input state.

    The input state is stored in the predefined tag YDOXH.

    1RWHVRQJHQHUDOXVH

    The following adaptations must be made before this button can be put to general use: The tag names must be adapted.

  • 6DPSOH3URMHFWYDULDB

    2-54 WinCC Configuration ManualC79000-G8276-C140-01

    7KHRWKHUH[DPSOHVUHODWHGWRWKLVWRSLF

    H[DPSOH

    The functionality of this example is to display the process values used in H[DPSOH.

  • 6DPSOH3URMHFWYDULDB

    WinCC Configuration Manual 2-55C79000-G8276-C140-01

    6LPXODWLRQRIWDJV

    You access the solutions that relate to these topics in ourYDULDB project by 8 the EXWWRQ depicted above. The examples are configured in thepicture named YDULDBBFKDSWHUBSGO.

    'HILQLWLRQ

    The term VLPXODWLRQ refers to changing the contents of a tag without a process driverconnection. Simulation is performed using utility programs.

  • 6DPSOH3URMHFWYDULDB

    2-56 WinCC Configuration ManualC79000-G8276-C140-01

    6LPXODWLQJDWULDQJXODURVFLOODWLRQE\PHDQVRID&DFWLRQ

    H[DPSOH

    7DVNGHILQLWLRQ

    A triangular oscillation simulation with settable values for the maximum value andminimum value is to be created. The plausibility of these values is to be verified as they areentered. Simulation is to be started and stopped by means of a EXWWRQ. Another EXWWRQ is tobe used to reset the tag value to zero.

    ,PSOHPHQWDWLRQFRQFHSW

    We implement starting of the simulation and initialization by means of two buttons, whichwe create under :LQGRZV2EMHFWV%XWWRQ. To display the tag value and to input themaximum and minimum values, we will create three I/O fields under 6PDUW2EMHFWV,2)LHOG. If simulation is started while the maximum and minimum values set are identical, amessage box pops up.

    ,PSOHPHQWLQJLQWKH:LQ&&SURMHFW

    6WHS 3URFHGXUHVLPXODWLQJDWULDQJXODURVFLOODWLRQE\PHDQVRID&DFWLRQ

    1 Create three tags of type 6LJQHGELWYDOXH in Tag Management. In ourexample, we use the tags called 6LBYDULDBVLPB6LBYDULDBVLPB and6LBYDULDBVLPB

    2 Create two tags of type %LQDU\WDJ in Tag Management. In our example, we usethe tags called %,1LBYDULDBVLPB and %,1LBYDULDBVLPB.

    3 Configure three I/O fields under 6PDUW2EMHFWV,2)LHOG. In our example, weuse ,2)LHOG, ,2)LHOG and ,2)LHOG.

    4 For object ,2)LHOG, create a WDJFRQQHFWLRQ to tag 6LBYDULDBVLPB under3URSHUWLHV2XWSXW,QSXW2XWSXW9DOXH and set the trigger to 8SRQFKDQJH.Change the 2XWSXW)RUPDW to . In the same way, configure ,2)LHOG, butset tag 6LBYDULDBVLPB 7RFKHFNWKHSODXVLELOLW\RI,2)LHOG, create a WDJFRQQHFWLRQ to tag6LBYDULDBVLPB under 3URSHUWLHV/LPLWV+LJK/LPLW9DOXH. In the sameway, configure the tag 6LBYDULDBVLPB as the /RZ/LPLW9DOXH for ,2)LHOG.

    6 For object ,2)LHOG, create a WDJFRQQHFWLRQ to tag 6LBYDULDBVLPB under3URSHUWLHV2XWSXW,QSXW2XWSXW9DOXH and set the trigger to 8SRQFKDQJH.Change the 2XWSXW)RUPDW to and the )LHOG7\SH to 2XWSXW.

    7 Configure a picture window at 6PDUW2EMHFWV3LFWXUH:LQGRZ; in our examplewe use GLDORJER[ Select 3URSHUWLHV0LVFHOODQHRXVand modify the properties0RYHDEOH and %RUGHU to

  • 6DPSOH3URMHFWYDULDB

    WinCC Configuration Manual 2-57C79000-G8276-C140-01

    6WHS 3URFHGXUHVLPXODWLQJDWULDQJXODURVFLOODWLRQE\PHDQVRID&DFWLRQ

    called %XWWRQ. Under (YHQWVB0RXVH3UHVVOHIW, generate a &DFWLRQ whichnegates the status of the %,1LBYDULDBVLPB tag. Under 3URSHUWLHV*HRPHWU\3RVLWLRQ;, create a &DFWLRQ, which executes tag simulation.

    10 Create a status display under 6PDUW2EMHFWV6WDWXV'LVSOD\ to display thestatus of simulation. In our example, we use the object called 6WDWXV'LVSOD\.Under &RQILJXUDWLRQ'LDORJ, set tag %,1LBYDULDBVLPB and set the trigger to8SRQFKDQJH. Add another status. For status , set the pictureJOKELUQHBB%LWEPS, and for status , set the picture JOKELUQHBB%LWEPS.

    &DFWLRQIRUWDJVLPXODWLRQ

    #include "apdefap.h"long _main(char* lpszPictureName, char* lpszObjectName, char*

    lpszPropertyName){BOOL state;static DWORD lowstore = 0;static BOOL statestore = 0;static DWORD r = 1;static DWORD i = 0;static DWORD box = 0;int high,low;

    //if button init was pressedif (GetTagBit("BINi_varia_sim_04")) { (i=lowstore); (r=1); SetTagDWord("S32i_varia_sim_00",i); SetTagDWord("BINi_varia_sim_04",0);

    }

    //get simulator statestate=GetTagBit("BINi_varia_sim_01");

    if (state!=statestore) (box=0);

    statestore=state;

    //get limitshigh=GetTagDWord("S32i_varia_sim_02");low=GetTagDWord("S32i_varia_sim_03");

    //set low limit storeif (low!=lowstore){

    lowstore = low;i=low;}//if

    //if limits differentif (high!=low) {

    box=0;//if simulator is activatedif (state==TRUE) {

    //inc or dec according to directionif (r==1) (i=i+1);else (i=i-1);//set direction

  • 6DPSOH3URMHFWYDULDB

    2-58 WinCC Configuration ManualC79000-G8276-C140-01

    if (i==high) (r=0);if (i==low) (r=1);//init simulator if limit overflowif ((i>high)||(i

  • 6DPSOH3URMHFWYDULDB

    WinCC Configuration Manual 2-59C79000-G8276-C140-01

    6LPXODWLRQE\PHDQVRIDQH[WHUQDOSURJUDPH[DPSOH

    WinCC provides its own simulation program, which can simulate tags using a number ofdifferent methods. This simulation program must be installed using the 6HWXSH[H programin the folder called 6PDUW7RROV&&B6LPXODWRU on the WinCC CD.

    7DVNGHILQLWLRQ

    Tags are to be simulated using the WinCC tag simulator.

    ,PSOHPHQWDWLRQFRQFHSW

    We will use a number of tags, which will be displayed in I/O fields created under 6PDUW2EMHFWV,2)LHOG and whose contents will be controlled by means of the tag simulator.

  • 6DPSOH3URMHFWYDULDB

    2-60 WinCC Configuration ManualC79000-G8276-C140-01

    ,PSOHPHQWLQJLQWKH:LQ&&SURMHFW

    6WHS 3URFHGXUHVLPXODWLQJE\PHDQVRIDQH[WHUQDOSURJUDP

    1 Create two LQWHUQDOWDJV of type 6LJQHGELWYDOXH in Tag Management. In ourexample, we use the tags called 6LBYDULDBVLPB and 6LBYDULDBVLPB

    2 Configure two I/O fields under 6PDUW2EMHFWV,2)LHOG. In our example, weuse ,2)LHOG and ,2)LHOG.

    3 For object ,2)LHOG, create a WDJFRQQHFWLRQ to tag 6LBYDULDBVLPB under3URSHUWLHV2XWSXW,QSXW2XWSXW9DOXH and set the trigger to 8SRQFKDQJH.Change the 2XWSXW)RUPDW to and the )LHOG7\SH to 2XWSXW)LHOG. In thesame way, configure ,2)LHOG, but set tag 6LBYDULDBVLPB.

    4 Start the tag simulator by means of the 6LPXODWRU button. If the tag simulator hasnot been installed under the default path, set the correct path by means of the3DWK button. If the simulation program is started using a method other than theone described, you must ensure that the project in question is running in runtimemode.

    5 In the simulator, select tag 6LBYDULDBVLPB under the menu item (GLW1HZ7DJ from the Tag Management screen which appears. Select the ,QF tab and enterthe 6WDUW9DOXH and (QG9DOXH. In our example, the values and have beenused. Simulation is started by selecting the item DFWLYH. The value of the tag isincreased from 0 to 20, after which simulation is restarted at 0.

    6 Proceed in the same way with tag 6LBYDULDBVLPB. In our example, the 6LQXVtab has been selected and $PSOLWXGH set to , 2IIVHW to and 2VFLOODWLRQWLPH to.

    1RWH

    In the sample project, you can use the flag icon to select the English or German version ofthe tag simulator.

    1RWHVRQJHQHUDOXVH

    The following adaptations must be made before this button can be put to general use: The tags to be simulated and the method of simulation must be customized to suit your

    own requirements.

  • 6DPSOH3URMHFWYDULDB

    WinCC Configuration Manual 2-61C79000-G8276-C140-01

    ,PSRUWLQJH[SRUWLQJWDJV

    You access the solutions that relate to these topics in ourYDULDB project by 8 the EXWWRQ d