# LGF_TriangleCI (FB / 3.0.1)

Overview

Author: Siemens Industry Support

## Short description

This function generates a triangular signal profile. For this it uses the time interval of the calling Cyclic Interrupt OB.

### Block Interface

| LGF_TriangleCI (FB) |
--- | --- | ---
Real |  |  | amplitude |  | value |  |  | Real
Real |  |  | offset |  | error |  |  | Bool
UDInt |  |  | periode |  | status |  |  | Word
Real |  |  | phaseShift |  | subFunctionStatus |  |  | Word
OB_CYCLIC |  |  | callOB |  |  |  |  |
Bool |  |  | reset |  |  |  |  |

### Input parameter

Identifier | Data type | Default value | Description
--- | --- | --- | ---
amplitude | Real | 1.0 | Amplitude of the signal profile.
offset | Real | 0.0 | Offset of the signal profile in the Y-direction.
periode | UDInt | 1000 | Period duration of the signal profile in [ms]
phaseShift | Real | 0.0 | Phase offset in [ms]
callOB | OB_CYCLIC | --- | Calling cyclic interrupt OB
reset | Bool | FALSE | Reset of the signal profile.

### Output parameter

Identifier | Data type | Description
--- | --- | ---
value | Real | Current value of the triangular signal.
error | Bool | FALSE: No error TRUE: An error occurred during the execution of the FB
status | Word | 16#0000-16#7FFF: Status of the FB 16#8000-16#FFFF: Error identification (see following Table)
subFunctionStatus | Word | Status or return value of called FB's, FC's and system blocks

### Status & Error codes

Code / Value | Identifier / Description
--- | ---
16#0000 | STATUS_FINISHED_NO_ERROR Status: Execution finished without errors
16#8600 | ERR_OB_UNAVAILABLE Error: OB on input `callOB` is not configured / present. Interconnect the constant name of a configured cyclic interrupt OB at the input `callOB`.
16#8601 | ERR_QRY_CINT Error in `QRY_CINT` command - check `subFunctionStatus` code

## Functional description

NOTE
  The status of called commands is output in `subFunctionStatus`. In this case, the output value in `status` indicates which command caused the error. In this case, refer to the TIA Portal Online Help section for information on the respective commands.

The block calculates the values for a triangular signal profile, which is output to the output parameter `value`.

The `amplitude`, the `offset` in the Y-direction, the `period`, and the `phase shift` can be set at the input parameters.

The input parameter `reset` resets the signal profile. At the `value` output parameter, the value `0` is output as long as `reset` is set to `TRUE`.

The block must be called in a cyclic interrupt OB. The time interval of the calling cyclic interrupt OB is determined in the FB with the command `QRY_CINT`. For this, the constant name of the calling cyclic interrupt OB must be interconnected at the input parameter `callOB`.

The number of calculated values of the signal profile per period duration is calculated as follows:

Quantity Values = \frac{Period duration}{Time intervak Cyclic interrupt OB}

Note
  To obtain a continuous signal profile of the curve, the time interval of the cyclic interrupt OB should not be selected too large depending on the period duration.

The Figure below shows the signal profile of the calculated values.

## Change log

Version & Date | Change description
--- | ---
| 1.0.0 | Siemens Industry Online Support
| 03.07.2018 | First released version
| 1.0.1 | Siemens Industry Online Support
| 17.08.2018 | Upgrade: TIA V15 Update 2
| 1.0.2 | Siemens Industry Online Support
| 23.11.2018 | Upgrade: TIA V15.1
| 1.0.3 | Simatic Systems Support
| 26.09.2019 | Code refactoring, regions and more comments added phase shift availability added
| 3.0.0 | Simatic Systems Support
| 23.04.2020 | Set version to V3.0.0, harmonize the version of the whole library
| 3.0.1 | Simatic Systems Support
| 15.02.2021 | Insert documentation