CALLEUJSRUSCALLJSR Function call (FC) / Call a routine (JSR)Function call (FC)Call a routine (JSR)
Also called: subroutine, JSR (Jump to Subroutine), call, function call (FC)
Calls a routine (or an FC function) when the rung is 1.
What it does
The call runs the rungs of another routine, then comes back to the rest of the program. A program can thus be split into readable pieces.
When to use it
To organise a program: one routine per machine or per mode, a function reused with parameters.
Operands
| European mnemonic | American mnemonic | Name | Data type | Direction | Required | Meaning |
|---|---|---|---|---|---|---|
| EN | EN | Enable | BOOL | Input | Yes | Call condition. |
| Routine / FC | Routine / FC | Called routine | — | Input | Yes | Routine (or FC) called. |
| Parameters | Parameters | Parameters | BOOL, INT, DINT, REAL, TIME / DINT | Input and output | Yes | One operand per routine parameter: inputs on the left, outputs on the right. |
| Mnemonic | Name | Data type | Direction | Required | Meaning |
|---|---|---|---|---|---|
| EN | Enable | BOOL | Input | Yes | Call condition. |
| Routine / FC | Called routine | — | Input | Yes | Routine (or FC) called. |
| Parameters | Parameters | BOOL, INT, DINT, REAL, TIME | Input and output | Yes | One operand per routine parameter: inputs on the left, outputs on the right. |
| Mnemonic | Name | Data type | Direction | Required | Meaning |
|---|---|---|---|---|---|
| EN | Enable | BOOL | Input | Yes | Call condition. |
| Routine / FC | Called routine | — | Input | Yes | Routine (or FC) called. |
| Parameters | Parameters | BOOL, INT, DINT, REAL | Input and output | Yes | One operand per routine parameter: inputs on the left, outputs on the right. |
Example
When S1 is 1, routine Tank runs with Level = V1.
Try it in the simulatorThe example opens in the free simulator; your own program stays as it was.
Behaviour in detail
- Rung at 0: the routine does not run at all; its coils keep their last value.
- Input parameters are copied before the call, output parameters after.
- Temporary variables go back to their initial value on every call (no memory between calls).
- A routine cannot call itself, directly or not.
European (IEC) and American styles
European: call of an FC function with its input and output parameters and its temporaries.
American: JSR (jump to subroutine) to a routine of the program, parameters received with SBR and returned with RET.