# LGF_RampCI (FB / V3.0.1)

Author: Siemens Digital Industries

## Short description

The function generates a speed curve based on an interpolation point table. Linear interpolation occurs between the points within the prescribed time.

### Block Interface

| LGF_RampCI (FB) |
--- | --- | ---
LReal |  |  | defaultOutValue |  | outputValue |  |  | LReal
Int |  |  | contStepNbr |  | actTimeTable |  |  | Bool
Time |  |  | contStepTime |  | stepNumber |  |  | Int
Bool |  |  | enDefaulftOutValue |  | remainTime |  |  | Time
Bool |  |  | start |  | totalTime |  |  | Time
Bool |  |  | hold |  | remainTotalTime |  |  | Time
Bool |  |  | continue |  | error |  |  | Bool
Bool |  |  | cyclicOP |  | status |  |  | Word
Bool |  |  | updateTime |  | subfunctionStatus |  |  | Word
Bool |  |  | reset |  |  |  |  |
OB_CYCLIC |  |  | callOB |  |  |  |  |
Array[*] of LGF_typeRampTimeTable |  |  | setpoints |  |  | Array[*] of LGF_typeRampTimeTable

### Input parameter

Identifier | Data type | Default value | Description
--- | --- | --- | ---
defaultOutValue | LReal | 0.0 | Value for pre-assignment of the output variable (`outputValue` = `defaultOutValue`)
contStepNbr | Int | 0 | Number of the next interpolation point for continuing
contStepTime | Time | T#0MS | Remaining time to continue to the interpolation point `contStepNbr`
enDefaulftOutValue | Bool | FALSE | Assign default output value (`outputValue` = `defaultOutValue`)
start | Bool | FALSE | Run down the interpolation point table
hold | Bool | FALSE | Freeze/ hold output at actual value
continue | Bool | FALSE | Continuing
cyclicOP | Bool | FALSE | Repeat interpolation point table cyclically
updateTime | Bool | FALSE | Update time values
reset | Bool | FALSE | Complete reset of function
callOB | OB_CYCLIC | --- | Calling wake-alarm interrupt OB (cyclic interrupt OB)

### Output parameter

Identifier | Data type | Description
--- | --- | ---
outputValue | LReal | Output value
actTimeTable | Bool | The interpolation point table will be edited.
stepNumber | Int | current interpolation point number (interpolation point that is approached)
remainTime | Time | Remaining time until reaching the next interpolation point
totalTime | Time | Total time for setpoint table
remainTotalTime | Time | Total remaining time
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

### In/Out parameter

Identifier | Data type | Description
--- | --- | ---
setpoints | Array[*] of LGF_typeRampTimeTable | Interpolation point table. You can find information on the data type `LGF_typeRampTimeTable` under the item “Global data” .

### Status & Error codes

Code / Value | Identifier / Description
--- | ---
16#0000 | STATUS_FINISHED_NO_ERROR Status: Execution finished without errors
16#7000 | STATUS_NO_CALL Status: Block is not being processed
16#7001 | STATUS_FIRST_CALL Status: First call, Rising edge `start`.
16#7002 | STATUS_FURTHER_CALLS Status: Further calls, cyclic operation, Input `cyclicOP` set.
16#8200 | 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#8201 | ERR_ARRAY_LOWER_BOUND Error: Array does not start with 0 / Low array limit <> 0. The array with the interpolation points must start with the index 0.
16#8400 | ERR_QRY_CINT Error in `QRY_CINT` command - check `subFunctionStatus` code

## User defined datatype(s)

### LGF_typeRampTimeTable (UDT)

Data type to setup a speed curve based on a setpoint table for the function `LGF_RampCI`

Identifier | Data type | Default value | Description
--- | --- | --- | ---
outputValue | LReal | 0.0 | Setpoint Value to reach by the interpolation curve
time | Time | T#0s | Time until the interpolation point is reached

## 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.

###### Global data

Together with the block, you automatically receive the PLC data type `LGF_typeRampTimeTable`, which is composed of the parameters `outVal` for the value of a base point and `time` for the time, until the next base point is reached. The declaration takes place in a one-dimensional array of the data type `LGF_typeRampTimeTable` beginning with the index `0`. The array is created in a global data block and then passed to the module `LGF_RampCI`.

Figure: Example of the declaration of the interpolation points

The parameter `time` of the last interpolation point must be parameterized with `0s`, since there is no longer any successor interpolation point.

###### Principle of operation

With this block, speed curves can be executed based on parameterized interpolation points; in each call cycle values are output according to a schedule, and interpolation takes place between the interpolation points.

In each cycle the currently approached interpolation point number `stepNumber`, the actual remaining time `remainTime` until reaching the interpolation point, the total time `totalTime,` and the total remaining time until reaching the end of the speed curve `remainTotalTime`, are output. In addition, the output `actTimeTable` is set if the projected speed curve is currently being output.

The time interval of the calling cyclic interrupt OB is determined by interconnecting the calling cyclic interrupt OB at the input parameter `callOB`.

Figure: Interconnecting the cyclic interrupt OB

The following operating modes can be selected via control inputs:

- Restart
- Pre-assigning an output
- Output a speed curve
- Stop processing
- Specify processing step and processing time
- Switch-on cyclic operation+F1
- Update total time and remaining time

###### Overview of the operating modes

Table: Overview of the operating modes

###### Restart

The output `outValue` is reset to `0.0` with a rising edge at the input `reset`. With `enDefaultOutValue = TRUE`, `defaultOutValue` is output at `outputValue`. The total time and total remaining time are updated and output.

###### Pre-assigning an output

If the speed curve should begin with a certain output value, then `enDefaultOutValue` must be `TRUE`. In this case the value `defaultOutValue` is present on the output of the timer. The internal processing of the speed curve continues during this time. If `enDefaultOutValue` changes to `FALSE` again, interpolation is performed to the currently active calibration point.

###### Output a speed curve

With a rising edge at the input `start`, the speed curve is output - as long as `start` is `TRUE` or until the speed curve is terminated by reaching the last interpolation point. Through a subsequent rising edge, the speed curve is output again. In addition, the total time is updated at each switch-on.

###### Switch-on cyclic operation

If, in addition to the input `start`, the input `cyclicOP` is also set to `TRUE`, the speed curve automatically returns to the start point after outputting the last interpolation point value and starts a new cycle.

There is no interpolation between the last interpolation point value and the starting point. The following must apply for a smooth transition: last interpolation point value = start point.

###### Stop speed curve

With `hold = TRUE` the value of the output variable (including time processing) is frozen. When resetting `hold = FALSE`, the program continues at the point of interruption or at a parameterized point (see "Defining the processing step and processing time"). The processing time of the speed curve is extended by the holding time `T1*`. (see Figure below).

###### Specify processing step and processing time

If the input parameter `continue` is set to `TRUE` for continuation while the speed curve is stopped (`hold = TRUE`), then after the input `hold` has been reset the interpolation point number `contStepNbr` (target interpolation point) will be approached within the time `contStepTime` (interpolation). The total remaining time will be recalculated.

###### Updating total time and total remaining time

If values of the interpolation points are changed, the total time and the total remaining time of the speed curve can change. Since calculation of `totalTime` and `remainTotalTime` can significantly increase the processing time of the function block at many interpolation points, the calculation is only executed once with a rising edge on the `updateTime` input.

###### Functional processes

Figure: Functional processes

## Change log

Version & Date | Change description
--- | ---
| 01.00.00 | Siemens Industry Online Support
| 03.02.2017 | First released version
| 01.00.01 | Siemens Industry Online Support
| 16.05.2017 | Comment correction (REGION)
| 01.00.02 | Siemens Industry Online Support
| 17.08.2018 | Upgrade: TIA V15 Update 2
| 01.00.03 | Siemens Industry Online Support
| 23.11.2018 | Upgrade: TIA V15.1
| 01.00.06 | Siemens Industry Presales Support
| 15.11.2019 | Code optimization, Regions, comments and constants are added
| 03.00.00 | Simatic Systems Support
| 23.04.2020 | Set version to V3.0.0, harmonize the version of the whole library
| 03.00.01 | Simatic Systems Support
| 22.03.2021 | Insert documentation Change UDT member name from `outValue` to `outputValue`