> For the complete documentation index, see [llms.txt](https://infosys.selmotech.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://infosys.selmotech.com/selmo-solution/selmo-solution-en/selmo-structure-and-standard/selmo-technical-standard-and-structure/description-selmo-plc-code/sequence-logic/less-than-sequence_name-greater-than/structure-less-than-sequence_name-greater-than/standard-end.md).

# Standard end

The function block fbStandardEnd contains the logic that extracts information from the machine state (step) for actuators and sensors (zones) and determines the type of subsequent actions. It also supervises the control of the step counter and provides diagnostics to the HMI. This FB is a main component of every sequence and can be found in the Selmo Basic library. **refSeqHmi** is the reference (pointer) to the variable list "[GVL\_\<Sequence\_name>\_HMI.stHmiIf](https://selmo-technology-gmbh.gitbook.io/selmo-solution/02-selmo-standard/04-selmo-plc-code/contents#221783-gvl_sequence1_hmi)" (stHmiSequence) **refSeqIf** is the reference (pointer) to the variable list "[GVL\_\<Sequence\_name>.stSeqIf](https://selmo-technology-gmbh.gitbook.io/selmo-solution/02-selmo-standard/04-selmo-plc-code/contents#221781-gvl_sequence1)" (stSequenceInterface) **iSeqEndStep** Query of the last modeled step "[GVL\_\<HwZone\_name>\_IOs.xSafetyFunctionKeySwitch](https://selmo-technology-gmbh.gitbook.io/selmo-solution/02-selmo-standard/04-selmo-plc-code/contents#22173-gvl_hwzone1_ios)" **iSeqStepcounter** current step counter of the sequence "[GVL\_\<Sequence\_name>.iStepcounter](https://selmo-technology-gmbh.gitbook.io/selmo-solution/02-selmo-standard/04-selmo-plc-code/contents#221781-gvl_sequence1)" **aLampMatrix** [Array of the bit matrix](https://selmo-technology-gmbh.gitbook.io/selmo-solution/02-selmo-standard/04-selmo-plc-code/contents#221786-sequence1) (variable declaration) is increased by two indices per zone **aStepMatrix** [Array of the bit matrix](https://selmo-technology-gmbh.gitbook.io/selmo-solution/02-selmo-standard/04-selmo-plc-code/contents#221786-sequence1) (variable declaration) is increased by two indices per zone **aTempMatrix** [Array of the bit matrix](https://selmo-technology-gmbh.gitbook.io/selmo-solution/02-selmo-standard/04-selmo-plc-code/contents#221786-sequence1) (variable declaration) is increased by two indices per zone **aSeqHmiBits** Array of the bit matrix is increased by two indices per zone and serves as information for the HMI "[GVL\_\<Sequence\_name>\_HMI.aHmi](https://selmo-technology-gmbh.gitbook.io/selmo-solution/02-selmo-standard/04-selmo-plc-code/contents#221783-gvl_sequence1_hmi)" **aStepMonitoringMatrix** Array for storing the times per step "[GVL\_\<Sequence\_name>.aStepMonitoringMatrix](https://selmo-technology-gmbh.gitbook.io/selmo-solution/02-selmo-standard/04-selmo-plc-code/contents#221781-gvl_sequence1)" **aStepMonitoringFb** [Array of the memory blocks](https://selmo-technology-gmbh.gitbook.io/selmo-solution/02-selmo-standard/04-selmo-plc-code/contents#221786-sequence1) (variable declaration) per step

Copy

```
// ########################### STANDARD END ###########################
   {region "Description Standard End"}
   (*
   The Standard End section provides the logic which extracts fault information from 
   the step sequence fault matrix determining the nature of the fault and subsequent actions.
   It also supervises control of the sequence step counter and provides the diagnostic  ‘link’ to the ‘HMI’ software.
   *)
   {endregion}
   GVL_<Sequence_name>.iStepCounterLastCycle := GVL_<Sequence_name>.iStepCounter;

   fbStandardEnd(
      refSeqHmi:= GVL_<Sequence_name>_HMI.stHmiIf,
      refSeqIf :=GVL_<Sequence_name>.stSeqIf,   
      iSeqEndStep := GVL_<Sequence_name>.iEndStep, 
      iSeqStepCounter := GVL_<Sequence_name>.iStepCounter, 
      aLampMatrix := aMatrix, 
      aStepMatrix := aStep, 
      aTempMatrix := aTemp, 
      aSeqHmiBits := GVL_<Sequence_name>_HMI.aHmi,
      aStepMonitoringMatrix := GVL_<Sequence_name>.aStepMonitoringMatrix,
      aStepMonitoringFb := aStepMonitoringFb);
```

**Interlock Stored**

Copy

```
// --------------------------- Interlock stored ---------------------------
   // Copy HMI Bits to stored array
   FOR nHmiStoredLoopCounter := 0 TO (UINT_TO_INT(SIZEOF(GVL_<Sequence_name>_HMI.aHmi)) - 1) BY 1 DO
      IF GVL_<Sequence_name>_HMI.aHmi[nHmiStoredLoopCounter] THEN
         GVL_<Sequence_name>_HMI.aHmiStored[nHmiStoredLoopCounter] := TRUE;
      END_IF
   END_FOR; 
   
   // Delete stored array every step counter change
   IF GVL_<Sequence_name>.iStepCounterLastCycle <> GVL_<Sequence_name>.iStepCounter OR GVL_Global.stGlobalIf.xFaultReset OR GVL_<Sequence_name>_HMI.stHmiIf.xHmiPbFaultReset THEN
      FOR nHmiStoredLoopCounter := 0 TO (UINT_TO_INT(SIZEOF(GVL_<Sequence_name>_HMI.aHmi)) - 1) BY 1 DO
         GVL_<Sequence_name>_HMI.aHmiStored[nHmiStoredLoopCounter] := FALSE;
      END_FOR; 
   END_IF
```

**2.2.1.7.8.7. \<Sequence\_name>\_InputMapping**

***

Copy

```
PROGRAM Sequence1_InputMapping
VAR
END_VAR

{region "Description Input Mapping"}
(*
All step sequence zone inputs that cannot be directly linked are connected to the real-world hardware in this section.
This must be done manually.
*)
{endregion}

(*
GVL_Sequence1_IOs.i_xDecision_1_Path1 := ; // Decision: Decision 1
GVL_Sequence1_IOs.i_xDecision_1_Path2 := ; // Decision: Decision 1

*)
```

<\*\*\*> Variable name, comment and data type are automatically taken from the Studio

In the input mapping the required hardware inputs are mapped to the input zones. Example:

Copy

```
GVL_Sequence1_IOs.i_xDecision_1_Path1 := GVL.I_Y3; 
GVL_Sequence1_IOs.i_xDecision_1_Path2 := GVL.I_Y4; 
```

**2.2.1.7.8.8. \<Sequence\_name>\_OutputMapping**

***

Copy

```
PROGRAM Sequence1_OutputMapping
VAR
END_VAR

{region "Description Output Mapping"}
(*
All step sequence zone outputs that cannot be directly linked are connected to the real-world hardware in this section.
This must be done manually.
*)
{endregion}

(*
 := GVL_<Sequence_name>_IOs.<o_xZone_name>; 
 := GVL_<Sequence_name>_IOs.<o_xZone_name>; 
 := GVL_<Sequence_name>_IOs.<o_xZone_name>; 
 := GVL_<Sequence_name>_IOs.<o_xZone_name>; 

*)
```

<\*\*\*> Variable name, comment and data type are automatically taken from the Studio

In the output mapping the output zones are mapped to the hardware outputs as required. Example:

Copy

```
GVL.O_Y1 := GVL_Sequence1_IOs.o_xZone9; 
GVL.O_Y2 := GVL_Sequence1_IOs.o_xZone10; 
GVL.O_Y3 := GVL_Sequence1_IOs.o_xZone11; 
GVL.O_Y4 := GVL_Sequence1_IOs.o_xZone12; 
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://infosys.selmotech.com/selmo-solution/selmo-solution-en/selmo-structure-and-standard/selmo-technical-standard-and-structure/description-selmo-plc-code/sequence-logic/less-than-sequence_name-greater-than/structure-less-than-sequence_name-greater-than/standard-end.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
