TwinCAT

1 program Added 2026-02-13T11:00:46Z Agent: claude-codeModel: sonnetWebSearch: disabled Evidence Report issue View issues
Aliases: TwinCAT ST, TwinCAT Structured Text
Provenance: commit c669f2d073 · authored 2026-02-13T12:01:25+01:00 · agent claude-code · model sonnet

Sources mentioning this language

1 source · not in taxonomy (canonical name didn't match any upstream)
LLM (this repo) · 1

Related languages

Structured Text (0.64)S-BASIC (0.24)SFTRAN (0.24)IEC 61131-3 (0.24)SQL (0.21)

LLM-contributed programs

PID Controller

Provenance: commit c669f2d073 · authored 2026-02-13T12:01:25+01:00 · agent claude-code · model sonnet · WebSearch disabled
code.st · added: 2026-02-13T11:00:38Z
FUNCTION_BLOCK FB_PID
VAR_INPUT
    fSetpoint : REAL;
    fActualValue : REAL;
    fKp : REAL := 1.0;
    fKi : REAL := 0.1;
    fKd : REAL := 0.01;
    fCycleTime : REAL;
END_VAR

VAR_OUTPUT
    fOut : REAL;
END_VAR

VAR
    fError : REAL;
    fErrorLast : REAL;
    fIntegral : REAL;
    fDerivative : REAL;
END_VAR

// Calculate error
fError := fSetpoint - fActualValue;

// Proportional term
fOut := fKp * fError;

// Integral term
fIntegral := fIntegral + (fKi * fError * fCycleTime);
fOut := fOut + fIntegral;

// Derivative term
fDerivative := fKd * (fError - fErrorLast) / fCycleTime;
fOut := fOut + fDerivative;

// Save error for next cycle
fErrorLast := fError;

Contribute — propose a file extension

Tell us where to find evidence about TwinCAT (mapped to pl/twincat). A reference URL is required; at least one of extension or program code must be provided too. A maintainer reviews each submission via a draft PR before anything lands.
Optional: attach a program from that URL
If the reference URL points at a single source file you'd like to add as an example program, paste it below. The workflow will write it under languages/TwinCAT/programs/<sha>/. Keep under ~200 lines.
(or open the pre-filled issue directly)
← twiki Twine →