SIEMENS SIMATIC S7 + WINCC

On-Off Valve




Boiler Project

• Create Function Block for on/off valve. Right-click on the Blocks folder and select Insert New Object > Function Block menu item.



• Set Symbolic Name to FB_VVONOFF, Symbol Comment with Function Block Valve On-Off and LAD language.



• Open Attributes tab and in line 1 include the attribute S7_m_c with value true. This monitoring and control attribute allows function block tags to be automatically generated in WinCC when the AS is compiled.



• Open the function block FB1 FB_VVONOFF for editing. In Component View, double-click on the function block.

• In Interface, enter the IN input parameters:

Name Type Description S7_m_c
ZSC Bool VV closed status True
ZSO Bool VV open status True
TMR Time Open/close time (seconds)


• Set attribute S7_m_c of the ZSC parameter to true. Double click on the ZSC line and in the Attributes tab insert the attribute S7_m_c with a value of true. Only parameters with this attribute in true tags will be automatically generated in WinCC when compiling the AS. ZSC and ZSO must have this attribute. TMR will not have, as this parameter is not used for monitoring and control in the supervisory.



• Observe in the figure below (highlighted in red) the indication of the attribute configured for ZSC and ZSO. The TMR parameter does not have a green flag that indicates the definition of the S7_m_c attribute.



• Enter the OUT output parameters:

Name Type Description S7_m_c
XV Bool Digital output command
ALM Bool Alarm True


• Enter the IN_OUT input/output parameters:

Name Type Description S7_m_c
AM Bool Auto/Manual True
AF Bool Open/close operator command True
CA Bool Open/close automatic command


• Insert logic for on-off valve.

Network 1

Command to open valve (move 1 to exit XV). The valve opens in two conditions:

• when in manual (AM = 0) and the operator button receives the open command (AF = 1).

• when in automatic (AM = 1) and the command in automatic orders to open (CA = 1).

• Insert contacts and coils into Network 1.





• Edit Network 1 lines.







Network 2

Command to close the valve (moves 0 to exit XV). The valve closes in two conditions:

• when in manual (AM = 0) and the operator button receives the close command (AF = 0).

• when in automatic (AM = 1) and the command in automatic orders to close (CA = 0).

• Insert new Network.





Network 3

Command to change the status of the operator manual push button to open when the valve opens in automatic. This instruction ensures that the valve remains in command to open as soon as the operating mode changes from automatic to manual.



Network 4

Command to change the status of the operator manual push button to closed when the valve closes automatically. This instruction ensures that the valve remains in command to close as soon as the operating mode changes from automatic to manual.



Networks 5 and 6

Activation of valve alarm (ALM = 1). The alarm is activated after the time defined in the TMR parameter (seconds) of at least one of the following conditions has elapsed:

• Valve command open (XV = 1) and with closed valve status return sensor activated (ZSL = 1) - indication that the valve has not opened;

• Valve command on closing (XV = 0) and with open valve status return sensor activated (ZSH = 1) - indication that the valve has not closed;

• Both valve status feedback sensors activated (ZSL = 1 and ZSH = 1);

• Both valve status return sensors deactivated (ZSL = 0 and ZSH = 0).

When none of the conditions are true, the alarm is immediately deactivated.

• Enter the STAT A1 static parameter of type SFB4:



• The SFB4 data type is used in the Timer On (TON) instruction.



• Enter the Bool type STAT A1AUX static parameter.

• Insert Network 5:



• Insert SFB4 TON IEC_TC System Function Block in the Network 6. Select SFB in Libraries > Standard Library > System Function Blocks.



• Change System Function Block TON to allow multiple instances. Right-click on the block and select Change to Multiple Instance Call ...



• Enter the name A1 in the Name of Multiple Instance field.



• Edit Network 6:





• Create Function for on/off valves. Right-click on the Blocks folder and select Insert New Object > Function menu item. Set Function properties:



• Open function VVS_ON_OFF and insert function block FB_VVONOFF for valve VV350 Bottom Dump Valve. Select FB_VVONOFF in the FB Blocks folder and drag it to network 1.



• At the top of the block, insert the DB1 instance data block.



• Edit the symbol for the DB1 address: VV350 – Bottom Dump Valve.



• Insert I/O variables in the input and output parameters (field) and determine the valve opening/closing timeout for alarm in 5 seconds (T#5S).



• Open Organization Block OB1 to make the call to function FC1 VVS_ON_OFF during the cyclic execution of this organization block.



• Enable Operator Control and Monitoring for DB 1 VV350. Right-click on DB 1 in the Component View and select Special Object Properties > Operator Control and Monitoring... menu item





Insert Organization Blocks

• Select File > Open menu item to open Standard Library.

• Open the Libraries tab, select Standard Library and click on OK button.



• Open the Organization Blocks folder in the Standard Library and select the following error handling blocks:

OB40 HW_INT0
OB70 RED_I/O_FLT1
OB72 RED_FLT
OB80 CYCL_FLT
OB81 PS_FLT
OB82 I/O_FLT1
OB83 I/O_FLT2
OB84 CPU_FLT
OB85 OBNL_FLT
OB86 RACK_FLT
OB87 COMM_FLT
OB88 BREAKUP ERROR
OB100 COMPLETE RESTART
OB121 PROG_ERR
OB122 MOD_ERR

• Copy selected blockss (Ctr + C).



• Close the Standard Library and paste (Ctr + V) the blocks in the Boiler project.



Compiling and Downloading AS

An AS can be compiled and downloaded to a controller by several means:

1 – Through HW Config (Component View > AS > Hardware) to compile and download the hardware configuration to the CPU.



Save and compile button

Download button

2 – Through NetPro (Component View > Menu Options > Configure Network) to compile and download the network and connection configuration.



Compile button

4 – Through SIMATIC Manager to compile and download objects individually in a multiproject.

Boiler Project

• Compile AS. Right-click on AS_CALD and select the PLC > Compile and Download Objects... menu item



• Select all items to compile and check Compile only option to compile only (no download). Click the Start button.