Attention
IronPLC can only run very simple programs. The steps described are accurate but many language features are not yet supported.
Variable Scope¶
IEC 61131-3 provides keywords to control the scope and direction of variables within program organization units.
IEC 61131-3 |
Section 2.4.3 |
Support |
Partial |
Scope Keywords¶
Keyword |
Description |
Status |
|---|---|---|
|
Local variable |
Supported |
|
Input parameter (read-only in callee) |
Partial |
|
Output parameter (written by callee) |
Partial |
|
In/out parameter (passed by reference) |
Partial |
|
Global variable (accessible across POUs) |
Not yet supported |
|
Reference to a global variable |
Not yet supported |
Example¶
FUNCTION_BLOCK MotorControl
VAR_INPUT
start : BOOL;
stop : BOOL;
END_VAR
VAR_OUTPUT
running : BOOL;
END_VAR
VAR
internal_state : INT;
END_VAR
IF start AND NOT stop THEN
running := TRUE;
ELSIF stop THEN
running := FALSE;
END_IF;
END_FUNCTION_BLOCK
See Also¶
Variable Declarations — basic variable syntax
FUNCTION_BLOCK — function blocks
FUNCTION — functions