# Function blocks

> The native and ST library function blocks of eaxPLC: every pin with its direction and IEC type.

Product: eaxPLC · Type: Reference · Editions: Free
Source: https://eaxware.com/docs/eaxplc/reference/generated/iec/function-blocks/
Verified against commit 3cbe414.

<!-- GENERATED by tools/docgen (node tools/docgen/docgen.mjs). Do not edit by hand: change the source and regenerate. -->

The function blocks every ST program can instantiate without declaring them: the native blocks (implemented in Go, eaxPLC/pkg/plc/fb) and the library blocks written in ST. A program may declare its own block of the same name as an ST library block.

| Block | Kind | Inputs | Outputs |
|---|---|---|---|
| [TON](#ton) | native | 2 | 2 |
| [TOF](#tof) | native | 2 | 2 |
| [TP](#tp) | native | 2 | 2 |
| [CTU](#ctu) | native | 3 | 2 |
| [CTD](#ctd) | native | 3 | 2 |
| [CTUD](#ctud) | native | 5 | 3 |
| [SR](#sr) | native | 2 | 1 |
| [RS](#rs) | native | 2 | 1 |
| [SEMA](#sema) | native | 2 | 1 |
| [R_TRIG](#r_trig) | native | 1 | 1 |
| [F_TRIG](#f_trig) | native | 1 | 1 |
| [RTC](#rtc) | native | 2 | 2 |
| [DERIVATIVE](#derivative) | native | 3 | 1 |
| [INTEGRAL](#integral) | native | 3 | 2 |
| [LIN_TRAFO](#lin_trafo) | native | 5 | 2 |
| [STATISTICS_INT](#statistics_int) | native | 2 | 3 |
| [STATISTICS_REAL](#statistics_real) | native | 2 | 3 |
| [VARIANCE](#variance) | native | 2 | 1 |
| [PD](#pd) | native | 10 | 2 |
| [PID](#pid) | native | 10 | 5 |
| [PID_FIXCYCLE](#pid_fixcycle) | native | 12 | 3 |
| [BLINK](#blink) | native | 3 | 1 |
| [FREQ_MEASURE](#freq_measure) | native | 3 | 2 |
| [GEN](#gen) | native | 6 | 1 |
| [CHARCURVE](#charcurve) | native | 3 | 2 |
| [RAMP_INT](#ramp_int) | native | 5 | 1 |
| [RAMP_REAL](#ramp_real) | native | 5 | 1 |
| [HYSTERESIS](#hysteresis) | native | 3 | 1 |
| [LIMITALARM](#limitalarm) | native | 3 | 3 |

## TON

TON implements the standard IEC 61131-3 On-Delay Timer.
Memory footprint: 24 bytes (fixed layout for persistent %M storage).

Kind: native. Instance size: 24 bytes. Source: `eaxPLC/pkg/plc/fb/timers_counters.go`

| Pin | Direction | Type |
|---|---|---|
| `IN` | input | `BOOL` |
| `Q` | output | `BOOL` |
| `PT` | input | `TIME` |
| `ET` | output | `TIME` |

## TOF

TOF implements the standard IEC 61131-3 Off-Delay Timer.

Kind: native. Instance size: 24 bytes. Source: `eaxPLC/pkg/plc/fb/timers_counters.go`

| Pin | Direction | Type |
|---|---|---|
| `IN` | input | `BOOL` |
| `Q` | output | `BOOL` |
| `PT` | input | `TIME` |
| `ET` | output | `TIME` |

## TP

TP implements the standard IEC 61131-3 Pulse Timer.
Memory footprint: 24 bytes.

Kind: native. Instance size: 24 bytes. Source: `eaxPLC/pkg/plc/fb/standard_lib.go`

| Pin | Direction | Type |
|---|---|---|
| `IN` | input | `BOOL` |
| `Q` | output | `BOOL` |
| `PT` | input | `TIME` |
| `ET` | output | `TIME` |

## CTU

CTU implements the standard IEC 61131-3 Up-Counter.

Kind: native. Instance size: 20 bytes. Source: `eaxPLC/pkg/plc/fb/timers_counters.go`

| Pin | Direction | Type |
|---|---|---|
| `CU` | input | `BOOL` |
| `RESET` | input | `BOOL` |
| `PV` | input | `DINT` |
| `Q` | output | `BOOL` |
| `CV` | output | `DINT` |

## CTD

CTD implements the standard IEC 61131-3 Down-Counter.

Kind: native. Instance size: 20 bytes. Source: `eaxPLC/pkg/plc/fb/timers_counters.go`

| Pin | Direction | Type |
|---|---|---|
| `CD` | input | `BOOL` |
| `LOAD` | input | `BOOL` |
| `PV` | input | `DINT` |
| `Q` | output | `BOOL` |
| `CV` | output | `DINT` |

## CTUD

CTUD implements the standard IEC 61131-3 Up/Down-Counter.

Kind: native. Instance size: 20 bytes. Source: `eaxPLC/pkg/plc/fb/timers_counters.go`

| Pin | Direction | Type |
|---|---|---|
| `CU` | input | `BOOL` |
| `CD` | input | `BOOL` |
| `RESET` | input | `BOOL` |
| `LOAD` | input | `BOOL` |
| `PV` | input | `DINT` |
| `QU` | output | `BOOL` |
| `QD` | output | `BOOL` |
| `CV` | output | `DINT` |

## SR

SR implements the IEC 61131-3 Set-Dominant Bistable function block.
Q1 = (NOT RESET AND Q1) OR SET1

Kind: native. Instance size: 3 bytes. Source: `eaxPLC/pkg/plc/fb/standard_lib.go`

| Pin | Direction | Type |
|---|---|---|
| `SET1` | input | `BOOL` |
| `RESET` | input | `BOOL` |
| `Q1` | output | `BOOL` |

## RS

RS implements the IEC 61131-3 Reset-Dominant Bistable function block.
Q1 = NOT RESET1 AND (Q1 OR SET)

Kind: native. Instance size: 3 bytes. Source: `eaxPLC/pkg/plc/fb/standard_lib.go`

| Pin | Direction | Type |
|---|---|---|
| `SET` | input | `BOOL` |
| `RESET1` | input | `BOOL` |
| `Q1` | output | `BOOL` |

## SEMA

SEMA implements the standard IEC 61131-3 Software Semaphore.

Kind: native. Instance size: 4 bytes. Source: `eaxPLC/pkg/plc/fb/standard_lib.go`

| Pin | Direction | Type |
|---|---|---|
| `CLAIM` | input | `BOOL` |
| `RELEASE` | input | `BOOL` |
| `BUSY` | output | `BOOL` |

## R_TRIG

R\_TRIG implements the standard IEC 61131-3 Rising Edge Detector.

Kind: native. Instance size: 3 bytes. Source: `eaxPLC/pkg/plc/fb/standard_lib.go`

| Pin | Direction | Type |
|---|---|---|
| `CLK` | input | `BOOL` |
| `Q` | output | `BOOL` |

## F_TRIG

F\_TRIG implements the standard IEC 61131-3 Falling Edge Detector.

Kind: native. Instance size: 3 bytes. Source: `eaxPLC/pkg/plc/fb/standard_lib.go`

| Pin | Direction | Type |
|---|---|---|
| `CLK` | input | `BOOL` |
| `Q` | output | `BOOL` |

## RTC

RTC implements the standard IEC 61131-3 Real Time Clock function block.
EN: Enable clock counting; PDT: Preset Date/Time in seconds; CDT: Current Date/Time.

Kind: native. Instance size: 32 bytes. Source: `eaxPLC/pkg/plc/fb/standard_lib.go`

| Pin | Direction | Type |
|---|---|---|
| `EN` | input | `BOOL` |
| `Q` | output | `BOOL` |
| `PDT` | input | `ULINT` |
| `CDT` | output | `ULINT` |

## DERIVATIVE

DERIVATIVE calculates the numerical derivative using 4-point approximation.

Kind: native. Instance size: 64 bytes. Source: `eaxPLC/pkg/plc/fb/util_lib.go`

| Pin | Direction | Type |
|---|---|---|
| `IN` | input | `REAL` |
| `TM` | input | `UDINT` |
| `RESET` | input | `BOOL` |
| `OUT` | output | `REAL` |

## INTEGRAL

INTEGRAL calculates the numerical integral using trapezoidal rule.

Kind: native. Instance size: 32 bytes. Source: `eaxPLC/pkg/plc/fb/util_lib.go`

| Pin | Direction | Type |
|---|---|---|
| `IN` | input | `REAL` |
| `TM` | input | `UDINT` |
| `RESET` | input | `BOOL` |
| `OUT` | output | `REAL` |
| `OVERFLOW` | output | `BOOL` |

## LIN_TRAFO

LIN\_TRAFO transforms a REAL value from input range [IN\_MIN..IN\_MAX] to output range [OUT\_MIN..OUT\_MAX].

Kind: native. Instance size: 28 bytes. Source: `eaxPLC/pkg/plc/fb/util_lib.go`

| Pin | Direction | Type |
|---|---|---|
| `IN` | input | `REAL` |
| `IN_MIN` | input | `REAL` |
| `IN_MAX` | input | `REAL` |
| `OUT_MIN` | input | `REAL` |
| `OUT_MAX` | input | `REAL` |
| `OUT` | output | `REAL` |
| `ERROR` | output | `BOOL` |

## STATISTICS_INT

STATISTICS\_INT calculates standard statistical values (MN, MX, AVG) for INTs.

Kind: native. Instance size: 40 bytes. Source: `eaxPLC/pkg/plc/fb/util_lib.go`

| Pin | Direction | Type |
|---|---|---|
| `IN` | input | `DINT` |
| `RESET` | input | `BOOL` |
| `MN` | output | `DINT` |
| `MX` | output | `DINT` |
| `AVG` | output | `DINT` |

## STATISTICS_REAL

STATISTICS\_REAL calculates standard statistical values (MN, MX, AVG) for REALs.

Kind: native. Instance size: 40 bytes. Source: `eaxPLC/pkg/plc/fb/util_lib.go`

| Pin | Direction | Type |
|---|---|---|
| `IN` | input | `REAL` |
| `RESET` | input | `BOOL` |
| `MN` | output | `REAL` |
| `MX` | output | `REAL` |
| `AVG` | output | `REAL` |

## VARIANCE

VARIANCE calculates running variance of REAL values.

Kind: native. Instance size: 40 bytes. Source: `eaxPLC/pkg/plc/fb/util_lib.go`

| Pin | Direction | Type |
|---|---|---|
| `IN` | input | `REAL` |
| `RESET` | input | `BOOL` |
| `OUT` | output | `REAL` |

## PD

PD implements a Proportional-Derivative controller.

Kind: native. Instance size: 56 bytes. Source: `eaxPLC/pkg/plc/fb/util_lib.go`

| Pin | Direction | Type |
|---|---|---|
| `ACTUAL` | input | `REAL` |
| `SET_POINT` | input | `REAL` |
| `KP` | input | `REAL` |
| `TV` | input | `REAL` |
| `Y_MANUAL` | input | `REAL` |
| `Y_OFFSET` | input | `REAL` |
| `Y_MIN` | input | `REAL` |
| `Y_MAX` | input | `REAL` |
| `MANUAL` | input | `BOOL` |
| `RESET` | input | `BOOL` |
| `Y` | output | `REAL` |
| `LIMITS_ACTIVE` | output | `BOOL` |

## PID

PID implements an industrial-grade IEC 61131-3 Proportional-Integral-Derivative controller.

Kind: native. Instance size: 88 bytes. Source: `eaxPLC/pkg/plc/fb/pid.go`

| Pin | Direction | Type | Also accepted as |
|---|---|---|---|
| `SET_POINT` | input | `REAL` | `SP` |
| `ACTUAL` | input | `REAL` | `PV` |
| `KP` | input | `REAL` |  |
| `TN` | input | `REAL` |  |
| `TV` | input | `REAL` |  |
| `TD` | input | `REAL` |  |
| `Y_MIN` | input | `REAL` | `LIM_L` |
| `Y_MAX` | input | `REAL` | `LIM_H` |
| `MANUAL` | input | `BOOL` |  |
| `Y_MANUAL` | input | `REAL` | `MANVAL` |
| `Y` | output | `REAL` | `OUT` |
| `LIMITS_ACTIVE` | output | `BOOL` | `LIM_ACT` |
| `P_Part` | output | `REAL` |  |
| `I_Part` | output | `REAL` |  |
| `D_Part` | output | `REAL` |  |

## PID_FIXCYCLE

PID\_FIXCYCLE implements a PID controller with fixed user-specified cycle time.

Kind: native. Instance size: 72 bytes. Source: `eaxPLC/pkg/plc/fb/util_lib.go`

| Pin | Direction | Type |
|---|---|---|
| `ACTUAL` | input | `REAL` |
| `SET_POINT` | input | `REAL` |
| `KP` | input | `REAL` |
| `TN` | input | `REAL` |
| `TV` | input | `REAL` |
| `Y_MANUAL` | input | `REAL` |
| `Y_OFFSET` | input | `REAL` |
| `Y_MIN` | input | `REAL` |
| `Y_MAX` | input | `REAL` |
| `MANUAL` | input | `BOOL` |
| `RESET` | input | `BOOL` |
| `CYCLE` | input | `REAL` |
| `Y` | output | `REAL` |
| `LIMITS_ACTIVE` | output | `BOOL` |
| `OVERFLOW` | output | `BOOL` |

## BLINK

BLINK generates a pulsating signal with configurable HIGH/LOW durations.

Kind: native. Instance size: 32 bytes. Source: `eaxPLC/pkg/plc/fb/util_lib.go`

| Pin | Direction | Type |
|---|---|---|
| `ENABLE` | input | `BOOL` |
| `TIMELOW` | input | `TIME` |
| `TIMEHIGH` | input | `TIME` |
| `OUT` | output | `BOOL` |

## FREQ_MEASURE

FREQ\_MEASURE measures the frequency of a digital pulse train.

Kind: native. Instance size: 40 bytes. Source: `eaxPLC/pkg/plc/fb/util_lib.go`

| Pin | Direction | Type |
|---|---|---|
| `IN` | input | `BOOL` |
| `PERIODS` | input | `INT` |
| `RESET` | input | `BOOL` |
| `OUT` | output | `REAL` |
| `VALID` | output | `BOOL` |

## GEN

GEN generates periodic waveforms (Triangle, Sawtooth, Square, Sine, Cosine).

Kind: native. Instance size: 32 bytes. Source: `eaxPLC/pkg/plc/fb/util_lib.go`

| Pin | Direction | Type |
|---|---|---|
| `MODE` | input | `INT` |
| `BASE` | input | `BOOL` |
| `PERIOD` | input | `TIME` |
| `CYCLES` | input | `INT` |
| `AMPLITUDE` | input | `INT` |
| `RESET` | input | `BOOL` |
| `OUT` | output | `INT` |

## CHARCURVE

CHARCURVE performs piecewise linear interpolation across an array of POINTs.

Kind: native. Instance size: 52 bytes. Source: `eaxPLC/pkg/plc/fb/util_lib.go`

| Pin | Direction | Type |
|---|---|---|
| `IN` | input | `INT` |
| `N` | input | `USINT` |
| `P` | input | `ARRAY[0..21] OF INT` |
| `OUT` | output | `INT` |
| `ERR` | output | `USINT` |

## RAMP_INT

RAMP\_INT limits rate of change (ascend/descend slope) for integer signals.

Kind: native. Instance size: 32 bytes. Source: `eaxPLC/pkg/plc/fb/util_lib.go`

| Pin | Direction | Type |
|---|---|---|
| `IN` | input | `DINT` |
| `ASCEND` | input | `DINT` |
| `DESCEND` | input | `DINT` |
| `TIMEBASE` | input | `TIME` |
| `RESET` | input | `BOOL` |
| `OUT` | output | `DINT` |

## RAMP_REAL

RAMP\_REAL limits rate of change (ascend/descend slope) for floating-point signals.

Kind: native. Instance size: 32 bytes. Source: `eaxPLC/pkg/plc/fb/util_lib.go`

| Pin | Direction | Type |
|---|---|---|
| `IN` | input | `REAL` |
| `ASCEND` | input | `REAL` |
| `DESCEND` | input | `REAL` |
| `TIMEBASE` | input | `TIME` |
| `RESET` | input | `BOOL` |
| `OUT` | output | `REAL` |

## HYSTERESIS

HYSTERESIS implements a dual-threshold Schmitt trigger comparator.

Kind: native. Instance size: 16 bytes. Source: `eaxPLC/pkg/plc/fb/util_lib.go`

| Pin | Direction | Type |
|---|---|---|
| `IN` | input | `DINT` |
| `HIGH` | input | `DINT` |
| `LOW` | input | `DINT` |
| `OUT` | output | `BOOL` |

## LIMITALARM

LIMITALARM monitors whether an input value violates HIGH/LOW boundary limits.

Kind: native. Instance size: 16 bytes. Source: `eaxPLC/pkg/plc/fb/util_lib.go`

| Pin | Direction | Type |
|---|---|---|
| `IN` | input | `DINT` |
| `HIGH` | input | `DINT` |
| `LOW` | input | `DINT` |
| `O` | output | `BOOL` |
| `U` | output | `BOOL` |
| `IL` | output | `BOOL` |
