# LGF_SawTooth (FB / 3.0.1)

Overview

Author: Siemens Digital Industries

## Short description

This function generates a sawtooth-shaped signal profile. Each sawtooth consists of a defined number of steps (increments).

NOTE
  LEGACY FUNCTION
  Please update and use the FB with the same name `LGF_CountRisInDWord` in the future!
  This function is no longer maintained!

### Block Interface

| LGF_SawTooth (FB) |
--- | --- | ---
Int |  |  | startValue |  | value |  |  | Int
Time |  |  | timeRange |  |  |  |  |
Int |  |  | incrementRange |  |  |  |  |
Int |  |  | numberSteps |  |  |  |  |
Bool |  |  | endlessSteps |  |  |  |  |
Bool |  |  | reset |  |  |  |  |

### Input parameter

Identifier | Data type | Default value | Description
--- | --- | --- | ---
startValue | Int | 0 | Start value at which the signal begins.
timeRange | Time | T#0s | Time after which the output parameter `value` is incremented
incrementRange | Int | 0 | Size of the jump from one increment to the next.
numberSteps | Int | 0 | Number of increments per sawtooth. (In the case of an endless sawtooth signal, this information is not necessary).
endlessSteps | Bool | FALSE | Specifies whether an endless sawtooth signal will be generated. `TRUE` - Activated, `FALSE` - Disabled
reset | Bool | FALSE | Sawtooth starts again at the start value, `startValue`.

### Output parameter

Identifier | Data type | Description
--- | --- | ---
value | Int | Current value of the sawtooth signal.

## Functional description

NOTE
  Please note that changes at the input parameters only become effective with `reset`.

The block calculates the values for a sawtooth-shaped signal profile, which is output to the output parameter `value`. The signal begins with the start value `startValue` and is added with the value `increment` after each elapse of the time interval `timeRange`. The value can also be negative.

If the variable `endlessSteps` is set to `FALSE`, the number of add operations is counted. If this exceeds the value `numberSteps`, the output parameter `value` is set back to the start value. A new sawtooth begins.

If the variable `endlessSteps` is set to `TRUE`, the value `increment` is added without interruption, starting once at `startValue`. If the maximum positive INT value range (32767) of the output parameter `value` is exceeded, `value` changes to the maximum negative INT value range (-32768) and will continue to be added up.

NOTE
  The duration of a sawtooth at `endlessSteps` on `FALSE` is calculated as follows:
  Duration = #timeRange * (#numberSteps + 1)

## Change log

Version & Date | Change description
--- | ---
| 1.0.0 | Siemens Industry Online Support
| 19.08.2015 | First released version
| 1.0.1 | Siemens Industry Online Support
| 02.11.2015 | Bug fix
| 1.0.2 | Siemens Industry Online Support
| 02.01.2017 | Upgrade: TIA Portal V14 Update 1
| 1.0.3 | Siemens Industry Online Support
| 17.08.2018 | Upgrade: TIA V15 Update 2
| 1.0.4 | Siemens Industry Online Support
| 23.11.2018 | Upgrade: TIA V15.1
| 1.0.10 | Simatic Systems Support
| 23.09.2019 | Code refactoring, regions and more comments added
| 3.0.1 | Simatic Systems Support
| 15.02.2021 | Insert documentation