FB_ModuleController - General Information

Overview

Type:

Function block

Available as of:

V1.0.4.0

Inherits from:

-

Implemented:

-

Task

This function block assigns commands to modules.

Description

The Controller module is switched on via the i_xEnable input. It indicates that it is switched on via the q_xActive output . A series of pointer checks are carried out during initialization. If an error is detected, the POU does not report q_xActive, but rather enters an exception state. After the cause of the exception has been resolved, the POU must be re-initialized (disable the POU and enable it again). If the module controller indicates an exception at the q_etDiag output after initialization, this can be acknowledged via the i_xDiagQuit input. Errors that arise during the initialization phase cannot be acknowledged. The corresponding exception message is provided with i_udiModuleId and i_sModulename and entered into the iq_stExceptionList. If an exception occurs, the q_etDiag, q_etDiagExt and q_sMsg output variables are also provided with the exception number and the exception text. In all other cases, these variables indicate the internal state of the ModuleController.

The module controller can send commands to submodules via the i_pstSubModulesItf input variable. Whether the number named is comprehensible is determined based on the size of the complete i_udiSizeOfSubModulesInterface structure and the number of individual i_udiNumberOfSubModules elements during the initialization phase.

The list of command tables is transferred to the module controller via the i_pstListofCmdTables input variable. During the initialization phase, a plausibility verification takes place via the i_udiSizeOfListOfCmdTables and i_udiNumberOfCmdTables variables. The ModuleController attempts to detect typical errors made when inserting a module. It checks, for example, whether the module is called. If a command is now sent to the module controller at the iq_diCmd input, the module controller checks if this command is contained in the list. If the command is contained in the list, the associated command table is processed. The user can see at the output that a command is being processed when q_xCmdActive jumps to TRUE and q_xCmdDone to FALSE. The module controller also indicates the command that is active via q_diCmdActive. The step currently active is indicated via q_diActiveStep; q_udiActiveSubModule indicates which submodule is currently receiving a command. The address of the current table to be processed or the last table processed can be found in the q_pstActCMDTable variable. The number of steps within q_pstActCmdTable is contained in q_diNumberOfCMDSteps. After the command table has been successfully processed, the iq_diCmd input variable is reset to zero. If the command is not found, the module controller reports an exception and returns the negated command. The command is also returned negated if a lower-level module was unable to execute the command sent and has sent a negative command itself. This mechanism is the cancel criterion of the command. After this detected error has been acknowledged, the command is reset to zero. If a value for the command is also contained in iq_diStartStep, the command table begins at this step and does not start at the beginning.

Interface

Input

Data type

Description

i_xEnable

BOOL

A rising edge FALSE -> TRUE activates the POU, a falling edge TRUE -> FALSE deactivates the POU.

A deactivated POU does not execute any actions.

i_xDiagQuit

BOOL

A rising edge FALSE -> TRUE acknowledges pending exceptions of the POUs.

Exceptions occurring during initialization can only be acknowledged by disabling the POUs.

i_udiModuleId

UDINT

The number of the module according to its position in the machine tree.

i_sModuleName

STRING[80]

The module name.

i_pstSubModulesItf

POINTER TO ST_StandardModuleInterface

Address of the array in which the default interfaces of the submodules are managed, which subordinate under this equipment module.

i_udiSizeOfSubModulesItf

UDINT

The size of the array at the i_pstSubModulesItf input.

i_udiNumberOfSubModules

UDINT

The number of elements of the array at the i_pstSubModulesItf input.

i_pstListOfCmdTables

POINTER TO ST_CmdTable

The address of the array in which the command table of the equipment module is managed.

i_udiSizeOfListOfCmdTables

UDINT

The size of the array at the i_pstListOfCmdTables input.

i_udiNumberOfCmdTables

UDINT

The number of elements of the array at the i_pstListOfCmdTables input.

i_pudiSubModuleGroups

POINTER TO UDINT

The address of the array in which the groups of submodules of the equipment module are managed.

i_udiSizeOfSubModuleGroups

UDINT

The size of the array at the i_pudiSubModuleGroups input.

i_udiNumberOfGroups

UDINT

The number of elements of the array at the i_pudiSubModuleGroups input.

i_udiNumberOfGroupMembers

UDINT

Maximum number of elements for modules of the array which manages a group.

i_udiReactionOffset

UDINT

Offset for the reaction of thrown errors. Switch with iq_stExt.udiReactionOffset or in the SR_MainMachine with stMachineInterface.iq_stExt.udiReactionOffset

i_xCancelTable

BOOL

Makes it possible to cancel a running table. If the input is TRUE, the ModuleController immediately stops processing the table. It does not send any new commands to submodules. However, any commands just sent to submodules are further processed. The module controller reports the command applied to it (in iq_diCmd) as failed by setting it to -iq_diCmd. In this case, no diagnostic message is entered into the error list. If a new command (iq_diCmd) or a StartStep (iq_diStartStep) is received while the input is TRUE, the command is rejected. Immediately reset the input to FALSE after the table was cancelled.

Output

Data type

Description

q_xActive

BOOL

TRUE: The POU is active and has to be executed further.

FALSE: The POU is inactive.

q_xReady

BOOL

TRUE: The POU is ready to operate and accepts user commands.

FALSE: the POU is not ready to operate and does not accept user commands.

q_etDiag

GD.ET_Diag

General, library-independent statement on the diagnostic.

A value not equal to ET_Diag.Ok corresponds to an error message.

q_etDiagExt

ET_DiagExt

POU-specific output on the diagnostic.

q_etDiag = ET_Diag.Ok -> Status message

q_etDiag <> ET_Diag.Ok -> Error message

q_sMsg

STRING[80]

Event-triggered message which gives more detailed information on the diagnostic state.

q_xCmdActive

BOOL

TRUE: The module executes a command.

q_xCmdDone

BOOL

TRUE: The module has successfully executed the command.

q_diActiveStep

DINT

The active step of the command table.

q_diCmdActive

DINT

The number of the command which is currently being executed or which was executed last.

q_udiActiveSubModule

UDINT

The number of the first active submodule which is subordinate to this equipment module.

The numbering starts with 1 and ends with the number of the submodules which are subordinate to this equipment module. The number does not match the module ID of the submodule.

q_xWaitForStartStep

BOOL

Waiting for the start signal.

Input/Output

Data type

Description

iq_diStartStep

DINT

Step as of which the command table shall be processed.

iq_diCmd

DINT

Transfer of the command to the module.

iq_stExceptionList

ST_ExceptionList

The global exception list.

iq_stLogDataList

ST_LogDataList

The global logging list.

Diagnostic Messages

q_etDiag

q_etDiagExt

Enumeration value

Description

OK

DeactivatingSubModules

38

The submodules are being disabled.

OK

Disabled

22

Diagnostic message disabled

OK

ExecuteStep

40

Step is being executed.

OK

Initializing

37

Initialization

OK

WaitAtNegativeStep

41

Waiting at a negative step.

OK

WaitCmdsDone

43

Waiting until commands are processed.

OK

WaitForCmd

39

Waiting for a command.

ExecutionAborted

CmdImpossibleState

142

Command is not possible in this state.

ExecutionAborted

CmdTimeout

108

A command was not processed within the defined time.

ExecutionAborted

CmdUnknown

57

Indeterminable command.

ExecutionAborted

MissingModuleCall

94

A call-up of a module is unavailable.

InputParameterInvalid

CmdOfListOfCmdTablesDuplicate

101

A command of the command table exists twice.

InputParameterInvalid

CmdOfListOfCmdTablesZero

100

A command of the command table is empty/zero.

InputParameterInvalid

CmdTableDublicatePointer

102

A pointer onto a command table exists twice.

InputParameterInvalid

CmdTableNoLastStep

107

The command table has no completion/last step.

InputParameterInvalid

GroupNumberInvalid

109

The number of a group is invalid.

InputParameterInvalid

ListOfCmdTablesInvalid

95

The list of the command table is invalid.

InputParameterInvalid

ModuleIdInvalid

67

The module ID is invalid.

InputParameterInvalid

NumberOfCmdStepsRange

98

The number of steps of a command is outside the valid range.

InputParameterInvalid

NumberOfCmdTablesRange

34

The number of command tables is outside the valid range.

InputParameterInvalid

NumberOfSubModulesRange

66

The number of submodules is outside the specified range

InputParameterInvalid

PointerCmdTableInvalid

36

The pointer onto CmdTable is invalid.

InputParameterInvalid

PointerListOfCmdTablesInvalid

33

The pointer onto ListOfCmdTables is invalid.

InputParameterInvalid

PointerSubModuleGroupsInvalid

104

The pointer onto SubModuleGroups is invalid.

InputParameterInvalid

PointerSubModulesItfInvalid

97

The pointer SubModulesItf is invalid

InputParameterInvalid

ReactionOffsetRange

42

ReactionOffset is outside the valid range.

InputParameterInvalid

SizeOfListOfCmdTablesInvalid

99

Invalid size of the ListOfCmdTables.

InputParameterInvalid

SizeOfSubModuleGroupsInvalid

105

Invalid size of the SubModuleGroups.

InputParameterInvalid

SizeOfSubModulesItfInvalid

96

The size of the submodule interface is invalid

InputParameterInvalid

StartStepInvalid

106

Invalid start step.

InputParameterInvalid

SubModuleItfNotInitialized

103

An interface of a submodule has not yet been initialized.

CmdImpossibleState

Enumeration name:

CmdImpossibleState

Enumeration value:

142

Description:

Command is not possible in this state.

Issue

Cause

Solution

-

The module controller was yet completely initialized when it was sent the first command.

The module controller is already being disabled when it was sent the last command.

Commands may only be sent to the module controller if it reports with q_xReady = TRUE that it is ready to receive commands.

CmdOfListOfCmdTablesDuplicate

Enumeration name:

CmdOfListOfCmdTablesDuplicate

Enumeration value:

101

Description:

A command of the command table exists twice.

Issue

Cause

Solution

-

A command table from the list of i_pstListOfCmdTables is entered twice.

Make sure that each command table is unambiguously activated by a command.

Verify the use of the FC_NextCmdTable function when initializing the command tables.

CmdOfListOfCmdTablesZero

Enumeration name:

CmdOfListOfCmdTablesZero

Enumeration value:

100

Description:

A command of the command table is empty/zero.

Issue

Cause

Solution

-

A command table from the list of i_pstListOfCmdTables shall be activated by the command 0.

Verify the use of the FC_NextCmdTable function when initializing the command tables.

CmdTableDublicatePointer

Enumeration name:

CmdTableDublicatePointer

Enumeration value:

102

Description:

A pointer onto a command table exists twice.

Issue

Cause

Solution

-

In the list of the command tables at the i_pstListofCMDTables input, the pointers of two different command tables refer to the same command table.

Verify the initialization of the command tables. Use the FC_FirstCmdTable and FC_NextCmdTable functions to initialize the command tables.

CmdTableNoLastStep

Enumeration name:

CmdTableNoLastStep

Enumeration value:

107

Description:

The command table has no completion/last step.

Issue

Cause

Solution

-

The command table has no completion/last step

Make sure that all command tables are completed with the FC_LastStep.

CmdTimeout

Enumeration name:

CmdTimeout

Enumeration value:

108

Description:

A command was not processed within the defined time.

Issue

Cause

Solution

-

The execution of a command took longer than specified in timTimeOu of ST_Cmd.

Increase the maximum execution time of the command by choosing a greater value for timTimeOut in the structure of the ST_Cmd command.

Search for the reasons of a long run time when executing the command.

CmdUnknown

Enumeration name:

CmdUnknown

Enumeration value:

57

Description:

Indeterminable command.

Issue

Cause

Solution

-

No command table is assigned to the command.

Verify whether the command for a command table was transferred to the module controller at the iq_diCmd input.

Verify the initialization of the command tables and make sure that the correct command is assigned to the command tables.

DeactivatingSubModules

Enumeration name:

DeactivatingSubModules

Enumeration value:

38

Description:

The submodules are being disabled.

The submodules are disabled.

Disabled

Enumeration name:

Disabled

Enumeration value:

22

Description:

Diagnostic message disabled

The function block is deactivated, it executes no actions whatsoever. i_xEnable and q_xActive have the value FALSE.

ExecuteStep

Enumeration name:

ExecuteStep

Enumeration value:

40

Description:

Step is being executed.

The pending process step is being executed

GroupNumberInvalid

Enumeration name:

GroupNumberInvalid

Enumeration value:

109

Description:

The number of a group is invalid.

Issue

Cause

Solution

-

At udiModuleName of the ST_Cmd command a group number (udiModuleName - Gc_udiGroupOffset) smaller than 1 or greater than the number of the defined groups was applied.

Verify the definition of the group.

Verify the command definition.

-

At udiModuleName of the ST_Cmd command a group number (udiModuleName - Gc_udiGroupOffset) was applied. However, no group was defined.

Make sure that no more than Gc_udiGroupOffset submodules are applied under the equipment module.

Verify the command definition.

Initializing

Enumeration name:

Initializing

Enumeration value:

37

Description:

Initialization

The POU is initialized. The completion of the initialization is reported by q_xReady = TRUE.

ListOfCmdTablesInvalid

Enumeration name:

ListOfCmdTablesInvalid

Enumeration value:

95

Description:

The list of the command table is invalid.

Issue

Cause

Solution

-

A command table was defined that does not contain any commands.

Make sure that all command tables contain at least one command.

An "empty" command table can be defined using the FC_FirstLastStepEmptyTable function.

MissingModuleCall

Enumeration name:

MissingModuleCall

Enumeration value:

94

Description:

A call-up of a module is unavailable.

Issue

Cause

Solution

-

A submodule is not called up.

Make sure that all submodules are called up cyclically.

-

A submodule does not update the q_dwModuleType value of the ST_StandardModuleInterface.

Make sure that all submodules announce their type.

ModuleIdInvalid

Enumeration name:

ModuleIdInvalid

Enumeration value:

67

Description:

The module ID is invalid.

Issue

Cause

Solution

-

The udiModuleName value of the ST_Cmd does not correspond to any number of the submodules.

Verify the initialization of the command tables.

-

The list of modules in a group contains the number which corresponds to none of the submodules.

Verify the definition of the groups.

NumberOfCmdStepsRange

Enumeration name:

NumberOfCmdStepsRange

Enumeration value:

98

Description:

The number of steps of a command is outside the valid range.

Issue

Cause

Solution

-

A command table with 0 or less steps was transferred.

Verify the initialization of the command tables.

Use the FC_FirstStep and FC_NextStep functions to define the command tables.

NumberOfCmdTablesRange

Enumeration name:

NumberOfCmdTablesRange

Enumeration value:

34

Description:

The number of command tables is outside the valid range.

Issue

Cause

Solution

-

The number of command tables at the input i_udiNumberofCmdTables is <= 0.

Make sure that at least one command table is contained in the list of the command tables at the i_pstListOfCmdTables input and assign the i_udiMumberOfCmdTables input with the number of the command tables in the list of the command tables.

NumberOfSubModulesRange

Enumeration name:

NumberOfSubModulesRange

Enumeration value:

66

Description:

The number of submodules is outside the specified range

Issue

Cause

Solution

-

The number of submodules at the input i_udiNumberOfSubModules is < 0.

Make sure that a value greater than or equal zero is applied at the i_udiNumberOfSubModules input that corresponds to the number of submodules under this equipment module.

PointerCmdTableInvalid

Enumeration name:

PointerCmdTableInvalid

Enumeration value:

36

Description:

The pointer onto CmdTable is invalid.

Issue

Cause

Solution

-

The list of command tables at the i_pstListOfCmdTables input has not been completely initialized.

Verify the call-up of FC_UpdateCmdTableListElement for each command table.

PointerListOfCmdTablesInvalid

Enumeration name:

PointerListOfCmdTablesInvalid

Enumeration value:

33

Description:

The pointer onto ListOfCmdTables is invalid.

Issue

Cause

Solution

-

The pointer of the i_pstListofCMDTables input is not assigned (zero).

Make sure that the address of the array of the command tables is transferred at the i_pstListofCMDTables input. For instance with ADR(astListOfCMDTables)

PointerSubModuleGroupsInvalid

Enumeration name:

PointerSubModuleGroupsInvalid

Enumeration value:

104

Description:

The pointer onto SubModuleGroups is invalid.

Issue

Cause

Solution

-

The pointer of the i_pudiSubModuleGroups input is not assigned (zero).

Make sure that the address of the array in which the groups of the submodules are managed is given at the i_pudiSubModuleGroups input. For instance with ADR(aaudiSubModuleGroups)

PointerSubModulesItfInvalid

Enumeration name:

PointerSubModulesItfInvalid

Enumeration value:

97

Description:

The pointer SubModulesItf is invalid

Issue

Cause

Solution

-

The pointer of the i_pstSubModulesItf input is not assigned (zero).

Make sure that the address of the array in which the submodules are managed is given at the i_pstSubModulesItf input. For instance with ADR(astSubModuleInterface)

ReactionOffsetRange

Enumeration name:

ReactionOffsetRange

Enumeration value:

42

Description:

ReactionOffset is outside the valid range.

Issue

Cause

Solution

-

An invalid value was transferred at the i_udiReactionOffset input.

Make sure that the i_udiReactionOffset input meets the following condition:

i_udiReactionOffset + 5 <= Gc_udiMaxNumberOfReactions

SizeOfListOfCmdTablesInvalid

Enumeration name:

SizeOfListOfCmdTablesInvalid

Enumeration value:

99

Description:

Invalid size of the ListOfCmdTables.

Issue

Cause

Solution

-

An invalid value was transferred at the i_udiSizeOfListOfCmdTables input.

The size of the array of the command tables must be transferred to the i_udiSizeOfListOfCmdTables input. For instance SIZEOF(astListOfCMDTables)

-

At the i_udiNumberOfCMDTables input, the number of the command tables in the list of command tables at the i_pstListofCMDTables input was not transferred.

Make sure that the number of command tables is transferred at the i_udiNumberOfCMDTables input.

SizeOfSubModuleGroupsInvalid

Enumeration name:

SizeOfSubModuleGroupsInvalid

Enumeration value:

105

Description:

Invalid size of the SubModuleGroups.

Issue

Cause

Solution

-

An invalid value was transferred at the i_udiSizeOfSubModuleGroups input.

The size of the array in which the groups are managed must be transferred to the i_udiSizeOfSubModuleGroups array. For instance SIZEOF(aaudiSubModuleGroups)

-

At the i_udiNumberOfGroups input. the number of groups defined in the list at the i_pudiSubModuleGroups input was not transferred.

Make sure that the correct number of groups is transferred at the i_udiNumberOfGroups input.

-

At the i_udiNumberOfGroupMembers input, the maximum number of slaves in a group defined in the list at the i_pudiSubModuleGroups input was not transferred.

Make sure that the correct maximum number of members of a group is transferred at the i_udiNumberOfGroupMembers input.

SizeOfSubModulesItfInvalid

Enumeration name:

SizeOfSubModulesItfInvalid

Enumeration value:

96

Description:

The size of the submodule interface is invalid

Issue

Cause

Solution

-

An invalid value was transferred at the i_udiSizeOfSubModulesItf input.

The size of the array must be transferred to the i_udiSizeOfSubModulesItf input in which the submodules are managed. For instance SIZEOF(astSubModuleInterface)

-

At the i_udiNumberOfSubModules input, the number of submodules managed in the list of submodules at the i_pstSubModulesItf input was not transferred.

Make sure that at the correct maximum number of submodules is transferred at the i_udiNumberOfSubModules input.

StartStepInvalid

Enumeration name:

StartStepInvalid

Enumeration value:

106

Description:

Invalid start step.

Issue

Cause

Solution

-

An invalid value was transferred at the input iq_diStartStep.

Make sure that the step of the command table selected via iq_diStartStep is also defined in the command table.

SubModuleItfNotInitialized

Enumeration name:

SubModuleItfNotInitialized

Enumeration value:

103

Description:

An interface of a submodule has not yet been initialized.

Issue

Cause

Solution

-

The name of a submodule is empty.

Make sure that the string of all submodules in which their name is given is not empty.

-

The ID of a submodule is 0.

Make sure that each submodule has an ID which describes its position in the machine tree.

WaitAtNegativeStep

Enumeration name:

WaitAtNegativeStep

Enumeration value:

41

Description:

Waiting at a negative step.

As requested, processing of the command table was interrupted.

The processing of the command table continues if the iq_diStartStep input is set to the step which shall be executed next.

WaitCmdsDone

Enumeration name:

WaitCmdsDone

Enumeration value:

43

Description:

Waiting until commands are processed.

The module controller processes the command table.

WaitForCmd

Enumeration name:

WaitForCmd

Enumeration value:

39

Description:

Waiting for a command.

The module controller is waiting for a command.

Methods

Name

Description

RegisterLoggerPoint

Registering the logger point of the POU in the Application Logger