You are on page 1of 35

Weihenstephan

Standards for
S7-1200 / S7-1500
Siemens
Program and State Management Industry
Online
https://support.industry.siemens.com/cs/ww/en/view/109475571 Support
Warranty and liability

Warranty and liability

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

We do not accept any liability for the information contained in this document.
Any claims against us – based on whatever legal reason – resulting from the use of
the examples, information, programs, engineering and performance data etc.,
described in this Application Example shall be excluded. Such an exclusion shall
not apply in the case of mandatory liability, e.g. under the German Product Liability
Act (“Produkthaftungsgesetz”), in case of intent, gross negligence, or injury of life,
body or health, guarantee for the quality of a product, fraudulent concealment of a
 Siemens AG 2017 All rights reserved

deficiency or breach of a condition which goes to the root of the contract


(“wesentliche Vertragspflichten”). The damages for a breach of a substantial
contractual obligation are, however, limited to the foreseeable damage, typical for
the type of contract, except in the event of intent or gross negligence or injury to
life, body or health. The above provisions do not imply a change of the burden of
proof to your detriment.
Any form of duplication or distribution of these Application Examples or excerpts
hereof is prohibited without the expressed consent of the Siemens AG.
Security Siemens provides products and solutions with industrial security functions that
informa- support the secure operation of plants, systems, machines and networks.
tion In order to protect plants, systems, machines and networks against cyber
threats, it is necessary to implement – and continuously maintain – a holistic,
state-of-the-art industrial security concept. Siemens’ products and solutions only
form one element of such a concept.
Customer is responsible to prevent unauthorized access to its plants, systems,
machines and networks. Systems, machines and components should only be
connected to the enterprise network or the internet if and to the extent necessary
and with appropriate security measures (e.g. use of firewalls and network
segmentation) in place.
Additionally, Siemens’ guidance on appropriate security measures should be
taken into account. For more information about industrial security, please visit
http://www.siemens.com/industrialsecurity.
Siemens’ products and solutions undergo continuous development to make them
more secure. Siemens strongly recommends to apply product updates as soon
as available and to always use the latest product versions. Use of product
versions that are no longer supported, and failure to apply latest updates may
increase customer’s exposure to cyber threats.
To stay informed about product updates, subscribe to the Siemens Industrial
Security RSS Feed under http://www.siemens.com/industrialsecurity.

LWeihStd for SIMATIC - Program and State Management


Entry-ID: 109475571, V1.0, 02/2017 2
1 Library Overview

Table of contents
Warranty and liability ............................................................................................... 2
1 Library Overview ............................................................................................ 4
1.1 Different user scenarios ..................................................................... 5
1.2 Hardware and software requirements............................................... 11
1.3 Library resources ............................................................................. 11
2 Blocks of the Library .................................................................................... 12
2.1 List of the blocks .............................................................................. 12
2.2 Explanation of the blocks ................................................................. 13
2.2.1 LWeihStd_ProgramStateManager (FB 30450) ................................. 13
2.2.2 LWeihStd_ConfigureDisabledPrograms (FC 30450)......................... 22
2.2.3 LWeihStd_ConfigureDisabledStates (FC 30451) .............................. 24
2.2.4 PLC data types ................................................................................ 26
2.2.5 PLC tags ......................................................................................... 29
3 Working with the Library .............................................................................. 32
3.1 Integrating the library into STEP 7.................................................... 32
3.2 Integrating the library blocks into STEP 7 ......................................... 33
4 Notes and Support ....................................................................................... 34
5 Related literature .......................................................................................... 35
 Siemens AG 2017 All rights reserved

6 Contact.......................................................................................................... 35
7 History .......................................................................................................... 35

LWeihStd for SIMATIC - Program and State Management


Entry-ID: 109475571, V1.0, 02/2017 3
1 Library Overview

1 Library Overview
What you get
This document describes the ‘Program and State Management’ part of the
LWeihStd block library. The block library provides you with the tested code with
clearly defined interfaces. They can be used as a basis for your task to be
implemented.
A key concern of the document is to describe
 all blocks of the block library
 the functionality implemented through these blocks.

Furthermore, this documentation shows possible fields of application and helps you
integrate the library into your STEP 7 project using step-by-step instructions.

Scope of application
 STEP 7 Professional V13 SP1
 S7-1200 CPU as of firmware 4.1.1

 Siemens AG 2017 All rights reserved

S7-1500 CPU as of firmware 1.8.0

LWeihStd for SIMATIC - Program and State Management


Entry-ID: 109475571, V1.0, 02/2017 4
1 Library Overview
1.1 Different user scenarios

1.1 Different user scenarios


Possible application for the LWeihStd library
A production machine consists of different machine programs (e.g. maintenance or
production program) and states (e.g. stopped or aborting). The machine state can
be controlled with commands (e.g. start or stop).
The library LWeihStd provides a standardized program and state manager to
control a machine. User defined code can be filled in an easy to use template
structure. In addition a machine HMI or an upper level system (MES) can be
connected by using the standardized machine interface.
The Weihenstephan program and state manager is harmonized with the OMAC
mode and state model. The goal of the harmonization is to ensure that the
preparation of a machine for connection of a PDA (Production Data Acquisition)
system in accordance with the Weihenstephan Standards also complies with
OMAC (Open Modular Architecture Controls) requirements.

Figure 1-1: Scenario overview (WS Protocol Version 08)


 Siemens AG 2017 All rights reserved

More information on the Weihenstephan Standards for the food and beverage
packaging industry can be found at the according homepage
(http://www.weihenstephaner-standards.de/index.php?id=2&L=1).

LWeihStd for SIMATIC - Program and State Management


Entry-ID: 109475571, V1.0, 02/2017 5
1 Library Overview
1.1 Different user scenarios

The following section shows a scenario for a possible application of the LWeihStd
library:

Scenario

General information
The LWeihStd library contains a function block for the program and state
management according to WS Pack Version 08.
 Programs Production, Startup, Rundown, Clean, Changeover, Maintenance,
Break and user-defined programs.
 Uniform states within a program
Defined states, such as Stopped, Starting, Operating, Aborting, etc. can be
used to handle the machine states within an operating mode. Users can
individually remove states that are not used in compliance with the
Weihenstephan guidelines.
The machine functionality to be executed in the particular programs and states
must be programmed by the user for the specific application.

Programs and states according to WS Pack Version 08


 Siemens AG 2017 All rights reserved

The standard programs and the user-defined programs with their associated states
defined by WS Pack V08 are listed in this section. The state machines of the
Production, Startup, Rundown, Clean, Changeover, Maintenance, Break and the
user-defined programs are typically a subset of the state machine of the Production
program. Which states are used in the individual programs is not standardized and
users can define them as required. The state model for the Production program
should be considered as the maximum quantity structure, which can be reduced,
but should not be increased. This means that the state machine of the Production
program is always used and for smaller quantity structures, individual states are
directly run-through or skipped.

Figure 1-2: Example of a state machine for the Production program

LWeihStd for SIMATIC - Program and State Management


Entry-ID: 109475571, V1.0, 02/2017 6
1 Library Overview
1.1 Different user scenarios

Figure 1-3: Example of a state machine for the Maintenance program

Programs
Table 1-1 Description of possible programs
 Siemens AG 2017 All rights reserved

Number Program Description


0 Undefined (No A machine was turned on, but no program for a special
Program) application function has been selected. “Undefined” may also
be used to provide the information that a machine is ready for
action, but not required (“No Order, No Activity”).
1 Production The machine is functioning as designed by the manufacturer.
2 Start Up Although the machine is functioning as designed by the
manufacturer, it is running a startup program which ensures
full production after a warm-up period as stipulated by
regulations or for safety considerations, or in conjunction with
container buffering machines.
4 Run Down Although the machine is functioning as designed by the
manufacturer, it is running a stop program which ensures
production stop after a run-down period as stipulated by
regulations or for safety considerations, or in conjunction with
container buffering machines.
8 Clean The machine is running the cleaning program. This program
can consist of program steps which can be controlled
independently of each another, for example the program step
“flush” for the filling or closing machine, or the program “
headspace disinfection” for the cleaning machine.
16 Changeover The machine is running the changeover program in which
automatic machine adjustments are made depending on
specific parameters.
32 Maintenance The machine is running the maintenance program in which
the maintenance and service work are carried out.
64 Break The machine is running the break program. This ensures
there is startup of the machine in accordance with regulations
after a break.
128..32768 UserProgram01… The requirements for user-defined programs differ depending
UserProgram09 on the machine and application.

LWeihStd for SIMATIC - Program and State Management


Entry-ID: 109475571, V1.0, 02/2017 7
1 Library Overview
1.1 Different user scenarios

States
Table 1-2 Description of possible states

Number State Description


0 Undefined Not a valid state.
1 Stopped The machine has electrical power, but is in a stationary state.
This state allows the machine to communicate, but it is not
yet initialized or ready to carry out its intended function.
2 Starting The machine is in production start. This is not to be confused
with program Start up. An example might be the self test of a
packing robot, which tests the functionality of the individual
servo motors through a movement test.
4 Prepared The machine is ready to carry out its intended function.
However, it is in a waiting state which was not recognized as
a lack or tailback state and can automatically start again.
8 Lack The machine is not carrying out its intended function due to a
lack detected by the sensor system in the inlet of the
machine (Machine Stop). In machines which have multiple
inlets, the lack state concerns the main inlet, namely
concerns the goods (bottles, crates) which are transported to
the filling machine (main machine) or from the filling
machine. The lack in the inlet is an external failure, however
due to its importance for the visualization and the technical
reporting it is recorded separately.
 Siemens AG 2017 All rights reserved

16 Tailback The machine is not carrying out its intended function due to a
tailback detected by the sensor system in the outlet of the
machine (Machine Stop). In machines which have multiple
outlets, the tailback state concerns the main outlet, namely
concerns the goods (e. g. product, bottles, crates) which are
transported to the filling machine (main machine) or from the
filling machine. The tailback in the outlet is an external
failure, however due to its importance for the visualization
and the technical reporting it is recorded separately.
32/64 Lack/Tailback branch The machine is not carrying out its intended function due to a
line lack in the secondary inlet or a tailback in the secondary
outlet of the machine (Machine Stop). This state can only
occur only in machines which have 2 or more inlets or
outlets, whereby the secondary flow leads to resp. from a
downstream or upstream machine in the filling system (e. g.
packing or palletizing machine). The secondary flow
concerns the goods (e. g. packaged good, packaging,
packaging aid) which are transported away from the filling
machine (main machine). The lack/tailback in the secondary
flow is an external failure, however due to its importance for
the visualization and the technical reporting it is recorded
separately. Lacks/Tailbacks caused by other media (e. g.
lack of compressed air) not processed in another machine of
the packaging plant does not follow the state Lack or
Tailback.
128 Operating The machine is carrying out its intended function (DIN EN
292-1).
256 Stopping The machine is being transferred to the stopped state
(Stopped) by a controlled stop routine. This is not to be
confused with the program Production Start Up / Run Down.
Rather it concerns the internal machine routines for reaching
a stationary state. An example would be the positioning of
the packing head of a packing robot in the park position.

LWeihStd for SIMATIC - Program and State Management


Entry-ID: 109475571, V1.0, 02/2017 8
1 Library Overview
1.1 Different user scenarios

512 Aborting The machine is in the time period between the occurrence of
the failure and the resulting end state (Emergency Stop).
1024 Equipment Failure Failure, which occurs in the machine itself and leads to a
machine stop (in accordance with DIN 8782). In the
operating state Equipment Failure the machine does not
carry out its intended function (Machine Stop) due to an
unpermitted deviation from the SET-state (Failure notice).
The unpermitted deviation is parameterized in the controls as
equipment failure.
2048 External Failure A failure which is not attributable to the machine but which
nonetheless leads to a machine stop (in accordance with DIN
8782). In the operating state External Failure, the machine
does not carry out its intended function (Machine Stop) due
to an unpermitted deviation from the SET-state (Failure
notice) detected by the control system sensors. The
unpermitted deviation is parameterized in the controls as an
external failure. The external failures Lack, Tailback, and
Lack/Tailback in Branch Line are recorded separately and
therefore are not assigned to this operating state. Other lack
or tailback situations are however considered External
Failures (E.g. lack of compressed air).
4096 Emergency Stop State that occurs after pressing the emergency stop switch or
the activation of another safety guard of a machine (E.g. door
in safety circuit). A "safe mode" (Safe Motion), in which a
machine continues to operate does not match the state
 Siemens AG 2017 All rights reserved

Emergency Stop.
8192 Holding The machine is in the time period between the holding and
the resulting end state (Held, Equipment Failure, External
Failure).
16384 Held The machine is not carrying out its intended function due to
an unpermitted deviation from the SET-state detected by a
control system sensor. The operator intervenes and stops
the machine manually (E. g. by handoff). The cause of failure
is classed by the operator as either equipment failure or
external failure.
32768 Idle The machine is ready to carry out its intended function. It is
however in a waiting state and must first be brought into
operation by the operators or by external automatic release.
65536 Unholding The machine is in the time period between the release of
held (Held, Equipment Failure, External Failure) by the
operator and the resulting end state (Operating).
131072 Suspending The machine is in the time period between the initiation of
Suspending and the resulting end state (Prepared, Lack,
Tailback, Lack Branch Line or Tailback Branch Line).
262144 Unsuspending The machine is in the time period between the release of
being suspended (Prepared, Lack, Tailback, Lack Branch
Line or Tailback Branch Line) and the resulting end state
(Operating).
524288 Resetting The machine is in the time period between the release after a
stop (Stopped) and the resulting end state (Idle).
1048576 Clearing The machine is in the time period between the release after
an Emergency Stop by the operator and the resulting end
state (Stopped).

NOTE The program Undefined can’t be disabled and includes always the full state
machine.

LWeihStd for SIMATIC - Program and State Management


Entry-ID: 109475571, V1.0, 02/2017 9
1 Library Overview
1.1 Different user scenarios

Control Commands
Table 1-3 Possible control commands
Number Control command
0 Undefined
1 Reset
2 Start
4 Stop
8 Hold
16 Unhold
32 Suspend
64 Unsuspend
128 Abort
256 Clear

Program transitions

Permitted change of the program


Changing the program is only permitted in wait states (state type: Wait, e.g.
Stopped, Idle, Prepared, Aborted, Held). The program change is only possible if
 Siemens AG 2017 All rights reserved

the wait state also exists in the requested program.

State transitions

Examples of change a state


A change is made from the Idle state to the Starting state with the Start command.
If the current state is Operating and you want to change into a Suspended sub
state (Prepared, Lack, Tailback, Lack Branch Line, and Tailback Branch Line) you
must send Suspend command and in addition the respective reason ID (Table 1-4).
If the current state is Starting, Operating or is in one of the Suspended branch
states and you want to change into a Held sub state (Held, Equipment Failure,
External Failure) you must send Hold command and in addition the respective
reason ID (Table 1-4).

Reason IDs
Table 1-4 Possible reason IDs
Number Reason ID
0 No Reason
1 Prepared
2 Lack
4 Tailback
8 Lack Branch Line
16 Tailback Branch Line
32 Held
64 Equipment Failure
128 External Failure

LWeihStd for SIMATIC - Program and State Management


Entry-ID: 109475571, V1.0, 02/2017 10
1 Library Overview
1.2 Hardware and software requirements

1.2 Hardware and software requirements


Requirements for this library
To be able to use the functionality of the library described in this document, the
following hardware and software requirements must be met:

Hardware
Table 1-1 Hardware components
No. Component Article number Alternative
1. CPU 1513-1 PN 6ES7513-1AL00-0AB0 Other S7-1500 CPU with FW V1.8.0
2. Or CPU 1215C 6ES7215-1AG40-0XB0 Other S7-1200 CPU with FW V4.1.1

Software
Table 1-2 Software components
No. Component Article number Quantity
3. Step7 Professional V13 SP1 6ES7822-1..03-.. 1
4. Or Step7 Basic V13 SP1 6ES7822-0..03-.. 1
 Siemens AG 2017 All rights reserved

1.3 Library resources


What will you find in this section?
The following section gives you an overview of the size of the blocks of the
LWeihStd library needed for program and state management in the main and load
memory.

Overall size
The overall size of all blocks used for program and state management of the
LWeihStd library in the main memory is 13 Kbytes and 156 Kbytes in the load
memory.
1
Size of the individual blocks

Table 1-3 Size of blocks


Block Symbol Size in main memory Size in load memory
[Kbytes] [Kbytes]
FB 30450 LWeihStd_ProgramStateManager 11.8 129.0
FC 30450 LWeihStd_ConfigureDisabledPrograms 0.3 8.6
FC 30451 LWeihStd_ConfigureDisabledStates 0.3 6.6
DB 30450 instLWeihStd_ProgramStateManager 1.0 11.4

1
Instance data blocks (prefix instLWeihStd_) are not delivered with the library. They will be
generated automatically with the call of a function block.

LWeihStd for SIMATIC - Program and State Management


Entry-ID: 109475571, V1.0, 02/2017 11
2 Blocks of the Library
2.1 List of the blocks

2 Blocks of the Library


What will you find in this section?
This chapter lists and explains all blocks of the LWeihStd library used for program
and state management. Before that, however, you are informed of the blocks that
are essentially involved in the implementation of the functionality.

2.1 List of the blocks


The following table lists all blocks of the LWeihStd library used for program and
state management.

Table 2-1 Blocks of the library


Block Symbol Classification
FB 30450 LWeihStd_ProgramStateManager In-house development
FC 30450 LWeihStd_ConfigureDisabledPrograms In-house development
FC 30451 LWeihStd_ConfigureDisabledStates In-house development
 Siemens AG 2017 All rights reserved

LWeihStd for SIMATIC - Program and State Management


Entry-ID: 109475571, V1.0, 02/2017 12
2 Blocks of the Library
2.2 Explanation of the blocks

2.2 Explanation of the blocks


The following table explains all blocks of the LWeihStd library used for program
and state management.

2.2.1 LWeihStd_ProgramStateManager (FB 30450)

Figure
Figure 2-1: Block diagram of LWeihStd_ProgramStateManager

LWeihStd_ProgramStateManager

UDInt Program ProgramCurrent UDInt

Bool ProgramChangeRequest ProgramRequested UDInt

UDInt CntrlCmd ProgramChangeInProcess Bool

Bool CmdChangeRequest StateCurrent UDInt

UDInt ReasonID StateRequested UDInt


 Siemens AG 2017 All rights reserved

Bool enableBooleanInterface StateChangeInProcess Bool

Bool ProductionProgramRequest ProductionProgramActive Bool

Bool StartUpProgramRequest StartUpProgramActive Bool

Bool RunDownProgramRequest RunDownProgramActive Bool

Bool CleanProgramRequest CleanProgramActive Bool

Bool ChangeoverProgramRequest ChangeoverProgramActive Bool

Bool MaintenanceProgramRequest MaintenanceProgramActive Bool

Bool BreakProgramRequest BreakProgramActive Bool

Bool UserProgram01Request UserProgram01Active Bool

Bool UserProgram02Request UserProgram02Active Bool

Bool UserProgram03Request UserProgram03Active Bool

Bool UserProgram04Request UserProgram04Active Bool

Bool UserProgram05Request UserProgram05Active Bool

Bool UserProgram06Request UserProgram06Active Bool

Bool UserProgram07Request UserProgram07Active Bool

Bool UserProgram08Request UserProgram08Active Bool

Bool UserProgram09Request UserProgram09Active Bool

LWeihStd for SIMATIC - Program and State Management


Entry-ID: 109475571, V1.0, 02/2017 13
2 Blocks of the Library
2.2 Explanation of the blocks

Bool ResetCmdRequest StoppedStateActive Bool

Bool StartCmdRequest StartingStateActive Bool

Bool StopCmdRequest PreparedStateActive Bool

Bool HoldCmdRequest LackStateActive Bool

Bool UnholdCmdRequest TailbackStateActive Bool

Bool SuspendCmdRequest LackBranchLineStateActive Bool

TailbackBranchLineStateActi
Bool UnsuspendCmdRequest Bool
ve

Bool AbortCmdRequest OperatingStateActive Bool

Bool ClearCmdRequest StoppingStateActive Bool

Bool PreparedReasonID AbortingStateActive Bool

Bool LackReasonID EquipmentFailureStateActive Bool

Bool TailbackReasonID ExternalFailureStateActive Bool


 Siemens AG 2017 All rights reserved

Bool LackBrLineReasonID EmergencyStopStateActive Bool

Bool TailbackBrLineReasonID HoldingStateActive Bool

Bool HeldReasonID HeldStateActive Bool

Bool EquipmentFailureReasonID IdleStateActive Bool

Bool ExternalFailureReasonID UnholdingStateActive Bool

Bool SC SuspendingStateActive Bool

"LWeihStd_typ
eManagerConfi configuration UnsuspendingStateActive Bool
guration"

ResettingStateActive Bool

ClearingStateActive Bool

StatesDisabled UDInt

"LWeihStd_typ
diagnostics eManagerDiag
nostics"

LWeihStd for SIMATIC - Program and State Management


Entry-ID: 109475571, V1.0, 02/2017 14
2 Blocks of the Library
2.2 Explanation of the blocks

Principle of operation
The function block LWeihStd_ProgramStateManager is the main block of ‘Program
and State Management’ part of LWeihStd library. It manages the transitions
between the programs and states according to the Weihenstephan standard.

Note If you want to use the boolean interface particularly in ladder, set input
enableBooleanInterface := TRUE.

Note The number of programs can be changed by changing the constant


LWEIHSTD_MAX_PROGRAMS_UPPER_LIM. In this case the number of the
inputs has to be changed respectively.

Function characteristics
Figure 2-2: Timing diagram of the LWeihStd_ProgramStateManager function block

Start
CntrlCmd Reset
Stop
 Siemens AG 2017 All rights reserved

CmdChangeRequest

SC

Starting
Idle
StateCurrent Resetting
Stopped
Stopping

Operating
StateRequested Idle
Stopped

StateChangeInProcess

1) 2) 3) 4) 5) 6) 7) 8) 9)

1. If CmdChangeRequest is not set, every CntrlCmd is ignored.


2. If CmdChangeRequest is set to TRUE and a valid CntrlCmd (in this case
Reset) is set, the StateChangeInProcess bit is set and the StateRequested (in
this case Idle) value is set (only wait states possible). A valid CntrlCmd is
always necessary if the current state is a wait state.
If the current state is an acting state (here Resetting), a rising edge at input SC
is necessary to leave the state.
If CmdChangeRequest is FALSE, the CntrlCmd (here Start) has already been
set in the acting state (here Resetting) and the wait state (Idle) is reached
through a rising edge at the input SC, the next acting state will not be reached
automatically. For the change in the next wait state (here Operating) is a rising
edge at CmdChangeRequest needed.
3. The StateChangeInProcess bit remains set until StateCurrent gets the same
value as StateRequested. The StateRequested changes from Operating to
Stopped, because in Starting state a valid Stop command was set.

LWeihStd for SIMATIC - Program and State Management


Entry-ID: 109475571, V1.0, 02/2017 15
2 Blocks of the Library
2.2 Explanation of the blocks

4. The SC input is not level sensitive. If the SC input is already set when reaching
the acting state, the Program and State Manager stays in the acting state as
long as a rising edge at SC input is detected.
5. The SC command is not related to the CmdChangeRequest input. Even if
CmdChangeRequest is FALSE, a state change can happen from acting to a
wait state.
6. A new CntrlCmd can also be set if CmdChangeRequest is FALSE. If
CmdChangeRequest changes to TRUE and the control command is valid in
this wait state, the state will be changed.
7. If no valid control command for the current state is written to input, edges at
CmdChangeRequest are ignored. To change from a wait to an acting state,
CmdChangeRequest has to be TRUE and the according CntrlCmd has to be
written to input CntrlCmd.
8. If no acting state is active the rising edge at the SC input is ignored.
9. If an invalid CntrlCmd is written to input CntrlCmd and CmdChangeRequest is
set to TRUE, the control command is ignored and an entry is written to the
diagnostics buffer of the FB.

Input parameters
Table 2-2 LWeihStd_ProgramStateManager input parameters
Parameter Data type Description
 Siemens AG 2017 All rights reserved

Program UDInt Requested program if


enableBooleanInterface = FALSE
(default: LWEIHSTD_PROGRAM_UNDEFINED)
ProgramChangeRequest Bool TRUE: Request program if
enableBooleanInterface = FALSE
(default: FALSE)
CntrlCmd UDInt Requested control command if
enableBooleanInterface = FALSE
(default: LWEIHSTD_CMD_UNDEFINED)
CmdChangeRequest Bool TRUE: Enable change into requested state if
enableBooleanInterface = FALSE
(default: FALSE)
ReasonID UDInt Requested reasonID if
enablBooleanInterface = FALSE
(default: LWEIHSTD_REASONID_NO_REASON)
enableBooleanInterface Bool TRUE: Enable boolean interface
(default: FALSE)
ProductionProgramRequ Bool TRUE: Request change to program Production if
est enableBooleanInterface = TRUE
(default: FALSE)
StartUpProgramRequest Bool TRUE: Request change to program Startup if
enableBooleanInterface = TRUE
(default: FALSE)
RunDownProgramReque Bool TRUE: Request change to program Rundown if
st enableBooleanInterface = TRUE
(default: FALSE)
CleanProgramRequest Bool TRUE: Request change to program Clean if
enableBooleanInterface = TRUE
(default: FALSE)

LWeihStd for SIMATIC - Program and State Management


Entry-ID: 109475571, V1.0, 02/2017 16
2 Blocks of the Library
2.2 Explanation of the blocks

Parameter Data type Description


ChangeoverProgramReq Bool TRUE: Request change to program Changeover if
uest enableBooleanInterface = TRUE
(default: FALSE)
MaintenanceProgramRe Bool TRUE: Request change to program Maintenance if
quest enableBooleanInterface = TRUE
(default: FALSE)
BreakProgramRequest Bool TRUE: Request change to program Break if
enableBooleanInterface = TRUE
(default: FALSE)
UserProgram01Request Bool TRUE: Request change to user-defined program 01 if
enableBooleanInterface = TRUE
(default: FALSE)
UserProgram02Request Bool TRUE: Request change to user-defined program 02 if
enableBooleanInterface = TRUE
(default: FALSE)
UserProgram03Request Bool TRUE: Request change to user-defined program 03 if
enableBooleanInterface = TRUE
(default: FALSE)
UserProgram04Request Bool TRUE: Request change to user-defined program 04 if
enableBooleanInterface = TRUE
(default: FALSE)
 Siemens AG 2017 All rights reserved

UserProgram05Request Bool TRUE: Request change to user-defined program 05 if


enableBooleanInterface = TRUE
(default: FALSE)
UserProgram06Request Bool TRUE: Request change to user-defined program 06 if
enableBooleanInterface = TRUE
(default: FALSE)
UserProgram07Request Bool TRUE: Request change to user-defined program 07 if
enableBooleanInterface = TRUE
(default: FALSE)
UserProgram08Request Bool TRUE: Request change to user-defined program 08 if
enableBooleanInterface = TRUE
(default: FALSE)
UserProgram09Request Bool TRUE: Request change to user-defined program 09 if
enableBooleanInterface = TRUE
(default: FALSE)
ResetCmdRequest Bool TRUE: Request control command Reset if
enableBooleanInterface = TRUE
(default: FALSE)
StartCmdRequest Bool TRUE: Request control command Start if
enableBooleanInterface = TRUE
(default: FALSE)
StopCmdRequest Bool TRUE: Request control command Stop if
enableBooleanInterface = TRUE
(default: FALSE)
HoldCmdRequest Bool TRUE: Request control command Hold if
enableBooleanInterface = TRUE
(default: FALSE)
UnholdCmdRequest Bool TRUE: Request control command Unhold if
enableBooleanInterface = TRUE
(default: FALSE)

LWeihStd for SIMATIC - Program and State Management


Entry-ID: 109475571, V1.0, 02/2017 17
2 Blocks of the Library
2.2 Explanation of the blocks

Parameter Data type Description


SuspendCmdRequest Bool TRUE: Request control command Suspend if
enableBooleanInterface = TRUE
(default: FALSE)
UnsuspendCmdRequest Bool TRUE: Request control command Unsuspend if
enableBooleanInterface = TRUE
(default: FALSE)
AbortCmdRequest Bool TRUE: Request control command Abort if
enableBooleanInterface = TRUE
(default: FALSE)
ClearCmdRequest Bool TRUE: Request control command Clear if
enableBooleanInterface = TRUE
(default: FALSE)
PreparedReasonID Bool TRUE: Request reasonID Prepared if
enableBooleanInterface = TRUE
(default: FALSE)
LackReasonID Bool TRUE: Request reasonID Lack if
enableBooleanInterface = TRUE
(default: FALSE)
TailbackReasonID Bool TRUE: Request reasonID Tailback if
enableBooleanInterface = TRUE
(default: FALSE)
 Siemens AG 2017 All rights reserved

LackBrLineReasonID Bool TRUE: Request reasonID Lack Branch Line if


enableBooleanInterface = TRUE
(default: FALSE)
TailbackBrLineReasonID Bool TRUE: Request reasonID Tailback Branch Line if
enableBooleanInterface = TRUE
(default: FALSE)
HeldReasonID Bool TRUE: Request reasonID Held if
enableBooleanInterface = TRUE
(default: FALSE)
EquipmentFailureReason Bool TRUE: Request reasonID Equipment Failure if
ID enableBooleanInterface = TRUE
(default: FALSE)
ExternalFailureReasonID Bool TRUE: Request reasonID External Failure if
enableBooleanInterface = TRUE
(default: FALSE)
SC Bool State Change from FALSE to TRUE (rising edge)
triggers state complete signal
(default: FALSE)
configuration "LWeihStd_typeMa FB configuration
nagerConfiguration"

Output parameters
Table 2-3 LWeihStd_ProgramStateManager output parameters
Parameter Data type Description
ProgramCurrent UDInt Current program
(default: LWEIHSTD_PROGRAM_UNDEFINED)
ProgramRequested UDInt Requested program
(default: 0)
ProgramChangeInProces Bool Program change in process

LWeihStd for SIMATIC - Program and State Management


Entry-ID: 109475571, V1.0, 02/2017 18
2 Blocks of the Library
2.2 Explanation of the blocks

Parameter Data type Description


s (default: FALSE)
StateCurrent UDInt Current State
(default: LWEIHSTD_STATE_STOPPED)
StateRequested UDInt Requested State
(default: 0)
StateChangeInProcess Bool State change in process
(default: FALSE)
ProductionProgramActive Bool TRUE: Program Production is currently active
(default: FALSE)
StartUpProgramActive Bool TRUE: ProgramStartup program is currently active
(default: FALSE)
RunDownProgramActive Bool TRUE: Program Run Down program is currently
active
(default: FALSE)
CleanProgramActive Bool TRUE: Program Clean program is currently active
(default: FALSE)
ChangeoverProgramActi Bool TRUE: Program Changeover program is currently
ve active
(default: FALSE)
MaintenanceProgramActi Bool TRUE: Program Maintenance program is currently
 Siemens AG 2017 All rights reserved

ve active
(default: FALSE)
BreakProgramActive Bool TRUE: Program Break program is currently active
(default: FALSE)
UserProgram01Active Bool TRUE: User-defined program 01 is currently active
(default: FALSE)
UserProgram02Active Bool TRUE: User-defined program 02 is currently active
(default: FALSE)
UserProgram03Active Bool TRUE: User-defined program 03 is currently active
(default: FALSE)
UserProgram04Active Bool TRUE: User-defined program 04 is currently active
(default: FALSE)
UserProgram05Active Bool TRUE: User-defined program 05 is currently active
(default: FALSE)
UserProgram06Active Bool TRUE: User-defined program 06 is currently active
(default: FALSE)
UserProgram07Active Bool TRUE: User-defined program 07 is currently active
(default: FALSE)
UserProgram08Active Bool TRUE: User-defined program 08 is currently active
(default: FALSE)
UserProgram09Active Bool TRUE: User-defined program 09 is currently active
(default: FALSE)
StoppedStateActive Bool TRUE: State Stopped is currently active
(default: FALSE)
StartingStateActive Bool TRUE: State Starting is currently active
(default: FALSE)
PreparedStateActive Bool TRUE: State Prepared is currently active
(default: FALSE)

LWeihStd for SIMATIC - Program and State Management


Entry-ID: 109475571, V1.0, 02/2017 19
2 Blocks of the Library
2.2 Explanation of the blocks

Parameter Data type Description


LackStateActive Bool TRUE: State Lack is currently active
(default: FALSE)
TailbackStateActive Bool TRUE: State Tailback is currently active
(default: FALSE)
LackBranchLineStateActi Bool TRUE: State Lack Branch Line is currently active
ve (default: FALSE)
TailbackBranchLineState Bool TRUE: State Tailback Branch Line is currently active
Active (default: FALSE)
OperatingStateActive Bool TRUE: State Execute is currently active
(default: FALSE)
StoppingStateActive Bool TRUE: State Stopping is currently active
(default: FALSE)
AbortingStateActive Bool TRUE: State Aborting is currently active(default:
FALSE)
EquipmentFailureStateAc Bool TRUE: State Equipment Failure is currently active
tive (default: FALSE)
ExternalFailureStateActiv Bool TRUE: State External Failure is currently active
e (default: FALSE)
EmergencyStopStateActi Bool TRUE: State Emergency Stop is currently active
 Siemens AG 2017 All rights reserved

ve (default: FALSE)
HoldingStateActive Bool TRUE: State Holding is currently active
(default: FALSE)
HeldStateActive Bool TRUE: State Held is currently active
(default: FALSE)
IdleStateActive Bool TRUE: State Idle is currently active
(default: FALSE)
UnholdingStateActive Bool TRUE: State Unholding is currently active
(default: FALSE)
SuspendingStateActive Bool TRUE: State Suspending is currently active
(default: FALSE)
UnsuspendingStateActiv Bool TRUE: State Unsuspending is currently active
e (default: FALSE)
ResettingStateActive Bool TRUE: State Resetting is currently active
(default: FALSE)
ClearingStateActive Bool TRUE: State Clearing is currently active
(default: FALSE)
StatesDisabled UDInt Disabled states in current program
(default: 0)
diagnostics "LWeihStd_typeMa Diagnostics information of FB
nagerDiagnostics"

LWeihStd for SIMATIC - Program and State Management


Entry-ID: 109475571, V1.0, 02/2017 20
2 Blocks of the Library
2.2 Explanation of the blocks

Status and error displays


Table 2-4 LWeihStd_ProgramStateManager diagnostics messages
Status Meaning Remedy / notes
16#00 MSG_NO_MESSAGE Initial value
16#01 MSG_PROGRAM_CHANGED_SUCCESSFULLY Program changed successfully
16#02 MSG_STATE_CHANGED_SUCCESSFULLY State changed successfully
16#03 MSG_PROGRAM_ALREADY_ACTIVE Requested program already active
16#80 MSG_PROGRAM_NOT_DEFINED Program not defined
16#81 MSG_CMD_NOT_DEFINED Control command not defined
16#82 MSG_REQ_PROGRAM_NOT_CONFIGURED Requested program not configured
16#83 MSG_PROGRAM_TRANSITION_NOT_ALLOWED Program transition not allowed
16#84 MSG_CMD_NOT_ALLOWED Control command in this state not
allowed
16#85 MSG_SC_NOT_ALLOWED SC in this state not allowed
16#86 MSG_STATE_CONFIG_FORCED State configuration forced to
Weihenstephan standard (corrected
configuration -> FB output
DisabledStates)
 Siemens AG 2017 All rights reserved

LWeihStd for SIMATIC - Program and State Management


Entry-ID: 109475571, V1.0, 02/2017 21
2 Blocks of the Library
2.2 Explanation of the blocks

2.2.2 LWeihStd_ConfigureDisabledPrograms (FC 30450)

Figure
Figure 2-3: Block diagram of LWeihStd_ConfigureDisabledPrograms

LWeihStd_ConfigureDisabledPrograms

Array[0.."LWEIHSTD_MAX_
Bool ProductionProgramDisable disabledPrograms PROGRAMS_UPPER_LIM"]
of Bool

Bool StartUpProgramDisable

Bool RunDownProgramDisable

Bool CleanProgramDisable

Bool ChangeoverProgramDisable

Bool MaintenanceProgramDisable

Bool BreakProgramDisable

Bool UserProgram01Disable
 Siemens AG 2017 All rights reserved

Bool UserProgram02Disable

Bool UserProgram03Disable

Bool UserProgram04Disable

Bool UserProgram05Disable

Bool UserProgram06Disable

Bool UserProgram07Disable

Bool UserProgram08Disable

Bool UserProgram09Disable

Principle of operation
This function allows the user to set the program configuration for the FB
LWeihStd_ProgramStateManager easily. Of course it is also possible to set the
program configuration directly in the FB LWeihStd_ProgramStateManager
configuration.
With the function the user has to set the associated inputs for the different
programs to “TRUE”, e.g. “MaintenanceProgramDisable := TRUE” for disabling the
program Maintenance.
To write the program configuration from the function output to the according
“Program and State Manager”, the output disabledPrograms has to be connected
to the configuration of the corresponding FB LWeihStd_ProgramStateManager.

LWeihStd for SIMATIC - Program and State Management


Entry-ID: 109475571, V1.0, 02/2017 22
2 Blocks of the Library
2.2 Explanation of the blocks

NOTE The number of programs can be changed by changing the constant


LWEIHSTD_MAX_PROGRAMS_UPPER_LIM. In this case the number of the
inputs has to be changed respectively.

Input parameters
Table 2-5 LWeihStd_ConfigureDisabledPrograms input parameters
Parameter Data type Description
ProductionProgramDisable Bool TRUE: Disable program Production
StartUpProgramDisable Bool TRUE: Disable program Start Up
RunDownProgramDisable Bool TRUE: Disable program Run Down
CleanProgramDisable Bool TRUE: Disable program Clean
ChangeoverProgramDisable Bool TRUE: Disable program Changeover
MaintenanceProgramDisable Bool TRUE: Disable program Maintenance
BreakProgramDisable Bool TRUE: Disable program Break
UserProgram01Disable Bool TRUE: Disable user-defined program 01
UserProgram02Disable Bool TRUE: Disable user-defined program 02
UserProgram03Disable Bool TRUE: Disable user-defined program 03
 Siemens AG 2017 All rights reserved

UserProgram04Disable Bool TRUE: Disable user-defined program 04


UserProgram05Disable Bool TRUE: Disable user-defined program 05
UserProgram06Disable Bool TRUE: Disable user-defined program 06
UserProgram07Disable Bool TRUE: Disable user-defined program 07
UserProgram08Disable Bool TRUE: Disable user-defined program 08
UserProgram09Disable Bool TRUE: Disable user-defined program 09

Output parameters
Table 2-6 LWeihStd_ConfigureDisabledPrograms output parameters
Parameter Data type Description
disabledPrograms Array[0.."LWEIHSTD_MAX_PRO Disabled program configuration
GRAMS_UPPER_LIM"] of Bool Index meaning see Table 1-1
Description of possible programs

Example: Program Changeover


Value 16 means the 5th bit is set.
Internally the ENCO instruction is used
to evaluate the bit position:
ENCO("LWEIHSTD_PROGRAM_CHA
NGEOVER"). That means program
Changeover can be configured using
index 5 in array disabledPrograms.

LWeihStd for SIMATIC - Program and State Management


Entry-ID: 109475571, V1.0, 02/2017 23
2 Blocks of the Library
2.2 Explanation of the blocks

2.2.3 LWeihStd_ConfigureDisabledStates (FC 30451)

Figure
Figure 2-4: Block diagram of LWeihStd_ConfigureDisabledStates

LWeihStd_ConfigureDisabledStates

Bool PreparedDisable disabledStates UDInt

Bool LackDisable

Bool TailbackDisable

Bool LackBranchLineDisable

Bool TailbackBranchLineDisable

Bool EquipmentFailureDisable

Bool ExternalFailureDisable

Bool HoldingDisable

Bool HeldDisable
 Siemens AG 2017 All rights reserved

Bool UnholdingDisable

Bool SuspendingDisable

Bool UnsuspendingDisable

Principle of operation
This function allows the user to set the state configuration for every program in
LWeihStd_ProgramStateManager easily. Of course it is also possible to set the
state configurations directly in the FB LWeihStd_ProgramStateManager
configuration.
With the function the user has to set the associated inputs for the different states to
“TRUE”, e.g. “LackDisable := TRUE” for disabling the state Lack.
The function generates a double integer value which represents the state
configuration for one program. This value is bit coded and means that every bit
represents a switch where states can be dis- or enabled for a program, e.g.
disabling the state Held (value 16384) the bit number 14 has to be set to “TRUE”.
As can be seen in the example the state numbers according to the Weihenstephan
standard also define the bit numbers in the double integer value. See Table 1-2
Description of possible states
To write the state configuration from the function output to the according “Program
and State Manager”, the output disabledStates has to be connected to the
configuration of the corresponding FB LWeihStd_ProgramStateManager.

LWeihStd for SIMATIC - Program and State Management


Entry-ID: 109475571, V1.0, 02/2017 24
2 Blocks of the Library
2.2 Explanation of the blocks

NOTE According to the Weihenstephan standard some states are mandatory and
cannot be disabled. If they are nevertheless disabled the “Program and State
Manager” will enable these states automatically and provides the corrected
configuration as a double integer value at output StatesDisabled. The same can
happen to states that are declared as initial states.

Input parameters
Table 2-7 LWeihStd_ConfigureDisabledStates input parameters
Parameter Data type Description
PreparedDisable Bool TRUE: Disable State Prepared
LackDisable Bool TRUE: Disable State Lack
TailbackDisable Bool TRUE: Disable State Tailback
LackBranchLineDisable Bool TRUE: Disable State Lack Branch Line
TailbackBranchLineDisable Bool TRUE: Disable State Tailback Branch Line
EquipmentFailureDisable Bool TRUE: Disable State Equipment Failure
ExternalFailureDisable Bool TRUE: Disable State External Failure
HoldingDisable Bool TRUE: Disable State Holding
HeldDisable Bool TRUE: Disable State Held
 Siemens AG 2017 All rights reserved

UnholdingDisable Bool TRUE: Disable State Unholding


SuspendingDisable Bool TRUE: Disable State Suspending
UnsuspendingDisable Bool TRUE: Disable State Unsuspending

Output parameters
Table 2-8 LWeihStd_ConfigureDisabledStates output parameters
Parameter Data type Description
disabledStates UDInt Disabled states configuration for one program

LWeihStd for SIMATIC - Program and State Management


Entry-ID: 109475571, V1.0, 02/2017 25
2 Blocks of the Library
2.2 Explanation of the blocks

2.2.4 PLC data types

LWeihStd_typeManagerConfiguration
This type contains parameter to set the FB configuration.
The parameter InitialProgram is the program with this the FB starts. If there is no
valid program configured the default value 2 (program Start Up) is set automatically
by the ProgramStateManager FB.
The parameter initialHeldSubstate is the default substate, which will be reached if
no valid reason ID is set and hold command is sent.
The parameter initialSuspendSubstate is the default substate, which will be
reached if no valid reason ID is set and suspend command is sent.

Note The initial held substate is automatically available in all programs where at least
one state of the held tree is configured. Parts of the held tree are the states
External Failure, Equipment Failure, Held, Holding and Unholding.
If no valid value for initial held substate is set, the Held substate is automatically
chosen as initial held substate internally.

Note The initial suspended substate is automatically available in all programs where at
 Siemens AG 2017 All rights reserved

least one state of the suspended tree is configured. Parts of the suspended tree
are the states Lack, Tailback, Lack Branch Line, Tailback Branch Line, Prepared,
Suspending and Unsuspending.
If no valid value for initial suspended substate is set, the Prepared substate is
automatically chosen as initial suspended substate internally.

LWeihStd for SIMATIC - Program and State Management


Entry-ID: 109475571, V1.0, 02/2017 26
2 Blocks of the Library
2.2 Explanation of the blocks

Table 2-9: LWeihStd_typeManagerConfiguration


Parameter Data type Description
initialProgram UDInt Start program when FB is enabled:
1=Production, 2=Start Up, 4=RunDown,
8=Clean, 16=Changeover, 32=Maintenance,
64=Break, 128=User Program 01, ...,
32768=User Program 09
(default: LWEIHSTD_PROGRAM_STARTUP)
initialSuspendedSubstate UDInt Suspended substate when no ReasonID is set:
4=Prepared, 8=Lack, 16=Tailback, 32=Lack Br
Line, 64=Tailback Br Line
(default: LWEIHSTD_STATE_PREPARED)
initialHeldSubstate UDInt Held Substate when no ReasonID is set:
1024=Equipment Failure, 2048=External
Failure, 16384 = Held
(default: LWEIHSTD_STATE_HELD)
disabledPrograms Array[0.."LWEIHSTD_MAX TRUE: Disable Program xx
_PROGRAMS_UPPER_LI (default: FALSE)
M"] of Bool
Example: Program Changeover
Value 16 means the 5th bit is set. Internally the
ENCO instruction is used to evaluate the bit
position:
ENCO("LWEIHSTD_PROGRAM_CHANGEOV
 Siemens AG 2017 All rights reserved

ER"). That means program Changeover can


be configured using index 5 in array
disabledPrograms.
disabledStatesInPrograms Array[0.."LWEIHSTD_MAX TRUE: Disable states in program (bit number =
_PROGRAMS_UPPER_LI state number)
M"] of UDInt (default: 0)
Example:
State 16384=Held is configured in bit 14.

LWeihStd for SIMATIC - Program and State Management


Entry-ID: 109475571, V1.0, 02/2017 27
2 Blocks of the Library
2.2 Explanation of the blocks

LWeihStd_typeManagerDiagnostics
This type contains diagnostics information for the ProgramStateManager FB.

Table 2-10 LWeihStd_typeManagerDiagnostics


Parameter Data type Description
bufferIndex Int Index of actual buffer entry
(default: 0)
buffer Array[0.."LWEIHSTD_DIAG_ Diagnostics information Buffer
BUFFER_UPPER_LIM"] of
"LWeihStd_typeManagerDia
gnosticEntry"

LWeihStd_typeManagerDiagnosticEntry
An entry in the diagnostic buffer will be made when a message occurs.

Table 2-11 LWeihStd_typeManagerDiagnosticEntry


Parameter Data type Description
Timestamp DTL Timestamp for this entry
 Siemens AG 2017 All rights reserved

(default: DTL#1970-01-01-00:00:00)
ProgramCurrent UDInt Current Program
(default: 0)
StateCurrent UDInt Current state
(default: 0)
Program UDInt Requested Program
(default: 0)
CntrlCmd UDInt Requested control command
(default: 0)
ReasonID UDInt Requested reason ID
(default: 0)
SC Bool State complete signal
(default: FALSE)
Message Byte Message for this entry
(default: 16#00)

LWeihStd for SIMATIC - Program and State Management


Entry-ID: 109475571, V1.0, 02/2017 28
2 Blocks of the Library
2.2 Explanation of the blocks

2.2.5 PLC tags

The PLC tag table LWeihStd_Manager includes user constants for programs,
states, control commands and array boundaries.

Programs
Table 2-12 Constants for programs
Value Constant Meaning
0 LWEIHSTD_PROGRAM_UNDEFINED LWeihStd program Undefined
1 LWEIHSTD_PROGRAM_PRODUCTION LWeihStd program Production
2 LWEIHSTD_PROGRAM_STARTUP LWeihStd program Startup (OMAC
PackMLV30 user-defined mode 01)
4 LWEIHSTD_PROGRAM_RUNDOWN LWeihStd program Rundown (OMAC
PackMLV30 user-defined mode 02)
8 LWEIHSTD_PROGRAM_CLEAN LWeihStd program Clean (OMAC PackMLV30
user-defined mode 03)
16 LWEIHSTD_PROGRAM_CHANGEOVE LWeihStd program Changeover (OMAC
R PackMLV30 user-defined mode 04)
32 LWEIHSTD_PROGRAM_MAINTENANC LWeihStd program Maintenance
E
64 LWEIHSTD_PROGRAM_BREAK LWeihStd program Break (OMAC PackMLV30
 Siemens AG 2017 All rights reserved

user-defined mode 05)


128 LWEIHSTD_PROGRAM_USER_01 LWeihStd user-defined program 01 (OMAC
PackMLV30 unit Mode Manual)
256 LWEIHSTD_PROGRAM_USER_02 LWeihStd user-defined program 02 (OMAC
PackMLV30 user-defined mode 06)
512 LWEIHSTD_PROGRAM_USER_03 LWeihStd user-defined program 03 (OMAC
PackMLV30 user-defined mode 07)
1024 LWEIHSTD_PROGRAM_USER_04 LWeihStd user-defined program 04 (OMAC
PackMLV30 user-defined mode 08)
2048 LWEIHSTD_PROGRAM_USER_05 LWeihStd user-defined program 05 (OMAC
PackMLV30 user-defined mode 09)
4096 LWEIHSTD_PROGRAM_USER_06 LWeihStd user-defined program 06 (OMAC
PackMLV30 user-defined mode 10)
8192 LWEIHSTD_PROGRAM_USER_07 LWeihStd user-defined program 07 (OMAC
PackMLV30 user-defined mode 11)
16384 LWEIHSTD_PROGRAM_USER_08 LWeihStd user-defined program 08 (OMAC
PackMLV30 user-defined mode 12)
32768 LWEIHSTD_PROGRAM_USER_09 LWeihStd user-defined program 09 (OMAC
PackMLV30 user-defined mode 13)

LWeihStd for SIMATIC - Program and State Management


Entry-ID: 109475571, V1.0, 02/2017 29
2 Blocks of the Library
2.2 Explanation of the blocks

States
Table 2-13 Constants for states
Value Constant Meaning
0 LWEIHSTD_STATE_UNDEFINED LWeihStd state Undefined
1 LWEIHSTD_STATE_STOPPED LWeihStd state Stopped
2 LWEIHSTD_STATE_STARTING LWeihStd state Starting
4 LWEIHSTD_STATE_PREPARED LWeihStd state Prepared (OMAC PackMLV30
state Suspended + Alarm ID)
8 LWEIHSTD_STATE_LACK LWeihStd state Lack (OMAC PackMLV30
state Suspended + Alarm ID)
16 LWEIHSTD_STATE_TAILBACK LWeihStd state Tailback (OMAC PackMLV30
state Suspended + Alarm ID)
32 LWEIHSTD_STATE_LACK_BRANCH_LI LWeihStd state Lack branch line (OMAC
NE PackMLV30 state Suspended + Alarm ID)
64 LWEIHSTD_STATE_TAILBACK_BRANC LWeihStd state Tailback branch line (OMAC
H_LINE PackMLV30 state Suspended + Alarm ID)
128 LWEIHSTD_STATE_OPERATING LWeihStd state Operating (OMAC
PackMLV30 state Execute)
256 LWEIHSTD_STATE_STOPPING LWeihStd state Stopping
512 LWEIHSTD_STATE_ABORTING LWeihStd state Aborting
 Siemens AG 2017 All rights reserved

1024 LWEIHSTD_STATE_EQUIPMENT_FAIL LWeihStd state Equipment failure (OMAC


URE PackMLV30 state Held + Alarm ID)
2048 LWEIHSTD_STATE_EXTERNAL_FAILU LWeihStd state External failure (OMAC
RE PackMLV30 state Held + Alarm ID)
4096 LWEIHSTD_STATE_EMERGENCY_ST LWeihStd state Emergency stop (OMAC
OP PackMLV30 state Aborted)
8192 LWEIHSTD_STATE_HOLDING LWeihStd state Holding
16384 LWEIHSTD_STATE_HELD LWeihStd state Held (OMAC PackMLV30
state Held + Alarm ID)
32768 LWEIHSTD_STATE_IDLE LWeihStd state Idle
65536 LWEIHSTD_STATE_UNHOLDING LWeihStd state Unholding
131072 LWEIHSTD_STATE_SUSPENDING LWeihStd state Suspending
262144 LWEIHSTD_STATE_UNSUSPENDING LWeihStd state Unsuspending
524288 LWEIHSTD_STATE_RESETTING LWeihStd state Resetting
1048576 LWEIHSTD_STATE_CLEARING LWeihStd state Clearing

LWeihStd for SIMATIC - Program and State Management


Entry-ID: 109475571, V1.0, 02/2017 30
2 Blocks of the Library
2.2 Explanation of the blocks

Control commands
Table 2-14 Constants for control commands
Value Constant Meaning
0 LWEIHSTD_CMD_UNDEFINED LWeihStd control command Undefined
1 LWEIHSTD_CMD_RESET LWeihStd control command Reset
2 LWEIHSTD_CMD_START LWeihStd control command Start
4 LWEIHSTD_CMD_STOP LWeihStd control command Stop
8 LWEIHSTD_CMD_HOLD LWeihStd control command Hold
16 LWEIHSTD_CMD_UNHOLD LWeihStd control command Unhold
32 LWEIHSTD_CMD_SUSPEND LWeihStd control command Suspend
64 LWEIHSTD_CMD_UNSUSPEND LWeihStd control command Unsuspend
128 LWEIHSTD_CMD_ABORT LWeihStd control command Abort
256 LWEIHSTD_CMD_CLEAR LWeihStd control command Clear

Array boundaries
Table 2-15 Constants for Array boundaries
Value Constant Meaning
14 LWEIHSTD_DIAG_BUFFER_UPPER_LI Diagnostic buffer array upper boundary (0-
M based)
 Siemens AG 2017 All rights reserved

15 LWEIHSTD_MAX_PROGRAMS_UPPER (Maximum number of programs - 1) ->


_LIM Array[0..LWEIHSTD_MAX_PROGRAMS_UP
PER_LIM]

LWeihStd for SIMATIC - Program and State Management


Entry-ID: 109475571, V1.0, 02/2017 31
3 Working with the Library
3.1 Integrating the library into STEP 7

3 Working with the Library


What will you find in this section?
This chapter consists of instructions for integrating the LWeihStd
library into your STEP 7 project and instructions for using the library blocks.

3.1 Integrating the library into STEP 7


The table below lists the steps for integrating the LWeihStd
library into your STEP 7 project. Subsequently, you can use the blocks of the
LWeihStd library.

Note The following section assumes that a STEP 7 project exists.

Table 3-1: Integrating the library into STEP 7


No. Action
1. Extract the library LWeihStd_V1_x_x.zip to a local folder.
 Siemens AG 2017 All rights reserved

2. In TIA Portal select “Options” -> “Global libraries” -> “Open library…”
3. Browse to the file LWeihStd.al13.
It can be found in the subfolder LWeihStd of the extracted zip file.
4. Open the global library in read-only mode.
5. The LWeihStd library is now available in the task card “Global libraries”

LWeihStd for SIMATIC - Program and State Management


Entry-ID: 109475571, V1.0, 02/2017 32
3 Working with the Library
3.2 Integrating the library blocks into STEP 7

3.2 Integrating the library blocks into STEP 7


The table below lists the steps for integrating the blocks of the LWeihStd
library into your STEP 7 program.

Figure 3-1: Integrating the library blocks into STEP 7


 Siemens AG 2017 All rights reserved

Table 3-2: Integrating the library blocks into STEP 7


No. Action Note
1. Copy the LWeihStd_ProgramStateManager FB in subfolder Copy program blocks
“01_ProgramStateManagement -> S7-1200/S7-1500 ->
LWeihStd_Blocks” with Drag & Drop into the “Program blocks” in the
PLC.
Alternatively copy the whole folder LWeihStd_Blocks with Drag & Drop
into the “Program blocks” in the PLC. In this case also additional and
optional blocks of LWeihStd library are available in the user program
(e.g. LWeihStd_ConfigureDisabledPrograms,
LWeihStd_ConfigureDisabledStates).
2. Copy the folder LWeihStd_Tags in subfolder Copy PLC tags
“01_ProgramStateManagemnt -> S7-1200/S7-1500” with Drag & Drop
into the “PLC tags” in the PLC.
3. Copy the folder LWeihStd_Types in subfolder Copy PLC data types
“01_ProgramStateManagement -> S7-1200/S7-1500” with Drag & Drop
into the “PLC data types” in the PLC.
4. Now the blocks can be configured and called in the user program.

LWeihStd for SIMATIC - Program and State Management


Entry-ID: 109475571, V1.0, 02/2017 33
4 Notes and Support

4 Notes and Support


What will you find in this section?
This chapter provides further support in handling the described LWeihStd library.
 Siemens AG 2017 All rights reserved

LWeihStd for SIMATIC - Program and State Management


Entry-ID: 109475571, V1.0, 02/2017 34
5 Related literature

5 Related literature
Table 5-1
Topic Title / Link
\1\ Siemens Industry http://support.automation.siemens.com
Online Support
\2\ Download page of https://support.industry.siemens.com/cs/ww/en/view/1094755
this entry 71
\3\ Weihenstephan http://www.weihenstephaner-standards.de/index.php?id=2&L=1
Standards
\4\ OMAC website http://www.omac.org

6 Contact
Siemens AG
Digital Factory Division
Factory Automation
 Siemens AG 2017 All rights reserved

Production Machines
DF FA PMA APC
Frauenauracher Str. 80
91056 Erlangen, Germany
mailto: tech.team.motioncontrol@siemens.com

7 History
Table 7-1
Version Date Modifications
V1.0 01/2016 First version
V1.0 02/2017 Adapted to LWeihStd V1.0.3

LWeihStd for SIMATIC - Program and State Management


Entry-ID: 109475571, V1.0, 02/2017 35

You might also like